diff options
Diffstat (limited to 'wl1271/stad/src/Data_link')
24 files changed, 0 insertions, 11920 deletions
diff --git a/wl1271/stad/src/Data_link/Ctrl.c b/wl1271/stad/src/Data_link/Ctrl.c deleted file mode 100644 index 6e04ede..0000000 --- a/wl1271/stad/src/Data_link/Ctrl.c +++ /dev/null @@ -1,1111 +0,0 @@ -/* - * Ctrl.c - * - * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 */ -/* */ -/***************************************************************************/ -#define __FILE_ID__ FILE_ID_51 -#include "Ctrl.h" -#include "802_11Defs.h" -#include "DataCtrl_Api.h" -#include "osApi.h" -#include "report.h" -#include "smeApi.h" -#include "siteMgrApi.h" -#include "TrafficMonitorAPI.h" -#include "TI_IPC_Api.h" -#include "EvHandler.h" -#include "apConn.h" -#include "rate.h" -#include "TWDriver.h" -#include "DrvMainModules.h" -#include "StaCap.h" - -static void selectRateTable(TI_HANDLE hCtrlData, TI_UINT32 rateMask); -static void ctrlData_setTxRatePolicies(ctrlData_t *pCtrlData); -static void ctrlData_UnregisterTrafficIntensityEvents (TI_HANDLE hCtrlData); -static void ctrlData_RegisterTrafficIntensityEvents (TI_HANDLE hCtrlData); -static void ctrlData_storeTSRateSet(ctrlData_t *pCtrlData, TTxDataQosParams *tsrsParams); -static void ctrlData_TrafficThresholdCrossed(TI_HANDLE Context,TI_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 -* -* RETURN: Handle to the allocated Ctrl data control block -************************************************************************/ -TI_HANDLE ctrlData_create(TI_HANDLE hOs) -{ - TI_HANDLE hCtrlData; - - 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; - } - - /* reset control module control block */ - os_memoryZero (hOs, hCtrlData, sizeof(ctrlData_t)); - - ((ctrlData_t *)hCtrlData)->hOs = hOs; - - return (hCtrlData); -} - - -/*************************************************************************** -* ctrlData_config * -**************************************************************************** -* DESCRIPTION: This function configures the Ctrl Data module -* -* INPUTS: pStadHandles - Other modules handles -* retriesUpdateCBFunc - Link test retries callback function -* retriesUpdateCBObj - Link test retries callback handle -* -* OUTPUT: -* -* RETURNS: void -***************************************************************************/ -void ctrlData_init (TStadHandlesList *pStadHandles, - retriesCB_t retriesUpdateCBFunc, - TI_HANDLE retriesUpdateCBObj) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)(pStadHandles->hCtrlData); - - /* set objects handles */ - pCtrlData->hTWD = pStadHandles->hTWD; - pCtrlData->hSiteMgr = pStadHandles->hSiteMgr; - pCtrlData->hTxCtrl = pStadHandles->hTxCtrl; - pCtrlData->hRxData = pStadHandles->hRxData; - pCtrlData->hOs = pStadHandles->hOs; - pCtrlData->hReport = pStadHandles->hReport; - pCtrlData->hAPConn = pStadHandles->hAPConnection; - pCtrlData->hEvHandler = pStadHandles->hEvHandler; - pCtrlData->hTrafficMonitor = pStadHandles->hTrafficMon; - pCtrlData->hTxDataQ = pStadHandles->hTxDataQ; - pCtrlData->hStaCap = pStadHandles->hStaCap; - -#ifdef XCC_MODULE_INCLUDED - /* Register the link test retries CB */ - pCtrlData->retriesUpdateCBFunc = retriesUpdateCBFunc; - pCtrlData->retriesUpdateCBObj = retriesUpdateCBObj; -#endif - - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_INIT, ".....Ctrl Data configured successfully ...\n"); -} - - -TI_STATUS ctrlData_SetDefaults (TI_HANDLE hCtrlData, ctrlDataInitParams_t *ctrlDataInitParams) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - TI_UINT32 ac; - - /* set Control module parameters */ - pCtrlData->ctrlDataDesiredIbssProtection = ctrlDataInitParams->ctrlDataDesiredIbssProtection; - pCtrlData->ctrlDataIbssProtectionType = ctrlDataInitParams->ctrlDataDesiredIbssProtection; - pCtrlData->ctrlDataRtsCtsStatus = ctrlDataInitParams->ctrlDataDesiredCtsRtsStatus; - - MAC_COPY (pCtrlData->ctrlDataDeviceMacAddress, - ctrlDataInitParams->ctrlDataDeviceMacAddress); - - pCtrlData->ctrlDataCurrentBssType = BSS_INFRASTRUCTURE; - - /* Set short/long retry for all ACs plus one policy for management packets */ - for (ac=0; ac < MAX_NUM_OF_AC + 1; ac++) - { - pCtrlData->ctrlDataTxRatePolicy.rateClass[ac].longRetryLimit = ctrlDataInitParams->ctrlDataTxRatePolicy.longRetryLimit; - pCtrlData->ctrlDataTxRatePolicy.rateClass[ac].shortRetryLimit = ctrlDataInitParams->ctrlDataTxRatePolicy.shortRetryLimit; - } - - /* Set enabled rates bitmap for each rates mode */ - pCtrlData->policyEnabledRatesMaskCck = ctrlDataInitParams->policyEnabledRatesMaskCck; - pCtrlData->policyEnabledRatesMaskOfdm = ctrlDataInitParams->policyEnabledRatesMaskOfdm; - pCtrlData->policyEnabledRatesMaskOfdmA = ctrlDataInitParams->policyEnabledRatesMaskOfdmA; - pCtrlData->policyEnabledRatesMaskOfdmN = ctrlDataInitParams->policyEnabledRatesMaskOfdmN; - - ctrlData_updateTxRateAttributes(hCtrlData); /* Update TxCtrl module with rate change.*/ - - /* 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; - - TRACE4(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "\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); - - return TI_OK; -} - - -/*************************************************************************** -* ctrlData_unLoad * -**************************************************************************** -* DESCRIPTION: This function unload the Ctrl data module. -* -* INPUTS: hCtrlData - the object -* -* OUTPUT: -* -* RETURNS: TI_OK - Unload succesfull -* TI_NOK - Unload unsuccesfull -***************************************************************************/ -TI_STATUS ctrlData_unLoad(TI_HANDLE hCtrlData) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - /* check parameters validity */ - if( pCtrlData == NULL ) - { - return TI_NOK; - } - - /* free control module object */ - os_memoryFree(pCtrlData->hOs, hCtrlData, sizeof(ctrlData_t)); - - return TI_OK; -} - -TI_STATUS ctrlData_getParamProtType(TI_HANDLE hCtrlData, erpProtectionType_e *protType) -{ /* CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM */ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - *protType = pCtrlData->ctrlDataIbssProtectionType; - return TI_OK; -} - -TI_STATUS ctrlData_getParamPreamble(TI_HANDLE hCtrlData, EPreamble *preamble) -{ /* CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM */ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - *preamble = pCtrlData->ctrlDataCurrentPreambleType; - return TI_OK; -} - -/*************************************************************************** -* ctrlData_getParamBssid * -**************************************************************************** -* DESCRIPTION: get a specific parameter related to Bssid -* -* INPUTS: hCtrlData - the object -* paramVal - type of parameter -* -* -* OUTPUT: bssid -* -* RETURNS: TI_OK -* TI_NOK -***************************************************************************/ -TI_STATUS ctrlData_getParamBssid(TI_HANDLE hCtrlData, EInternalParam paramVal, TMacAddr bssid) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - if (paramVal == CTRL_DATA_CURRENT_BSSID_PARAM) { - MAC_COPY (bssid, pCtrlData->ctrlDataCurrentBSSID); - } - else if (paramVal == CTRL_DATA_MAC_ADDRESS) { - TFwInfo *pFwInfo = TWD_GetFWInfo (pCtrlData->hTWD); - MAC_COPY (bssid, pFwInfo->macAddress); - } - - return TI_OK; -} - -/*************************************************************************** -* ctrlData_getParam * -**************************************************************************** -* DESCRIPTION: get a specific parameter -* -* INPUTS: hCtrlData - the object -* -* -* OUTPUT: pParamInfo - structure which include the value of -* the requested parameter -* -* RETURNS: TI_OK -* TI_NOK -***************************************************************************/ - -TI_STATUS ctrlData_getParam(TI_HANDLE hCtrlData, paramInfo_t *pParamInfo) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - TRACE1(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "ctrlData_getParam() : param=0x%x \n", pParamInfo->paramType); - - switch (pParamInfo->paramType) - { - case CTRL_DATA_CURRENT_BSSID_PARAM: - MAC_COPY (pParamInfo->content.ctrlDataCurrentBSSID, - pCtrlData->ctrlDataCurrentBSSID); - break; - - case CTRL_DATA_CURRENT_BSS_TYPE_PARAM: - pParamInfo->content.ctrlDataCurrentBssType = pCtrlData->ctrlDataCurrentBssType; - break; - - case CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM: - pParamInfo->content.ctrlDataCurrentPreambleType = pCtrlData->ctrlDataCurrentPreambleType; - break; - - case CTRL_DATA_MAC_ADDRESS: - { - TFwInfo *pFwInfo = TWD_GetFWInfo (pCtrlData->hTWD); - MAC_COPY (pParamInfo->content.ctrlDataDeviceMacAddress, pFwInfo->macAddress); - } - 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: - txDataClsfr_GetClsfrType (pCtrlData->hTxDataQ, &pParamInfo->content.ctrlDataClsfrType); - 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: - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " ctrlData_getParam() : PARAMETER NOT SUPPORTED \n"); - return (PARAM_NOT_SUPPORTED); - } - - return (TI_OK); -} - -/*************************************************************************** -* ctrlData_buildSupportedHwRates * -**************************************************************************** -* DESCRIPTION: builds HwRatesBitMap (supported rates) for txRatePolicy by anding -* the AP support and the Policy rates (Enabled/Disabled rates) -* -* OUTPUT: -* -* RETURNS: TI_OK -* TI_NOK -***************************************************************************/ -static TI_UINT32 ctrlData_buildSupportedHwRates (TI_UINT32 APsupport, - TI_UINT32 policySupport) -{ - TI_UINT32 AppRateBitMap = 0; - TI_UINT32 HwRatesBitMap = 0; - - /* 1. AND all Supported Rates masks */ - AppRateBitMap = APsupport & policySupport; - - /* 2. Incase there are no mutual rates: ignor Policy Rate Settings (use only AP Rates) */ - if ( AppRateBitMap == 0 ) - { - AppRateBitMap = APsupport; - } - - /* 3. Set total supported rates bit map for txRatePolicy */ - rate_DrvBitmapToHwBitmap (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) -{ - TI_UINT32 ac; - TI_UINT32 uPolicyRateMask; /* policy rates */ - TI_UINT32 uSupportedRateMask; /* AP supported rates */ - TI_UINT32 fwPolicyID = 0; - TI_UINT32 uEnabledHwRatesMask; - TI_UINT32 uShiftedBit; - TI_UINT32 i; - TTwdParamInfo param; - - for (ac = 0; ac < MAX_NUM_OF_AC; ac++) - { - /* 1. If a special rate set is defined for this AC, use its related policy */ - /* Otherwise use default settings for this class */ - if (pCtrlData->tsrsParameters[ac].supportedRatesMask != 0) - { - uPolicyRateMask = pCtrlData->tsrsParameters[ac].policyClassRateMask; - uSupportedRateMask = pCtrlData->tsrsParameters[ac].supportedRatesMask; - } - else - { - uPolicyRateMask = pCtrlData->uCurrPolicyEnabledRatesMask; - uSupportedRateMask = pCtrlData->ctrlDataCurrentRateMask; - } - - /* 2. Build a bitMap for the supported rates */ - uEnabledHwRatesMask = ctrlData_buildSupportedHwRates (uSupportedRateMask, uPolicyRateMask); - pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].txEnabledRates = uEnabledHwRatesMask; - - TRACE2(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "ctrlData_setTxRatePolicies: AC %d, rate-policy 0x%x", ac, uEnabledHwRatesMask); - - /* Note that Long/Short retries are pre-set during configuration stage */ - - /* 3. Finally, increase total number of policies */ - pCtrlData->tsrsParameters[ac].fwPolicyID = fwPolicyID++; - - } /* for (ac = 0; ac < MAX_NUM_OF_AC; ac++) */ - - /* Add a specific policy for management packets, which uses only the lowest supported rate */ - pCtrlData->uMgmtPolicyId = fwPolicyID; - uShiftedBit = 1; - for (i = 0; i < 32; i++) - { - if ((uShiftedBit & uEnabledHwRatesMask) != 0) - { - break; - } - uShiftedBit = uShiftedBit << 1; - } - pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].txEnabledRates = uShiftedBit; - fwPolicyID++; - - /* Download policies to the FW. Num of policies is 8 - one for each AC for every class */ - TRACE1(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "ctrlData_setTxRatePolicies: num of Rate policies: %d\n", fwPolicyID); - - pCtrlData->ctrlDataTxRatePolicy.numOfRateClasses = fwPolicyID; - param.paramType = TWD_TX_RATE_CLASS_PARAM_ID; - param.content.pTxRatePlicy = &pCtrlData->ctrlDataTxRatePolicy; - - TWD_SetParam (pCtrlData->hTWD, ¶m); -} - - -/*************************************************************************** -* 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: TI_OK -* TI_NOK -***************************************************************************/ - -TI_STATUS ctrlData_setParam(TI_HANDLE hCtrlData, paramInfo_t *pParamInfo) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - TTwdParamInfo param; - - TRACE1(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "ctrlData_setParam() : param=0x%x \n", pParamInfo->paramType); - - switch (pParamInfo->paramType) - { - case CTRL_DATA_RATE_CONTROL_ENABLE_PARAM: - selectRateTable(pCtrlData, pCtrlData->ctrlDataCurrentRateMask); - - ctrlData_setTxRatePolicies(pCtrlData); - - ctrlData_updateTxRateAttributes(hCtrlData); /* Update the TxCtrl module with rate changes. */ - - break; - - case CTRL_DATA_CURRENT_BSSID_PARAM: - MAC_COPY (pCtrlData->ctrlDataCurrentBSSID, - pParamInfo->content.ctrlDataCurrentBSSID); - txCtrlParams_setBssId (pCtrlData->hTxCtrl, &(pCtrlData->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; - txCtrlParams_setBssType (pCtrlData->hTxCtrl, 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_CURRENT_SUPPORTED_RATE_MASK_PARAM: - pCtrlData->ctrlDataCurrentRateMask = pParamInfo->content.ctrlDataCurrentRateMask; - selectRateTable(pCtrlData, pCtrlData->ctrlDataCurrentRateMask); - ctrlData_updateTxRateAttributes(hCtrlData); /* Update the TxCtrl module with rate changes. */ - 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 = TWD_CTS_TO_SELF_PARAM_ID; - if(pCtrlData->ctrlDataProtectionEnabled == TI_TRUE) - param.content.halCtrlCtsToSelf = CTS_TO_SELF_ENABLE; - else - param.content.halCtrlCtsToSelf = CTS_TO_SELF_DISABLE; - - TWD_SetParam (pCtrlData->hTWD, ¶m); - - - /* In case of using protection fragmentation should be disabled */ - param.paramType = TWD_FRAG_THRESHOLD_PARAM_ID; - if(pCtrlData->ctrlDataProtectionEnabled == TI_TRUE) - { - /* save last non-protection mode fragmentation threshold */ - TWD_GetParam(pCtrlData->hTWD,¶m); - pCtrlData->lastFragmentThreshold = param.content.halCtrlFragThreshold; - /* set fragmentation threshold to max (disable) */ - param.content.halCtrlFragThreshold = TWD_FRAG_THRESHOLD_MAX; - } - else - param.content.halCtrlFragThreshold = pCtrlData->lastFragmentThreshold; - - TWD_SetParam(pCtrlData->hTWD,¶m); - } - - break; - - case CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM: - if(ERP_PROTECTION_STANDARD == pCtrlData->ctrlDataDesiredIbssProtection) - { - pCtrlData->ctrlDataIbssProtectionType = pParamInfo->content.ctrlDataIbssProtecionType; - } - else - { - pCtrlData->ctrlDataIbssProtectionType = ERP_PROTECTION_NONE; - } - - /* set indication also to TNET */ - param.paramType = TWD_CTS_TO_SELF_PARAM_ID; - if(pCtrlData->ctrlDataIbssProtectionType != ERP_PROTECTION_NONE) - param.content.halCtrlCtsToSelf = CTS_TO_SELF_ENABLE; - else - param.content.halCtrlCtsToSelf = CTS_TO_SELF_DISABLE; - - TWD_SetParam (pCtrlData->hTWD, ¶m); - break; - - case CTRL_DATA_CURRENT_RTS_CTS_STATUS_PARAM: - pCtrlData->ctrlDataRtsCtsStatus = pParamInfo->content.ctrlDataRtsCtsStatus; - break; - case CTRL_DATA_CLSFR_TYPE: - txDataClsfr_SetClsfrType (pCtrlData->hTxDataQ, pParamInfo->content.ctrlDataClsfrType); - break; - - case CTRL_DATA_CLSFR_CONFIG: - txDataClsfr_InsertClsfrEntry(pCtrlData->hTxDataQ, &pParamInfo->content.ctrlDataClsfrInsertTable); - break; - - case CTRL_DATA_CLSFR_REMOVE_ENTRY: - txDataClsfr_RemoveClsfrEntry(pCtrlData->hTxDataQ, &pParamInfo->content.ctrlDataClsfrInsertTable); - break; - - case CTRL_DATA_TOGGLE_TRAFFIC_INTENSITY_EVENTS: - - /* Enable or disable events according to flag */ - ctrlData_ToggleTrafficIntensityNotification (pCtrlData, (TI_BOOL)pParamInfo->content.ctrlDataTrafficIntensityEventsFlag); - - break; - - case CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD: - { - OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS *localParams = &pParamInfo->content.ctrlDataTrafficIntensityThresholds; - TI_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, TI_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: -TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " ctrlData_setParam() : PARAMETER NOT SUPPORTED \n"); - return (PARAM_NOT_SUPPORTED); - } - - return (TI_OK); -} - - -/*************************************************************************** -* selectRateTable * -**************************************************************************** -* DESCRIPTION: -* -* INPUTS: hCtrlData - the object -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ - -static void selectRateTable(TI_HANDLE hCtrlData, TI_UINT32 rateMask) -{ - paramInfo_t param; - ERate rate; - TI_BOOL b11nEnable; - - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - rate = rate_GetMaxFromDrvBitmap (rateMask); - - param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM; - siteMgr_getParam(pCtrlData->hSiteMgr, ¶m); - - switch(param.content.siteMgrDot11OperationalMode) - { - case DOT11_B_MODE: - pCtrlData->uCurrPolicyEnabledRatesMask = pCtrlData->policyEnabledRatesMaskCck; - break; - - case DOT11_G_MODE: - if( (rate == DRV_RATE_11M) || - (rate == DRV_RATE_5_5M)|| - (rate == DRV_RATE_2M) || - (rate == DRV_RATE_1M) ) - { - pCtrlData->uCurrPolicyEnabledRatesMask = pCtrlData->policyEnabledRatesMaskCck; - } - else - { - pCtrlData->uCurrPolicyEnabledRatesMask = pCtrlData->policyEnabledRatesMaskOfdm; - } - break; - - case DOT11_A_MODE: - pCtrlData->uCurrPolicyEnabledRatesMask = pCtrlData->policyEnabledRatesMaskOfdmA; - break; - - case DOT11_DUAL_MODE: - case DOT11_MAX_MODE: - case DOT11_N_MODE: - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " uCurrPolicyEnabledRatesMask not configured !!!"); - break; - } - - /* add HT MCS rates */ - StaCap_IsHtEnable (pCtrlData->hStaCap, &b11nEnable); - if (b11nEnable == TI_TRUE) - { - if ((rate == DRV_RATE_MCS_0) | - (rate == DRV_RATE_MCS_1) | - (rate == DRV_RATE_MCS_2) | - (rate == DRV_RATE_MCS_3) | - (rate == DRV_RATE_MCS_4) | - (rate == DRV_RATE_MCS_5) | - (rate == DRV_RATE_MCS_6) | - (rate == DRV_RATE_MCS_7)) - { - pCtrlData->uCurrPolicyEnabledRatesMask = pCtrlData->policyEnabledRatesMaskOfdmN; - } - } -} - - -/*************************************************************************** -* ctrlData_stop * -**************************************************************************** -* DESCRIPTION: This function stop the link control algorithms. -* -* INPUTS: hCtrlData - the object -* -* OUTPUT: -* -* RETURNS: TI_OK -* TI_NOK -***************************************************************************/ - -TI_STATUS ctrlData_stop(TI_HANDLE hCtrlData) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - /* set Preamble length option to default value*/ - pCtrlData->ctrlDataCurrentPreambleType = DEF_CURRENT_PREAMBLE; - - os_memoryZero(pCtrlData->hOs, - &pCtrlData->tsrsParameters, - sizeof(pCtrlData->tsrsParameters)); - - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, " ctrlData_stop() : Link control algorithms stoped \n"); - - return TI_OK; -} - - -/*************************************************************************** -* ctrlData_updateTxRateAttributes * -**************************************************************************** -* DESCRIPTION: This function updates the TxCtrl module with all Tx rate attributes -* whenever any of them changes. -* It is called from ctrlData_setParam() after any rate param update. -***************************************************************************/ -void ctrlData_updateTxRateAttributes(TI_HANDLE hCtrlData) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - TI_UINT8 ac; - - /* For each AC, get current Tx-rate policy for Data and for Mgmt packets and update the TxCtrl module. */ - for (ac = 0; ac < MAX_NUM_OF_AC; ac++) - { - txCtrlParams_updateMgmtRateAttributes(pCtrlData->hTxCtrl, pCtrlData->uMgmtPolicyId, ac); - txCtrlParams_updateDataRateAttributes(pCtrlData->hTxCtrl, pCtrlData->tsrsParameters[ac].fwPolicyID, ac); - } -} - -/*************************************************************************** -* 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, TMacAddr *pCurrBssid, - ScanBssType_e *pCurrBssType) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - MAC_COPY (*pCurrBssid, pCtrlData->ctrlDataCurrentBSSID); - *pCurrBssType = pCtrlData->ctrlDataCurrentBssType; - -} - - -/*----------------------------------------------------------------------------- -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, TI_BOOL enabledFlag) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - TI_UINT8 idx; - - if (enabledFlag) - { - for (idx=0; idx < CTRL_DATA_TRAFFIC_INTENSITY_MAX_EVENTS; idx++) - { - TrafficMonitor_StartEventNotif (pCtrlData->hTrafficMonitor,pCtrlData->ctrlDataTrafficThresholdEvents[idx]); - } - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "ctrlData_ToggleTrafficIntensityNotification (TI_TRUE)\n"); - } - else - { - for (idx=0; idx < CTRL_DATA_TRAFFIC_INTENSITY_MAX_EVENTS; idx++) - { - TrafficMonitor_StopEventNotif (pCtrlData->hTrafficMonitor,pCtrlData->ctrlDataTrafficThresholdEvents[idx]); - } - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "ctrlData_ToggleTrafficIntensityNotification (TI_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; - TI_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]); - } - - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, "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,TI_FALSE); - - if (pCtrlData->ctrlDataTrafficThresholdEvents[0] == NULL) - { - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " 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,TI_FALSE); - - if (pCtrlData->ctrlDataTrafficThresholdEvents[1] == NULL) - { - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " 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], - TI_TRUE); - - if (status != TI_OK) - { - TRACE1(pCtrlData->hReport, REPORT_SEVERITY_ERROR , "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,TI_FALSE); - - if (pCtrlData->ctrlDataTrafficThresholdEvents[2] == NULL) - { - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " 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,TI_FALSE); - - if (pCtrlData->ctrlDataTrafficThresholdEvents[3] == NULL) - { - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " 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], - TI_TRUE); - - if (status != TI_OK) - { - TRACE1(pCtrlData->hReport, REPORT_SEVERITY_ERROR , "ctrlData_RegisterTrafficIntensityEvents: TrafficMonitor_SetRstCondition returned status = %d\n",status); - } - - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_INFORMATION, " 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: ------------------------------------------------------------------------------*/ -static void ctrlData_TrafficThresholdCrossed(TI_HANDLE Context,TI_UINT32 Cookie) -{ - ctrlData_t *pCtrlData = (ctrlData_t *)Context; - trafficIntensityThresholdCross_t crossInfo; - - switch(Cookie) - { - case CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_ABOVE: - crossInfo.thresholdCross = (TI_UINT32)HIGH_THRESHOLD_CROSS; - crossInfo.thresholdCrossDirection = (TI_UINT32)CROSS_ABOVE; - EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (TI_UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t)); - break; - - case CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_BELOW: - crossInfo.thresholdCross = (TI_UINT32)HIGH_THRESHOLD_CROSS; - crossInfo.thresholdCrossDirection = (TI_UINT32)CROSS_BELOW; - EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (TI_UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t)); - break; - - case CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_ABOVE: - crossInfo.thresholdCross = (TI_UINT32)LOW_THRESHOLD_CROSS; - crossInfo.thresholdCrossDirection = (TI_UINT32)CROSS_ABOVE; - EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (TI_UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t)); - break; - - case CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_BELOW: - crossInfo.thresholdCross = (TI_UINT32)LOW_THRESHOLD_CROSS; - crossInfo.thresholdCrossDirection = (TI_UINT32)CROSS_BELOW; - EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (TI_UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t)); - break; - default: - TRACE0(pCtrlData->hReport, REPORT_SEVERITY_ERROR, " ctrlData_TrafficThresholdCrossed() : Unknown cookie received from traffic monitor !!! \n"); - break; - } - -} - -/************************************************************************* - * * - * DEBUG FUNCTIONS * - * * - *************************************************************************/ - -#ifdef TI_DBG - -void ctrlData_printTxParameters(TI_HANDLE hCtrlData) -{ -#ifdef REPORT_LOG - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - - WLAN_OS_REPORT((" Tx Parameters \n")); - WLAN_OS_REPORT(("-------------------------------------\n")); - WLAN_OS_REPORT(("currentPreamble = %d\n\n",pCtrlData->ctrlDataCurrentPreambleType)); - WLAN_OS_REPORT(("ctrlDataCurrentRateMask = 0x%X\n",pCtrlData->ctrlDataCurrentRateMask)); -#endif -} - - -void ctrlData_printCtrlBlock(TI_HANDLE hCtrlData) -{ -#ifdef REPORT_LOG - ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData; - TI_UINT32 i; - - WLAN_OS_REPORT((" CtrlData BLock \n")); - WLAN_OS_REPORT(("----------------------\n")); - - WLAN_OS_REPORT(("hSiteMgr = 0x%X\n",pCtrlData->hSiteMgr)); - WLAN_OS_REPORT(("hTWD = 0x%X\n",pCtrlData->hTWD)); - WLAN_OS_REPORT(("hOs = 0x%X\n",pCtrlData->hOs)); - WLAN_OS_REPORT(("hReport = 0x%X\n",pCtrlData->hReport)); - - WLAN_OS_REPORT(("ctrlDataDeviceMacAddress = 0x%X.0x%X.0x%X.0x%X.0x%X.0x%X. \n", pCtrlData->ctrlDataDeviceMacAddress[0], - pCtrlData->ctrlDataDeviceMacAddress[1], - pCtrlData->ctrlDataDeviceMacAddress[2], - pCtrlData->ctrlDataDeviceMacAddress[3], - pCtrlData->ctrlDataDeviceMacAddress[4], - pCtrlData->ctrlDataDeviceMacAddress[5])); - - WLAN_OS_REPORT(("ctrlDataCurrentBSSID = 0x%X.0x%X.0x%X.0x%X.0x%X.0x%X. \n", pCtrlData->ctrlDataCurrentBSSID[0], - pCtrlData->ctrlDataCurrentBSSID[1], - pCtrlData->ctrlDataCurrentBSSID[2], - pCtrlData->ctrlDataCurrentBSSID[3], - pCtrlData->ctrlDataCurrentBSSID[4], - pCtrlData->ctrlDataCurrentBSSID[5])); - - WLAN_OS_REPORT(("ctrlDataCurrentBssType = %d\n", pCtrlData->ctrlDataCurrentBssType)); - WLAN_OS_REPORT(("ctrlDataCurrentRateMask = 0x%X\n", pCtrlData->ctrlDataCurrentRateMask)); - WLAN_OS_REPORT(("ctrlDataCurrentPreambleType = %d\n", pCtrlData->ctrlDataCurrentPreambleType)); - - WLAN_OS_REPORT(("Traffic Intensity threshold events status: %s\n", (pCtrlData->ctrlDataTrafficIntensityEventsEnabled ? "Enabled" : "Disabled"))); - WLAN_OS_REPORT(("Traffic Intensity high threshold: %d packets/sec \n", pCtrlData->ctrlDataTrafficIntensityThresholds.uHighThreshold)); - WLAN_OS_REPORT(("Traffic Intensity low threshold: %d packets/sec \n", pCtrlData->ctrlDataTrafficIntensityThresholds.uLowThreshold)); - WLAN_OS_REPORT(("Traffic Intensity test interval: %d ms\n", pCtrlData->ctrlDataTrafficIntensityThresholds.TestInterval)); - - for (i=0; i < pCtrlData->ctrlDataTxRatePolicy.numOfRateClasses; i++) - { - WLAN_OS_REPORT(("Rate Enable/Disable Mask = 0x%x\n", - pCtrlData->ctrlDataTxRatePolicy.rateClass[i].txEnabledRates)); - - WLAN_OS_REPORT(("Long retry = %d, Short retry = %d\n", - pCtrlData->ctrlDataTxRatePolicy.rateClass[i].longRetryLimit, - pCtrlData->ctrlDataTxRatePolicy.rateClass[i].shortRetryLimit)); - } -#endif -} - - -#endif /*TI_DBG*/ - - -/*************************************************************************** -* 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, TTxDataQosParams *tsrsParams) -{ - TI_UINT32 rateCount; - TI_UINT32 acID; - TI_UINT32 tsrsRequestedMap; - ERate rateNumber; - - acID = tsrsParams->acID; - os_memoryZero(pCtrlData->hOs, - &(pCtrlData->tsrsParameters[acID]), - sizeof(pCtrlData->tsrsParameters[acID])); - - 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 ERate and then to ETxRateClassId */ - /* and update retransmission map in accordance to rate definitions */ - rateNumber = rate_NumberToDrv ((tsrsParams->tsrsArr[rateCount] & 0x7F) >> 1); - - pCtrlData->tsrsParameters[acID].policyClassRateMask = pCtrlData->uCurrPolicyEnabledRatesMask; - - tsrsRequestedMap |= 1 << (rateNumber - 1); - } - /* Update supportedRatesMask according to TSRS rates and rates supported */ - pCtrlData->tsrsParameters[acID].supportedRatesMask = tsrsRequestedMap; - - /* Check that Rate Fallback policy map is not empty; if this is the case, ignore pre-defined policy */ - if (pCtrlData->tsrsParameters[acID].policyClassRateMask == 0) - { - pCtrlData->tsrsParameters[acID].policyClassRateMask = pCtrlData->tsrsParameters[acID].supportedRatesMask; - } -} - - - - diff --git a/wl1271/stad/src/Data_link/Ctrl.h b/wl1271/stad/src/Data_link/Ctrl.h deleted file mode 100644 index 9e9d3f2..0000000 --- a/wl1271/stad/src/Data_link/Ctrl.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Ctrl.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: tx.h */ -/* PURPOSE: Tx module Header file */ -/* */ -/***************************************************************************/ -#ifndef _CTRL_H_ -#define _CTRL_H_ - -#include "tidef.h" -#include "paramOut.h" -#include "rxXfer_api.h" -#include "DataCtrl_Api.h" - - -#define DEF_CURRENT_PREAMBLE PREAMBLE_LONG -#define ALL_RATES_AVAILABLE 0xFFFFFFFF - -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 -{ - TI_UINT32 supportedRatesMask; - TI_UINT32 policyClassRateMask; - TI_UINT32 fwPolicyID; -}tsrsParameters_t; - -typedef struct -{ - TI_HANDLE hSiteMgr; - TI_HANDLE hTxCtrl; - TI_HANDLE hRxData; - TI_HANDLE hTWD; - TI_HANDLE hOs; - TI_HANDLE hReport; - TI_HANDLE hAPConn; - TI_HANDLE hEvHandler; - TI_HANDLE hTrafficMonitor; - TI_HANDLE hTxDataQ; - TI_HANDLE hStaCap; - - TMacAddr ctrlDataCurrentBSSID; - ScanBssType_e ctrlDataCurrentBssType; - TI_UINT32 ctrlDataCurrentRateMask; - EPreamble ctrlDataCurrentPreambleType; - TMacAddr ctrlDataDeviceMacAddress; - TI_BOOL ctrlDataProtectionEnabled; - RtsCtsStatus_e ctrlDataRtsCtsStatus; - erpProtectionType_e ctrlDataIbssProtectionType; - erpProtectionType_e ctrlDataDesiredIbssProtection; /* 0 = CTS protaction disable ; 1 = Standard CTS protaction */ - - /* - * txRatePolicy section - */ - - /* txRatePolicies - here we store the policy and set it to the FW */ - TTxRatePolicy ctrlDataTxRatePolicy; - - /* number of retries for each rate in each class in the policy that we set to the FW */ - TI_UINT32 policyEnabledRatesMaskCck; - TI_UINT32 policyEnabledRatesMaskOfdm; - TI_UINT32 policyEnabledRatesMaskOfdmA; - TI_UINT32 policyEnabledRatesMaskOfdmN; - - TI_UINT32 uCurrPolicyEnabledRatesMask; /* holds the current used En/Dis Rates Mask */ - TI_UINT32 uMgmtPolicyId; /* the management packets policy ID */ - -#ifdef XCC_MODULE_INCLUDED - /* Callback for update retries in Link Test */ - retriesCB_t retriesUpdateCBFunc; - TI_HANDLE retriesUpdateCBObj; -#endif - - /* Flag to indicate whether traffic intensity events should be sent or not */ - TI_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 */ - TI_UINT16 lastFragmentThreshold; - -} ctrlData_t; - - -#endif diff --git a/wl1271/stad/src/Data_link/DataCtrl_Api.h b/wl1271/stad/src/Data_link/DataCtrl_Api.h deleted file mode 100644 index baa4f4f..0000000 --- a/wl1271/stad/src/Data_link/DataCtrl_Api.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * DataCtrl_Api.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* */ -/* PURPOSE: DataCtrl module api functions header file */ -/* */ -/***************************************************************************/ - -#ifndef _DATA_CTRL_API_H_ -#define _DATA_CTRL_API_H_ - -#include "paramOut.h" -#include "rxXfer_api.h" -#include "802_11Defs.h" -#include "GeneralUtilApi.h" -#include "DrvMainModules.h" - -/* Include all core Tx modules APIs */ -#include "txCtrl_Api.h" -#include "txPort_Api.h" -#include "txDataQueue_Api.h" -#include "txMgmtQueue_Api.h" - - -typedef enum -{ - RX_DATA_EAPOL_DESTINATION_PARAM = 0x01, - RX_DATA_PORT_STATUS_PARAM = 0x02 - -} ERxDataParam; - - -/* 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); - -void rxData_init (TStadHandlesList *pStadHandles); - -TI_STATUS rxData_SetDefaults (TI_HANDLE hRxData, rxDataInitParams_t * rxDataInitParams); - -void rxData_receivePacketFromWlan (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); - -TI_STATUS rxData_stop(TI_HANDLE hRxData); - -TI_STATUS rxData_unLoad(TI_HANDLE hRxData); - -TI_STATUS ctrlData_getParamProtType(TI_HANDLE hCtrlData, erpProtectionType_e *protType); - -TI_STATUS ctrlData_getParamPreamble(TI_HANDLE hCtrlData, EPreamble *preamble); - -TI_STATUS ctrlData_getParamBssid(TI_HANDLE hCtrlData, EInternalParam paramVal, TMacAddr bssid); - -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); - -void rxData_resetCounters(TI_HANDLE hRxData); - -TI_HANDLE rxData_RegNotif(TI_HANDLE hRxData,TI_UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,TI_UINT32 Cookie); - -TI_STATUS rxData_UnRegNotif(TI_HANDLE hRxData,TI_HANDLE RegEventHandle); - -TI_STATUS rxData_AddToNotifMask(TI_HANDLE hRxData,TI_HANDLE Notifh,TI_UINT16 EventMask); - -void rxData_SetReAuthInProgress(TI_HANDLE hRxData, TI_BOOL value); - -TI_BOOL rxData_IsReAuthInProgress(TI_HANDLE hRxData); - -void rxData_StopReAuthActiveTimer(TI_HANDLE hRxData); -void rxData_ReauthDisablePriority(TI_HANDLE hRxData); - -/* 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); - - - -/* CONTROL MODULE */ -/*----------------*/ - -#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 MAX_TX_NOTIF_REQ_ELMENTS 8 - - -typedef struct -{ - TMacAddr ctrlDataDeviceMacAddress; -} ctrlDataConfig_t; - -/* retries for the next link test packet Callback */ -typedef void (*retriesCB_t)(TI_HANDLE handle, TI_UINT8 ackFailures); - -/*******************************/ -/* Control module interface functions */ -TI_HANDLE ctrlData_create(TI_HANDLE hOs); - -void ctrlData_init (TStadHandlesList *pStadHandles, - retriesCB_t retriesUpdateCBFunc, - TI_HANDLE retriesUpdateCBObj); - -TI_STATUS ctrlData_SetDefaults (TI_HANDLE hCtrlData, 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_stop(TI_HANDLE hCtrlData); - -TI_STATUS ctrlData_getTiwlnCounters(TI_HANDLE hCtrlData, TIWLN_COUNTERS *pTiwlnCounters); - -void ctrlData_updateTxRateAttributes(TI_HANDLE hCtrlData); - -void ctrlData_getCurrBssTypeAndCurrBssId(TI_HANDLE hCtrlData, TMacAddr *pCurrBssid, - ScanBssType_e *pCurrBssType); - -void ctrlData_txCompleteStatus(TI_HANDLE hCtrlData, TxResultDescriptor_t *pTxResultInfo, - EHwRateBitFiled HwTxRequestRate, TI_UINT8 txPktFlags); - -void ctrlData_ToggleTrafficIntensityNotification (TI_HANDLE hCtrlData, TI_BOOL enabledFlag); - - -/* dbg functions */ -/*---------------*/ -#ifdef TI_DBG -void ctrlData_printTxParameters(TI_HANDLE hCtrlData); -void ctrlData_printCtrlBlock(TI_HANDLE hCtrlData); -#endif /* TI_DBG */ - - -#endif /* _DATA_CTRL_API_H_ */ - diff --git a/wl1271/stad/src/Data_link/GeneralUtil.c b/wl1271/stad/src/Data_link/GeneralUtil.c deleted file mode 100644 index 4db873d..0000000 --- a/wl1271/stad/src/Data_link/GeneralUtil.c +++ /dev/null @@ -1,511 +0,0 @@ -/* - * GeneralUtil.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define __FILE_ID__ FILE_ID_52 -#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 = TI_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: TI_OK - Unload succesfull -* TI_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 TI_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 = TI_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 TI_NOK; - - for(index=0;index<List->MaxNumOfElements;index++) - { - if(List->ElementList[index].Container == Container) - { - if(!List->ElementList[index].Inuse) - return TI_NOK; /*double free not legal*/ - List->ElementList[index].Inuse = TI_FALSE; - return TI_OK; - } - } - return TI_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 TI_NOK; - - List_Destroy(DistributorMgr->DistributionList); - - os_memoryFree(DistributorMgr->hOs, hDistributorMgr, sizeof(DistributorMgr_t)); - - return TI_OK; - -} - -/*************************************************************************** -* DistributorMgr_Reg * -**************************************************************************** -* -* Use by the client to register a callback function -* with the mask condition that will trigger the call. -* -* input -* TI_UINT16 Mask -* TI_HANDLE CallBack -* HANDLE Context -* TI_UINT32 Cookie -* -* -***************************************************************************/ -TI_HANDLE DistributorMgr_Reg(TI_HANDLE hDistributorMgr,TI_UINT16 Mask,TI_HANDLE CallBack, - TI_HANDLE Context,TI_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 = TI_FALSE; - return (TI_HANDLE)NotifReqElment; -} - - -/*************************************************************************** -* DistributorMgr_ReReg * -**************************************************************************** -* -***************************************************************************/ -TI_STATUS DistributorMgr_ReReg(TI_HANDLE hDistributorMgr,TI_HANDLE ReqElmenth ,TI_UINT16 Mask,TI_HANDLE CallBack,TI_HANDLE Context,TI_UINT32 Cookie) -{ - DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr; - NotifReqElment_t *NotifReqElment = (NotifReqElment_t*)ReqElmenth; - - if(DistributorMgr == NULL) - return TI_NOK; - - if (NotifReqElment == NULL) - return TI_NOK; - - NotifReqElment->CallBack = (GeneralEventCall_t)CallBack; - NotifReqElment->Mask = Mask; - NotifReqElment->Context = Context; - NotifReqElment->Cookie = Cookie; - return TI_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,TI_UINT16 Mask) -{ - DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr; - NotifReqElment_t *NotifReqElment = (NotifReqElment_t*)ReqElmenth; - - if(DistributorMgr == NULL) - return TI_NOK; - - if (NotifReqElment == NULL) - return TI_NOK; - - NotifReqElment->Mask |= Mask; - return TI_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 = TI_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 = TI_FALSE; - -} -/*************************************************************************** -* DistributorMgr_UnReg * -**************************************************************************** -* -* -***************************************************************************/ -TI_STATUS DistributorMgr_UnReg(TI_HANDLE hDistributorMgr,TI_HANDLE RegEventHandle) -{ - DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr; - - if(DistributorMgr == NULL) - return TI_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,TI_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/wl1271/stad/src/Data_link/GeneralUtil.h b/wl1271/stad/src/Data_link/GeneralUtil.h deleted file mode 100644 index eb3e631..0000000 --- a/wl1271/stad/src/Data_link/GeneralUtil.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * GeneralUtil.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: TrafficMonitor.h */ -/* PURPOSE: TrafficMonitor module Header file */ -/* */ -/***************************************************************************/ -#ifndef _GENERALUTIL_H_ -#define _GENERALUTIL_H_ - - -#include "tidef.h" -#include "GeneralUtilApi.h" - - - - -/*******************************************************************************************/ -typedef struct -{ - TI_HANDLE Container; - TI_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{ - TI_UINT16 Mask; - TI_BOOL HaltReq; - GeneralEventCall_t CallBack; - TI_HANDLE Context; - TI_UINT32 Cookie; -}NotifReqElment_t; - -/*******************************************************************************************/ - - -#endif diff --git a/wl1271/stad/src/Data_link/GeneralUtilApi.h b/wl1271/stad/src/Data_link/GeneralUtilApi.h deleted file mode 100644 index dbf22cd..0000000 --- a/wl1271/stad/src/Data_link/GeneralUtilApi.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * GeneralUtilApi.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: TrafficMonitor.h */ -/* PURPOSE: TrafficMonitor module Header file */ -/* */ -/***************************************************************************/ -#ifndef _GENERALUTIL_API_H_ -#define _GENERALUTIL_API_H_ - -#include "tidef.h" -#include "paramOut.h" /* check tis include*/ -/**/ -/* call back functions prototype.*/ -/**/ -typedef void (*GeneralEventCall_t)(TI_HANDLE Context,int EventCount,TI_UINT16 Mask,TI_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,TI_UINT16 Mask,TI_HANDLE CallBack,TI_HANDLE Context,TI_UINT32 Cookie); -TI_STATUS DistributorMgr_ReReg(TI_HANDLE hDistributorMgr,TI_HANDLE ReqElmenth ,TI_UINT16 Mask,TI_HANDLE CallBack,TI_HANDLE Context,TI_UINT32 Cookie); -TI_STATUS DistributorMgr_AddToMask(TI_HANDLE hDistributorMgr,TI_HANDLE ReqElmenth,TI_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,TI_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/wl1271/stad/src/Data_link/TrafficMonitor.c b/wl1271/stad/src/Data_link/TrafficMonitor.c deleted file mode 100644 index 08f7f46..0000000 --- a/wl1271/stad/src/Data_link/TrafficMonitor.c +++ /dev/null @@ -1,1340 +0,0 @@ -/* - * TrafficMonitor.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/***************************************************************************/ -/* */ -/* MODULE: TrafficMonitor.c */ -/* PURPOSE: Traffic Monitor */ -/* */ -/***************************************************************************/ -#define __FILE_ID__ FILE_ID_55 -#include "TrafficMonitorAPI.h" -#include "TrafficMonitor.h" -#include "DataCtrl_Api.h" -#include "osApi.h" -#include "report.h" -#include "timer.h" -#include "DrvMainModules.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, TI_BOOL bTwdInitOccured); -#endif - - -/************************************************************************/ -/* Function prototype */ -/************************************************************************/ -static void TimerMonitor_TimeOut (TI_HANDLE hTrafficMonitor, TI_BOOL bTwdInitOccured); -static void TrafficMonitor_updateBW(BandWidth_t *pBandWidth, TI_UINT32 uCurrentTS); -static TI_UINT32 TrafficMonitor_calcBW(BandWidth_t *pBandWidth, TI_UINT32 uCurrentTS); -static TI_BOOL isThresholdDown(TrafficAlertElement_t *AlertElement,TI_UINT32 CurrentTime); -static TI_BOOL isThresholdUp(TrafficAlertElement_t *AlertElement , TI_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, TI_UINT32 downEventsFound, TI_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)); - -#ifdef TRAFF_TEST - TestEventTimer = NULL; -#endif - - TrafficMonitor->hOs = 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->hTrafficMonTimer) - { - tmr_DestroyTimer (TrafficMonitor->hTrafficMonTimer); - } - os_memoryFree(hOs, TrafficMonitor, sizeof(TrafficMonitor_t)); - } - return NULL; -} - - - -/************************************************************************/ -/* TrafficMonitor_config */ -/************************************************************************/ -void TrafficMonitor_Init (TStadHandlesList *pStadHandles, TI_UINT32 BWwindowMs) -{ - TrafficMonitor_t *TrafficMonitor = (TrafficMonitor_t *)(pStadHandles->hTrafficMon); - TI_UINT32 uCurrTS = os_timeStampMs (TrafficMonitor->hOs); - - /* Create the base threshold timer that will serve all the down thresholds*/ - TrafficMonitor->hTrafficMonTimer = tmr_CreateTimer (pStadHandles->hTimer); - - TrafficMonitor->Active = TI_FALSE; - - TrafficMonitor->hRxData = pStadHandles->hRxData; - TrafficMonitor->hTxCtrl = pStadHandles->hTxCtrl; - TrafficMonitor->hTimer = pStadHandles->hTimer; - - /*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 (pStadHandles->hRxData, - DIRECTED_FRAMES_RECV, - TrafficMonitor_Event, - TrafficMonitor, - RX_TRAFF_MODULE); - - /*Registering to the TX module for notification .*/ - TrafficMonitor->TxRegReqHandle = txCtrlParams_RegNotif (pStadHandles->hTxCtrl, - DIRECTED_FRAMES_XFER, - TrafficMonitor_Event, - TrafficMonitor, - TX_TRAFF_MODULE); - - TrafficMonitor->DownTimerEnabled = TI_FALSE; - TrafficMonitor->trafficDownTestIntervalPercent = MIN_INTERVAL_PERCENT; - -#ifdef TRAFF_TEST - TestTrafficMonitor = TrafficMonitor; - TestEventTimer = tmr_CreateTimer (pStadHandles->hTimer); - tmr_StartTimer (TestEventTimer, TestEventFunc, (TI_HANDLE)TrafficMonitor, 5000, TI_TRUE); -#endif -} - -/************************************************************************/ -/* TrafficMonitor_Start */ -/************************************************************************/ -TI_STATUS TrafficMonitor_Start(TI_HANDLE hTrafficMonitor) -{ - TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor; - TrafficAlertElement_t *AlertElement; - TI_UINT32 CurentTime; - - - if(TrafficMonitor == NULL) - return TI_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 = TI_TRUE; - - return TI_OK; -} - - - -/************************************************************************/ -/* TrafficMonitor_Stop */ -/************************************************************************/ -TI_STATUS TrafficMonitor_Stop(TI_HANDLE hTrafficMonitor) -{ - TrafficMonitor_t *pTrafficMonitor = (TrafficMonitor_t*)hTrafficMonitor; - TrafficAlertElement_t *AlertElement; - - if (pTrafficMonitor == NULL) - { - return TI_NOK; - } - - if (pTrafficMonitor->Active) /*To prevent double call to timer stop*/ - { - - pTrafficMonitor->Active = TI_FALSE; - - pTrafficMonitor->DownTimerEnabled = TI_FALSE; - tmr_StopTimer (pTrafficMonitor->hTrafficMonTimer); - } - - /* Set all events state to ALERT_OFF to enable them to "kick" again once after TrafficMonitor is started */ - AlertElement = (TrafficAlertElement_t*)List_GetFirst(pTrafficMonitor->NotificationRegList); - - while(AlertElement) - { - AlertElement->CurrentState = ALERT_OFF; - AlertElement = (TrafficAlertElement_t*)List_GetNext(pTrafficMonitor->NotificationRegList); - } - - return TI_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*/ - txCtrlParams_UnRegNotif(TrafficMonitor->hTxCtrl,TrafficMonitor->TxRegReqHandle); - rxData_UnRegNotif(TrafficMonitor->hRxData,TrafficMonitor->RxRegReqHandle); - - if(TrafficMonitor->NotificationRegList) - { - List_Destroy(TrafficMonitor->NotificationRegList); - } - - if(TrafficMonitor->hTrafficMonTimer) - { - tmr_DestroyTimer (TrafficMonitor->hTrafficMonTimer); - } - -#ifdef TRAFF_TEST - if (TestEventTimer) - { - tmr_DestroyTimer (TestEventTimer); - } -#endif - - os_memoryFree(TrafficMonitor->hOs, TrafficMonitor, sizeof(TrafficMonitor_t)); - - return TI_OK; - } - - return TI_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,TI_BOOL AutoResetCreate) -{ - TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor; - TrafficAlertElement_t *TrafficAlertElement; - TI_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 = TI_FALSE; - TrafficAlertElement->Enabled = TI_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 = TI_TRUE; - - TrafficAlertElement->ResetElment[0]->RstWasAssigned = TI_TRUE; - TrafficAlertElement->RstWasAssigned = TI_TRUE; - - } - else/* The reset element will be supplied afterward by the user in the meanwhile disable the alert till then*/ - { - TrafficAlertElement->RstWasAssigned = TI_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 TI_NOK; - *Index = i; - return TI_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) -{ - TI_UINT32 TxMask = 0; - TI_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 TI_NOK; - } - - - if(RxMask) - { - TrafficAlertElement->MonitorMask[RX_TRAFF_MODULE] = RxMask; - if(rxData_AddToNotifMask(TrafficMonitor->hRxData,TrafficMonitor->RxRegReqHandle,RxMask) == TI_NOK) - return TI_NOK; - } - - if(TxMask) - { - TrafficAlertElement->MonitorMask[TX_TRAFF_MODULE] = TxMask; - if(txCtrlParams_AddToNotifMask(TrafficMonitor->hTxCtrl,TrafficMonitor->TxRegReqHandle,TxMask) == TI_NOK) - return TI_NOK; - } - - return TI_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: TI_OK on success, TI_NOK otherwise - -************************************************************************/ -TI_STATUS TrafficMonitor_SetRstCondition(TI_HANDLE hTrafficMonitor, TI_HANDLE EventHandle,TI_HANDLE ResetEventHandle,TI_BOOL MutualRst) -{ - TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor; - TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle; - TrafficAlertElement_t *TrafficResetAlertElement = (TrafficAlertElement_t*)ResetEventHandle; - int i,x; - TI_UINT32 CurentTime ; - - if((TrafficMonitor == NULL) || (EventHandle == NULL) || (TrafficResetAlertElement == NULL)) - return TI_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 TI_NOK; - if(TrafficResetAlertElement->Direction == TrafficAlertElement->Direction) - return TI_NOK; - - - /*Find an empty Rst element entry*/ - if(FindRstElemEntryIndex(TrafficMonitor,TrafficResetAlertElement,&i) == TI_NOK) - return TI_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 = TI_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) == TI_NOK) - { - /*this clean up is not complete*/ - TrafficResetAlertElement->ResetElment[i] = NULL; - return TI_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 = TI_TRUE; - TrafficResetAlertElement->CurrentState = ALERT_OFF; - TrafficResetAlertElement->TimeOut = CurentTime + TrafficAlertElement->TimeIntervalMs; - TrafficResetAlertElement->EventCounter = 0; - } - } - return TI_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 = TI_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 = TI_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 TI_TRUE else False - -************************************************************************/ -static TI_BOOL isThresholdUp(TrafficAlertElement_t *AlertElement , TI_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 TI_TRUE; - } - - return TI_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 TI_TRUE else False - -************************************************************************/ -static TI_BOOL isThresholdDown(TrafficAlertElement_t *AlertElement , TI_UINT32 CurrentTime) -{ - int i; - TI_BOOL returnVal = TI_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 = TI_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, TI_BOOL bTwdInitOccured) -{ - - TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor; - TrafficAlertElement_t *AlertElement; - TI_UINT32 CurentTime; - TI_UINT32 activeTrafDownEventsNum = 0; - TI_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 == TI_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 - -************************************************************************/ -TI_BOOL TrafficMonitor_IsEventOn(TI_HANDLE EventHandle) -{ - TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle; - - if(TrafficAlertElement == NULL) - return TI_FALSE; - - - if (TrafficAlertElement->CurrentState == ALERT_OFF) - return TI_FALSE; - else - return TI_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; - TI_UINT32 uCurentTS; - - if(pTrafficMonitor == NULL) - return TI_NOK; - - uCurentTS = os_timeStampMs(pTrafficMonitor->hOs); - - /* 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, TI_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 -************************************************************************/ -TI_UINT32 TrafficMonitor_calcBW(BandWidth_t *pBandWidth, TI_UINT32 uCurrentTS) -{ - TI_UINT32 uTotalTime = uCurrentTS - pBandWidth->auFirstEventsTS[pBandWidth->uCurrentWindow]; - TI_UINT32 uTotalBW = 0; - TI_INT32 iter = (TI_INT32)pBandWidth->uCurrentWindow; - TI_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,TI_UINT16 Mask,TI_UINT32 MonitorModuleType) -{ - TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor; - TrafficAlertElement_t *AlertElement; - TI_UINT32 activeTrafDownEventsNum = 0; - TI_UINT32 trafficDownMinTimeout = 0xFFFFFFFF; - TI_UINT32 uCurentTS; - - if(TrafficMonitor == NULL) - return; - - if(!TrafficMonitor->Active) - return; - - uCurentTS = os_timeStampMs(TrafficMonitor->hOs); - - /* 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 == TI_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; - TI_UINT32 activeTrafDownEventsNum = 0; - TI_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 == TI_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, TI_UINT32 downEventsFound, TI_UINT32 minIntervalTime) -{ - TrafficMonitor_t *pTrafficMonitor = (TrafficMonitor_t*)hTrafficMonitor; - - if ((downEventsFound == 0) && pTrafficMonitor->DownTimerEnabled) - { - pTrafficMonitor->DownTimerEnabled = TI_FALSE; - tmr_StopTimer (pTrafficMonitor->hTrafficMonTimer); - os_wake_unlock(pTrafficMonitor->hOs); - } - else if ((downEventsFound > 0) && (pTrafficMonitor->DownTimerEnabled == TI_FALSE)) - { - os_wake_lock(pTrafficMonitor->hOs); - pTrafficMonitor->DownTimerEnabled = TI_TRUE; - /* Start the timer with user defined percentage of the the minimum interval discovered earlier */ - tmr_StartTimer (pTrafficMonitor->hTrafficMonTimer, - TimerMonitor_TimeOut, - (TI_HANDLE)pTrafficMonitor, - ((minIntervalTime * pTrafficMonitor->trafficDownTestIntervalPercent) / 100), - TI_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; - TI_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 == TI_TRUE)) - { - activeTrafDownEventsNum++; - } - AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList); - } - -} - - -#endif - -#ifdef TRAFF_TEST -/* - * TEST Function - */ -void func1(TI_HANDLE Context,TI_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, TI_BOOL bTwdInitOccured) -{ - - static flag = TI_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,TI_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,TI_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,TI_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,TI_FALSE); - - TrafficMonitor_SetRstCondition(TestTrafficMonitor, Alert1,Alert3,TI_TRUE); - TrafficMonitor_SetRstCondition(TestTrafficMonitor, Alert2,Alert3,TI_FALSE); - flag = TI_FALSE; - } - - PrintElertStus(); - -} - -#endif diff --git a/wl1271/stad/src/Data_link/TrafficMonitor.h b/wl1271/stad/src/Data_link/TrafficMonitor.h deleted file mode 100644 index 6606c57..0000000 --- a/wl1271/stad/src/Data_link/TrafficMonitor.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * TrafficMonitor.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: TrafficMonitor.h */ -/* PURPOSE: TrafficMonitor module Header file */ -/* */ -/***************************************************************************/ -#ifndef _TRAFFIC_MONITOR_H -#define _TRAFFIC_MONITOR_H - - -#include "tidef.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 -{ - TI_UINT32 uCurrentWindow; - TI_UINT32 auFirstEventsTS[NUM_OF_SLIDING_WINDOWS]; - TI_UINT32 auWindowCounter[NUM_OF_SLIDING_WINDOWS]; -}BandWidth_t; - - -/* The traffic manger class structure */ -typedef struct -{ - TI_BOOL Active; - TI_HANDLE NotificationRegList; - - TI_HANDLE hOs; - TI_HANDLE hTimer; - TI_HANDLE hRxData; - TI_HANDLE hTxCtrl; - - TI_HANDLE TxRegReqHandle; - TI_HANDLE RxRegReqHandle; - - BandWidth_t DirectTxFrameBW; - BandWidth_t DirectRxFrameBW; - - TI_UINT8 trafficDownTestIntervalPercent; /* Percentage of max down events test interval */ - /*to use in our "traffic down" timer */ - TI_BOOL DownTimerEnabled; /* Indicates whether the "down traffic" timer is active or not */ - - TI_HANDLE hTrafficMonTimer; - -}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; - TI_UINT32 TimeOut; - TraffDirection_t Direction; - TraffTrigger_t Trigger; - TI_BOOL Enabled; - int LastCounte; - TraffEevntCall_t CallBack; - TI_HANDLE Context ; - TI_UINT32 Cookie; - TI_UINT32 TimeIntervalMs; - TI_BOOL AutoCreated; - TI_BOOL RstWasAssigned; - TraffActionFunc_t ActionFunc; - TI_UINT32 MonitorMask[MAX_NUM_MONITORED_MODULES]; - struct AlertElement_t *ResetElment[MAX_RST_ELMENT_PER_ALERT]; -}TrafficAlertElement_t; - -#endif diff --git a/wl1271/stad/src/Data_link/TrafficMonitorAPI.h b/wl1271/stad/src/Data_link/TrafficMonitorAPI.h deleted file mode 100644 index 9fd71a6..0000000 --- a/wl1271/stad/src/Data_link/TrafficMonitorAPI.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * TrafficMonitorAPI.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: TrafficMonitor.h */ -/* PURPOSE: TrafficMonitor module Header file */ -/* */ -/***************************************************************************/ -#ifndef _TRAFFIC_MONITOR_API_H -#define _TRAFFIC_MONITOR_API_H - -#include "DataCtrl_Api.h" -#include "DrvMainModules.h" - -/**/ -/* call back functions prototype.*/ -/**/ -typedef void (*TraffEevntCall_t)(TI_HANDLE Context,TI_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; - TI_UINT32 Cookie; - TraffDirection_t Direction; - TraffTrigger_t Trigger; - int Threshold; - TI_UINT32 TimeIntervalMs; - TraffEvntOptNum_t MonitorType; -}TrafficAlertRegParm_t; - - -/*********************************************************************/ - - -TI_HANDLE TrafficMonitor_create(TI_HANDLE hOs); -void TrafficMonitor_Init (TStadHandlesList *pStadHandles, TI_UINT32 BWwindowMs); -TI_STATUS TrafficMonitor_Destroy(TI_HANDLE hTrafficMonitor); -TI_HANDLE TrafficMonitor_RegEvent(TI_HANDLE hTrafficMonitor, TrafficAlertRegParm_t *TrafficAlertRegParm, TI_BOOL AutoResetCreate); -TI_STATUS TrafficMonitor_SetRstCondition(TI_HANDLE hTrafficMonitor,TI_HANDLE EventHandle,TI_HANDLE ResetEventHandle,TI_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,TI_UINT16 Mask,TI_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); -TI_BOOL TrafficMonitor_IsEventOn(TI_HANDLE EventHandle); - - - - -#endif - - diff --git a/wl1271/stad/src/Data_link/TxDataClsfr.c b/wl1271/stad/src/Data_link/TxDataClsfr.c deleted file mode 100644 index 1d19c7f..0000000 --- a/wl1271/stad/src/Data_link/TxDataClsfr.c +++ /dev/null @@ -1,777 +0,0 @@ -/* - * TxDataClsfr.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/** \file txDataClsfr.c - * \brief The Tx Data Classifier sub-module (under txDataQueue module). - * - * \see txDataQueue.h (the classifier uses the same object as txDataQueue) - */ - -#define __FILE_ID__ FILE_ID_59 -#include "paramOut.h" -#include "osApi.h" -#include "report.h" -#include "context.h" -#include "Ethernet.h" -#include "TWDriver.h" -#include "txDataQueue.h" - - - -/** - * \fn txDataClsfr_Config - * \brief Configure the classifier paramters - * - * Configure the classifier parameters according to the init parameters. - * Called from the txDataQueue configuration function. - * - * \note - * \param hTxDataQ - The object handle - * \param pClsfrInitParams - Pointer to the classifier init params - * \return TI_OK on success or TI_NOK on failure - * \sa - */ -TI_STATUS txDataClsfr_Config (TI_HANDLE hTxDataQ, TClsfrParams *pClsfrInitParams) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TClsfrParams *pParams = &pTxDataQ->tClsfrParams; /* where to save the new params */ - TI_UINT32 uActualEntryCount; - TI_UINT32 i, j; - TI_BOOL bConflictFound; - - /* Active classification algorithm */ - pParams->eClsfrType = pClsfrInitParams->eClsfrType; - - /* the number of active entries */ - if (pClsfrInitParams->uNumActiveEntries <= NUM_OF_CLSFR_TABLE_ENTRIES) - pParams->uNumActiveEntries = pClsfrInitParams->uNumActiveEntries; - else - pParams->uNumActiveEntries = NUM_OF_CLSFR_TABLE_ENTRIES; - - /* Initialization of the classification table */ - switch (pParams->eClsfrType) - { - case D_TAG_CLSFR: - pParams->uNumActiveEntries = 0; - break; - - case DSCP_CLSFR: - uActualEntryCount=0; - for (i = 0; i < pParams->uNumActiveEntries; i++) - { - bConflictFound = TI_FALSE; - /* check conflict */ - for (j = 0; j < i; j++) - { - /* Detect both duplicate and conflicting entries */ - if (pParams->ClsfrTable[j].Dscp.CodePoint == pClsfrInitParams->ClsfrTable[i].Dscp.CodePoint) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_WARNING , "ERROR: txDataClsfr_Config(): duplicate/conflicting classifier entries\n"); - bConflictFound = TI_TRUE; - } - } - if (bConflictFound == TI_FALSE) - { - pParams->ClsfrTable[uActualEntryCount].Dscp.CodePoint = pClsfrInitParams->ClsfrTable[i].Dscp.CodePoint; - pParams->ClsfrTable[uActualEntryCount].DTag = pClsfrInitParams->ClsfrTable[i].DTag; - uActualEntryCount++; - } - } - pParams->uNumActiveEntries = uActualEntryCount; - break; - - case PORT_CLSFR: - uActualEntryCount=0; - for (i = 0; (i < pParams->uNumActiveEntries) ; i++) - { - bConflictFound = TI_FALSE; - /* check conflict */ - for (j = 0; j < i; j++) - { - /* Detect both duplicate and conflicting entries */ - if (pParams->ClsfrTable[j].Dscp.DstPortNum == pClsfrInitParams->ClsfrTable[i].Dscp.DstPortNum) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_WARNING , "ERROR: txDataClsfr_Config(): classifier entries conflict\n"); - bConflictFound = TI_TRUE; - } - } - if (bConflictFound == TI_FALSE) - { - pParams->ClsfrTable[uActualEntryCount].Dscp.DstPortNum = pClsfrInitParams->ClsfrTable[i].Dscp.DstPortNum; - pParams->ClsfrTable[uActualEntryCount].DTag = pClsfrInitParams->ClsfrTable[i].DTag; - uActualEntryCount++; - } - } - pParams->uNumActiveEntries = uActualEntryCount; - break; - - case IPPORT_CLSFR: - uActualEntryCount=0; - for (i=0; (i < pParams->uNumActiveEntries ) ; i++) - { - bConflictFound = TI_FALSE; - /* check conflict */ - for (j = 0; j < i; j++) - { - /* Detect both duplicate and conflicting entries */ - if ((pParams->ClsfrTable[j].Dscp.DstIPPort.DstIPAddress == pClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress)&& - (pParams->ClsfrTable[j].Dscp.DstIPPort.DstPortNum == pClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum)) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_WARNING , "ERROR: txDataClsfr_Config(): classifier entries conflict\n"); - bConflictFound = TI_TRUE; - } - } - if (bConflictFound == TI_FALSE) - { - pParams->ClsfrTable[uActualEntryCount].Dscp.DstIPPort.DstIPAddress = pClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress; - pParams->ClsfrTable[uActualEntryCount].Dscp.DstIPPort.DstPortNum = pClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum; - pParams->ClsfrTable[uActualEntryCount].DTag = pClsfrInitParams->ClsfrTable[i].DTag; - uActualEntryCount++; - } - } - pParams->uNumActiveEntries = uActualEntryCount; - break; - - default: - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_WARNING , "ERROR: txDataClsfr_Config(): Classifier type -- unknown --> set to D-Tag\n"); - pParams->eClsfrType = D_TAG_CLSFR; - pParams->uNumActiveEntries = 0; - break; - } - - return TI_OK; -} - - -/** - * \fn getIpAndUdpHeader - * \brief Get IP & UDP headers addresses if exist - * - * This function gets the addresses of the IP and UDP headers - * - * \note A local inline function! - * \param pTxDataQ - The object handle - * \param pPktCtrlBlk - Pointer to the packet - * \param pIpHeader - Pointer to pointer to IP header - * \param pUdpHeader - Pointer to pointer to UDP header - * \return TI_OK on success, TI_NOK if it's not an IP packet - * \sa - */ -static inline TI_STATUS getIpAndUdpHeader(TTxDataQ *pTxDataQ, - TTxCtrlBlk *pPktCtrlBlk, - TI_UINT8 **pIpHeader, - TI_UINT8 **pUdpHeader) -{ - TI_UINT8 *pEthHead = pPktCtrlBlk->tTxnStruct.aBuf[0]; - TI_UINT8 ipHeaderLen = 0; - - /* check if frame is IP according to ether type */ - if( ( HTOWLANS(((TEthernetHeader *)pEthHead)->type) ) != ETHERTYPE_IP) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION, " getIpAndUdpHeader: EthTypeLength is not 0x0800 \n"); - return TI_NOK; - } - - /* set the pointer to the beginning of the IP header and calculate it's size */ - *pIpHeader = pPktCtrlBlk->tTxnStruct.aBuf[1]; - ipHeaderLen = ((*(unsigned char*)(*pIpHeader) & 0x0f) * 4); - - /* Set the pointer to the beggining of the TCP/UDP header */ - if (ipHeaderLen == pPktCtrlBlk->tTxnStruct.aLen[1]) - { - *pUdpHeader = pPktCtrlBlk->tTxnStruct.aBuf[2]; - } - else - { - *pUdpHeader = *pIpHeader + ipHeaderLen; - } - - return TI_OK; -} - - -/** - * \fn txDataClsfr_ClassifyTxPacket - * \brief Configure the classifier paramters - * - * This function classifies the given Tx packet according to the classifier parameters. - * It sets the TID field with the classification result. - * The classification is according to one of the following methods: - * - D-Tag - Transparent (TID = Dtag) - * - DSCP - According to the DSCP field in the IP header - the default method! - * - Dest UDP-Port - * - Dest IP-Addr & UDP-Port - * - * \note - * \param hTxDataQ - The object handle - * \param pPktCtrlBlk - Pointer to the classified packet - * \param uPacketDtag - The packet priority optionaly set by the OAL - * \return TI_OK on success, PARAM_VALUE_NOT_VALID in case of input parameters problems. - * \sa - */ -TI_STATUS txDataClsfr_ClassifyTxPacket (TI_HANDLE hTxDataQ, TTxCtrlBlk *pPktCtrlBlk, TI_UINT8 uPacketDtag) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TClsfrParams *pClsfrParams = &pTxDataQ->tClsfrParams; - TI_UINT8 *pUdpHeader = NULL; - TI_UINT8 *pIpHeader = NULL; - TI_UINT8 uDscp; - TI_UINT16 uDstUdpPort; - TI_UINT32 uDstIpAdd; - TI_UINT32 i; - - pPktCtrlBlk->tTxDescriptor.tid = 0; - - switch(pClsfrParams->eClsfrType) - { - /* Trivial mapping D-tag to D-tag */ - case D_TAG_CLSFR: - if (uPacketDtag > MAX_NUM_OF_802_1d_TAGS) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR , "txDataClsfr_ClassifyTxPacket(): uPacketDtag error\n"); - return PARAM_VALUE_NOT_VALID; - } - pPktCtrlBlk->tTxDescriptor.tid = uPacketDtag; - TRACE1(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION , "Classifier D_TAG_CLSFR. uPacketDtag = %d\n", uPacketDtag); - break; - - case DSCP_CLSFR: - if( (getIpAndUdpHeader(pTxDataQ, pPktCtrlBlk, &pIpHeader, &pUdpHeader) != TI_OK) - || (pIpHeader == NULL) ) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION , "txDataClsfr_ClassifyTxPacket(): DSCP clsfr, getIpAndUdpHeader mismatch\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* DSCP to D-tag mapping */ - uDscp = *((TI_UINT8 *)(pIpHeader + 1)); /* Fetching the DSCP from the header */ - uDscp = (uDscp >> 2); - - /* looking for the specific DSCP, if found, its corresponding D-tag is set to the TID */ - for(i = 0; i < pClsfrParams->uNumActiveEntries; i++) - { - if (pClsfrParams->ClsfrTable[i].Dscp.CodePoint == uDscp) - { - pPktCtrlBlk->tTxDescriptor.tid = pClsfrParams->ClsfrTable[i].DTag; - TRACE2(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION , "Classifier DSCP_CLSFR found match - entry %d - Tid = %d\n",i,pPktCtrlBlk->tTxDescriptor.tid); - break; - } - } - break; - - case PORT_CLSFR: - if( (getIpAndUdpHeader(pTxDataQ, pPktCtrlBlk, &pIpHeader, &pUdpHeader) != TI_OK) || - (pUdpHeader == NULL) ) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION, " txDataClsfr_ClassifyTxPacket() : DstPort clsfr, getIpAndUdpHeader error\n"); - return PARAM_VALUE_NOT_VALID; - } - - uDstUdpPort = *((TI_UINT16 *)(pUdpHeader + 2)); - uDstUdpPort = HTOWLANS(uDstUdpPort); - - /* Looking for the specific port number. If found, its corresponding D-tag is set to the TID. */ - for(i = 0; i < pClsfrParams->uNumActiveEntries; i++) - { - if (pClsfrParams->ClsfrTable[i].Dscp.DstPortNum == uDstUdpPort) - { - pPktCtrlBlk->tTxDescriptor.tid = pClsfrParams->ClsfrTable[i].DTag; - TRACE2(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION , "Classifier PORT_CLSFR found match - entry %d - Tid = %d\n", i, pPktCtrlBlk->tTxDescriptor.tid); - break; - } - } - break; - - case IPPORT_CLSFR: - if ( (getIpAndUdpHeader(pTxDataQ, pPktCtrlBlk, &pIpHeader, &pUdpHeader) != TI_OK) - || (pIpHeader == NULL) || (pUdpHeader == NULL) ) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION, "txDataClsfr_ClassifyTxPacket(): Dst IP&Port clsfr, getIpAndUdpHeader error\n"); - return PARAM_VALUE_NOT_VALID; - } - - uDstUdpPort = *((TI_UINT16 *)(pUdpHeader + 2)); - uDstUdpPort = HTOWLANS(uDstUdpPort); - uDstIpAdd = *((TI_UINT32 *)(pIpHeader + 16)); - - /* - * Looking for the specific pair of dst IP address and dst port number. - * If found, its corresponding D-tag is set to the TID. - */ - for(i = 0; i < pClsfrParams->uNumActiveEntries; i++) - { - if ((pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress == uDstIpAdd) && - (pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum == uDstUdpPort)) - { - pPktCtrlBlk->tTxDescriptor.tid = pClsfrParams->ClsfrTable[i].DTag; - TRACE2(pTxDataQ->hReport, REPORT_SEVERITY_INFORMATION , "Classifier IPPORT_CLSFR found match - entry %d - Tid = %d\n", i, pPktCtrlBlk->tTxDescriptor.tid); - break; - } - } - break; - - default: - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "txDataClsfr_ClassifyTxPacket(): eClsfrType error\n"); - } - - return TI_OK; -} - - -/** - * \fn txDataClsfr_InsertClsfrEntry - * \brief Insert a new entry to classifier table - * - * Add a new entry to the classification table. - * If the new entry is invalid or conflicts with existing entries, the operation is canceled. - * - * \note - * \param hTxDataQ - The object handle - * \param pNewEntry - Pointer to the new entry to insert - * \return TI_OK on success, PARAM_VALUE_NOT_VALID in case of input parameters problems. - * \sa txDataClsfr_RemoveClsfrEntry - */ -TI_STATUS txDataClsfr_InsertClsfrEntry(TI_HANDLE hTxDataQ, TClsfrTableEntry *pNewEntry) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TClsfrParams *pClsfrParams = &pTxDataQ->tClsfrParams; - TI_UINT32 i; - - if(pNewEntry == NULL) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): NULL ConfigBuffer pointer Error - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* If no available entries, exit */ - if (pClsfrParams->uNumActiveEntries == NUM_OF_CLSFR_TABLE_ENTRIES) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): Bad Number Of Entries - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - if (pClsfrParams->eClsfrType == D_TAG_CLSFR) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): D-Tag classifier - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* Check new entry and conflict with existing entries and if OK, insert to classifier table */ - switch (pClsfrParams->eClsfrType) - { - case DSCP_CLSFR: - - /* Check entry */ - if ( (pNewEntry->Dscp.CodePoint > CLASSIFIER_CODE_POINT_MAX) || - (pNewEntry->DTag > CLASSIFIER_DTAG_MAX) ) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): bad parameter - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* Check conflict*/ - for (i = 0; i < pClsfrParams->uNumActiveEntries; i++) - { - /* Detect both duplicate and conflicting entries */ - if (pClsfrParams->ClsfrTable[i].Dscp.CodePoint == pNewEntry->Dscp.CodePoint) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): classifier entries conflict - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - } - - /* Insert new entry to classifier table. */ - /* Note: Protect from txDataClsfr_ClassifyTxPacket context preemption. */ - context_EnterCriticalSection (pTxDataQ->hContext); - pClsfrParams->ClsfrTable[pClsfrParams->uNumActiveEntries].Dscp.CodePoint = pNewEntry->Dscp.CodePoint; - pClsfrParams->ClsfrTable[pClsfrParams->uNumActiveEntries].DTag = pNewEntry->DTag; - context_LeaveCriticalSection (pTxDataQ->hContext); - - break; - - case PORT_CLSFR: - - /* Check entry */ - if ((pNewEntry->DTag > CLASSIFIER_DTAG_MAX) || - (pNewEntry->Dscp.DstPortNum > CLASSIFIER_PORT_MAX-1) || - (pNewEntry->Dscp.DstPortNum < CLASSIFIER_PORT_MIN) ) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): bad parameter - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* Check conflict*/ - for (i = 0; i < pClsfrParams->uNumActiveEntries; i++) - { - /* Detect both duplicate and conflicting entries */ - if ((pClsfrParams->ClsfrTable[i].Dscp.DstPortNum == pNewEntry->Dscp.DstPortNum)) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): classifier entries conflict - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - } - - /* Insert new entry to classifier table. */ - /* Note: Protect from txDataClsfr_ClassifyTxPacket context preemption. */ - context_EnterCriticalSection (pTxDataQ->hContext); - pClsfrParams->ClsfrTable[pClsfrParams->uNumActiveEntries].Dscp.DstPortNum = pNewEntry->Dscp.DstPortNum; - pClsfrParams->ClsfrTable[pClsfrParams->uNumActiveEntries].DTag = pNewEntry->DTag; - context_LeaveCriticalSection (pTxDataQ->hContext); - - break; - - case IPPORT_CLSFR: - - /* Check entry */ - if ( (pNewEntry->DTag > CLASSIFIER_DTAG_MAX) || - (pNewEntry->Dscp.DstIPPort.DstPortNum > CLASSIFIER_PORT_MAX-1) || - (pNewEntry->Dscp.DstIPPort.DstPortNum < CLASSIFIER_PORT_MIN) || - (pNewEntry->Dscp.DstIPPort.DstIPAddress > CLASSIFIER_IPADDRESS_MAX-1) || - (pNewEntry->Dscp.DstIPPort.DstIPAddress < CLASSIFIER_IPADDRESS_MIN+1) ) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): bad parameter - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* Check conflict*/ - for (i = 0; i < pClsfrParams->uNumActiveEntries; i++) - { - /* Detect both duplicate and conflicting entries */ - if ( (pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress == pNewEntry->Dscp.DstIPPort.DstIPAddress) && - (pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum == pNewEntry->Dscp.DstIPPort.DstPortNum)) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): classifier entries conflict - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - } - - /* Insert new entry to classifier table */ - /* Note: Protect from txDataClsfr_ClassifyTxPacket context preemption. */ - context_EnterCriticalSection (pTxDataQ->hContext); - pClsfrParams->ClsfrTable[pClsfrParams->uNumActiveEntries].Dscp.DstIPPort.DstIPAddress = pNewEntry->Dscp.DstIPPort.DstIPAddress; - pClsfrParams->ClsfrTable[pClsfrParams->uNumActiveEntries].Dscp.DstIPPort.DstPortNum = pNewEntry->Dscp.DstIPPort.DstPortNum; - pClsfrParams->ClsfrTable[pClsfrParams->uNumActiveEntries].DTag = pNewEntry->DTag; - context_LeaveCriticalSection (pTxDataQ->hContext); - - break; - - default: -TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): Classifier type -- unknown - Aborting\n"); - - } - - /* Increment the number of classifier active entries */ - pClsfrParams->uNumActiveEntries++; - - return TI_OK; -} - - -/** - * \fn txDataClsfr_RemoveClsfrEntry - * \brief Remove an entry from classifier table - * - * Remove an entry from classifier table. - * - * \note - * \param hTxDataQ - The object handle - * \param pRemEntry - Pointer to the entry to remove - * \return TI_OK on success, PARAM_VALUE_NOT_VALID in case of input parameters problems. - * \sa txDataClsfr_InsertClsfrEntry - */ -TI_STATUS txDataClsfr_RemoveClsfrEntry(TI_HANDLE hTxDataQ, TClsfrTableEntry *pRemEntry) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TClsfrParams *pClsfrParams = &pTxDataQ->tClsfrParams; - TI_UINT32 i, j; - - if(pRemEntry == NULL) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "classifier_RemoveClsfrEntry(): NULL ConfigBuffer pointer Error - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - if (pClsfrParams->uNumActiveEntries == 0) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "classifier_RemoveClsfrEntry(): Classifier table is empty - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - if (pClsfrParams->eClsfrType == D_TAG_CLSFR) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "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 TI_OK --> insert to classifier table*/ - - switch (pClsfrParams->eClsfrType) - { - case DSCP_CLSFR: - - /* Find the classifier entry */ - i = 0; - while ((i < pClsfrParams->uNumActiveEntries) && - ((pClsfrParams->ClsfrTable[i].Dscp.CodePoint != pRemEntry->Dscp.CodePoint) || - (pClsfrParams->ClsfrTable[i].DTag != pRemEntry->DTag))) - { - i++; - } - - /* If we have reached the number of active entries, it means we couldn't find the requested entry */ - if (i == pClsfrParams->uNumActiveEntries) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "classifier_RemoveClsfrEntry(): Entry not found - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* Shift all entries above the removed one downward */ - /* Note: Protect from txDataClsfr_ClassifyTxPacket context preemption. */ - context_EnterCriticalSection (pTxDataQ->hContext); - for (j = i; j < pClsfrParams->uNumActiveEntries - 1; j++) - { - /* Move entries */ - pClsfrParams->ClsfrTable[j].Dscp.CodePoint = pClsfrParams->ClsfrTable[j+1].Dscp.CodePoint; - pClsfrParams->ClsfrTable[j].DTag = pClsfrParams->ClsfrTable[j+1].DTag; - } - context_LeaveCriticalSection (pTxDataQ->hContext); - - break; - - case PORT_CLSFR: - - /* Find the classifier entry */ - i = 0; - while ((i < pClsfrParams->uNumActiveEntries) && - ((pClsfrParams->ClsfrTable[i].Dscp.DstPortNum != pRemEntry->Dscp.DstPortNum) || - (pClsfrParams->ClsfrTable[i].DTag != pRemEntry->DTag))) - { - i++; - } - - /* If we have reached the number of active entries, it means we couldn't find the requested entry */ - if (i == pClsfrParams->uNumActiveEntries) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "classifier_RemoveClsfrEntry(): Entry not found - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* Shift all entries above the removed one downward */ - /* Note: Protect from txDataClsfr_ClassifyTxPacket context preemption. */ - context_EnterCriticalSection (pTxDataQ->hContext); - for (j = i; j < pClsfrParams->uNumActiveEntries - 1; j++) - { - pClsfrParams->ClsfrTable[j].Dscp.DstPortNum = pClsfrParams->ClsfrTable[j+1].Dscp.DstPortNum; - pClsfrParams->ClsfrTable[j].DTag = pClsfrParams->ClsfrTable[j+1].DTag; - } - context_LeaveCriticalSection (pTxDataQ->hContext); - - break; - - case IPPORT_CLSFR: - - /* Find the classifier entry */ - i = 0; - while ((i < pClsfrParams->uNumActiveEntries) && - ((pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress != pRemEntry->Dscp.DstIPPort.DstIPAddress) || - (pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum != pRemEntry->Dscp.DstIPPort.DstPortNum) || - (pClsfrParams->ClsfrTable[i].DTag != pRemEntry->DTag))) - { - i++; - } - - /* If we have reached the number of active entries, it means we couldn't find the requested entry */ - if (i == pClsfrParams->uNumActiveEntries) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "classifier_RemoveClsfrEntry(): Entry not found - Aborting\n"); - return PARAM_VALUE_NOT_VALID; - } - - /* Shift all entries above the removed one downward. */ - /* Note: Protect from txDataClsfr_ClassifyTxPacket context preemption. */ - context_EnterCriticalSection (pTxDataQ->hContext); - for (j = i; j < pClsfrParams->uNumActiveEntries - 1; j++) - { - pClsfrParams->ClsfrTable[j].Dscp.DstIPPort.DstIPAddress = pClsfrParams->ClsfrTable[j+1].Dscp.DstIPPort.DstIPAddress; - pClsfrParams->ClsfrTable[j].Dscp.DstIPPort.DstPortNum = pClsfrParams->ClsfrTable[j+1].Dscp.DstIPPort.DstPortNum; - pClsfrParams->ClsfrTable[j].DTag = pClsfrParams->ClsfrTable[j+1].DTag; - } - context_LeaveCriticalSection (pTxDataQ->hContext); - - break; - - default: -TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "classifier_RemoveClsfrEntry(): Classifier type -- unknown - Aborting\n"); - } - - /* Decrement the number of classifier active entries */ - pClsfrParams->uNumActiveEntries--; - - return TI_OK; -} - - -/** - * \fn txDataClsfr_SetClsfrType & txDataClsfr_GetClsfrType - * \brief Set / Get classifier type - * - * Set / Get classifier type. - * When setting type, the table is emptied! - * - * \note - * \param hTxDataQ - The object handle - * \param eNewClsfrType - New type - * \return TI_OK on success, PARAM_VALUE_NOT_VALID in case of input parameters problems. - * \sa - */ -TI_STATUS txDataClsfr_SetClsfrType (TI_HANDLE hTxDataQ, EClsfrType eNewClsfrType) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - if (eNewClsfrType > CLSFR_TYPE_MAX) - { -TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_setClsfrType(): classifier type exceed its MAX \n"); - return PARAM_VALUE_NOT_VALID; - } - - if (pTxDataQ->tClsfrParams.eClsfrType == eNewClsfrType) - { -TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_WARNING, "Classifier_setClsfrType(): equal classifier type --> will empty classifier table \n"); - } - - /* Update type and empty table. */ - /* Note: Protect from txDataClsfr_ClassifyTxPacket context preemption. */ - context_EnterCriticalSection (pTxDataQ->hContext); - pTxDataQ->tClsfrParams.eClsfrType = eNewClsfrType; - pTxDataQ->tClsfrParams.uNumActiveEntries = 0; - context_LeaveCriticalSection (pTxDataQ->hContext); - - return TI_OK; -} - -TI_STATUS txDataClsfr_GetClsfrType (TI_HANDLE hTxDataQ, EClsfrType *pClsfrType) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - *pClsfrType = pTxDataQ->tClsfrParams.eClsfrType; - return TI_OK; -} - - - -#ifdef TI_DBG - -/** - * \fn txDataClsfr_PrintClsfrTable - * \brief Print classifier table - * - * Print the classifier table for debug - * - * \note - * \param hTxDataQ - The object handle - * \return void - * \sa - */ -void txDataClsfr_PrintClsfrTable (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TClsfrParams *pClsfrParams = &pTxDataQ->tClsfrParams; - TI_UINT32 uIpAddr, i; - - if (pClsfrParams->eClsfrType == D_TAG_CLSFR) - { - WLAN_OS_REPORT (("D_TAG classifier type selected...Nothing to print...\n")); - return; - } - - WLAN_OS_REPORT (("Number of active entries in classifier table : %d\n",pClsfrParams->uNumActiveEntries)); - - switch (pClsfrParams->eClsfrType) - { - case DSCP_CLSFR: - WLAN_OS_REPORT (("+------+-------+\n")); - WLAN_OS_REPORT (("| Code | D-Tag |\n")); - WLAN_OS_REPORT (("+------+-------+\n")); - - for (i = 0; i < pClsfrParams->uNumActiveEntries; i++) - { - WLAN_OS_REPORT (("| %5d | %5d |\n", - pClsfrParams->ClsfrTable[i].Dscp.CodePoint,pClsfrParams->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 < pClsfrParams->uNumActiveEntries; i++) - { - WLAN_OS_REPORT (("| %5d | %5d |\n", - pClsfrParams->ClsfrTable[i].Dscp.DstPortNum,pClsfrParams->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 < pClsfrParams->uNumActiveEntries; i++) - { - uIpAddr = pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress; - WLAN_OS_REPORT (("| %02x.%02x.%02x.%02x | %5d | %5d |\n", - (uIpAddr & 0xFF),((uIpAddr >> 8) & (0xFF)),((uIpAddr >> 16) & (0xFF)),((uIpAddr >> 24) & (0xFF)), - pClsfrParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum, pClsfrParams->ClsfrTable[i].DTag)); - } - - WLAN_OS_REPORT (("+-------------+-------+-------+\n")); - break; - - default: -TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "Classifier_InsertClsfrEntry(): Classifier type -- unknown - Aborting\n"); - break; - } -} - -#endif /* TI_DBG */ - - - diff --git a/wl1271/stad/src/Data_link/rx.c b/wl1271/stad/src/Data_link/rx.c deleted file mode 100644 index c197963..0000000 --- a/wl1271/stad/src/Data_link/rx.c +++ /dev/null @@ -1,2083 +0,0 @@ -/* - * rx.c - * - * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 */ -/* */ -/***************************************************************************/ -#define __FILE_ID__ FILE_ID_54 -#include "tidef.h" -#include "paramOut.h" -#include "rx.h" -#include "osApi.h" -#include "timer.h" -#include "DataCtrl_Api.h" -#include "Ctrl.h" -#include "802_11Defs.h" -#include "Ethernet.h" -#include "report.h" -#include "rate.h" -#include "mlmeApi.h" -#include "rsnApi.h" -#include "smeApi.h" -#include "siteMgrApi.h" -#include "GeneralUtil.h" -#include "EvHandler.h" -#ifdef XCC_MODULE_INCLUDED -#include "XCCMngr.h" -#endif -#include "TWDriver.h" -#include "RxBuf.h" -#include "DrvMainModules.h" -#include "bmtrace_api.h" -#include "PowerMgr_API.h" - - -#define EAPOL_PACKET 0x888E -#define IAPP_PACKET 0x0000 -#define PREAUTH_EAPOL_PACKET 0x88C7 - - -#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 - -#define PADDING_ETH_PACKET_SIZE 2 - -/* CallBack for recieving packet from rxXfer */ -static void rxData_ReceivePacket (TI_HANDLE hRxData, void *pBuffer); - -static ERxBufferStatus rxData_RequestForBuffer (TI_HANDLE hRxData, void **pBuf, TI_UINT16 aLength, TI_UINT32 uEncryptionFlag,PacketClassTag_e ePacketClassTag); - -#if 0 -static TI_STATUS rxData_checkBssIdAndBssType(TI_HANDLE hRxData, - dot11_header_t* dot11_header, - TMacAddr **rxBssid, - ScanBssType_e *currBssType, - TMacAddr *currBssId); -#endif -static TI_STATUS rxData_convertWlanToEthHeader (TI_HANDLE hRxData, void *pBuffer, TI_UINT16 * etherType); -static TI_STATUS rxData_ConvertAmsduToEthPackets (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); -static void rxData_dataPacketDisptcher (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); -static void rxData_discardPacket (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); -static void rxData_discardPacketVlan (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); -static void rxData_rcvPacketInOpenNotify (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); -static void rxData_rcvPacketEapol (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); -static void rxData_rcvPacketData (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); - -static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, TI_BOOL enabled); -static TI_STATUS rxData_addRxDataFilter(TI_HANDLE hRxData, TRxDataFilterRequest* request); -static TI_STATUS rxData_removeRxDataFilter(TI_HANDLE hRxData, TRxDataFilterRequest* request); - - -#ifdef XCC_MODULE_INCLUDED -static void rxData_rcvPacketIapp(TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr); -#endif -#ifdef TI_DBG -static void rxData_printRxThroughput(TI_HANDLE hRxData, TI_BOOL bTwdInitOccured); -#endif - -static void rxData_StartReAuthActiveTimer(TI_HANDLE hRxData); -static void reAuthTimeout(TI_HANDLE hRxData, TI_BOOL bTwdInitOccured); -static void rxData_ReauthEnablePriority(TI_HANDLE hRxData); - - -/************************************************************************* -* rxData_create * -************************************************************************** -* DESCRIPTION: This function initializes the Rx data module. -* -* INPUT: hOs - handle to Os Abstraction Layer -* -* OUTPUT: -* -* RETURN: Handle to the allocated Rx data control block -************************************************************************/ -TI_HANDLE rxData_create (TI_HANDLE hOs) -{ - rxData_t *pRxData; - - /* 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 */ - pRxData = os_memoryAlloc(hOs, (sizeof(rxData_t))); - - if (!pRxData) - { - WLAN_OS_REPORT(("FATAL ERROR: rxData_create(): Error Creating Rx Module - Aborting\n")); - return NULL; - } - - /* reset Rx control block */ - os_memoryZero (hOs, pRxData, (sizeof(rxData_t))); - - pRxData->RxEventDistributor = DistributorMgr_Create (hOs, MAX_RX_NOTIF_REQ_ELMENTS); - - pRxData->hOs = hOs; - - return (TI_HANDLE)pRxData; -} - -/*************************************************************************** -* rxData_config * -**************************************************************************** -* DESCRIPTION: This function configures the Rx Data module -* -* INPUTS: pStadHandles - The driver modules handles -* -* OUTPUT: -* -* RETURNS: void -***************************************************************************/ -void rxData_init (TStadHandlesList *pStadHandles) -{ - rxData_t *pRxData = (rxData_t *)(pStadHandles->hRxData); - - pRxData->hCtrlData = pStadHandles->hCtrlData; - pRxData->hTWD = pStadHandles->hTWD; - pRxData->hMlme = pStadHandles->hMlmeSm; - pRxData->hRsn = pStadHandles->hRsn; - pRxData->hSiteMgr = pStadHandles->hSiteMgr; - pRxData->hOs = pStadHandles->hOs; - pRxData->hReport = pStadHandles->hReport; - pRxData->hXCCMgr = pStadHandles->hXCCMngr; - pRxData->hEvHandler = pStadHandles->hEvHandler; - pRxData->hTimer = pStadHandles->hTimer; - pRxData->hPowerMgr = pStadHandles->hPowerMgr; - - pRxData->rxDataExcludeUnencrypted = DEF_EXCLUDE_UNENCYPTED; - pRxData->rxDataExludeBroadcastUnencrypted = DEF_EXCLUDE_UNENCYPTED; - pRxData->rxDataEapolDestination = DEF_EAPOL_DESTINATION; - pRxData->rxDataPortStatus = DEF_RX_PORT_STATUS; - pRxData->genericEthertype = EAPOL_PACKET; - - /* - * configure rx data dispatcher - */ - - /* port status close */ - pRxData->rxData_dispatchBuffer[CLOSE][DATA_DATA_PACKET] = &rxData_discardPacket; /* data */ - pRxData->rxData_dispatchBuffer[CLOSE][DATA_EAPOL_PACKET] = &rxData_discardPacket; /* eapol */ - pRxData->rxData_dispatchBuffer[CLOSE][DATA_IAPP_PACKET] = &rxData_discardPacket; /* Iapp */ - pRxData->rxData_dispatchBuffer[CLOSE][DATA_VLAN_PACKET] = &rxData_discardPacketVlan; /* VLAN */ - - /* port status open notify */ - pRxData->rxData_dispatchBuffer[OPEN_NOTIFY][DATA_DATA_PACKET] = &rxData_rcvPacketInOpenNotify; /* data */ - pRxData->rxData_dispatchBuffer[OPEN_NOTIFY][DATA_EAPOL_PACKET] = &rxData_rcvPacketInOpenNotify; /* eapol */ - pRxData->rxData_dispatchBuffer[OPEN_NOTIFY][DATA_IAPP_PACKET] = &rxData_rcvPacketInOpenNotify; /* Iapp */ - pRxData->rxData_dispatchBuffer[OPEN_NOTIFY][DATA_VLAN_PACKET] = &rxData_discardPacketVlan; /* VLAN */ - - /* port status open eapol */ - pRxData->rxData_dispatchBuffer[OPEN_EAPOL][DATA_DATA_PACKET] = &rxData_discardPacket; /* data */ - pRxData->rxData_dispatchBuffer[OPEN_EAPOL][DATA_EAPOL_PACKET] = &rxData_rcvPacketEapol; /* eapol */ - pRxData->rxData_dispatchBuffer[OPEN_EAPOL][DATA_IAPP_PACKET] = &rxData_discardPacket; /* Iapp */ - pRxData->rxData_dispatchBuffer[OPEN_EAPOL][DATA_VLAN_PACKET] = &rxData_discardPacketVlan; /* VLAN */ - - /* port status open */ - pRxData->rxData_dispatchBuffer[OPEN][DATA_DATA_PACKET] = &rxData_rcvPacketData; /* data */ - pRxData->rxData_dispatchBuffer[OPEN][DATA_EAPOL_PACKET] = &rxData_rcvPacketEapol; /* eapol */ -#ifdef XCC_MODULE_INCLUDED - pRxData->rxData_dispatchBuffer[OPEN][DATA_IAPP_PACKET] = &rxData_rcvPacketIapp; /* Iapp */ -#else - pRxData->rxData_dispatchBuffer[OPEN][DATA_IAPP_PACKET] = &rxData_rcvPacketData; /* Iapp */ -#endif - pRxData->rxData_dispatchBuffer[OPEN][DATA_VLAN_PACKET] = &rxData_discardPacketVlan;/* VLAN */ - - /* register CB's for request buffer and receive CB to the lower layers */ - TWD_RegisterCb (pRxData->hTWD, - TWD_EVENT_RX_RECEIVE_PACKET, - (void *)rxData_ReceivePacket, - pStadHandles->hRxData); - - TWD_RegisterCb (pRxData->hTWD, - TWD_EVENT_RX_REQUEST_FOR_BUFFER, - (void*)rxData_RequestForBuffer, - pStadHandles->hRxData); -} - - -TI_STATUS rxData_SetDefaults (TI_HANDLE hRxData, rxDataInitParams_t * rxDataInitParams) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - int i; - - /* init rx data filters */ - pRxData->filteringEnabled = rxDataInitParams->rxDataFiltersEnabled; - pRxData->filteringDefaultAction = rxDataInitParams->rxDataFiltersDefaultAction; - TWD_CfgEnableRxDataFilter (pRxData->hTWD, 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]) != TI_OK) - { - TRACE1(pRxData->hReport, REPORT_SEVERITY_ERROR, ": Invalid Rx Data Filter configured at init stage (at index %d)!\n", i); - } - } - } - - pRxData->reAuthActiveTimer = tmr_CreateTimer (pRxData->hTimer); - if (pRxData->reAuthActiveTimer == NULL) - { - WLAN_OS_REPORT(("rxData_SetDefaults(): Failed to create reAuthActiveTimer!\n")); - return TI_NOK; - } - - pRxData->reAuthActiveTimeout = rxDataInitParams->reAuthActiveTimeout; - - rxData_SetReAuthInProgress(pRxData, TI_FALSE); - -#ifdef TI_DBG - /* reset counters */ - rxData_resetCounters(pRxData); - rxData_resetDbgCounters(pRxData); - - /* allocate timer for debug throughput */ - pRxData->hThroughputTimer = tmr_CreateTimer (pRxData->hTimer); - if (pRxData->hThroughputTimer == NULL) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, "rxData_SetDefaults(): Failed to create hThroughputTimer!\n"); - return TI_NOK; - } - pRxData->rxThroughputTimerEnable = TI_FALSE; -#endif - - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INIT, ".....Rx Data configured successfully\n"); - - return TI_OK; -} - -/*************************************************************************** -* rxData_unLoad * -**************************************************************************** -* DESCRIPTION: This function unload the Rx data module. -* -* INPUTS: hRxData - the object -* -* OUTPUT: -* -* RETURNS: TI_OK - Unload succesfull -* TI_NOK - Unload unsuccesfull -***************************************************************************/ -TI_STATUS rxData_unLoad(TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - /* check parameters validity */ - if (pRxData == NULL) - { - return TI_NOK; - } - - DistributorMgr_Destroy(pRxData->RxEventDistributor); - -#ifdef TI_DBG - /* destroy periodic rx throughput timer */ - if (pRxData->hThroughputTimer) - { - tmr_DestroyTimer (pRxData->hThroughputTimer); - } - #endif - - if (pRxData->reAuthActiveTimer) - { - tmr_DestroyTimer (pRxData->reAuthActiveTimer); - } - - /* free Rx Data controll block */ - os_memoryFree(pRxData->hOs, pRxData, sizeof(rxData_t)); - - return TI_OK; -} - - -/*************************************************************************** -* rxData_stop * -**************************************************************************** -* DESCRIPTION: this function stop the rx data. -* -* INPUTS: hRxData - the object -* -* OUTPUT: -* -* RETURNS: TI_OK - stop succesfull -* TI_NOK - stop unsuccesfull -***************************************************************************/ -TI_STATUS rxData_stop (TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - /* check parameters validity */ - if (pRxData == NULL) - { - return TI_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) - { - tmr_StopTimer (pRxData->hThroughputTimer); - pRxData->rxThroughputTimerEnable = TI_FALSE; - } - #endif - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_stop() : Succeeded.\n"); - - return TI_OK; - -} - -/*************************************************************************** -* rxData_getParam * -**************************************************************************** -* DESCRIPTION: get a specific parameter -* -* INPUTS: hRxData - the object -* -* OUTPUT: pParamInfo - structure which include the value of -* the requested parameter -* -* RETURNS: TI_OK -* TI_NOK -***************************************************************************/ -TI_STATUS rxData_getParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - /* check handle validity */ - if (pRxData == NULL) - { - return TI_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: - TWD_ItrDataFilterStatistics (pRxData->hTWD, - pParamInfo->content.interogateCmdCBParams.fCb, - pParamInfo->content.interogateCmdCBParams.hCb, - pParamInfo->content.interogateCmdCBParams.pCb); - break; - - case RX_DATA_RATE_PARAM: - pParamInfo->content.siteMgrCurrentRxRate = pRxData->uLastDataPktRate; - break; - - default: - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, " rxData_getParam() : PARAMETER NOT SUPPORTED \n"); - return (PARAM_NOT_SUPPORTED); - } - - return TI_OK; -} - -/*************************************************************************** -* rxData_setParam * -**************************************************************************** -* DESCRIPTION: set a specific parameter -* -* INPUTS: hRxData - the object -* pParamInfo - structure which include the value to set for -* the requested parameter -* -* OUTPUT: -* -* RETURNS: TI_OK -* TI_NOK -***************************************************************************/ -TI_STATUS rxData_setParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - /* check handle validity */ - if( pRxData == NULL ) - { - return TI_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: - { - TRxDataFilterRequest* pRequest = &pParamInfo->content.rxDataFilterRequest; - - return rxData_addRxDataFilter(hRxData, pRequest); - } - - case RX_DATA_REMOVE_RX_DATA_FILTER: - { - TRxDataFilterRequest* pRequest = &pParamInfo->content.rxDataFilterRequest; - - return rxData_removeRxDataFilter(hRxData, pRequest); - } - - case RX_DATA_GENERIC_ETHERTYPE_PARAM: - pRxData->genericEthertype = pParamInfo->content.rxGenericEthertype; - break; - - default: - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, " rxData_setParam() : PARAMETER NOT SUPPORTED \n"); - return (PARAM_NOT_SUPPORTED); - } - - return TI_OK; -} - -/*************************************************************************** -* rxData_enableDisableRxDataFilters * -**************************************************************************** -* DESCRIPTION: -* -* -* INPUTS: -* -* -* -* OUTPUT: -* -* RETURNS: -* -***************************************************************************/ -static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, TI_BOOL enabled) -{ - rxData_t * pRxData = (rxData_t *) hRxData; - - /* assert 0 or 1 */ - if (enabled != TI_FALSE) - enabled = 1; - - if (enabled == pRxData->filteringEnabled) - return TI_OK; - - pRxData->filteringEnabled = enabled; - - return TWD_CfgEnableRxDataFilter (pRxData->hTWD, pRxData->filteringEnabled, pRxData->filteringDefaultAction); -} - -/*************************************************************************** -* findFilterRequest * -**************************************************************************** -* DESCRIPTION: -* -* -* INPUTS: -* -* -* -* OUTPUT: -* -* RETURNS: -* -***************************************************************************/ -static int findFilterRequest(TI_HANDLE hRxData, TRxDataFilterRequest* 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, TI_UINT8 * fieldPatterns, TI_UINT8 * lenFieldPatterns) -{ - //fieldPatterns[*lenFieldPatterns] = fieldPattern->offset; - os_memoryCopy(pRxData->hOs, fieldPatterns + *lenFieldPatterns, (TI_UINT8 *)&fieldPattern->offset, sizeof(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; - } - - TRACE3(pRxData->hReport, REPORT_SEVERITY_INFORMATION, ": Closed field pattern, length = %d, total length = %d, pattern bit mask = %d.\n", 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, TRxDataFilterRequest* request, TI_UINT8 * numFieldPatterns, TI_UINT8 * lenFieldPatterns, TI_UINT8 * fieldPatterns) -{ - rxData_t * pRxData = (rxData_t *) hRxData; - - int maskIter; - int patternIter = 0; - - /* used to store field patterns while they are built */ - TI_BOOL isBuildingFieldPattern = TI_FALSE; - rxDataFilterFieldPattern_t fieldPattern; - - for (maskIter = 0; maskIter < request->maskLength * 8; ++maskIter) - { - /* which byte in the mask and which bit in the byte we're at */ - int bit = maskIter % 8; - int byte = maskIter / 8; - - /* is the bit in the mask set */ - TI_BOOL isSet = ((request->mask[byte] & (1 << bit)) == (1 << bit)); - - TRACE4(pRxData->hReport, REPORT_SEVERITY_INFORMATION, ": MaskIter = %d, Byte = %d, Bit = %d, isSet = %d\n", 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 == TI_FALSE) || (request->offset + maskIter == RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY)) - { - closeFieldPattern(hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns); - - isBuildingFieldPattern = TI_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 == TI_FALSE) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, ": Creating a new field pattern.\n"); - - isBuildingFieldPattern = TI_TRUE; - ++(*numFieldPatterns); - - if (*numFieldPatterns > RX_DATA_FILTER_MAX_FIELD_PATTERNS) - { - TRACE1(pRxData->hReport, REPORT_SEVERITY_ERROR, ": Invalid filter, too many field patterns, maximum of %u is allowed!\n", RX_DATA_FILTER_MAX_FIELD_PATTERNS); - - return TI_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; - } - - TRACE2(pRxData->hReport, REPORT_SEVERITY_INFORMATION, ": offset = %d, flag = %d.\n", fieldPattern.offset, fieldPattern.flag); - } - - /* check that the pattern is long enough */ - if (patternIter > request->patternLength) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, ": Invalid filter, mask and pattern length are not consistent!\n"); - - return TI_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) - { - TRACE1(pRxData->hReport, REPORT_SEVERITY_ERROR, ": Invalid filter, pattern matching cannot exceed first %u characters.\n", RX_DATA_FILTER_FILTER_BOUNDARY); - - return TI_NOK; - } - } - } - - /* check that the pattern is long enough */ - if (patternIter != request->patternLength) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, ": Invalid filter, mask and pattern lengths are not consistent!\n"); - - return TI_NOK; - } - - /* close the last field pattern if needed */ - if (isBuildingFieldPattern) - { - closeFieldPattern (hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns); - } - - return TI_OK; -} - - -/*************************************************************************** -* rxData_setRxDataFilter * -**************************************************************************** -* DESCRIPTION: -* -* -* INPUTS: -* -* -* -* OUTPUT: -* -* RETURNS: -* -***************************************************************************/ -static TI_STATUS rxData_addRxDataFilter (TI_HANDLE hRxData, TRxDataFilterRequest* request) -{ - rxData_t * pRxData = (rxData_t *) hRxData; - - /* firmware request fields */ - TI_UINT8 index = 0; - TI_UINT8 numFieldPatterns = 0; - TI_UINT8 lenFieldPatterns = 0; - TI_UINT8 fieldPatterns[MAX_DATA_FILTER_SIZE]; - - /* does the filter already exist? */ - if (findFilterRequest(hRxData, request) >= 0) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, ": Filter already exists.\n"); - - return RX_FILTER_ALREADY_EXISTS; - } - - /* find place for insertion */ - for (index = 0; index < MAX_DATA_FILTERS; ++index) - { - if (pRxData->isFilterSet[index] == TI_FALSE) - break; - } - - /* are all filter slots taken? */ - if (index == MAX_DATA_FILTERS) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, ": No place to insert filter!\n"); - - return RX_NO_AVAILABLE_FILTERS; - } - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION, ": Inserting filter at index %d.\n", index); - - /* parse the filter request into discrete field patterns */ - if (parseRxDataFilterRequest(hRxData, request, &numFieldPatterns, &lenFieldPatterns, fieldPatterns) != TI_OK) - return TI_NOK; - - if (numFieldPatterns == 0) - return TI_NOK; - - /* Store configuration for future manipulation */ - pRxData->isFilterSet[index] = TI_TRUE; - os_memoryCopy(pRxData->hOs, &pRxData->filterRequests[index], request, sizeof(pRxData->filterRequests[index])); - - /* Send configuration to firmware */ - return TWD_CfgRxDataFilter (pRxData->hTWD, - index, - ADD_FILTER, - FILTER_SIGNAL, - numFieldPatterns, - lenFieldPatterns, - fieldPatterns); - -} - -/*************************************************************************** -* rxData_removeRxDataFilter * -**************************************************************************** -* DESCRIPTION: -* -* -* INPUTS: -* -* -* -* OUTPUT: -* -* RETURNS: -* -***************************************************************************/ -static TI_STATUS rxData_removeRxDataFilter (TI_HANDLE hRxData, TRxDataFilterRequest* request) -{ - rxData_t * pRxData = (rxData_t *) hRxData; - - int index = findFilterRequest(hRxData, request); - - /* does the filter exist? */ - if (index < 0) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_WARNING, ": Remove data filter request received but the specified filter was not found!"); - - return RX_FILTER_DOES_NOT_EXIST; - } - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION, ": Removing filter at index %d.", index); - - pRxData->isFilterSet[index] = TI_FALSE; - - return TWD_CfgRxDataFilter (pRxData->hTWD, - index, - REMOVE_FILTER, - FILTER_SIGNAL, - 0, - 0, - NULL); -} - -/*************************************************************************** -* rxData_DistributorRxEvent * -**************************************************************************** -* DESCRIPTION: -* -* -* INPUTS: -* -* -* -* OUTPUT: -* -* RETURNS: -* -***************************************************************************/ -static void rxData_DistributorRxEvent (rxData_t *pRxData, TI_UINT16 Mask, int DataLen) -{ - DistributorMgr_EventCall (pRxData->RxEventDistributor, Mask, DataLen); -} - -/*************************************************************************** -* rxData_RegNotif * -****************************************************************************/ -TI_HANDLE rxData_RegNotif (TI_HANDLE hRxData, TI_UINT16 EventMask, GeneralEventCall_t CallBack, TI_HANDLE context, TI_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, TI_UINT16 EventMask) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - if (!hRxData) - return TI_NOK; - - return DistributorMgr_AddToMask (pRxData->RxEventDistributor, Notifh, EventMask); -} - - -/*************************************************************************** -* rxData_UnRegNotif * -****************************************************************************/ -TI_STATUS rxData_UnRegNotif(TI_HANDLE hRxData,TI_HANDLE RegEventHandle) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - if (!hRxData) - return TI_NOK; - - return DistributorMgr_UnReg (pRxData->RxEventDistributor, RegEventHandle); -} - - -/*************************************************************************** -* rxData_receivePacketFromWlan * -**************************************************************************** -* DESCRIPTION: this function is called by the GWSI for each received Buffer. -* It filter and distribute the received Buffer. -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -void rxData_receivePacketFromWlan (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - TMacAddr address3; - dot11_header_t *pDot11Hdr; - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_receivePacketFromWlan() : pRxAttr->packetType = %d\n", pRxAttr->ePacketType); - - switch (pRxAttr->ePacketType) - { - case TAG_CLASS_MANAGEMENT: - case TAG_CLASS_BCN_PRBRSP: - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION, "rxData_receivePacketFromWlan(): Received management Buffer len = %d\n", RX_BUF_LEN(pBuffer)); - - /* update siteMngr - * - * the BSSID in mgmt frames is always addr3 in the header - * must copy address3 since Buffer is freed in mlmeParser_recv - */ - pDot11Hdr = (dot11_header_t*)RX_BUF_DATA(pBuffer); - - os_memoryCopy(pRxData->hOs, &address3, &pDot11Hdr->address3, sizeof(address3)); - - /* distribute mgmt pBuffer to mlme */ - if( mlmeParser_recv(pRxData->hMlme, pBuffer, pRxAttr) != TI_OK ) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, " rxData_receivePacketFromWlan() : MLME returned error \n"); - } - break; - - case TAG_CLASS_DATA: - case TAG_CLASS_QOS_DATA: - case TAG_CLASS_AMSDU: - case TAG_CLASS_EAPOL: - { - CL_TRACE_START_L3(); - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_receivePacketFromWlan() : Received Data Buffer len = %d\n", RX_BUF_LEN(pBuffer)); - - /* send pBuffer to data dispatcher */ - rxData_dataPacketDisptcher(hRxData, pBuffer, pRxAttr); - CL_TRACE_END_L3("tiwlan_drv.ko", "INHERIT", "RX", ".DataPacket"); - break; - } - - default: - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_receivePacketFromWlan(): Received unspecified packet type !!! \n"); - RxBufFree(pRxData->hOs, pBuffer); - break; - } -} - -/*************************************************************************** -* rxData_dataPacketDisptcher * -**************************************************************************** -* DESCRIPTION: this function is called upon receving data Buffer, -* it dispatches the packet to the approciate function according to -* data packet type and rx port status. -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ - -static void rxData_dataPacketDisptcher (TI_HANDLE hRxData, void *pBuffer, TRxAttr* 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) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_dataPacketDisptcher() : Received Data Buffer while Rx data port is closed \n"); - - rxData_discardPacket (hRxData, pBuffer, pRxAttr); - return; - } - - /* get data packet type */ - - pRxData->uLastDataPktRate = pRxAttr->Rate; /* save Rx packet rate for statistics */ - -#ifdef XCC_MODULE_INCLUDED - if (XCCMngr_isIappPacket (pRxData->hXCCMgr, pBuffer) == TI_TRUE) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_dataPacketDisptcher() : Received Iapp Buffer \n"); - - DataPacketType = DATA_IAPP_PACKET; - - /* dispatch Buffer according to packet type and current rx data port status */ - pRxData->rxData_dispatchBuffer[DataPortStatus][DataPacketType] (hRxData, pBuffer, pRxAttr); - } - else -#endif - { - /* A-MSDU ? */ - if (TAG_CLASS_AMSDU == pRxAttr->ePacketType) - { - rxData_ConvertAmsduToEthPackets (hRxData, pBuffer, pRxAttr); - } - else - { - TI_UINT16 etherType = 0; - TEthernetHeader * 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, pBuffer, ðerType); - - pEthernetHeader = (TEthernetHeader *)RX_ETH_PKT_DATA(pBuffer); - - if (etherType == ETHERTYPE_802_1D) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_dataPacketDisptcher() : Received VLAN packet \n"); - - DataPacketType = DATA_VLAN_PACKET; - } - else if ((HTOWLANS(pEthernetHeader->type) == EAPOL_PACKET) || - (HTOWLANS(pEthernetHeader->type) == pRxData->genericEthertype)) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_dataPacketDisptcher() : Received Eapol packet \n"); - - if (rxData_IsReAuthInProgress(pRxData)) - { - /* ReAuth already in progress, restart timer */ - rxData_StopReAuthActiveTimer(pRxData); - rxData_StartReAuthActiveTimer(pRxData); - } - else - { - if (PowerMgr_getReAuthActivePriority(pRxData->hPowerMgr)) - { - /* ReAuth not in progress yet, force active, set flag, restart timer, send event */ - rxData_SetReAuthInProgress(pRxData, TI_TRUE); - rxData_StartReAuthActiveTimer(pRxData); - rxData_ReauthEnablePriority(pRxData); - EvHandlerSendEvent(pRxData->hEvHandler, IPC_EVENT_RE_AUTH_STARTED, NULL, 0); - } - } - - DataPacketType = DATA_EAPOL_PACKET; - } - else - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_dataPacketDisptcher() : Received Data packet \n"); - - DataPacketType = DATA_DATA_PACKET; - } - - /* dispatch Buffer according to packet type and current rx data port status */ - pRxData->rxData_dispatchBuffer[DataPortStatus][DataPacketType] (hRxData, pBuffer, pRxAttr); - } - } - -} - -/*************************************************************************** -* rxData_discardPacket * -**************************************************************************** -* DESCRIPTION: this function is called to discard Buffer -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -static void rxData_discardPacket (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE2(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_discardPacket: rx port status = %d , Buffer status = %d \n", pRxData->rxDataPortStatus, pRxAttr->status); - - pRxData->rxDataDbgCounters.excludedFrameCounter++; - - /* free Buffer */ - RxBufFree(pRxData->hOs, pBuffer); - -} - -/*************************************************************************** -* rxData_discardPacketVlan * -**************************************************************************** -* DESCRIPTION: this function is called to discard Buffer -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -static void rxData_discardPacketVlan (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE0(pRxData->hReport, REPORT_SEVERITY_WARNING, " rxData_discardPacketVlan : drop packet that contains VLAN tag\n"); - - pRxData->rxDataDbgCounters.rxDroppedDueToVLANIncludedCnt++; - - /* free Buffer */ - RxBufFree(pRxData->hOs, pBuffer); -} - - -/*************************************************************************** -* rxData_rcvPacketInOpenNotify * -**************************************************************************** -* DESCRIPTION: this function is called upon receving data Eapol packet type -* while rx port status is "open notify" -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -static void rxData_rcvPacketInOpenNotify (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, " rxData_rcvPacketInOpenNotify: receiving data packet while in rx port status is open notify\n"); - - pRxData->rxDataDbgCounters.rcvUnicastFrameInOpenNotify++; - - /* free Buffer */ - RxBufFree(pRxData->hOs, pBuffer); -} - - -/*************************************************************************** -* rxData_rcvPacketEapol * -**************************************************************************** -* DESCRIPTION: this function is called upon receving data Eapol packet type -* while rx port status is "open eapol" -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -static void rxData_rcvPacketEapol(TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_rcvPacketEapol() : Received an EAPOL frame tranferred to OS\n"); - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_rcvPacketEapol() : Received an EAPOL frame tranferred to OS\n"); - - EvHandlerSendEvent (pRxData->hEvHandler, IPC_EVENT_EAPOL, NULL, 0); - os_receivePacket (pRxData->hOs, (struct RxIfDescriptor_t*)pBuffer, pBuffer, (TI_UINT16)RX_ETH_PKT_LEN(pBuffer)); - -} - -/*************************************************************************** -* rxData_rcvPacketData * -**************************************************************************** -* DESCRIPTION: this function is called upon receving data "data" packet type -* while rx port status is "open" -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -static void rxData_rcvPacketData(TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - TEthernetHeader *pEthernetHeader; - TI_UINT16 EventMask = 0; - TFwInfo *pFwInfo; - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_rcvPacketData() : Received DATA frame tranferred to OS\n"); - - /* check encryption status */ - pEthernetHeader = (TEthernetHeader *)RX_ETH_PKT_DATA(pBuffer); - if (!MAC_MULTICAST (pEthernetHeader->dst)) - { /* unicast frame */ - if((pRxData->rxDataExcludeUnencrypted) && (!(pRxAttr->packetInfo & RX_DESC_ENCRYPT_MASK))) - { - pRxData->rxDataDbgCounters.excludedFrameCounter++; - /* free Buffer */ - TRACE0(pRxData->hReport, REPORT_SEVERITY_WARNING, " rxData_rcvPacketData() : exclude unicast unencrypted is TI_TRUE & packet encryption is OFF\n"); - - RxBufFree(pRxData->hOs, pBuffer); - return; - } - } - else - { /* broadcast frame */ - if ((pRxData->rxDataExludeBroadcastUnencrypted) && (!(pRxAttr->packetInfo & RX_DESC_ENCRYPT_MASK))) - { - pRxData->rxDataDbgCounters.excludedFrameCounter++; - /* free Buffer */ - TRACE0(pRxData->hReport, REPORT_SEVERITY_WARNING, " rxData_rcvPacketData() : exclude broadcast unencrypted is TI_TRUE & packet encryption is OFF\n"); - - RxBufFree(pRxData->hOs, pBuffer); - return; - } - - /* - * Discard multicast/broadcast frames that we sent ourselves. - * Per IEEE 802.11-2007 section 9.2.7: "STAs shall filter out - * broadcast/multicast messages that contain their address as - * the source address." - */ - pFwInfo = TWD_GetFWInfo (pRxData->hTWD); - if (MAC_EQUAL(pFwInfo->macAddress, pEthernetHeader->src)) - { - pRxData->rxDataDbgCounters.excludedFrameCounter++; - /* free Buffer */ - RxBufFree(pRxData->hOs, pBuffer); - return; - } - } - - /* update traffic monitor parameters */ - pRxData->rxDataCounters.RecvOk++; - EventMask |= RECV_OK; - - if (!MAC_MULTICAST (pEthernetHeader->dst)) - { - /* Directed frame */ - pRxData->rxDataCounters.DirectedFramesRecv++; - pRxData->rxDataCounters.DirectedBytesRecv += RX_ETH_PKT_LEN(pBuffer); - EventMask |= DIRECTED_BYTES_RECV; - EventMask |= DIRECTED_FRAMES_RECV; - } - else if (MAC_BROADCAST (pEthernetHeader->dst)) - { - /* Broadcast frame */ - pRxData->rxDataCounters.BroadcastFramesRecv++; - pRxData->rxDataCounters.BroadcastBytesRecv += RX_ETH_PKT_LEN(pBuffer); - EventMask |= BROADCAST_BYTES_RECV; - EventMask |= BROADCAST_FRAMES_RECV; - } - else - { - /* Multicast Address */ - pRxData->rxDataCounters.MulticastFramesRecv++; - pRxData->rxDataCounters.MulticastBytesRecv += RX_ETH_PKT_LEN(pBuffer); - EventMask |= MULTICAST_BYTES_RECV; - EventMask |= MULTICAST_FRAMES_RECV; - } - pRxData->rxDataCounters.LastSecBytesRecv += RX_ETH_PKT_LEN(pBuffer); - - /*Handle PREAUTH_EAPOL_PACKET*/ - if (HTOWLANS(pEthernetHeader->type) == PREAUTH_EAPOL_PACKET) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_rcvPacketData() : Received an Pre-Auth EAPOL frame tranferred to OS\n"); - } - - rxData_DistributorRxEvent (pRxData, EventMask, RX_ETH_PKT_LEN(pBuffer)); - - /* deliver packet to os */ - os_receivePacket (pRxData->hOs, (struct RxIfDescriptor_t*)pBuffer, pBuffer, (TI_UINT16)RX_ETH_PKT_LEN(pBuffer)); -} - - -/*************************************************************************** -* rxData_rcvPacketIapp * -**************************************************************************** -* DESCRIPTION: this function is called upon receving data IAPP packet type -* while rx port status is "open" -* -* INPUTS: hRxData - the object -* pBuffer - the received Buffer. -* pRxAttr - Rx attributes -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -#ifdef XCC_MODULE_INCLUDED - -static void rxData_rcvPacketIapp(TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_rcvPacketIapp() : Received IAPP frame tranferred to XCCMgr\n"); - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_rcvPacketIapp() : Received IAPP frame tranferred to XCCMgr\n"); - - /* tranfer packet to XCCMgr */ - XCCMngr_recvIAPPPacket (pRxData->hXCCMgr, pBuffer, pRxAttr); - - /* free Buffer */ - RxBufFree(pRxData->hOs, pBuffer); -} - -#endif - - -/**************************************************************************** -* rxData_convertWlanToEthHeader * -***************************************************************************** -* DESCRIPTION: this function convert the Packet header from 802.11 header -* format to ethernet format -* -* INPUTS: hRxData - the object -* pBuffer - the received pBuffer in 802.11 format -* -* OUTPUT: pEthPacket - pointer to the received pBuffer in ethernet format -* uEthLength - ethernet packet length -* -* RETURNS: TI_OK/TI_NOK -***************************************************************************/ -static TI_STATUS rxData_convertWlanToEthHeader (TI_HANDLE hRxData, void *pBuffer, TI_UINT16 * etherType) -{ - TEthernetHeader EthHeader; - Wlan_LlcHeader_T *pWlanSnapHeader; - TI_UINT8 *dataBuf; - dot11_header_t *pDot11Header; - TI_UINT32 lengthDelta; - TI_UINT16 swapedTypeLength; - TI_UINT32 headerLength; - TI_UINT8 createEtherIIHeader; - rxData_t *pRxData = (rxData_t *)hRxData; - - dataBuf = (TI_UINT8 *)RX_BUF_DATA(pBuffer); - - /* Setting the mac header len according to the received FrameControl field in the Mac Header */ - GET_MAX_HEADER_SIZE (dataBuf, &headerLength); - pDot11Header = (dot11_header_t*) dataBuf; - pWlanSnapHeader = (Wlan_LlcHeader_T*)((TI_UINT32)dataBuf + (TI_UINT32)headerLength); - - swapedTypeLength = WLANTOHS (pWlanSnapHeader->Type); - *etherType = swapedTypeLength; - - /* Prepare the Ethernet header. */ - if( ENDIAN_HANDLE_WORD(pDot11Header->fc) & DOT11_FC_FROM_DS) - { /* Infrastructure bss */ - MAC_COPY (EthHeader.dst, pDot11Header->address1); - MAC_COPY (EthHeader.src, pDot11Header->address3); - } - else - { /* Independent bss */ - MAC_COPY (EthHeader.dst, pDot11Header->address1); - MAC_COPY (EthHeader.src, pDot11Header->address2); - } - - createEtherIIHeader = TI_FALSE; - /* 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 = TI_TRUE; - } - /* Check for the RFC 1042 OUI in the SNAP Header */ - else - { - /* Check for the RFC 1042 OUI in the SNAP Header */ - if( (SNAP_OUI_RFC1042_BYTE0 == pWlanSnapHeader->OUI[ 0 ]) && - (SNAP_OUI_RFC1042_BYTE1 == pWlanSnapHeader->OUI[ 1 ]) && - (SNAP_OUI_RFC1042_BYTE2 == pWlanSnapHeader->OUI[ 2 ])) - { - /* 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 = TI_TRUE; - } - } - } - } - - if( createEtherIIHeader == TI_TRUE ) - { - /* The LEN/TYPE bytes are set to TYPE, the entire WLAN+SNAP is removed.*/ - lengthDelta = headerLength + WLAN_SNAP_HDR_LEN - ETHERNET_HDR_LEN; - EthHeader.type = 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.*/ - lengthDelta = headerLength - ETHERNET_HDR_LEN; - EthHeader.type = WLANTOHS((TI_UINT16)(RX_BUF_LEN(pBuffer) - headerLength)); - } - - /* Replace the 802.11 header and the LLC with Ethernet packet. */ - dataBuf += lengthDelta; - os_memoryCopy (pRxData->hOs, dataBuf, (void*)&EthHeader, ETHERNET_HDR_LEN); - RX_ETH_PKT_DATA(pBuffer) = dataBuf; - RX_ETH_PKT_LEN(pBuffer) = RX_BUF_LEN(pBuffer) - lengthDelta; - - return TI_OK; -} - - -/** - * \brief convert A-MSDU to several ethernet packets - * - * \param hRxData - the object - * \param pBuffer - the received Buffer in A-MSDU 802.11n format - * \param pRxAttr - Rx attributes - * \return TI_OK on success or TI_NOK on failure - * - * \par Description - * Static function - * This function convert the A-MSDU Packet from A-MSDU 802.11n packet - * format to several ethernet packets format and pass them to the OS layer - * - * \sa - */ -static TI_STATUS rxData_ConvertAmsduToEthPackets (TI_HANDLE hRxData, void *pBuffer, TRxAttr* pRxAttr) -{ - - TEthernetHeader *pMsduEthHeader; - TEthernetHeader *pEthHeader; - Wlan_LlcHeader_T *pWlanSnapHeader; - TI_UINT8 *pAmsduDataBuf; - TI_UINT16 uAmsduDataLen; - void *pDataBuf; - TI_UINT16 uDataLen; - TI_UINT32 lengthDelta; - TI_UINT16 swapedTypeLength; - TI_UINT32 headerLength; - rxDataPacketType_e DataPacketType; - rxData_t *pRxData = (rxData_t *)hRxData; - - /* total AMPDU header */ - pAmsduDataBuf = (TI_UINT8 *)RX_BUF_DATA(pBuffer); - /* Setting the mac header len according to the received FrameControl field in the Mac Header */ - GET_MAX_HEADER_SIZE (pAmsduDataBuf, &headerLength); - - /* - * init loop setting - */ - /* total AMPDU size */ - uAmsduDataLen = (TI_UINT16)(RX_BUF_LEN(pBuffer) - headerLength); - /* ETH header */ - pMsduEthHeader = (TEthernetHeader *)(pAmsduDataBuf + headerLength); - /* ETH length, in A-MSDU the MSDU header type contain the MSDU length and not the type */ - uDataLen = WLANTOHS(pMsduEthHeader->type); - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION, "rxData_ConvertAmsduToEthPackets(): A-MSDU received in length %d \n",uAmsduDataLen); - - /* if we have another packet at the AMSDU */ - while((uDataLen < uAmsduDataLen) && (uAmsduDataLen > ETHERNET_HDR_LEN + FCS_SIZE)) - { - /* allocate a new buffer */ - /* RxBufAlloc() add an extra word for alignment the MAC payload */ - rxData_RequestForBuffer (hRxData, &pDataBuf, sizeof(RxIfDescriptor_t) + WLAN_SNAP_HDR_LEN + ETHERNET_HDR_LEN + uDataLen, 0, TAG_CLASS_AMSDU); - if (NULL == pDataBuf) - { - TRACE1(pRxData->hReport, REPORT_SEVERITY_ERROR, "rxData_ConvertAmsduToEthPackets(): cannot alloc MSDU packet. length %d \n",uDataLen); - rxData_discardPacket (hRxData, pBuffer, pRxAttr); - return TI_NOK; - } - - /* read packet type from LLC */ - pWlanSnapHeader = (Wlan_LlcHeader_T*)((TI_UINT8*)pMsduEthHeader + ETHERNET_HDR_LEN); - swapedTypeLength = WLANTOHS (pWlanSnapHeader->Type); - - /* copy the RxIfDescriptor */ - os_memoryCopy (pRxData->hOs, pDataBuf, pBuffer, sizeof(RxIfDescriptor_t)); - - /* update length, in the RxIfDescriptor the Len in words (4B) */ - ((RxIfDescriptor_t *)pDataBuf)->length = (sizeof(RxIfDescriptor_t) + WLAN_SNAP_HDR_LEN + ETHERNET_HDR_LEN + uDataLen) >> 2; - ((RxIfDescriptor_t *)pDataBuf)->extraBytes = 4 - ((sizeof(RxIfDescriptor_t) + WLAN_SNAP_HDR_LEN + ETHERNET_HDR_LEN + uDataLen) & 0x3); - - /* Prepare the Ethernet header pointer. */ - /* add padding in the start of the buffer in order to align ETH payload */ - pEthHeader = (TEthernetHeader *)((TI_UINT8 *)(RX_BUF_DATA(pDataBuf)) + - WLAN_SNAP_HDR_LEN + - PADDING_ETH_PACKET_SIZE); - - /* copy the Ethernet header */ - os_memoryCopy (pRxData->hOs, pEthHeader, pMsduEthHeader, ETHERNET_HDR_LEN); - - /* The LEN/TYPE bytes are set to TYPE */ - pEthHeader->type = pWlanSnapHeader->Type; - - /* Delta length for the next packet */ - lengthDelta = ETHERNET_HDR_LEN + uDataLen; - - /* copy the packet payload */ - if (uDataLen > WLAN_SNAP_HDR_LEN) - os_memoryCopy (pRxData->hOs, - (((TI_UINT8*)pEthHeader) + ETHERNET_HDR_LEN), - ((TI_UINT8*)pMsduEthHeader) + ETHERNET_HDR_LEN + WLAN_SNAP_HDR_LEN, - uDataLen - WLAN_SNAP_HDR_LEN); - - /* set the packet type */ - if (swapedTypeLength == ETHERTYPE_802_1D) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_ConvertAmsduToEthPackets() : Received VLAN Buffer \n"); - - DataPacketType = DATA_VLAN_PACKET; - } - else if (HTOWLANS(pEthHeader->type) == EAPOL_PACKET) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_ConvertAmsduToEthPackets() : Received Eapol pBuffer \n"); - - DataPacketType = DATA_EAPOL_PACKET; - } - else - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, " rxData_ConvertAmsduToEthPackets() : Received Data pBuffer \n"); - - DataPacketType = DATA_DATA_PACKET; - } - - /* update buffer setting */ - /* save the ETH packet address */ - RX_ETH_PKT_DATA(pDataBuf) = pEthHeader; - /* save the ETH packet size */ - RX_ETH_PKT_LEN(pDataBuf) = uDataLen + ETHERNET_HDR_LEN - WLAN_SNAP_HDR_LEN; - - /* star of MSDU packet always align acceding to 11n spec */ - lengthDelta = (lengthDelta + ALIGN_4BYTE_MASK) & ~ALIGN_4BYTE_MASK; - pMsduEthHeader = (TEthernetHeader *)(((TI_UINT8*)pMsduEthHeader) + lengthDelta); - - if(uAmsduDataLen > lengthDelta) - { - /* swich to the next MSDU */ - uAmsduDataLen = uAmsduDataLen - lengthDelta; - - /* Clear the EndOfBurst flag for all packets except the last one */ - ((RxIfDescriptor_t *)pDataBuf)->driverFlags &= ~DRV_RX_FLAG_END_OF_BURST; - } - else - { - /* no more MSDU */ - uAmsduDataLen = 0; - } - - - /* in A-MSDU the MSDU header type contain the MSDU length and not the type */ - uDataLen = WLANTOHS(pMsduEthHeader->type); - - - /* dispatch Buffer according to packet type and current rx data port status */ - pRxData->rxData_dispatchBuffer[pRxData->rxDataPortStatus][DataPacketType] (hRxData, pDataBuf, pRxAttr); - - } /* while end */ - - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION, "rxData_ConvertAmsduToEthPackets(): A-MSDU Packe conversion done.\n"); - - /* free the A-MSDU packet */ - RxBufFree(pRxData->hOs, pBuffer); - - return TI_OK; -} - -/**************************************************************************************** - * rxData_ReceivePacket * - **************************************************************************************** -DESCRIPTION: receive packet CB from RxXfer. - parse the status and other parameters and forward the frame to - rxData_receivePacketFromWlan() - -INPUT: Rx frame with its parameters - -OUTPUT: - -RETURN: - -************************************************************************/ -static void rxData_ReceivePacket (TI_HANDLE hRxData, - void *pBuffer) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION, "rxData_ReceivePacket: Received BUF %x\n", pBuffer); - - if (pBuffer) - { - RxIfDescriptor_t *pRxParams = (RxIfDescriptor_t*)pBuffer; - TRxAttr RxAttr; - ERate appRate; - 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 - */ - - pHdr = (dot11_header_t *)RX_BUF_DATA(pBuffer); - - /* Check status */ - switch (pRxParams->status & RX_DESC_STATUS_MASK) - { - case RX_DESC_STATUS_SUCCESS: - break; - - case RX_DESC_STATUS_DECRYPT_FAIL: - { - /* This error is not important before the Connection, so we ignore it when portStatus is not OPEN */ - if (pRxData->rxDataPortStatus == OPEN) - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_WARNING, "rxData_ReceivePacket: Received Packet with RX_DESC_DECRYPT_FAIL\n"); - } - - RxBufFree(pRxData->hOs, pBuffer); - return; - } - case RX_DESC_STATUS_MIC_FAIL: - { - TI_UINT8 uKeyType; - paramInfo_t Param; - TMacAddr* 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 = (TI_UINT8)KEY_TKIP_MIC_GROUP; - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, "rxData_ReceivePacket: Received Packet MIC failure. Type = Group\n"); - } - /* Unicast on infrastructure */ - else - { - uKeyType = (TI_UINT8)KEY_TKIP_MIC_PAIRWISE; - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, "rxData_ReceivePacket: Received Packet MIC failure. Type = Pairwise\n"); - } - - - rsn_reportMicFailure (pRxData->hRsn, &uKeyType, sizeof(uKeyType)); - RxBufFree(pRxData->hOs, pBuffer); - return; - } - - case RX_DESC_STATUS_DRIVER_RX_Q_FAIL: - { - /* Rx queue error - free packet and return */ - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR, "rxData_ReceivePacket: Received Packet with Rx queue error \n"); - - RxBufFree(pRxData->hOs, pBuffer); - return; - } - - default: - /* Unknown error - free packet and return */ - TRACE1(pRxData->hReport, REPORT_SEVERITY_ERROR, "rxData_ReceivePacket: Received Packet with unknown status = %d\n", (pRxParams->status & RX_DESC_STATUS_MASK)); - - RxBufFree(pRxData->hOs, pBuffer); - return; - } - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION , "Receive good Packet\n"); - - if (rate_PolicyToDrv ((ETxRateClassId)(pRxParams->rate), &appRate) != TI_OK) - { - TRACE1(pRxData->hReport, REPORT_SEVERITY_ERROR , "rxData_ReceivePacket: can't convert hwRate=0x%x\n", pRxParams->rate); - } - - /* - * Set rx attributes - */ - RxAttr.channel = pRxParams->channel; - RxAttr.packetInfo = pRxParams->flags; - RxAttr.ePacketType= pRxParams->packet_class_tag; - RxAttr.Rate = appRate; - RxAttr.Rssi = pRxParams->rx_level; - RxAttr.SNR = pRxParams->rx_snr; - RxAttr.status = pRxParams->status & RX_DESC_STATUS_MASK; - /* for now J band not implemented */ - RxAttr.band = ((pRxParams->flags & RX_DESC_BAND_MASK) == RX_DESC_BAND_A) ? - RADIO_BAND_5_0_GHZ : RADIO_BAND_2_4_GHZ ; - RxAttr.eScanTag = (EScanResultTag)(pRxParams->proccess_id_tag); - /* timestamp is 32 bit so do bytes copy to avoid exception in case the RxInfo is in 2 bytes offset */ - os_memoryCopy (pRxData->hOs, - (void *)&(RxAttr.TimeStamp), - (void *)&(pRxParams->timestamp), - sizeof(pRxParams->timestamp) ); - RxAttr.TimeStamp = ENDIAN_HANDLE_LONG(RxAttr.TimeStamp); - - TRACE8(pRxData->hReport, REPORT_SEVERITY_INFORMATION, "rxData_ReceivePacket: channel=%d, info=0x%x, type=%d, rate=0x%x, RSSI=%d, SNR=%d, status=%d, scan tag=%d\n", RxAttr.channel, RxAttr.packetInfo, RxAttr.ePacketType, RxAttr.Rate, RxAttr.Rssi, RxAttr.SNR, RxAttr.status, RxAttr.eScanTag); - - rxData_receivePacketFromWlan (hRxData, pBuffer, &RxAttr); - - /* - * Buffer MUST be freed until now - */ - } - else - { - TRACE0(pRxData->hReport, REPORT_SEVERITY_ERROR , "rxData_ReceivePacket: null Buffer received"); - } -} - - -/**************************************************************************************** - * rxData_RequestForBuffer * - **************************************************************************************** -DESCRIPTION: RX request for buffer - uEncryptionflag API are for GWSI use. -INPUT: - -OUTPUT: - -RETURN: - -************************************************************************/ -static ERxBufferStatus rxData_RequestForBuffer (TI_HANDLE hRxData, - void **pBuf, - TI_UINT16 aLength, - TI_UINT32 uEncryptionflag, - PacketClassTag_e ePacketClassTag) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION , " RequestForBuffer, length = %d \n",aLength); - - *pBuf = RxBufAlloc (pRxData->hOs, aLength, ePacketClassTag); - - if (*pBuf) - { - return RX_BUF_ALLOC_COMPLETE; - } - else - { - return RX_BUF_ALLOC_OUT_OF_MEM; - } -} - - -/******************************************************************* -* DEBUG FUNCTIONS * -*******************************************************************/ - -#ifdef TI_DBG - -/*************************************************************************** -* rxData_resetCounters * -**************************************************************************** -* DESCRIPTION: This function reset the Rx Data module counters -* -* INPUTS: hRxData - the object -* -* OUTPUT: -* -* RETURNS: void -***************************************************************************/ -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) -{ -#ifdef REPORT_LOG - 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)); - } -#endif -} - - -void rxData_printRxBlock(TI_HANDLE hRxData) -{ -#ifdef REPORT_LOG - 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(("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(("rxDataPortStatus = %d\n", pRxData->rxDataPortStatus)); - WLAN_OS_REPORT(("rxDataExcludeUnencrypted = %d\n", pRxData->rxDataExcludeUnencrypted)); - WLAN_OS_REPORT(("rxDataEapolDestination = %d\n", pRxData->rxDataEapolDestination)); -#endif -} - - -void rxData_startRxThroughputTimer (TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - if (!pRxData->rxThroughputTimerEnable) - { - /* reset throughput counter */ - pRxData->rxDataCounters.LastSecBytesRecv = 0; - pRxData->rxThroughputTimerEnable = TI_TRUE; - - /* start 1 sec throughput timer */ - tmr_StartTimer (pRxData->hThroughputTimer, - rxData_printRxThroughput, - (TI_HANDLE)pRxData, - 1000, - TI_TRUE); - } -} - - -void rxData_stopRxThroughputTimer (TI_HANDLE hRxData) -{ - - rxData_t *pRxData = (rxData_t *)hRxData; - - if (pRxData->rxThroughputTimerEnable) - { - tmr_StopTimer (pRxData->hThroughputTimer); - pRxData->rxThroughputTimerEnable = TI_FALSE; - } -} - - -static void rxData_printRxThroughput (TI_HANDLE hRxData, TI_BOOL bTwdInitOccured) -{ - 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) -{ - TI_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)); - report_PrintDump(pRxData->filterRequests[index].pattern, pRxData->filterRequests[index].patternLength); - report_PrintDump(pRxData->filterRequests[index].mask, pRxData->filterRequests[index].maskLength); - } - else - { - WLAN_OS_REPORT (("No Filter defined for index-%d\n", index)); - } - } -} - -#endif /*TI_DBG*/ - -/**************************************************************************** - * rxData_SetReAuthInProgress() - **************************************************************************** - * DESCRIPTION: Sets the ReAuth flag value - * - * INPUTS: hRxData - the object - * value - value to set the flag to - * - * OUTPUT: None - * - * RETURNS: OK or NOK - ****************************************************************************/ -void rxData_SetReAuthInProgress(TI_HANDLE hRxData, TI_BOOL value) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE1(pRxData->hReport, REPORT_SEVERITY_INFORMATION , "Set ReAuth flag to %d\n", value); - - pRxData->reAuthInProgress = value; -} - -/**************************************************************************** - * rxData_IsReAuthInProgress() - **************************************************************************** - * DESCRIPTION: Returns the ReAuth flag value - * - * INPUTS: hRxData - the object - * - * OUTPUT: None - * - * RETURNS: ReAuth flag value - ****************************************************************************/ -TI_BOOL rxData_IsReAuthInProgress(TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - return pRxData->reAuthInProgress; -} - -/**************************************************************************** -* rxData_StartReAuthActiveTimer * -***************************************************************************** -* DESCRIPTION: this function starts the ReAuthActive timer -* -* INPUTS: hRxData - the object -* -* OUTPUT: None -* -* RETURNS: None -***************************************************************************/ -static void rxData_StartReAuthActiveTimer(TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION , "Start ReAuth Active Timer\n"); - tmr_StartTimer (pRxData->reAuthActiveTimer, - reAuthTimeout, - (TI_HANDLE)pRxData, - pRxData->reAuthActiveTimeout, - TI_FALSE); -} - -/**************************************************************************** -* rxData_StopReAuthActiveTimer * -***************************************************************************** -* DESCRIPTION: this function stops the ReAuthActive timer -* -* INPUTS: hRxData - the object -* -* OUTPUT: None -* -* RETURNS: None -***************************************************************************/ -void rxData_StopReAuthActiveTimer(TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION , "Stop ReAuth Active Timer\n"); - tmr_StopTimer (pRxData->reAuthActiveTimer); -} - -/**************************************************************************** -* reAuthTimeout * -***************************************************************************** -* DESCRIPTION: this function ia called when the ReAuthActive timer elapses -* It resets the Reauth flag and restore the PS state. -* It also sends RE_AUTH_TERMINATED event to upper layer. -* -* INPUTS: hRxData - the object -* -* OUTPUT: None -* -* RETURNS: None -***************************************************************************/ -static void reAuthTimeout(TI_HANDLE hRxData, TI_BOOL bTwdInitOccured) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - - TRACE0(pRxData->hReport, REPORT_SEVERITY_INFORMATION , "ReAuth Active Timeout\n"); - rxData_SetReAuthInProgress(pRxData, TI_FALSE); - rxData_ReauthDisablePriority(pRxData); - EvHandlerSendEvent(pRxData->hEvHandler, IPC_EVENT_RE_AUTH_TERMINATED, NULL, 0); -} - -void rxData_ReauthEnablePriority(TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - paramInfo_t param; - - param.paramType = POWER_MGR_ENABLE_PRIORITY; - param.content.powerMngPriority = POWER_MANAGER_REAUTH_PRIORITY; - powerMgr_setParam(pRxData->hPowerMgr,¶m); -} - -void rxData_ReauthDisablePriority(TI_HANDLE hRxData) -{ - rxData_t *pRxData = (rxData_t *)hRxData; - paramInfo_t param; - - param.paramType = POWER_MGR_DISABLE_PRIORITY; - param.content.powerMngPriority = POWER_MANAGER_REAUTH_PRIORITY; - powerMgr_setParam(pRxData->hPowerMgr,¶m); -} diff --git a/wl1271/stad/src/Data_link/rx.h b/wl1271/stad/src/Data_link/rx.h deleted file mode 100644 index 76cab1e..0000000 --- a/wl1271/stad/src/Data_link/rx.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * rx.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: rx.h */ -/* PURPOSE: Rx module functions header file */ -/* */ -/***************************************************************************/ -#ifndef _RX_DATA_H_ -#define _RX_DATA_H_ - -#include "paramOut.h" -#include "TWDriver.h" - -#define DEF_EXCLUDE_UNENCYPTED TI_FALSE -#define DEF_EAPOL_DESTINATION OS_ABS_LAYER -#define DEF_RX_PORT_STATUS CLOSE - -typedef struct -{ - TI_UINT32 excludedFrameCounter; - TI_UINT32 rxDroppedDueToVLANIncludedCnt; - TI_UINT32 rxWrongBssTypeCounter; - TI_UINT32 rxWrongBssIdCounter; - TI_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_pBufferDispatchert) (TI_HANDLE hRxData , void *pBuffer, TRxAttr *pRxAttr); - - -typedef struct -{ - /* Handles */ - TI_HANDLE hCtrlData; - TI_HANDLE hTWD; - TI_HANDLE hMlme; - TI_HANDLE hOs; - TI_HANDLE hRsn; - TI_HANDLE hReport; - TI_HANDLE hSiteMgr; - TI_HANDLE hXCCMgr; - TI_HANDLE hEvHandler; - TI_HANDLE hTimer; - TI_HANDLE RxEventDistributor; - TI_HANDLE hThroughputTimer; - TI_HANDLE hPowerMgr; - TI_BOOL rxThroughputTimerEnable; - TI_BOOL rxDataExcludeUnencrypted; - TI_BOOL rxDataExludeBroadcastUnencrypted; - eapolDestination_e rxDataEapolDestination; - - portStatus_e rxDataPortStatus; - - /* Rx Data Filters */ - filter_e filteringDefaultAction; - TI_BOOL filteringEnabled; - TI_BOOL isFilterSet[MAX_DATA_FILTERS]; - TRxDataFilterRequest filterRequests[MAX_DATA_FILTERS]; - - /* Counters */ - rxDataCounters_t rxDataCounters; - rxDataDbgCounters_t rxDataDbgCounters; - - rxData_pBufferDispatchert rxData_dispatchBuffer[MAX_NUM_OF_RX_PORT_STATUS][MAX_NUM_OF_RX_DATA_TYPES]; - - TI_INT32 prevSeqNum; - - TI_UINT32 uLastDataPktRate; /* save Rx packet rate for statistics */ - - TI_BOOL reAuthInProgress; - TI_HANDLE reAuthActiveTimer; - TI_UINT32 reAuthActiveTimeout; - - - /* Generic Ethertype support */ - TI_UINT16 genericEthertype; -}rxData_t; - -#endif diff --git a/wl1271/stad/src/Data_link/txCtrl.c b/wl1271/stad/src/Data_link/txCtrl.c deleted file mode 100644 index 22977cd..0000000 --- a/wl1271/stad/src/Data_link/txCtrl.c +++ /dev/null @@ -1,1378 +0,0 @@ -/* - * txCtrl.c - * - * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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: txCtrl.c */ -/* PURPOSE: The central Tx path module. */ -/* Prepares Tx packets sent from the data-queue and mgmt-queue */ -/* for copy to the FW, including building the header and the */ -/* Tx-descriptor. */ -/* */ -/*******************************************************************************/ -#define __FILE_ID__ FILE_ID_56 -#include "tidef.h" -#include "paramOut.h" -#include "osApi.h" -#include "TWDriver.h" -#include "DataCtrl_Api.h" -#include "802_11Defs.h" -#include "Ethernet.h" -#include "report.h" -#include "timer.h" -#include "TI_IPC_Api.h" -#include "EvHandler.h" -#include "qosMngr_API.h" -#include "healthMonitor.h" -#include "txCtrl.h" -#include "txCtrl_Api.h" -#include "DrvMainModules.h" -#ifdef XCC_MODULE_INCLUDED -#include "XCCMngr.h" -#endif -#include "bmtrace_api.h" - - -/* - * Module internal functions prototypes: - */ - -/* Note: put here and not in txCtrl.h to avoid warning in the txCtrl submodules that include txCtrl.h */ - -static void txCtrl_TxCompleteCb (TI_HANDLE hTxCtrl, TxResultDescriptor_t *pTxResultInfo); -static void txCtrl_BuildDataPkt (txCtrl_t *pTxCtrl, TTxCtrlBlk *pPktCtrlBlk, - TI_UINT32 uAc, TI_UINT32 uBackpressure); -static void txCtrl_BuildMgmtPkt (txCtrl_t *pTxCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_UINT32 uAc); -static void txCtrl_UpdateHighestAdmittedAcTable (txCtrl_t *pTxCtrl); -static void txCtrl_UpdateAcToTidMapping (txCtrl_t *pTxCtrl); -static void txCtrl_UpdateBackpressure (txCtrl_t *pTxCtrl, TI_UINT32 freedAcBitmap); -static void txCtrl_UpdateTxCounters (txCtrl_t *pTxCtrl, - TxResultDescriptor_t *pTxResultInfo, - TTxCtrlBlk *pPktCtrlBlk, - TI_UINT32 ac, - TI_BOOL bIsDataPkt); -#ifdef XCC_MODULE_INCLUDED /* Needed only for XCC-V4 */ -static void txCtrl_SetTxDelayCounters (txCtrl_t *pTxCtrl, - TI_UINT32 ac, - TI_UINT32 fwDelay, - TI_UINT32 driverDelay, - TI_UINT32 mediumDelay); -#endif /* XCC_MODULE_INCLUDED */ - - -/******************************************************************************** -* * -* MACROS and INLINE FUNCTIONS * -* * -*********************************************************************************/ -/* Get the highest admitted AC equal or below the requested one. */ -/* AC to TID translation is bivalent so update TID only if the AC was changed. */ -#define SELECT_AC_FOR_TID(ptc,tid,ac) \ - ac = ptc->highestAdmittedAc[WMEQosTagToACTable[tid]]; \ - if (ac != WMEQosTagToACTable[tid]) \ - tid = WMEQosAcToTid[ac] - -/* Update packet length in the descriptor according to HW interface requirements */ -static inline TI_UINT16 txCtrl_TranslateLengthToFw (TTxCtrlBlk *pPktCtrlBlk) -{ - TI_UINT16 uPktLen = pPktCtrlBlk->tTxDescriptor.length; - TI_UINT16 uLastWordPad; - TI_UINT32 uBufNum; - - uPktLen = (uPktLen + 3) & 0xFFFC; /* Add alignment bytes if needed */ - uLastWordPad = uPktLen - pPktCtrlBlk->tTxDescriptor.length; /* Find number of alignment bytes added */ - uPktLen = uPktLen >> 2; /* Convert length to words */ - pPktCtrlBlk->tTxDescriptor.length = ENDIAN_HANDLE_WORD(uPktLen);/* Save FW format length in descriptor */ - - /* Find last buffer (last buffer in use is pointed by uBufNum-1) */ - for (uBufNum = 1; uBufNum < MAX_XFER_BUFS; uBufNum++) - { - if (pPktCtrlBlk->tTxnStruct.aLen[uBufNum] == 0) - { - break; - } - } - /* Add last word alignment pad also to the last buffer length */ - pPktCtrlBlk->tTxnStruct.aLen[uBufNum - 1] += uLastWordPad; - - return uLastWordPad; -} - -/* Translate packet timestamp to FW time, and update also lifeTime and uDriverDelay */ -static inline void txCtrl_TranslateTimeToFw (txCtrl_t *pTxCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_UINT16 uLifeTime) -{ - TI_UINT32 uPktStartTime = pPktCtrlBlk->tTxDescriptor.startTime; /* Contains host start time */ - - /* Save host packet handling time until this point (for statistics) */ - pPktCtrlBlk->tTxPktParams.uDriverDelay = os_timeStampMs (pTxCtrl->hOs) - uPktStartTime; - - /* Translate packet timestamp to FW time and undate descriptor */ - uPktStartTime = TWD_TranslateToFwTime (pTxCtrl->hTWD, uPktStartTime); - pPktCtrlBlk->tTxDescriptor.startTime = ENDIAN_HANDLE_LONG (uPktStartTime); - pPktCtrlBlk->tTxDescriptor.lifeTime = ENDIAN_HANDLE_WORD (uLifeTime); -} - - - -/******************************************************************************** -* * -* PUBLIC FUNCTIONS IMPLEMENTATION * -* * -*********************************************************************************/ - -/************************************************************************* -* txCtrl_Create * -************************************************************************** -* DESCRIPTION: This function initializes the Tx module. -* -* INPUT: hOs - handle to Os Abstraction Layer -* -* OUTPUT: -* -* RETURN: Handle to the allocated Tx data control block -*************************************************************************/ -TI_HANDLE txCtrl_Create (TI_HANDLE hOs) -{ - txCtrl_t *pTxCtrl; - - /* allocate Tx module control block */ - pTxCtrl = os_memoryAlloc(hOs, (sizeof(txCtrl_t))); - - if (!pTxCtrl) - return NULL; - - /* reset tx control object */ - os_memoryZero(hOs, pTxCtrl, (sizeof(txCtrl_t))); - - pTxCtrl->TxEventDistributor = DistributorMgr_Create(hOs, MAX_TX_NOTIF_REQ_ELMENTS); - - pTxCtrl->hOs = hOs; - - return pTxCtrl; -} - - -/*************************************************************************** -* txCtrl_Init * -**************************************************************************** -* DESCRIPTION: This function configures the TxCtrl module. -***************************************************************************/ -void txCtrl_Init (TStadHandlesList *pStadHandles) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)(pStadHandles->hTxCtrl); - TI_UINT32 ac; - - /* Save other modules handles */ - pTxCtrl->hOs = pStadHandles->hOs; - pTxCtrl->hReport = pStadHandles->hReport; - pTxCtrl->hCtrlData = pStadHandles->hCtrlData; - pTxCtrl->hTWD = pStadHandles->hTWD; - pTxCtrl->hTxDataQ = pStadHandles->hTxDataQ; - pTxCtrl->hTxMgmtQ = pStadHandles->hTxMgmtQ; - pTxCtrl->hEvHandler = pStadHandles->hEvHandler; - pTxCtrl->hHealthMonitor = pStadHandles->hHealthMonitor; - pTxCtrl->hTimer = pStadHandles->hTimer; - pTxCtrl->hStaCap = pStadHandles->hStaCap; - pTxCtrl->hXCCMngr = pStadHandles->hXCCMngr; - pTxCtrl->hQosMngr = pStadHandles->hQosMngr; - pTxCtrl->hRxData = pStadHandles->hRxData; - - /* Set Tx parameters to defaults */ - pTxCtrl->headerConverMode = HDR_CONVERT_NONE; - pTxCtrl->currentPrivacyInvokedMode = DEF_CURRENT_PRIVACY_MODE; - pTxCtrl->eapolEncryptionStatus = DEF_EAPOL_ENCRYPTION_STATUS; - pTxCtrl->encryptionFieldSize = 0; - pTxCtrl->currBssType = BSS_INFRASTRUCTURE; - pTxCtrl->busyAcBitmap = 0; - pTxCtrl->dbgPktSeqNum = 0; - pTxCtrl->bCreditCalcTimerRunning = TI_FALSE; - pTxCtrl->genericEthertype = ETHERTYPE_EAPOL; - - for (ac = 0; ac < MAX_NUM_OF_AC; ac++) - { - pTxCtrl->aMsduLifeTimeTu[ac] = MGMT_PKT_LIFETIME_TU; - pTxCtrl->ackPolicy[ac] = ACK_POLICY_LEGACY; - pTxCtrl->admissionState[ac] = AC_ADMITTED; - pTxCtrl->admissionRequired[ac] = ADMISSION_NOT_REQUIRED; - pTxCtrl->useAdmissionAlgo[ac] = TI_FALSE; - pTxCtrl->mediumTime[ac] = 0; - pTxCtrl->lastCreditCalcTimeStamp[ac] = 0; - pTxCtrl->credit[ac] = 0; - } - - /* Reset counters */ - txCtrlParams_resetCounters (pStadHandles->hTxCtrl); - -#ifdef TI_DBG - txCtrlParams_resetDbgCounters (pStadHandles->hTxCtrl); -#endif - - /* Register the Tx-Complete callback function. */ - TWD_RegisterCb (pTxCtrl->hTWD, - TWD_EVENT_TX_RESULT_SEND_PKT_COMPLETE, - (void*)txCtrl_TxCompleteCb, - pStadHandles->hTxCtrl); - - /* Register the Update-Busy-Map callback function. */ - TWD_RegisterCb (pTxCtrl->hTWD, - TWD_EVENT_TX_HW_QUEUE_UPDATE_BUSY_MAP, - (void *)txCtrl_UpdateBackpressure, - pStadHandles->hTxCtrl); - - TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_INIT, ".....Tx Data configured successfully\n"); -} - - -/************************************************************************* -* txCtrl_SetDefaults * -************************************************************************** -* DESCRIPTION: -* -* INPUT: -* txDataInitParams - Tx Data creation parameters -* -* OUTPUT: -* -* RETURN: -*************************************************************************/ -TI_STATUS txCtrl_SetDefaults (TI_HANDLE hTxCtrl, txDataInitParams_t *txDataInitParams) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->creditCalculationTimeout = txDataInitParams->creditCalculationTimeout; - pTxCtrl->bCreditCalcTimerEnabled = txDataInitParams->bCreditCalcTimerEnabled; - - /* Update queues mapping (AC/TID/Backpressure) after module init. */ - txCtrl_UpdateQueuesMapping (hTxCtrl); - - /* allocate timer for credit calculation */ - pTxCtrl->hCreditTimer = tmr_CreateTimer (pTxCtrl->hTimer); - if (pTxCtrl->hCreditTimer == NULL) - { - TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, "txCtrl_SetDefaults(): Failed to create hCreditTimer!\n"); - return TI_NOK; - } - - return TI_OK; -} - - -/*************************************************************************** -* txCtrl_Unload * -**************************************************************************** -* DESCRIPTION: This function unload the tx ctrl module. -* -***************************************************************************/ -TI_STATUS txCtrl_Unload (TI_HANDLE hTxCtrl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - if (pTxCtrl == NULL) - { - return TI_NOK; - } - - DistributorMgr_Destroy (pTxCtrl->TxEventDistributor); - - if (pTxCtrl->hCreditTimer) - { - tmr_DestroyTimer (pTxCtrl->hCreditTimer); - } - - /* free Tx Data control block */ - os_memoryFree (pTxCtrl->hOs, pTxCtrl, sizeof(txCtrl_t)); - - return TI_OK; -} - - - -/******************************************************************************* -* txCtrl_XmitData * -******************************************************************************** -* DESCRIPTION: Get a packet from the data-queue, allocate HW resources and CtrlBlk, -* build header and descriptor, and send it to HW by TxXfer. -* -* RETURNS: STATUS_XMIT_SUCCESS - Packet sent succesfully -* STATUS_XMIT_BUSY - Packet dropped due to lack of HW resources, retransmit later. -* STATUS_XMIT_ERROR - Packet dropped due to an unexpected problem (bug). -********************************************************************************/ -TI_STATUS txCtrl_XmitData (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - ETxnStatus eStatus; /* The Xfer return value (different than this function's return values). */ - TI_UINT32 uAc; - TI_UINT32 uBackpressure = 0; /* HwQueue's indication when the current queue becomes busy. */ - ETxHwQueStatus eHwQueStatus; - CL_TRACE_START_L3(); - - /* Get an admitted AC corresponding to the packet TID. - * If downgraded due to admission limitation, the TID is downgraded as well. - */ - SELECT_AC_FOR_TID (pTxCtrl, pPktCtrlBlk->tTxDescriptor.tid, uAc); - -#ifdef TI_DBG -TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_XmitData(): Pkt Tx, DescID=%d, AC=%d, Len=%d\n", pPktCtrlBlk->tTxDescriptor.descID, uAc, pPktCtrlBlk->tTxDescriptor.length ); - - pTxCtrl->dbgCounters.dbgNumPktsSent[uAc]++; -#endif - - /* Call TxHwQueue for Hw resources allocation. */ - { - CL_TRACE_START_L4(); - eHwQueStatus = TWD_txHwQueue_AllocResources (pTxCtrl->hTWD, pPktCtrlBlk); - CL_TRACE_END_L4("tiwlan_drv.ko", "INHERIT", "TX", ".allocResources"); - } - - /* If the current AC can't get more packets, stop it in data-queue module. */ - if (eHwQueStatus == TX_HW_QUE_STATUS_STOP_NEXT) - { -#ifdef TI_DBG - pTxCtrl->dbgCounters.dbgNumPktsBackpressure[uAc]++; - TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_XmitData(): Backpressure = 0x%x, queue = %d\n", uBackpressure, uAc); -#endif - uBackpressure = 1 << uAc; - pTxCtrl->busyAcBitmap |= uBackpressure; /* Set the busy bit of the current AC. */ - txDataQ_StopQueue (pTxCtrl->hTxDataQ, pTxCtrl->admittedAcToTidMap[uAc]); - } - - /* If current packet can't be transmitted due to lack of resources, return with BUSY value. */ - else if (eHwQueStatus == TX_HW_QUE_STATUS_STOP_CURRENT) - { -#ifdef TI_DBG - pTxCtrl->dbgCounters.dbgNumPktsBusy[uAc]++; - TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_XmitData(): Queue busy - Packet dropped, queue = %d\n", uAc); -#endif - txDataQ_StopQueue (pTxCtrl->hTxDataQ, pTxCtrl->admittedAcToTidMap[uAc]); - CL_TRACE_END_L3("tiwlan_drv.ko", "INHERIT", "TX", ""); - return STATUS_XMIT_BUSY; - } - - /* Prepare the packet control-block including the Tx-descriptor. */ - { - CL_TRACE_START_L4(); - txCtrl_BuildDataPkt(pTxCtrl, pPktCtrlBlk, uAc, uBackpressure); - CL_TRACE_END_L4("tiwlan_drv.ko", "INHERIT", "TX", ".FillCtrlBlk"); - } - - /* Call the Tx-Xfer to start packet transfer to the FW and return its result. */ - { - CL_TRACE_START_L4(); - eStatus = TWD_txXfer_SendPacket (pTxCtrl->hTWD, pPktCtrlBlk); - CL_TRACE_END_L4("tiwlan_drv.ko", "INHERIT", "TX", ".XferSendPacket"); - } - - if (eStatus == TXN_STATUS_ERROR) - { -#ifdef TI_DBG -TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, "txCtrl_XmitData(): Xfer Error, queue = %d, Status = %d\n", uAc, eStatus); - pTxCtrl->dbgCounters.dbgNumPktsError[uAc]++; -#endif - - /* Free the packet resources (packet and CtrlBlk) */ - txCtrl_FreePacket (pTxCtrl, pPktCtrlBlk, TI_NOK); - - CL_TRACE_END_L3("tiwlan_drv.ko", "INHERIT", "TX", ""); - return STATUS_XMIT_ERROR; - } - -#ifdef TI_DBG - pTxCtrl->dbgCounters.dbgNumPktsSuccess[uAc]++; -#endif - CL_TRACE_END_L3("tiwlan_drv.ko", "INHERIT", "TX", ""); - return STATUS_XMIT_SUCCESS; -} - - -/******************************************************************************* -* txCtrl_XmitMgmt * -******************************************************************************** -* DESCRIPTION: Get a packet from the Mgmt-Queue (management, EAPOL or IAPP), -* allocate HW resources and CtrlBlk, build header if Ethernet (EAPOL), -* build descriptor, and send packet to HW by TxXfer. -* -* RETURNS: STATUS_XMIT_SUCCESS - Packet sent succesfully. -* STATUS_XMIT_BUSY - Packet dropped due to lack of HW resources, retransmit later. -* STATUS_XMIT_ERROR - Packet dropped due to an unexpected problem (bug). -********************************************************************************/ -TI_STATUS txCtrl_XmitMgmt (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - ETxnStatus eStatus; /* The Xfer return value (different than this function's return values). */ - TI_UINT32 uAc; /* The AC selected for the packet transmission. */ - TI_UINT32 uBackpressure = 0;/* HwQueue's indication when the current queue becomes busy. */ - ETxHwQueStatus eHwQueStatus; - - /* Get an admitted AC corresponding to the packet TID. - * If downgraded due to admission limitation, the TID is downgraded as well. - */ - SELECT_AC_FOR_TID (pTxCtrl, pPktCtrlBlk->tTxDescriptor.tid, uAc); - -#ifdef TI_DBG - pTxCtrl->dbgCounters.dbgNumPktsSent[uAc]++; -#endif - - /* Call TxHwQueue for Hw resources allocation. */ - eHwQueStatus = TWD_txHwQueue_AllocResources (pTxCtrl->hTWD, pPktCtrlBlk); - - /* If the used AC can't get more packets, stop it in mgmt-queue module. */ - if (eHwQueStatus == TX_HW_QUE_STATUS_STOP_NEXT) - { -#ifdef TI_DBG - pTxCtrl->dbgCounters.dbgNumPktsBackpressure[uAc]++; - TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_XmitMgmt(): Backpressure = 0x%x, queue = %d\n", uBackpressure, uAc); -#endif - uBackpressure = 1 << uAc; - pTxCtrl->busyAcBitmap |= uBackpressure; /* Set the busy bit of the current AC. */ - txMgmtQ_StopQueue (pTxCtrl->hTxMgmtQ, pTxCtrl->admittedAcToTidMap[uAc]); - } - - /* If current packet can't be transmitted due to lack of resources, return with BUSY value. */ - else if (eHwQueStatus == TX_HW_QUE_STATUS_STOP_CURRENT) - { -#ifdef TI_DBG - pTxCtrl->dbgCounters.dbgNumPktsBusy[uAc]++; - TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_XmitMgmt(): Queue busy - Packet dropped, queue = %d\n", uAc); -#endif - txMgmtQ_StopQueue (pTxCtrl->hTxMgmtQ, pTxCtrl->admittedAcToTidMap[uAc]); - return STATUS_XMIT_BUSY; - } - - /* Prepare the packet control-block including the Tx-descriptor. */ - txCtrl_BuildMgmtPkt (pTxCtrl, pPktCtrlBlk, uAc); - - /* Call the Tx-Xfer to start packet transfer to the FW and return the result. */ - eStatus = TWD_txXfer_SendPacket (pTxCtrl->hTWD, pPktCtrlBlk); - - if (eStatus == TXN_STATUS_ERROR) - { -#ifdef TI_DBG -TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, "txCtrl_XmitMgmt(): Xfer Error, Status = %d\n", eStatus); - pTxCtrl->dbgCounters.dbgNumPktsError[uAc]++; -#endif - /* Free the packet resources (packet and CtrlBlk) */ - txCtrl_FreePacket (pTxCtrl, pPktCtrlBlk, TI_NOK); - return STATUS_XMIT_ERROR; - } - -#ifdef TI_DBG - pTxCtrl->dbgCounters.dbgNumPktsSuccess[uAc]++; -#endif - return STATUS_XMIT_SUCCESS; -} - - -/*************************************************************************** -* txCtrl_UpdateQueuesMapping -**************************************************************************** -* DESCRIPTION: This function should be called upon the following events: -* 1) Init -* 2) ACs admission required change (upon association) -* 3) ACs admission state change (upon association and add/delete Tspec). -* It updates the following mappings (by this oredr!): -* 1) Update mapping from requested-AC to highest-admitted-AC. -* 2) Update mapping from actual-AC to requested-TID (for backpressure mapping). -* 3) Update TID-backpressure bitmap, and if changed update data-queue and mgmt-queue. -* -***************************************************************************/ -void txCtrl_UpdateQueuesMapping (TI_HANDLE hTxCtrl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - /* Update mapping from requested-AC to highest-admitted-AC. */ - txCtrl_UpdateHighestAdmittedAcTable (pTxCtrl); - - /* Update mapping from actual-AC to requested-TID (for backpressure mapping). */ - txCtrl_UpdateAcToTidMapping (pTxCtrl); - - /* Update TID-backpressure bitmap, and if changed update data-queue and mgmt-queue. */ - txCtrl_UpdateBackpressure (pTxCtrl, 0); -} - - -/*************************************************************************** -* txCtrl_AllocPacketBuffer -**************************************************************************** -* DESCRIPTION: Allocate a raw buffer for the whole Tx packet. - Used for driver generated packets and when the OAL needs to - copy the packet to a new buffer (e.g. to gather multiple buffers). -***************************************************************************/ -void *txCtrl_AllocPacketBuffer (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_UINT32 uPacketLen) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - void *pRawBuf = os_memoryAlloc (pTxCtrl->hOs, uPacketLen); - - if (pRawBuf) - { - /* Indicate that the packet is in a raw buffer (i.e. not OS packet) and save its address and length */ - pPktCtrlBlk->tTxPktParams.uFlags |= TX_CTRL_FLAG_PKT_IN_RAW_BUF; - - /* Save buffer address and length for the free operation */ - pPktCtrlBlk->tTxPktParams.pInputPkt = pRawBuf; - pPktCtrlBlk->tTxPktParams.uInputPktLen = uPacketLen; - - TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_AllocPacketBuffer(): pRawBuf = 0x%x, uPacketLen = %d\n", pRawBuf, uPacketLen); - } - else - { - TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, "txCtrl_AllocPacketBuffer(): uPacketLen = %d, returning NULL\n", uPacketLen); - } - - return pRawBuf; -} - - -/*************************************************************************** -* txCtrl_FreePacket -**************************************************************************** -* DESCRIPTION: Free the packet resources, including the packet and the CtrlBlk -***************************************************************************/ -void txCtrl_FreePacket (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_STATUS eStatus) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_FreePacket(): RawBufFlag = 0x%x, pBuf = 0x%x, Len = %d\n", (pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_PKT_IN_RAW_BUF), pPktCtrlBlk->tTxPktParams.pInputPkt, pPktCtrlBlk->tTxPktParams.uInputPktLen); - - /* If the packet is in a raw buffer, free its memory */ - if (pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_PKT_IN_RAW_BUF) - { - os_memoryFree (pTxCtrl->hOs, - pPktCtrlBlk->tTxPktParams.pInputPkt, - pPktCtrlBlk->tTxPktParams.uInputPktLen); - } - /* If the original packet is in OS format, call the OAL to free it */ - else - { - wlanDrvIf_FreeTxPacket (pTxCtrl->hOs, pPktCtrlBlk, eStatus); - } - - /* Free the CtrlBlk */ - TWD_txCtrlBlk_Free (pTxCtrl->hTWD, pPktCtrlBlk); -} - - - -/******************************************************************************** -* * -* LOCAL FUNCTIONS IMPLEMENTATION * -* * -*********************************************************************************/ - - -/************************************************************************* -* txCtrl_TxCompleteCb * -************************************************************************** -* DESCRIPTION: Called by the TWD upon Tx-complete of one packet. -* Handle packet result: -* - Update counters (statistics and medium-usage) -* - Free the packet resources (Wbuf and CtrlBlk) -* -* INPUT: hTWD - The Tnetw-Driver handle. -* pTxResultInfo - The packet's Tx result information. -* -*************************************************************************/ -static void txCtrl_TxCompleteCb (TI_HANDLE hTxCtrl, TxResultDescriptor_t *pTxResultInfo) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TTxCtrlBlk *pPktCtrlBlk; - TI_UINT32 ac; - TI_BOOL bIsDataPkt; - CL_TRACE_START_L3(); - - /* Get packet ctrl-block by desc-ID. */ - pPktCtrlBlk = TWD_txCtrlBlk_GetPointer (pTxCtrl->hTWD, pTxResultInfo->descID); - ac = WMEQosTagToACTable[pPktCtrlBlk->tTxDescriptor.tid]; - -#ifdef TI_DBG - /* If the pointed entry is already free, print error and exit (not expected to happen). */ - if (pPktCtrlBlk->pNextFreeEntry != NULL) - { -TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, "txCtrl_TxCompleteCb(): Pkt already free!!, DescID=%d, AC=%d\n", pTxResultInfo->descID, ac); - CL_TRACE_END_L3("tiwlan_drv.ko", "INHERIT", "TX_Cmplt", ""); - return; - } -TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_TxCompleteCb(): Pkt Tx Complete, DescID=%d, AC=%d, Status=%d\n", pTxResultInfo->descID, ac, pTxResultInfo->status); -#endif - /* 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. */ - TWD_SetSecuritySeqNum (pTxCtrl->hTWD, pTxResultInfo->lsbSecuritySequenceNumber); - - bIsDataPkt = ( (pPktCtrlBlk->tTxPktParams.uPktType == TX_PKT_TYPE_ETHER) || - (pPktCtrlBlk->tTxPktParams.uPktType == TX_PKT_TYPE_WLAN_DATA) ); - -#ifdef XCC_MODULE_INCLUDED - /* If it's a XCC link-test packet, call its handler. */ - if (pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_LINK_TEST) - { - CL_TRACE_START_L4(); - XCCMngr_LinkTestRetriesUpdate (pTxCtrl->hXCCMngr, pTxResultInfo->ackFailures); - CL_TRACE_END_L4("tiwlan_drv.ko", "INHERIT", "TX_Cmplt", ".XCCLinkTest"); - } -#endif - - /* Add the medium usage time for the specific queue. */ - pTxCtrl->totalUsedTime[ac] += (TI_UINT32)ENDIAN_HANDLE_WORD(pTxResultInfo->mediumUsage); - - /* update TX counters for txDistributer */ - { - CL_TRACE_START_L4(); - txCtrl_UpdateTxCounters (pTxCtrl, pTxResultInfo, pPktCtrlBlk, ac, bIsDataPkt); - CL_TRACE_END_L4("tiwlan_drv.ko", "INHERIT", "TX_Cmplt", ".Cntrs"); - } - - /* Free the packet resources (packet and CtrlBlk) */ - txCtrl_FreePacket (pTxCtrl, pPktCtrlBlk, TI_OK); - - CL_TRACE_END_L3("tiwlan_drv.ko", "INHERIT", "TX_Cmplt", ""); -} - - -/*************************************************************************** -* txCtrl_BuildDataPktHdr * -**************************************************************************** -* DESCRIPTION: this function builds the WLAN header from ethernet format, -* including 802.11-MAC, LLC/SNAP, security padding, alignment padding. -* -* INPUTS: hTxCtrl - the object -* pPktCtrlBlk - data packet control block (Ethernet header) -* -* RETURNS: uHdrAlignPad - Num of bytes (0 or 2) added at the header's beginning for 4-bytes alignment. -***************************************************************************/ - -TI_UINT32 txCtrl_BuildDataPktHdr (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk, AckPolicy_e eAckPolicy) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TEthernetHeader *pEthHeader; - dot11_header_t *pDot11Header; - Wlan_LlcHeader_T *pWlanSnapHeader; - EHeaderConvertMode eQosMode = pTxCtrl->headerConverMode; - TI_UINT32 uHdrLen = 0; - TI_UINT32 uHdrAlignPad = 0; - TI_UINT16 uQosControl; - TI_UINT16 fc = 0; - TI_UINT16 typeLength; - - - /* - * Handle encryption if needed, for data or EAPOL (decision was done at RSN): - * - Set WEP bit in header. - * - Add padding for FW security overhead: 4 bytes for TKIP, 8 for AES. - */ - - if (( (pPktCtrlBlk->tTxPktParams.uPktType == TX_PKT_TYPE_EAPOL) - && - pTxCtrl->eapolEncryptionStatus) - || - ((pPktCtrlBlk->tTxPktParams.uPktType != TX_PKT_TYPE_EAPOL) - && - pTxCtrl->currentPrivacyInvokedMode )) - { - fc |= DOT11_FC_WEP; - uHdrLen += pTxCtrl->encryptionFieldSize; - uHdrAlignPad = pTxCtrl->encryptionFieldSize % 4; - } - - /* - * Handle QoS if needed: - */ - if (eQosMode == HDR_CONVERT_QOS) - { - uHdrAlignPad = (uHdrAlignPad + HEADER_PAD_SIZE) % 4; /* Add 2 bytes pad at the header beginning for 4 bytes alignment. */ - pDot11Header = (dot11_header_t *)&(pPktCtrlBlk->aPktHdr[uHdrAlignPad]); - uHdrLen += WLAN_QOS_HDR_LEN; - - /* add empty 4Byte for HT control field set via the FW */ - if (pTxCtrl->tTxCtrlHtControl.bHtEnable == TI_TRUE) - { - uHdrLen += WLAN_QOS_HT_CONTROL_FIELD_LEN; - fc |= DOT11_FC_ORDER; - } - - /* Set Qos control fields. */ - uQosControl = (TI_UINT16)(pPktCtrlBlk->tTxDescriptor.tid); - if ( TI_UNLIKELY(eAckPolicy == ACK_POLICY_NO_ACK) ) - uQosControl |= DOT11_QOS_CONTROL_DONT_ACK; - COPY_WLAN_WORD(&pDot11Header->qosControl, &uQosControl); /* copy with endianess handling. */ - } - else /* No QoS (legacy header, padding is not needed). */ - { - pDot11Header = (dot11_header_t *)&(pPktCtrlBlk->aPktHdr[uHdrAlignPad]); - uHdrLen += WLAN_HDR_LEN; - } - uHdrLen += uHdrAlignPad; - - /* Before the header translation the first buf-pointer points to the Ethernet header. */ - pEthHeader = (TEthernetHeader *)(pPktCtrlBlk->tTxnStruct.aBuf[0]); - - if (TI_UNLIKELY(MAC_MULTICAST(pEthHeader->dst))) - { - pPktCtrlBlk->tTxPktParams.uFlags |= TX_CTRL_FLAG_MULTICAST; - if (MAC_BROADCAST(pEthHeader->dst)) - { - pPktCtrlBlk->tTxPktParams.uFlags |= TX_CTRL_FLAG_BROADCAST; - } - } - - /* Set MAC header fields for Independent-BSS case. */ - if ( TI_UNLIKELY(pTxCtrl->currBssType == BSS_INDEPENDENT) ) - { - MAC_COPY (pDot11Header->address1, pEthHeader->dst); - MAC_COPY (pDot11Header->address2, pEthHeader->src); - MAC_COPY (pDot11Header->address3, pTxCtrl->currBssId); - - if (eQosMode == HDR_CONVERT_QOS) - fc |= DOT11_FC_DATA_QOS; - else - fc |= DOT11_FC_DATA; - } - - /* Set MAC header fields for Infrastructure-BSS case. */ - else - { - MAC_COPY (pDot11Header->address1, pTxCtrl->currBssId); - MAC_COPY (pDot11Header->address2, pEthHeader->src); - MAC_COPY (pDot11Header->address3, pEthHeader->dst); - - if (eQosMode == HDR_CONVERT_QOS) - fc |= DOT11_FC_DATA_QOS | DOT11_FC_TO_DS; - else - fc |= DOT11_FC_DATA | DOT11_FC_TO_DS; - } - - COPY_WLAN_WORD(&pDot11Header->fc, &fc); /* copy with endianess handling. */ - - /* Set the SNAP header pointer right after the other header parts handled above. */ - pWlanSnapHeader = (Wlan_LlcHeader_T *)&(pPktCtrlBlk->aPktHdr[uHdrLen]); - - typeLength = HTOWLANS(pEthHeader->type); - - /* Detect the packet type and decide if to create a */ - /* new SNAP or leave the original LLC. */ - /*------------------------------------------------------*/ - if( typeLength > ETHERNET_MAX_PAYLOAD_SIZE ) - { - /* Create the SNAP Header: */ - /*-----------------------------*/ - /* - * Make a working copy of the SNAP header - * initialised to zero - */ - - pWlanSnapHeader->DSAP = SNAP_CHANNEL_ID; - pWlanSnapHeader->SSAP = SNAP_CHANNEL_ID; - pWlanSnapHeader->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 == typeLength ) || - ( ETHERTYPE_DIX_II_IPX == typeLength )) - { - /* Fill out the SNAP Header with 802.1H extention */ - pWlanSnapHeader->OUI[0] = SNAP_OUI_802_1H_BYTE0; - pWlanSnapHeader->OUI[1] = SNAP_OUI_802_1H_BYTE1; - pWlanSnapHeader->OUI[2] = SNAP_OUI_802_1H_BYTE2; - - } - else - { - /* otherwise, add the RFC1042 SNAP */ - pWlanSnapHeader->OUI[0] = SNAP_OUI_RFC1042_BYTE0; - pWlanSnapHeader->OUI[1] = SNAP_OUI_RFC1042_BYTE0; - pWlanSnapHeader->OUI[2] = SNAP_OUI_RFC1042_BYTE0; - } - - /* set type length */ - pWlanSnapHeader->Type = pEthHeader->type; - - /* Add the SNAP length to the total header length. */ - uHdrLen += sizeof(Wlan_LlcHeader_T); - } - - /* Replace first buffer pointer and length to the descriptor and WLAN-header (instead of Ether header) */ - pPktCtrlBlk->tTxnStruct.aBuf[0] = (TI_UINT8 *)&(pPktCtrlBlk->tTxDescriptor); - pPktCtrlBlk->tTxnStruct.aLen[0] = sizeof(TxIfDescriptor_t) + uHdrLen; - pPktCtrlBlk->tTxDescriptor.length += pPktCtrlBlk->tTxnStruct.aLen[0] - ETHERNET_HDR_LEN; - - /* Return the number of bytes (0 or 2) added at the header's beginning for 4-bytes alignment. */ - return uHdrAlignPad; -} - - -/*************************************************************************** -* txCtrl_BuildDataPkt -**************************************************************************** -* DESCRIPTION: Prepare the Data packet control-block including the Tx-descriptor. -***************************************************************************/ -static void txCtrl_BuildDataPkt (txCtrl_t *pTxCtrl, TTxCtrlBlk *pPktCtrlBlk, - TI_UINT32 uAc, TI_UINT32 uBackpressure) -{ - TI_UINT32 uHdrAlignPad; /* Num of bytes added between Tx-descriptor and header for 4 bytes alignment (0 or 2). */ - TI_UINT16 uLastWordPad; /* Num of bytes added at the end of the packet for 4 bytes alignment */ - TI_UINT16 uTxDescAttr; - AckPolicy_e eAckPolicy = pTxCtrl->ackPolicy[uAc]; - - /* Build packet header (including MAC, LLC/SNAP, security padding, header alignment padding). */ - uHdrAlignPad = txCtrl_BuildDataPktHdr ((TI_HANDLE)pTxCtrl, pPktCtrlBlk, eAckPolicy); - - /* Update packet length in the descriptor according to HW interface requirements */ - uLastWordPad = txCtrl_TranslateLengthToFw (pPktCtrlBlk); - - /* Set the descriptor attributes */ - uTxDescAttr = pTxCtrl->dataPktDescAttrib; - uTxDescAttr |= uLastWordPad << TX_ATTR_OFST_LAST_WORD_PAD; - uTxDescAttr |= pTxCtrl->dataRatePolicy[uAc] << TX_ATTR_OFST_RATE_POLICY; - if (uHdrAlignPad) - { - uTxDescAttr |= TX_ATTR_HEADER_PAD; - } - if (uBackpressure) - { - uTxDescAttr |= TX_ATTR_TX_CMPLT_REQ; /* Request immediate Tx-Complete from FW if the AC is busy */ - } - if (TI_UNLIKELY(pTxCtrl->currBssType == BSS_INDEPENDENT) && - (pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_MULTICAST)) - { - /* If packet is Broadcast in IBSS, overwrite rate policy with mgmt value. */ - uTxDescAttr &= ~TX_ATTR_RATE_POLICY; - uTxDescAttr |= pTxCtrl->mgmtRatePolicy[uAc] << TX_ATTR_OFST_RATE_POLICY; - } - pPktCtrlBlk->tTxDescriptor.txAttr = ENDIAN_HANDLE_WORD(uTxDescAttr); - - /* Translate packet timestamp to FW time (also updates lifeTime and driverHandlingTime) */ - txCtrl_TranslateTimeToFw (pTxCtrl, pPktCtrlBlk, pTxCtrl->aMsduLifeTimeTu[uAc]); - - /* Indicate that the packet is transfered to the FW, and the descriptor fields are in FW format! */ - pPktCtrlBlk->tTxPktParams.uFlags |= TX_CTRL_FLAG_SENT_TO_FW; - -#ifdef TI_DBG - pTxCtrl->dbgPktSeqNum++; - pTxCtrl->dbgCounters.dbgNumPktsXfered[uAc]++; /* Count packets sent to Xfer. */ -#endif -} - - -/*************************************************************************** -* txCtrl_BuildMgmtPkt -**************************************************************************** -* DESCRIPTION: Prepare the Mgmt-Queue packet control-block including the Tx-descriptor. -***************************************************************************/ -static void txCtrl_BuildMgmtPkt (txCtrl_t *pTxCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_UINT32 uAc) -{ - TI_UINT32 uHdrAlignPad; /* Num of bytes added between Tx-descriptor and header for alignment (0 or 2). */ - TI_UINT16 uLastWordPad; /* Num of bytes added at the end of the packet for 4 bytes alignment */ - TI_UINT16 uTxDescAttr; - TI_UINT16 uRatePolicy; - TI_UINT8 uPktType = pPktCtrlBlk->tTxPktParams.uPktType; - dot11_header_t *pDot11Header; - - /* If EAPOL packet (Ethernet), build header (including MAC,SNAP,security pad & alignment pad). */ - if (uPktType == TX_PKT_TYPE_EAPOL) - { - uHdrAlignPad = txCtrl_BuildDataPktHdr ((TI_HANDLE)pTxCtrl, pPktCtrlBlk, ACK_POLICY_LEGACY); - - uRatePolicy = pTxCtrl->dataRatePolicy[uAc]; - } - - /* Other types are already in WLAN format so copy header from Wbuf to Ctrl-Blk. */ - else - { - TI_UINT32 uHdrLen = pPktCtrlBlk->tTxnStruct.aLen[0]; - TI_UINT32 uHdrLenDelta; /* Add the header pad (2 bytes) and Tx-Descriptor length */ - - /* - * Update the length fields to include the header pad and the Tx-Descriptor. - * Note: The mgmt-queue provides the header length without the alignment pad, so if - * it's not 4-byte aligned, a 2-bytes pad was added at the header beginning. - */ - uHdrAlignPad = (uHdrLen & ALIGN_4BYTE_MASK) ? HEADER_PAD_SIZE : 0; - uHdrLenDelta = uHdrAlignPad + sizeof(TxIfDescriptor_t); - pPktCtrlBlk->tTxnStruct.aBuf[0] -= uHdrLenDelta; - pPktCtrlBlk->tTxnStruct.aLen[0] += uHdrLenDelta; - pPktCtrlBlk->tTxDescriptor.length += uHdrLenDelta; - - uRatePolicy = pTxCtrl->mgmtRatePolicy[uAc]; - - if (uPktType == TX_PKT_TYPE_WLAN_DATA) - { - /* If QoS mode, update TID in QoS header in case it was downgraded. */ - /* Note: Qos-hdr update for EAPOL is done in txCtrl_BuildDataPktHeader() and doesn't exist in mgmt. */ - if (pTxCtrl->headerConverMode == HDR_CONVERT_QOS) - { - TI_UINT16 tidWord = (TI_UINT16)pPktCtrlBlk->tTxDescriptor.tid; - pDot11Header = (dot11_header_t *)&(pPktCtrlBlk->aPktHdr[uHdrAlignPad]); - COPY_WLAN_WORD(&pDot11Header->qosControl, &tidWord); /* copy with endianess handling. */ - } - } - } - - /* Update packet length in the descriptor according to HW interface requirements */ - uLastWordPad = txCtrl_TranslateLengthToFw (pPktCtrlBlk); - - /* Set fields in the descriptor attributes bitmap. */ - uTxDescAttr = uRatePolicy << TX_ATTR_OFST_RATE_POLICY; - uTxDescAttr |= pTxCtrl->txSessionCount << TX_ATTR_OFST_SESSION_COUNTER; - uTxDescAttr |= uLastWordPad << TX_ATTR_OFST_LAST_WORD_PAD; - uTxDescAttr |= TX_ATTR_TX_CMPLT_REQ; - if (uHdrAlignPad) - { - uTxDescAttr |= TX_ATTR_HEADER_PAD; - } - pPktCtrlBlk->tTxDescriptor.txAttr = ENDIAN_HANDLE_WORD(uTxDescAttr); - - /* Translate packet timestamp to FW time (also updates lifeTime and driverHandlingTime) */ - txCtrl_TranslateTimeToFw (pTxCtrl, pPktCtrlBlk, MGMT_PKT_LIFETIME_TU); - - /* Indicate that the packet is transfered to the FW, and the descriptor fields are in FW format! */ - pPktCtrlBlk->tTxPktParams.uFlags |= TX_CTRL_FLAG_SENT_TO_FW; - -#ifdef TI_DBG - pTxCtrl->dbgPktSeqNum++; - pTxCtrl->dbgCounters.dbgNumPktsXfered[uAc]++; /* Count packets sent to Xfer. */ -#endif -} - - -/*************************************************************************** -* txCtrl_UpdateHighestAdmittedAcTable -**************************************************************************** -* DESCRIPTION: This function updates the table that provides for each requested AC -* the highest AC that can be currently used, as follows: -* If requested AC is admitted use it. -* If not, find highest AC below it that doesn't require admission. -* This function should be called opon the following events: -* 1) Init -* 2) ACs admission required change (upon association) -* 3) ACs admission state change (upon association and add/delete Tspec). -* -***************************************************************************/ -static void txCtrl_UpdateHighestAdmittedAcTable (txCtrl_t *pTxCtrl) -{ - int inputIdx; - int outputIdx; - EAcTrfcType inputAc; - EAcTrfcType outputAc; - - /* Loop over all ACs in priority order (BE is higher priority than BK). */ - for (inputIdx = 0; inputIdx < MAX_NUM_OF_AC; inputIdx++) - { - inputAc = priorityOrderedAc[inputIdx]; - - /* If input AC is admitted, use it. */ - if(pTxCtrl->admissionState[inputAc] == AC_ADMITTED) - pTxCtrl->highestAdmittedAc[inputAc] = inputAc; - - /* If input AC is not admitted, find next highest priority AC that doesn't require admission. */ - else - { - /* Loop from input AC downward by priority order. */ - for (outputIdx = inputIdx; outputIdx >= 0; outputIdx--) - { - outputAc = priorityOrderedAc[outputIdx]; /* Get priority ordered AC. */ - - /* Break with first (highest) AC that doesn't require admission (we don't want to - * redirect traffic to an AC that requires admission even if admitted for other traffic). - */ - if(pTxCtrl->admissionRequired[outputAc] == ADMISSION_NOT_REQUIRED) - break; - } - - /* If we've found a valid AC insert it, else use BE as default. */ - if (outputIdx >= 0) - pTxCtrl->highestAdmittedAc[inputAc] = outputAc; - else - pTxCtrl->highestAdmittedAc[inputAc] = QOS_AC_BE; - } - } -} - - -/*************************************************************************** -* txCtrl_UpdateAcToTidMapping -**************************************************************************** -* DESCRIPTION: This function updates the table that provides per each AC -* a bitmap of the TIDs that are mapped to it when transitting packets. -* Note that this mapping considers the ACs admission states. -* It is used for mapping ACs backpressure to TIDs (for updating the data/mgmt queues) -* -* This table is updated after txCtrl_UpdateHighestAdmittedAcTable() is called! -* It may also effect the backpressure picture seen by the Data-Queue and -* Mgmt-Queue, so they should be updated subsequently. -* -***************************************************************************/ -static void txCtrl_UpdateAcToTidMapping (txCtrl_t *pTxCtrl) -{ - TI_UINT32 tid; - EAcTrfcType inputAc; - EAcTrfcType admittedAc; - - os_memoryZero(pTxCtrl->hOs, (void *)&(pTxCtrl->admittedAcToTidMap[0]), sizeof(pTxCtrl->admittedAcToTidMap)); - - /* Loop over all TIDs. */ - for (tid = 0; tid < MAX_NUM_OF_802_1d_TAGS; tid++) - { - /* Find the AC that is used for transmitting this TID. */ - inputAc = (EAcTrfcType)WMEQosTagToACTable[tid]; /* Standard translation from TID to AC. */ - admittedAc = pTxCtrl->highestAdmittedAc[inputAc]; /* The actual AC that is used for Tx. */ - - /* Set the bit related to the TID in the correlated AC. */ - pTxCtrl->admittedAcToTidMap[admittedAc] |= 1 << tid; - } -} - - -/*************************************************************************** -* txCtrl_UpdateBackpressure -**************************************************************************** -* DESCRIPTION: This function is called whenever the busy-TIDs bitmap may change, -* (except on packet-xmit - handled separately for performance). -* This includes: -* 1) Init -* 2) ACs admission required change (upon association) -* 3) ACs admission state change (upon association and add/delete Tspec). -* 4) Tx-Complete - provides also freed ACs. -* -* It updates the local bitmap, and the data-queue and mgmt-queue. -* -***************************************************************************/ -static void txCtrl_UpdateBackpressure (txCtrl_t *pTxCtrl, TI_UINT32 freedAcBitmap) -{ - TI_UINT32 busyAcBitmap = pTxCtrl->busyAcBitmap; - TI_UINT32 busyTidBitmap = 0; - TI_UINT32 ac = 0; - - - busyAcBitmap &= ~freedAcBitmap; /* Clear backpressure bits of freed ACs. */ - pTxCtrl->busyAcBitmap = busyAcBitmap; /* Save new bitmap before manipulating it. */ - - /* Loop while there are busy ACs. */ - while (busyAcBitmap) - { - /* If the AC is busy, add its related TIDs to the total busy TIDs bitmap. */ - if (busyAcBitmap & 1) - busyTidBitmap |= pTxCtrl->admittedAcToTidMap[ac]; - - /* Move to next AC. */ - busyAcBitmap = busyAcBitmap >> 1; - ac++; - } - - TRACE6(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "txCtrl_UpdateBackpressure(): busyTidBitmap = 0x%x, busyAcBitmap = 0x%x, HighestAdmittedAc[3,2,1,0] = %d, %d, %d, %d\n", busyTidBitmap, pTxCtrl->busyAcBitmap, pTxCtrl->highestAdmittedAc[3], pTxCtrl->highestAdmittedAc[2], pTxCtrl->highestAdmittedAc[1], pTxCtrl->highestAdmittedAc[0]); - - /* Save new bitmap and update the data-queue and mgmt-queue. */ - pTxCtrl->busyTidBitmap = busyTidBitmap; - txDataQ_UpdateBusyMap (pTxCtrl->hTxDataQ, busyTidBitmap); - txMgmtQ_UpdateBusyMap (pTxCtrl->hTxMgmtQ, busyTidBitmap); -} - - -/**************************************************************************** - * txCtrl_SetTxDelayCounters() - **************************************************************************** - * DESCRIPTION: Update transmission path delay counters. -* -* INPUTS: hTxCtrl - the object -* ac - the AC to count delay for -* fwDelay - the time consumed in FW for packet transmission -* driverDelay - the time consumed in driver for packet transmission -* -* OUTPUT: -* -* RETURNS: - ****************************************************************************/ - -#ifdef XCC_MODULE_INCLUDED /* Needed only for XCC-V4 */ - -static void txCtrl_SetTxDelayCounters (txCtrl_t *pTxCtrl, - TI_UINT32 ac, - TI_UINT32 fwDelay, - TI_UINT32 driverDelay, - TI_UINT32 mediumDelay) -{ - int rangeIndex; - TI_UINT32 totalTxDelayUsec = fwDelay + driverDelay; - - /* 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 ( (totalTxDelayUsec >= txDelayRangeStart[rangeIndex]) && - (totalTxDelayUsec <= txDelayRangeEnd [rangeIndex]) ) - { - pTxCtrl->txDataCounters[ac].txDelayHistogram[rangeIndex]++; - break; - } - } - - /* Update total delay and FW delay sums and packets number for average delay calculation. */ - /* Note: Accumulate Total-Delay in usec to avoid division per packet (convert to msec - only when results are requested by user). */ - if (pTxCtrl->SumTotalDelayUs[ac] < 0x7FFFFFFF) /* verify we are not close to the edge. */ - { - pTxCtrl->txDataCounters[ac].NumPackets++; - pTxCtrl->SumTotalDelayUs[ac] += totalTxDelayUsec; - pTxCtrl->txDataCounters[ac].SumFWDelayUs += fwDelay; - pTxCtrl->txDataCounters[ac].SumMacDelayUs += mediumDelay; - } - else /* If we get close to overflow, restart average accumulation. */ - { - pTxCtrl->txDataCounters[ac].NumPackets = 1; - pTxCtrl->SumTotalDelayUs[ac] = totalTxDelayUsec; - pTxCtrl->txDataCounters[ac].SumFWDelayUs = fwDelay; - pTxCtrl->txDataCounters[ac].SumMacDelayUs = mediumDelay; - } -} - -#endif /* XCC_MODULE_INCLUDED */ - - - -/*************************************************************************** -* txCtrl_UpdateTxCounters -**************************************************************************** -* DESCRIPTION: Update Tx statistics counters according to the transmitted packet. -***************************************************************************/ -static void txCtrl_UpdateTxCounters (txCtrl_t *pTxCtrl, - TxResultDescriptor_t *pTxResultInfo, - TTxCtrlBlk *pPktCtrlBlk, - TI_UINT32 ac, - TI_BOOL bIsDataPkt) -{ - TI_UINT32 pktLen; - TI_UINT32 dataLen; - TI_UINT32 retryHistogramIndex; - TI_UINT16 EventMask = 0; - - pktLen = (TI_UINT32)ENDIAN_HANDLE_WORD(pPktCtrlBlk->tTxDescriptor.length); - pktLen = pktLen << 2; - -#ifdef TI_DBG - - /* update debug counters. */ - pTxCtrl->dbgCounters.dbgNumTxCmplt[ac]++; - if (pTxResultInfo->status == TX_SUCCESS) - { - pTxCtrl->dbgCounters.dbgNumTxCmpltOk[ac]++; - pTxCtrl->dbgCounters.dbgNumTxCmpltOkBytes[ac] += pktLen; - } - else - { - pTxCtrl->dbgCounters.dbgNumTxCmpltError[ac]++; - - if (pTxResultInfo->status == TX_HW_ERROR || - pTxResultInfo->status == TX_KEY_NOT_FOUND || - pTxResultInfo->status == TX_PEER_NOT_FOUND) - { -TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, "txCtrl_UpdateTxCounters(): TxResult = %d !!!\n", pTxResultInfo->status); - } - else - { -TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_WARNING, "txCtrl_UpdateTxCounters(): TxResult = %d !!!\n", pTxResultInfo->status); - } - } - -#endif /* TI_DBG */ - - /* If it's not a data packet, exit (the formal statistics are only on network stack traffic). */ - if ( !bIsDataPkt ) - return; - - if (pTxResultInfo->status == TX_SUCCESS) - { - /* update the retry histogram */ - retryHistogramIndex = (pTxResultInfo->ackFailures >= TX_RETRY_HISTOGRAM_SIZE) ? - (TX_RETRY_HISTOGRAM_SIZE - 1) : pTxResultInfo->ackFailures; - pTxCtrl->txDataCounters[ac].RetryHistogram[retryHistogramIndex]++; - -#ifdef XCC_MODULE_INCLUDED - /* update delay histogram */ - txCtrl_SetTxDelayCounters (pTxCtrl, - ac, - ENDIAN_HANDLE_LONG(pTxResultInfo->fwHandlingTime), - pPktCtrlBlk->tTxPktParams.uDriverDelay, - ENDIAN_HANDLE_LONG(pTxResultInfo->mediumDelay)); -#endif - - if (pTxCtrl->headerConverMode == HDR_CONVERT_QOS) - { - dataLen = pktLen - (WLAN_WITH_SNAP_QOS_HEADER_MAX_SIZE - ETHERNET_HDR_LEN); - } - else - { - dataLen = pktLen - (WLAN_WITH_SNAP_HEADER_MAX_SIZE - ETHERNET_HDR_LEN); - } - - if (pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_MULTICAST) - { - if (pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_BROADCAST) - { - /* Broadcast frame */ - pTxCtrl->txDataCounters[ac].BroadcastFramesXmit++; - pTxCtrl->txDataCounters[ac].BroadcastBytesXmit += dataLen; - EventMask |= BROADCAST_BYTES_XFER; - EventMask |= BROADCAST_FRAMES_XFER; - } - else - { - /* Multicast Address */ - pTxCtrl->txDataCounters[ac].MulticastFramesXmit++; - pTxCtrl->txDataCounters[ac].MulticastBytesXmit += dataLen; - EventMask |= MULTICAST_BYTES_XFER; - EventMask |= MULTICAST_FRAMES_XFER; - } - } - else - { - /* Save last data Tx rate for applications' query */ - EHwBitRate eHwTxRate = ENDIAN_HANDLE_LONG((EHwBitRate)(pTxResultInfo->rate)); - rate_PolicyToDrv (eHwTxRate, &pTxCtrl->eCurrentTxRate); - - /* Directed frame statistics */ - pTxCtrl->txDataCounters[ac].DirectedFramesXmit++; - pTxCtrl->txDataCounters[ac].DirectedBytesXmit += dataLen; - EventMask |= DIRECTED_BYTES_XFER; - EventMask |= DIRECTED_FRAMES_XFER; - } - - pTxCtrl->txDataCounters[ac].XmitOk++; - EventMask |= XFER_OK; - - /* update the max consecutive retry failures (if needed) */ - if (pTxCtrl->currentConsecutiveRetryFail > pTxCtrl->txDataCounters[ac].MaxConsecutiveRetryFail) - { - pTxCtrl->txDataCounters[ac].MaxConsecutiveRetryFail = pTxCtrl->currentConsecutiveRetryFail; - } - pTxCtrl->currentConsecutiveRetryFail = 0; - - if(pTxCtrl->TxEventDistributor) - { - DistributorMgr_EventCall(pTxCtrl->TxEventDistributor, EventMask, dataLen); - } - } - else /* Handle Errors */ - { - /* - NOTE: if the FW sets more then 1 error bit at a time change the error handling - code below - */ - if (pTxResultInfo->status == TX_RETRY_EXCEEDED) - { - pTxCtrl->txDataCounters[ac].RetryFailCounter++; - pTxCtrl->currentConsecutiveRetryFail++; - } - else if (pTxResultInfo->status == TX_TIMEOUT) - { - pTxCtrl->txDataCounters[ac].TxTimeoutCounter++; - } - else - { - pTxCtrl->txDataCounters[ac].OtherFailCounter++; - } - } -} - - -/*************************************************************************** -* txCtrl_notifyFwReset * -**************************************************************************** -* DESCRIPTION: Go over all CtrlBlk entries and free the active ones including the packet. -***************************************************************************/ -TI_STATUS txCtrl_NotifyFwReset (TI_HANDLE hTxCtrl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_UINT32 entry; - TTxCtrlBlk *pPktCtrlBlk; - - pTxCtrl->busyAcBitmap = 0; /* clean busy bitmap */ - txCtrl_UpdateBackpressure(pTxCtrl, 0); - - for (entry = 0; entry < CTRL_BLK_ENTRIES_NUM-1; entry++) - { - /* Get packet ctrl-block by desc-ID. */ - pPktCtrlBlk = TWD_txCtrlBlk_GetPointer(pTxCtrl->hTWD, entry); - if (pPktCtrlBlk->pNextFreeEntry == 0) - { - /* Don't free if the packet still in tx input queues */ - if ((pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_SENT_TO_FW)) - { - /* Free the packet resources (packet and CtrlBlk) */ - txCtrl_FreePacket (pTxCtrl, pPktCtrlBlk, TI_NOK); - } - } - } - - return TI_OK; -} /* txCtrl_notifyFwReset */ - - -/*************************************************************************** -* txCtrl_CheckForTxStuck * -**************************************************************************** -* DESCRIPTION: Check if there are stale packets in the TxCtrlTable. -* The criterion for staleness is function of life time (2 times the longest life time) -* Note that only packets that were not sent to the FW are checked for simplicity! -***************************************************************************/ -TI_STATUS txCtrl_CheckForTxStuck (TI_HANDLE hTxCtrl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_UINT32 entry; - TTxCtrlBlk *pPktCtrlBlk; - TI_UINT32 uPktAge; /* Time in uSec since packet start time. */ - - for (entry = 0; entry < CTRL_BLK_ENTRIES_NUM-1; entry++) - { - /* Get packet ctrl-block by desc-ID. */ - pPktCtrlBlk = TWD_txCtrlBlk_GetPointer(pTxCtrl->hTWD, entry); - - /* If entry is in use */ - if (pPktCtrlBlk->pNextFreeEntry == 0) - { - /* If the packet wasn't sent to the FW yet (time is in host format) */ - if ((pPktCtrlBlk->tTxPktParams.uFlags & TX_CTRL_FLAG_SENT_TO_FW) == 0) - { - /* If packet age is more than twice the maximum lifetime, return NOK */ - uPktAge = os_timeStampMs (pTxCtrl->hOs) - pPktCtrlBlk->tTxDescriptor.startTime; - if (uPktAge > ((MGMT_PKT_LIFETIME_TU << SHIFT_BETWEEN_TU_AND_USEC) * 2)) - { - return TI_NOK; /* call for recovery */ - } - } - } - } - - return TI_OK; -} /* txCtrl_FailureTest */ - - - diff --git a/wl1271/stad/src/Data_link/txCtrl.h b/wl1271/stad/src/Data_link/txCtrl.h deleted file mode 100644 index b2e0745..0000000 --- a/wl1271/stad/src/Data_link/txCtrl.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * txCtrl.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: txCtrl.h */ -/* PURPOSE: txCtrl module Header file */ -/* */ -/***************************************************************************/ -#ifndef _TX_CTRL_H_ -#define _TX_CTRL_H_ - - -#include "paramOut.h" -#include "DataCtrl_Api.h" - - -extern void wlanDrvIf_FreeTxPacket (TI_HANDLE hOs, TTxCtrlBlk *pPktCtrlBlk, TI_STATUS eStatus); - - -#define DEF_TX_PORT_STATUS CLOSE -#define DEF_CURRENT_PRIVACY_MODE TI_FALSE -#define DEF_EAPOL_ENCRYPTION_STATUS TI_FALSE -#define HEADER_PAD_SIZE 2 /* 2-byte pad before header with QoS, for 4-byte alignment */ -#define MGMT_PKT_LIFETIME_TU 2000 /* Mgmt pkts lifetime in TUs (1024 usec). */ - -/* defined in qosMngr.c - standard WMM translation from TID to AC. */ -extern int WMEQosTagToACTable[MAX_NUM_OF_802_1d_TAGS]; -extern const TI_UINT8 WMEQosAcToTid[MAX_NUM_OF_AC]; - -/* The TX delay histogram ranges start and end in uSec. */ -static const TI_UINT32 txDelayRangeStart[TX_DELAY_RANGES_NUM] = { 0, 1000, 10000, 20000, 40000, 60000, 80000, 100000, 200000 }; -static const TI_UINT32 txDelayRangeEnd [TX_DELAY_RANGES_NUM] = { 1000, 10000, 20000, 40000, 60000, 80000, 100000, 200000, 0xFFFFFFFF }; - -/* BE is ordered here above BK for priority sensitive functions (BE is 0 but has higher priority than BK). */ -static const EAcTrfcType priorityOrderedAc[] = {QOS_AC_BK, QOS_AC_BE, QOS_AC_VI, QOS_AC_VO}; - -typedef struct -{ - TI_UINT32 dbgNumPktsSent[MAX_NUM_OF_AC]; /* Pkts sent by data-queue or mgmt-queue. */ - TI_UINT32 dbgNumPktsBackpressure[MAX_NUM_OF_AC];/* Pkts for which backpressure was set by HW-Q */ - TI_UINT32 dbgNumPktsBusy[MAX_NUM_OF_AC]; /* Pkts for which busy was received from HW-Q */ - TI_UINT32 dbgNumPktsXfered[MAX_NUM_OF_AC]; /* Pkts sent to Xfer */ - TI_UINT32 dbgNumPktsSuccess[MAX_NUM_OF_AC]; /* Pkts for which success was received from Xfer */ - TI_UINT32 dbgNumPktsPending[MAX_NUM_OF_AC]; /* Pkts for which pending was received from Xfer */ - TI_UINT32 dbgNumPktsError[MAX_NUM_OF_AC]; /* Pkts for which error was received from Xfer */ - TI_UINT32 dbgNumTxCmplt[MAX_NUM_OF_AC]; /* Pkts that reached complete CB */ - TI_UINT32 dbgNumTxCmpltOk[MAX_NUM_OF_AC]; /* Pkts that reached complete CB with status TI_OK */ - TI_UINT32 dbgNumTxCmpltError[MAX_NUM_OF_AC]; /* Pkts that reached complete CB with status TI_NOK */ - TI_UINT32 dbgNumTxCmpltOkBytes[MAX_NUM_OF_AC];/* Acknowledged bytes (complete status TI_OK) */ - TI_UINT32 dbgNumXferCmplt; /* Number of Xfer-Complete events (after pending). */ -} txDataDbgCounters_t; - - - -/* - * Module object structure. - */ -typedef struct -{ - /* Handles */ - TI_HANDLE hOs; - TI_HANDLE hReport; - TI_HANDLE hCtrlData; - TI_HANDLE hTWD; - TI_HANDLE hTxDataQ; - TI_HANDLE hTxMgmtQ; - TI_HANDLE hEvHandler; - TI_HANDLE TxEventDistributor; - TI_HANDLE hHealthMonitor; - TI_HANDLE hTimer; - TI_HANDLE hStaCap; - TI_HANDLE hXCCMngr; - TI_HANDLE hQosMngr; - TI_HANDLE hRxData; - - TI_HANDLE hCreditTimer; /* The medium-usage credit timer handle */ - - /* External parameters */ - EHeaderConvertMode headerConverMode; /* QoS header needed for data or not. */ - TI_BOOL currentPrivacyInvokedMode; - TI_BOOL eapolEncryptionStatus; - TI_UINT8 encryptionFieldSize; /* size to reserve in WLAN header for encryption */ - ScanBssType_e currBssType; - TMacAddr currBssId; - TI_UINT16 aMsduLifeTimeTu[MAX_NUM_OF_AC]; - AckPolicy_e ackPolicy[MAX_NUM_OF_AC]; - TtxCtrlHtControl tTxCtrlHtControl; - TI_UINT16 genericEthertype; - - /* ACs admission and busy mapping */ - TI_UINT32 busyAcBitmap; /* Current bitmap of busy ACs (in HW-Q backpressure format). */ - TI_UINT32 busyTidBitmap; /* Current bitmap of busy TIDs reflected from admitted ACs. */ - TI_UINT32 admittedAcToTidMap[MAX_NUM_OF_AC]; /* From HW-AC to bitmap of TIDs that currently use it. */ - EAcTrfcType highestAdmittedAc[MAX_NUM_OF_AC]; /* Provide highest admitted AC equal or below given AC. */ - ETrafficAdmState admissionState[MAX_NUM_OF_AC]; /* AC is allowed to transmit or not. */ - EAdmissionState admissionRequired[MAX_NUM_OF_AC]; /* AC requires AP's admission or not. */ - - /* Tx Attributes */ - TI_UINT32 mgmtRatePolicy[MAX_NUM_OF_AC]; /* Current rate policy for mgmt packets per AC. */ - TI_UINT32 dataRatePolicy[MAX_NUM_OF_AC]; /* Current rate policy for data packets per AC. */ - TI_UINT16 txSessionCount; /* Current Tx-Session index as configured to FW in last Join command. */ - TI_UINT16 dataPktDescAttrib; /* A prototype of Tx-desc attrib bitmap for data pkts. */ - TI_UINT8 dbgPktSeqNum; /* Increment every tx-pkt, insert in descriptor for debug. */ - - /* Counters */ - TTxDataCounters txDataCounters[MAX_NUM_OF_AC]; /* Save Tx statistics per Tx-queue. */ - TI_UINT32 SumTotalDelayUs[MAX_NUM_OF_AC]; /* Store pkt delay sum in Usecs to avoid divide per - pkt, and covert to msec on user request. */ - TI_UINT32 currentConsecutiveRetryFail; /* current consecutive number of tx failures due to max retry */ - ERate eCurrentTxRate; /* Save last data Tx rate for applications' query */ - - /* credit calculation parameters */ - TI_BOOL bCreditCalcTimerEnabled; /* credit timer is enabled from registry */ - TI_BOOL bCreditCalcTimerRunning; /* credit calculation timer is running */ - TI_UINT32 creditCalculationTimeout; - TI_INT32 lowMediumUsageThreshold[MAX_NUM_OF_AC]; - TI_INT32 highMediumUsageThreshold[MAX_NUM_OF_AC]; - TI_UINT32 lastCreditCalcTimeStamp[MAX_NUM_OF_AC]; - TI_BOOL useAdmissionAlgo[MAX_NUM_OF_AC]; - TI_INT32 credit[MAX_NUM_OF_AC]; - TI_UINT32 mediumTime[MAX_NUM_OF_AC]; - TI_UINT32 totalUsedTime[MAX_NUM_OF_AC]; - -#ifdef TI_DBG - txDataDbgCounters_t dbgCounters; /* debug counters */ -#endif - -} txCtrl_t; - - - -#endif /* _TX_CTRL_H_ */ diff --git a/wl1271/stad/src/Data_link/txCtrlParams.c b/wl1271/stad/src/Data_link/txCtrlParams.c deleted file mode 100644 index 9fdee31..0000000 --- a/wl1271/stad/src/Data_link/txCtrlParams.c +++ /dev/null @@ -1,816 +0,0 @@ -/* - * txCtrlParams.c - * - * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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: txCtrlParams.c */ -/* PURPOSE: The txCtrl module parameters handling. */ -/* This is a part of the txCtrl module (using the same object). */ -/* */ -/*******************************************************************************/ - -#define __FILE_ID__ FILE_ID_57 -#include "tidef.h" -#include "report.h" -#include "paramOut.h" -#include "osApi.h" -#include "timer.h" -#include "EvHandler.h" -#include "txCtrl.h" - - - - - -/*********************************************************************** - * calcCreditFromTimer - *********************************************************************** -DESCRIPTION: This function is called when credit calculation timer - is expired. it calculate the credit for the admission ctrl - credit algorithm - - -INPUT: hTxCtrl - handle to the ts data object - bTwdInitOccured - Indicates if TWDriver recovery occured since timer started - -OUTPUT: None - -RETURN: void -************************************************************************/ -static void calcCreditFromTimer(TI_HANDLE hTxCtrl, TI_BOOL bTwdInitOccured) -{ - OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS mediumTimeCross; - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_UINT32 ac; - TI_INT32 prevCredit; - TI_INT32 highCreditThreshold; - TI_INT32 lowCreditThreshold; - TI_INT32 usageRatio; - TI_INT32 currUsage; - TI_INT32 prevUsage; - TI_UINT32 currentTimeStamp = os_timeStampMs(pTxCtrl->hOs); /* get current time stamp */ - - /* - * For each AC under admission control calculate the new usage and credit time, - * and send events if a threshold is crossed. - */ - for(ac = 0 ; ac < MAX_NUM_OF_AC ; ac++) - { - /* check if this queue is under admission ctrl operation */ - if(pTxCtrl->mediumTime[ac] == 0) - { -TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, ": ac = %d mediumTime = 0 \n", ac); - - continue; - } - - /* in case of wraparound */ - if(currentTimeStamp < pTxCtrl->lastCreditCalcTimeStamp[ac]) - pTxCtrl->lastCreditCalcTimeStamp[ac] = 0; - - /* store prev credit */ - prevCredit = pTxCtrl->credit[ac]; - - /* 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 = pTxCtrl->totalUsedTime[ac] / pTxCtrl->mediumTime[ac]; - - /* calculate credit */ - pTxCtrl->credit[ac] += (currentTimeStamp - pTxCtrl->lastCreditCalcTimeStamp[ac]) - usageRatio; - - /* update last time stamp */ - pTxCtrl->lastCreditCalcTimeStamp[ac] = currentTimeStamp; - - /* in case credit is bigger than mediumTime -> set credit to medium time */ - if (pTxCtrl->credit[ac] > (TI_INT32)(pTxCtrl->mediumTime[ac]) ) - pTxCtrl->credit[ac] = pTxCtrl->mediumTime[ac]; - - TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "credit = %d | TotalUsedTime = %d\n", pTxCtrl->credit[ac], pTxCtrl->totalUsedTime[ac]/1000); - - /* 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. - * - * Note: The driver doesn't delay traffic even if violating the usage limit! - * It only indicates the user application about the thresholds crossing. - */ - - highCreditThreshold = (TI_INT32)((pTxCtrl->mediumTime[ac])*(pTxCtrl->highMediumUsageThreshold[ac])/100); - lowCreditThreshold = (TI_INT32)((pTxCtrl->mediumTime[ac])*(pTxCtrl->lowMediumUsageThreshold[ac])/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 = -pTxCtrl->credit[ac]; - prevUsage = -prevCredit; - - /* crossing below the low threshold */ - if ( (currUsage < lowCreditThreshold) && (prevUsage >= lowCreditThreshold) ) - { - /* send event */ - mediumTimeCross.uAC = ac; - mediumTimeCross.uHighOrLowThresholdFlag = (TI_UINT32)LOW_THRESHOLD_CROSS; - mediumTimeCross.uAboveOrBelowFlag = (TI_UINT32)CROSS_BELOW; - - EvHandlerSendEvent(pTxCtrl->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS, - (TI_UINT8 *)&mediumTimeCross, sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS)); - - TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "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 = ac; - mediumTimeCross.uHighOrLowThresholdFlag = (TI_UINT32)HIGH_THRESHOLD_CROSS; - mediumTimeCross.uAboveOrBelowFlag = (TI_UINT32)CROSS_ABOVE; - - EvHandlerSendEvent(pTxCtrl->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS, - (TI_UINT8 *)&mediumTimeCross, sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS)); - - TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "crossed above high threshold !!! prevUsage = %d, currUsage = %d, highCreditThreshold = %d\n", prevUsage, currUsage, highCreditThreshold); - } - - /* reset totalUsedTime */ - pTxCtrl->totalUsedTime[ac] = 0; - } -} - - -/**************************************************************************** - * updateDataPktPrototype() - **************************************************************************** - * DESCRIPTION: Updates the data packet prototype values according to - changed parameters (e.g. rate policy change). - ****************************************************************************/ -static void updateDataPktPrototype(txCtrl_t *pTxCtrl) -{ - pTxCtrl->dataPktDescAttrib = pTxCtrl->txSessionCount << TX_ATTR_OFST_SESSION_COUNTER; -} - - -/*************************************************************************** -* txCtrlParams_resetCounters -**************************************************************************** -* DESCRIPTION: Reset the tx data module counters -* -* INPUTS: hTxCtrl - the object -* -* OUTPUT: -* -* RETURNS: -***************************************************************************/ -void txCtrlParams_resetCounters(TI_HANDLE hTxCtrl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - os_memoryZero(pTxCtrl->hOs, &pTxCtrl->txDataCounters, sizeof(TTxDataCounters) * MAX_NUM_OF_AC); - os_memoryZero(pTxCtrl->hOs, &pTxCtrl->SumTotalDelayUs, sizeof(pTxCtrl->SumTotalDelayUs)); - pTxCtrl->currentConsecutiveRetryFail = 0; -} - - -/*************************************************************************** -* txCtrlParams_RegNotif * -****************************************************************************/ -TI_HANDLE txCtrlParams_RegNotif(TI_HANDLE hTxCtrl, TI_UINT16 EventMask, GeneralEventCall_t CallBack, - TI_HANDLE context, TI_UINT32 Cookie) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - if (!hTxCtrl) - return NULL; - return DistributorMgr_Reg(pTxCtrl->TxEventDistributor,EventMask,(TI_HANDLE)CallBack,context,Cookie); -} - - -/*************************************************************************** -* txCtrlParams_AddToNotifMask * -****************************************************************************/ -TI_STATUS txCtrlParams_AddToNotifMask(TI_HANDLE hTxCtrl, TI_HANDLE Notifh, TI_UINT16 EventMask) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - if (!hTxCtrl) - return TI_NOK; - return DistributorMgr_AddToMask(pTxCtrl->TxEventDistributor, Notifh, EventMask); -} - - -/*************************************************************************** -* txCtrlParams_UnRegNotif * -****************************************************************************/ -TI_STATUS txCtrlParams_UnRegNotif(TI_HANDLE hTxCtrl, TI_HANDLE RegEventHandle) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - if (!hTxCtrl) - return TI_NOK; - - return (DistributorMgr_UnReg(pTxCtrl->TxEventDistributor,RegEventHandle)); -} - - -/*********************************************************************** - * txCtrlParams_setAdmissionCtrlParams - *********************************************************************** -DESCRIPTION: This function is called for add/delete a tspec in order - to update parameters. - -INPUT: hTxCtrl - 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 txCtrlParams_setAdmissionCtrlParams(TI_HANDLE hTxCtrl, TI_UINT8 acId, TI_UINT16 mediumTime, - TI_UINT32 minimumPHYRate, TI_BOOL admFlag) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_UINT32 i; - - if(admFlag == TI_TRUE) - { - /* tspec added */ - pTxCtrl->mediumTime[acId] = mediumTime; - pTxCtrl->admissionState[acId] = AC_ADMITTED; - pTxCtrl->useAdmissionAlgo[acId] = TI_TRUE; - pTxCtrl->lastCreditCalcTimeStamp[acId] = os_timeStampMs(pTxCtrl->hOs); - pTxCtrl->credit[acId] = mediumTime; - } - else - { - /* tspaec deleted */ - pTxCtrl->mediumTime[acId] = 0; - pTxCtrl->admissionState[acId] = AC_NOT_ADMITTED; - pTxCtrl->useAdmissionAlgo[acId] = TI_FALSE; - pTxCtrl->lastCreditCalcTimeStamp[acId] = 0; - pTxCtrl->credit[acId] = 0; - } - - /* Update the Tx queues mapping after admission change. */ - txCtrl_UpdateQueuesMapping (hTxCtrl); - - /* If the timer was not enabled in registry than we will never set it */ - if (pTxCtrl->bCreditCalcTimerEnabled) - { - /* enable disable credit calculation timer */ - for (i = 0; i < MAX_NUM_OF_AC; i++) - { - if (pTxCtrl->useAdmissionAlgo[i]) - { - if (!pTxCtrl->bCreditCalcTimerRunning) - { - pTxCtrl->bCreditCalcTimerRunning = TI_TRUE; - tmr_StartTimer (pTxCtrl->hCreditTimer, - calcCreditFromTimer, - (TI_HANDLE)pTxCtrl, - pTxCtrl->creditCalculationTimeout, - TI_TRUE); - } - - return TI_OK; - } - } - - /* in all queues useAdmissionAlgo is not TRUE, so stop timer if running */ - if (pTxCtrl->bCreditCalcTimerRunning) - { - tmr_StopTimer (pTxCtrl->hCreditTimer); - pTxCtrl->bCreditCalcTimerRunning = TI_FALSE; - } - } - - return TI_OK; -} - - -/*************************************************************************** -* txCtrlParams_getParam -**************************************************************************** -* DESCRIPTION: Get a specific parameter by an external user application. -* -* OUTPUT: pParamInfo - structure which include the value of -* the requested parameter -***************************************************************************/ -TI_STATUS txCtrlParams_getParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_UINT32 ac; - - if(pTxCtrl == NULL) /* check handle validity */ - { - return TI_NOK; - } - - switch (pParamInfo->paramType) - { - case TX_CTRL_COUNTERS_PARAM: - /* Convert total-delays units from usec to mSec. */ - for(ac = 0 ; ac < MAX_NUM_OF_AC ; ac++) - { - pTxCtrl->txDataCounters[ac].SumTotalDelayMs = pTxCtrl->SumTotalDelayUs[ac] / 1000; - } - os_memoryCopy( pTxCtrl->hOs, pParamInfo->content.pTxDataCounters, &(pTxCtrl->txDataCounters[0]), - sizeof(TTxDataCounters) * MAX_NUM_OF_AC); - pParamInfo->paramLength = sizeof(TTxDataCounters) * MAX_NUM_OF_AC; - break; - - case TX_CTRL_GET_DATA_FRAME_COUNTER: - pParamInfo->content.txPacketsCount = 0; - for (ac = 0; ac < MAX_NUM_OF_AC; ac++) - pParamInfo->content.txPacketsCount += pTxCtrl->txDataCounters[ac].XmitOk; - break; - - case TX_CTRL_REPORT_TS_STATISTICS: - ac = pParamInfo->content.tsMetricsCounters.acID; - os_memoryCopy(pTxCtrl->hOs, - pParamInfo->content.tsMetricsCounters.pTxDataCounters, - &(pTxCtrl->txDataCounters[ac]), - sizeof(TTxDataCounters)); - os_memoryZero(pTxCtrl->hOs, &(pTxCtrl->txDataCounters[ac]), sizeof(TTxDataCounters)); - break; - - case TX_CTRL_GENERIC_ETHERTYPE: - pParamInfo->content.txGenericEthertype = pTxCtrl->genericEthertype; - break; - - - default: - TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": PARAMETER NOT SUPPORTED\n"); - return PARAM_NOT_SUPPORTED; - } - - return TI_OK; -} - - -/*************************************************************************** -* txCtrlParams_setParam -**************************************************************************** -* DESCRIPTION: Set a specific parameter by an external user application. -* -* INPUTS: hTxCtrl - the object -* pParamInfo - structure which include the value to set for -* the requested parameter -***************************************************************************/ -TI_STATUS txCtrlParams_setParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_UINT8 acID; - - if(pTxCtrl == NULL) /* check handle validity */ - { - return TI_NOK; - } - - switch (pParamInfo->paramType) - { - case TX_CTRL_SET_MEDIUM_USAGE_THRESHOLD: - acID = (TI_UINT8)pParamInfo->content.txDataMediumUsageThreshold.uAC; - if(acID < MAX_NUM_OF_AC) - { - pTxCtrl->highMediumUsageThreshold[acID] = - pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold; - pTxCtrl->lowMediumUsageThreshold[acID] = - pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold; - } - else -TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": Wrong AC (AC=%d > 3)\n", acID); - break; - - case TX_CTRL_GET_MEDIUM_USAGE_THRESHOLD: - /* Note: SET operation is used for GET, because AC parameter should be supplied from Utility- - Adapter to driver (copy of user supplied block of data is only performed in SetParam calls). */ - acID = (TI_UINT8)pParamInfo->content.txDataMediumUsageThreshold.uAC; - pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold = pTxCtrl->highMediumUsageThreshold[acID]; - pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold = pTxCtrl->lowMediumUsageThreshold[acID]; - break; - - case TX_CTRL_POLL_AP_PACKETS_FROM_AC: - TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": Poll-AP is not supported in this version!!\n"); - return PARAM_NOT_SUPPORTED; - - case TX_CTRL_RESET_COUNTERS_PARAM: - txCtrlParams_resetCounters(hTxCtrl); - break; - - case TX_CTRL_GENERIC_ETHERTYPE: - pTxCtrl->genericEthertype = pParamInfo->content.txGenericEthertype; - { - paramInfo_t param; - param.paramType = RX_DATA_GENERIC_ETHERTYPE_PARAM; - param.content.rxGenericEthertype = pTxCtrl->genericEthertype; - rxData_setParam(pTxCtrl->hRxData, ¶m); - } - break; - - - default: - TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": PARAMETER NOT SUPPORTED\n"); - return PARAM_NOT_SUPPORTED; - } - - return TI_OK; -} - - -/*********************************************************************** - * txCtrlParams_setBssId - *********************************************************************** -DESCRIPTION: Update the BSS-ID. -************************************************************************/ -void txCtrlParams_setBssId (TI_HANDLE hTxCtrl, TMacAddr *pCurrBssId) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - MAC_COPY (pTxCtrl->currBssId, *pCurrBssId); -} - - -/*********************************************************************** - * txCtrlParams_setBssType - *********************************************************************** -DESCRIPTION: Update the BSS type. -************************************************************************/ -void txCtrlParams_setBssType (TI_HANDLE hTxCtrl, ScanBssType_e currBssType) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->currBssType = currBssType; -} - - -/*********************************************************************** - * txCtrlParams_setQosHeaderConverMode - *********************************************************************** -DESCRIPTION: Update the BSS type. -************************************************************************/ -void txCtrlParams_setQosHeaderConverMode (TI_HANDLE hTxCtrl, EHeaderConvertMode headerConverMode) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->headerConverMode = headerConverMode; - - updateDataPktPrototype(pTxCtrl); /* Needed due to QoS mode change. */ -} - -/** - * \fn txCtrlParams_SetHtControl() - * \brief Update The HT Control Field on txCtrl module. - * - * \note - * \param hTxCtrl - the hTxCtrl handle. - * \param pHtCapabilitiesIe - input structure. - * \return TI_OK on success or TI_NOK on failure - * \sa - */ -TI_STATUS txCtrlParams_SetHtControl (TI_HANDLE hTxCtrl, TtxCtrlHtControl *pHtControl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->tTxCtrlHtControl.bHtEnable = pHtControl->bHtEnable; - - return TI_OK; -} - -/*********************************************************************** - * txCtrlParams_setCurrentPrivacyInvokedMode - *********************************************************************** -DESCRIPTION: Update the current privacy invoked mode. -************************************************************************/ -void txCtrlParams_setCurrentPrivacyInvokedMode (TI_HANDLE hTxCtrl, TI_BOOL currentPrivacyInvokedMode) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->currentPrivacyInvokedMode = currentPrivacyInvokedMode; -} - - -/*********************************************************************** - * txCtrlParams_setEapolEncryptionStatus - *********************************************************************** -DESCRIPTION: Update the Eapol Encryption Status. -************************************************************************/ -void txCtrlParams_setEapolEncryptionStatus (TI_HANDLE hTxCtrl, TI_BOOL eapolEncryptionStatus) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->eapolEncryptionStatus = eapolEncryptionStatus; -} - - -/*********************************************************************** - * txCtrlParams_setEncryptionFieldSizes - *********************************************************************** -DESCRIPTION: Update the encryption field size for the header padding. -************************************************************************/ -void txCtrlParams_setEncryptionFieldSizes (TI_HANDLE hTxCtrl, TI_UINT8 encryptionFieldSize) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->encryptionFieldSize = encryptionFieldSize; -} - - -/*********************************************************************** - * txCtrlParams_getCurrentEncryptionInfo - *********************************************************************** -DESCRIPTION: Provide the current encryption mode and padding size. -************************************************************************/ -void txCtrlParams_getCurrentEncryptionInfo (TI_HANDLE hTxCtrl, - TI_BOOL *pCurrentPrivacyInvokedMode, - TI_UINT8 *pEncryptionFieldSize) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - *pCurrentPrivacyInvokedMode = pTxCtrl->currentPrivacyInvokedMode; - *pEncryptionFieldSize = pTxCtrl->encryptionFieldSize; -} - - -/*********************************************************************** - * txCtrlParams_GetTxRate - *********************************************************************** -DESCRIPTION: Provide the last successfull data packet Tx rate. -************************************************************************/ -ERate txCtrlParams_GetTxRate (TI_HANDLE hTxCtrl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - return pTxCtrl->eCurrentTxRate; -} - - -/*********************************************************************** - * txCtrlParams_setAcAdmissionStatus - *********************************************************************** -DESCRIPTION: Update the AC admission status - required or not and admitted or not. - Update also the queues mapping in case it should change. -************************************************************************/ -void txCtrlParams_setAcAdmissionStatus (TI_HANDLE hTxCtrl, - TI_UINT8 ac, - EAdmissionState admissionRequired, - ETrafficAdmState admissionState) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->admissionRequired[ac] = admissionRequired; - pTxCtrl->admissionState[ac] = admissionState; - - /* Update the Tx queues mapping after admission change. */ - txCtrl_UpdateQueuesMapping (hTxCtrl); -} - - -/*********************************************************************** - * txCtrlParams_setAcMsduLifeTime - *********************************************************************** -DESCRIPTION: Update the AC MSDU lifetime. The units are TUs (1024 usec). -************************************************************************/ -void txCtrlParams_setAcMsduLifeTime (TI_HANDLE hTxCtrl, TI_UINT8 ac, TI_UINT32 uMsduLifeTimeTu) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->aMsduLifeTimeTu[ac] = (TI_UINT16)uMsduLifeTimeTu; -} - - -/*********************************************************************** - * txCtrlParams_setAcAckPolicy - *********************************************************************** -DESCRIPTION: Update the AC Ack policy. -************************************************************************/ -void txCtrlParams_setAcAckPolicy (TI_HANDLE hTxCtrl, TI_UINT8 ac, AckPolicy_e ackPolicy) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->ackPolicy[ac] = ackPolicy; -} - - -/*********************************************************************** - * txCtrlParams_updateMgmtRateAttributes - *********************************************************************** -DESCRIPTION: Update per AC the rate policy for Mgmnt packets or IBSS BCAST packets. -************************************************************************/ -void txCtrlParams_updateMgmtRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->mgmtRatePolicy[ac] = ratePolicyId; -} - - -/*********************************************************************** - * txCtrlParams_updateDataRateAttributes - *********************************************************************** -DESCRIPTION: Update per AC the rate policy for regular data packets (excluding IBSS BCAST packets). -************************************************************************/ -void txCtrlParams_updateDataRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->dataRatePolicy[ac] = ratePolicyId; -} - - -/*********************************************************************** - * txCtrlParams_updateTxSessionCount - *********************************************************************** -DESCRIPTION: Update the current Tx-session index configured to FW. -************************************************************************/ -void txCtrlParams_updateTxSessionCount(TI_HANDLE hTxCtrl, TI_UINT16 txSessionCount) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - pTxCtrl->txSessionCount = txSessionCount; - - updateDataPktPrototype(pTxCtrl); -} - - - - -/******************************************************************************** -* * -* DEBUG FUNCTIONS IMPLEMENTATION * -* * -*********************************************************************************/ - -#ifdef TI_DBG - -/*********************************************************************** - * txCtrlParams_printInfo - *********************************************************************** -DESCRIPTION: Print module internal information. -************************************************************************/ -void txCtrlParams_printInfo(TI_HANDLE hTxCtrl) -{ -#ifdef REPORT_LOG - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - WLAN_OS_REPORT(("-------------- Tx-Ctrl Module Information --------------\n")); - WLAN_OS_REPORT(("========================================================\n")); - - WLAN_OS_REPORT(("ACs Mapping:\n")); - WLAN_OS_REPORT(("------------\n")); - WLAN_OS_REPORT(("admissionRequired[3,2,1,0] = %d, %d, %d, %d\n", - pTxCtrl->admissionRequired[3], pTxCtrl->admissionRequired[2], - pTxCtrl->admissionRequired[1], pTxCtrl->admissionRequired[0])); - WLAN_OS_REPORT(("admissionState[3,2,1,0] = %d, %d, %d, %d\n", - pTxCtrl->admissionState[3], pTxCtrl->admissionState[2], - pTxCtrl->admissionState[1], pTxCtrl->admissionState[0])); - WLAN_OS_REPORT(("highestAdmittedAc[3,2,1,0] = %d, %d, %d, %d\n", - pTxCtrl->highestAdmittedAc[3], pTxCtrl->highestAdmittedAc[2], - pTxCtrl->highestAdmittedAc[1], pTxCtrl->highestAdmittedAc[0])); - WLAN_OS_REPORT(("admittedAcToTidMap[3,2,1,0] = 0x%x, 0x%x, 0x%x, 0x%x\n", - pTxCtrl->admittedAcToTidMap[3], pTxCtrl->admittedAcToTidMap[2], - pTxCtrl->admittedAcToTidMap[1], pTxCtrl->admittedAcToTidMap[0])); - WLAN_OS_REPORT(("busyAcBitmap = 0x%x\n", pTxCtrl->busyAcBitmap)); - WLAN_OS_REPORT(("busyTidBitmap = 0x%x\n", pTxCtrl->busyTidBitmap)); - WLAN_OS_REPORT(("--------------------------------------------------------\n")); - - WLAN_OS_REPORT(("Tx Attributes:\n")); - WLAN_OS_REPORT(("--------------\n")); - WLAN_OS_REPORT(("mgmtRatePolicy[3,2,1,0] = %d, %d, %d, %d\n", - pTxCtrl->mgmtRatePolicy[3], pTxCtrl->mgmtRatePolicy[2], - pTxCtrl->mgmtRatePolicy[1], pTxCtrl->mgmtRatePolicy[0])); - WLAN_OS_REPORT(("dataRatePolicy[3,2,1,0] = %d, %d, %d, %d\n", - pTxCtrl->dataRatePolicy[3], pTxCtrl->dataRatePolicy[2], - pTxCtrl->dataRatePolicy[1], pTxCtrl->dataRatePolicy[0])); - WLAN_OS_REPORT(("dataPktDescAttrib = 0x%x\n", pTxCtrl->dataPktDescAttrib)); - WLAN_OS_REPORT(("--------------------------------------------------------\n")); - - WLAN_OS_REPORT(("Parameters:\n")); - WLAN_OS_REPORT(("----------\n")); - WLAN_OS_REPORT(("headerConverMode = %d\n", pTxCtrl->headerConverMode)); - WLAN_OS_REPORT(("currentPrivacyInvokedMode = %d\n", pTxCtrl->currentPrivacyInvokedMode)); - WLAN_OS_REPORT(("eapolEncryptionStatus = %d\n", pTxCtrl->eapolEncryptionStatus)); - WLAN_OS_REPORT(("encryptionFieldSize = %d\n", pTxCtrl->encryptionFieldSize)); - WLAN_OS_REPORT(("currBssType = %d\n", pTxCtrl->currBssType)); - WLAN_OS_REPORT(("========================================================\n\n")); -#endif -} - - -/*********************************************************************** - * txCtrlParams_printDebugCounters - *********************************************************************** -DESCRIPTION: Print Tx statistics debug counters. -************************************************************************/ -void txCtrlParams_printDebugCounters(TI_HANDLE hTxCtrl) -{ -#ifdef REPORT_LOG - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_UINT32 ac; - - WLAN_OS_REPORT(("-------------- Tx-Ctrl Statistics Per AC ---------------\n")); - WLAN_OS_REPORT(("========================================================\n")); - - WLAN_OS_REPORT(("---------- Packets Sent To Tx-Ctrl ---------------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsSent[ac])); - - WLAN_OS_REPORT(("---------- Number of Queue-Stop (BP) -------------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsBackpressure[ac])); - - WLAN_OS_REPORT(("---------- Number of AC Busy (Requeue pkt) -------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsBusy[ac])); - - WLAN_OS_REPORT(("---------- Packets Sent to Xfer ------------------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsXfered[ac])); - - WLAN_OS_REPORT(("----------- Xfer rc = Success --------------------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsSuccess[ac])); - - WLAN_OS_REPORT(("----------- Xfer rc = Pending --------------------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsPending[ac])); - - WLAN_OS_REPORT(("----------- Xfer rc = Error ----------------------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsError[ac])); - - WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets --------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmplt[ac])); - - WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets TI_OK -----------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltOk[ac])); - - WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets Fails --------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltError[ac])); - - WLAN_OS_REPORT(("----------- Number of Tx-Complete Bytes TI_OK -------------\n")); - for(ac = 0; ac < MAX_NUM_OF_AC; ac++) - WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltOkBytes[ac])); - WLAN_OS_REPORT(("--------------------------------------------------------\n")); - - WLAN_OS_REPORT(("Total Number of Xfer-Complete Events = %d\n", pTxCtrl->dbgCounters.dbgNumXferCmplt)); - WLAN_OS_REPORT(("Total Number of Xfer-Pending Events = %d\n", - pTxCtrl->dbgCounters.dbgNumPktsPending[0] + pTxCtrl->dbgCounters.dbgNumPktsPending[1] + - pTxCtrl->dbgCounters.dbgNumPktsPending[2] + pTxCtrl->dbgCounters.dbgNumPktsPending[3])); - WLAN_OS_REPORT(("========================================================\n\n")); -#endif -} - - -/*************************************************************************** -* txCtrlParams_resetDbgCounters -**************************************************************************** -* DESCRIPTION: Reset the tx data module debug counters -***************************************************************************/ -void txCtrlParams_resetDbgCounters(TI_HANDLE hTxCtrl) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - - os_memoryZero(pTxCtrl->hOs, &pTxCtrl->dbgCounters, sizeof(txDataDbgCounters_t)); -} - - - -#endif /* TI_DBG */ diff --git a/wl1271/stad/src/Data_link/txCtrlServ.c b/wl1271/stad/src/Data_link/txCtrlServ.c deleted file mode 100644 index 0638eaa..0000000 --- a/wl1271/stad/src/Data_link/txCtrlServ.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * txCtrlServ.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/****************************************************************************/ -/* */ -/* MODULE: txCtrlServ.c */ -/* */ -/* PURPOSE: Tx services module, e.g. send-null packet. */ -/* A sub-module of TxCtrl module (uses it's object). */ -/* */ -/****************************************************************************/ - -#define __FILE_ID__ FILE_ID_58 -#include "paramOut.h" -#include "osApi.h" -#include "TWDriver.h" -#include "report.h" -#include "txCtrl.h" -#include "Ethernet.h" -#include "qosMngr_API.h" - - - -/*********************************************************************** - * txCtrlServ_buildNullFrame - *********************************************************************** - -DESCRIPTION: Build Null frame Function. - The function does the following: - - Builds Null Data Frame, considering current QoS mode. - -INPUT: hTxCtrl - Tx Ctrl module handle (the txServ uses the txCtrl object!!). - pFrame - A pointer to a buffer where the frame should be stored - pLength - A pointer to a placeholder for the frame length - -************************************************************************/ -TI_STATUS txCtrlServ_buildNullFrame(TI_HANDLE hTxCtrl, TI_UINT8* pFrame, TI_UINT32* pLength) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - EHeaderConvertMode qosMode = pTxCtrl->headerConverMode; - dot11_header_t *pHeader; /* Note : there is no body for null frame */ - TI_STATUS status; - TI_UINT16 fc; - - pHeader = (dot11_header_t*)(pFrame); - - if (qosMode == HDR_CONVERT_QOS) - { - *pLength = WLAN_QOS_HDR_LEN; - SET_WLAN_WORD(&pHeader->qosControl, 0); /* We are using user priority 0 (BE) so no need for shift and endianess */ - } - else - { - *pLength = WLAN_HDR_LEN; - } - - - /* Set the Frame Control with Null Data type, QoS or non-QoS */ - if (qosMode == HDR_CONVERT_QOS) - fc = DOT11_FC_DATA_NULL_QOS | DOT11_FC_TO_DS; - else - fc = DOT11_FC_DATA_NULL_FUNCTION | DOT11_FC_TO_DS; - COPY_WLAN_WORD(&pHeader->fc, &fc); /* copy with endianess handling. */ - - /* copy destination mac address */ - status = ctrlData_getParamBssid(pTxCtrl->hCtrlData, CTRL_DATA_CURRENT_BSSID_PARAM, pHeader->address3); - if (status != TI_OK) - { - return TI_NOK; - } - - /* copy source mac address */ - status = ctrlData_getParamBssid(pTxCtrl->hCtrlData, CTRL_DATA_MAC_ADDRESS, pHeader->address2); - if (status != TI_OK) - { - return TI_NOK; - } - - /* copy BSSID (destination mac address) */ - MAC_COPY (pHeader->address1, pHeader->address3); - - return status; -} - - -/*********************************************************************** - * txCtrlServ_buildWlanHeader - *********************************************************************** - -DESCRIPTION: Build WLAN header from Ethernet header. - -INPUT: hTxCtrl - Tx Ctrl module handle (the txServ uses the txCtrl object!!). - pFrame - A pointer to a buffer where the frame should be stored - pLength - A pointer to a placeholder for the frame length - -************************************************************************/ -TI_STATUS txCtrlServ_buildWlanHeader(TI_HANDLE hTxCtrl, TI_UINT8* pFrame, TI_UINT32* pLength) -{ - txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl; - TI_STATUS status; - TMacAddr daBssid; - TMacAddr saBssid; - EQosProtocol qosProt; - ScanBssType_e currBssType; - TMacAddr currBssId; - TI_UINT32 headerLength; - TI_UINT16 headerFlags; - TI_BOOL currentPrivacyInvokedMode; - TI_UINT8 encryptionFieldSize; - TTxCtrlBlk tPktCtrlBlk; - dot11_header_t *pDot11Header = (dot11_header_t*)(tPktCtrlBlk.aPktHdr); - Wlan_LlcHeader_T *pWlanSnapHeader; - - /* - * If QoS is used, add two bytes padding before the header for 4-bytes alignment. - * Note that the header length doesn't include it, so the txCtrl detects the pad existence - * by checking if the header-length is a multiple of 4. - */ - qosMngr_getParamsActiveProtocol(pTxCtrl->hQosMngr, &qosProt); - - if (qosProt == QOS_WME) - { - headerLength = WLAN_QOS_HDR_LEN; - headerFlags = DOT11_FC_DATA_QOS | DOT11_FC_TO_DS; - pDot11Header->qosControl = 0; - } - else - { - headerLength = WLAN_HDR_LEN; - headerFlags = DOT11_FC_DATA | DOT11_FC_TO_DS; - } - - /* - * Handle encryption if needed (decision was done at RSN and is provided by TxCtrl): - * - Set WEP bit in header. - * - Add padding for FW security overhead: 4 bytes for TKIP, 8 for AES. - */ - txCtrlParams_getCurrentEncryptionInfo (hTxCtrl, - ¤tPrivacyInvokedMode, - &encryptionFieldSize); - if (currentPrivacyInvokedMode) - { - headerFlags |= DOT11_FC_WEP; - headerLength += encryptionFieldSize; - } - - COPY_WLAN_WORD (&pDot11Header->fc, &headerFlags); /* copy with endianess handling. */ - - /* Get the Destination MAC address */ - status = ctrlData_getParamBssid (pTxCtrl->hCtrlData, CTRL_DATA_CURRENT_BSSID_PARAM, daBssid); - if (status != TI_OK) - { - return TI_NOK; - } - - /* Get the Source MAC address */ - status = ctrlData_getParamBssid (pTxCtrl->hCtrlData, CTRL_DATA_MAC_ADDRESS, saBssid); - if (status != TI_OK) - { - return TI_NOK; - } - - /* receive BssId and Bss Type from control module */ - ctrlData_getCurrBssTypeAndCurrBssId (pTxCtrl->hCtrlData, &currBssId, &currBssType); - if (currBssType != BSS_INFRASTRUCTURE) - { - return TI_NOK; - } - - /* copy BSSID */ - MAC_COPY (pDot11Header->address1, currBssId); - /* copy source mac address */ - MAC_COPY (pDot11Header->address2, saBssid); - /* copy destination mac address*/ - MAC_COPY (pDot11Header->address3, daBssid); - - - /* Set the SNAP header pointer right after the other header parts handled above. */ - pWlanSnapHeader = (Wlan_LlcHeader_T *)&(tPktCtrlBlk.aPktHdr[headerLength]); - - pWlanSnapHeader->DSAP = SNAP_CHANNEL_ID; - pWlanSnapHeader->SSAP = SNAP_CHANNEL_ID; - pWlanSnapHeader->Control = LLC_CONTROL_UNNUMBERED_INFORMATION; - - /* add RFC1042. */ - pWlanSnapHeader->OUI[0] = SNAP_OUI_RFC1042_BYTE0; - pWlanSnapHeader->OUI[1] = SNAP_OUI_RFC1042_BYTE1; - pWlanSnapHeader->OUI[2] = SNAP_OUI_RFC1042_BYTE2; - - /* set ETH type to IP */ - pWlanSnapHeader->Type = HTOWLANS(ETHERTYPE_IP); - - /* Add the SNAP length to the total header length. */ - headerLength += sizeof(Wlan_LlcHeader_T); - - /* copy WLAN header */ - os_memoryCopy (pTxCtrl->hOs, pFrame, tPktCtrlBlk.aPktHdr, headerLength); - *pLength = headerLength; - - return TI_OK; -} - diff --git a/wl1271/stad/src/Data_link/txCtrl_Api.h b/wl1271/stad/src/Data_link/txCtrl_Api.h deleted file mode 100644 index cd68368..0000000 --- a/wl1271/stad/src/Data_link/txCtrl_Api.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * txCtrl_Api.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: txCtrl_Api.h */ -/* PURPOSE: TxCtrl module API Header file */ -/* */ -/***************************************************************************/ -#ifndef _TX_CTRL_API_H_ -#define _TX_CTRL_API_H_ - -#include "GeneralUtilApi.h" -#include "DrvMainModules.h" - -/* TxCtrl Xmit results */ -typedef enum -{ - STATUS_XMIT_SUCCESS, - STATUS_XMIT_BUSY, - STATUS_XMIT_ERROR -} EStatusXmit; - - -typedef struct -{ - TI_BOOL bHtEnable; /* current flag of HT Capabilities enabled */ - TI_UINT32 uTxCtrlHtControl; /* The HT Control Field for futur use. for now empty and the FW set it */ -} TtxCtrlHtControl; - - -/* Build the buffers descriptor of a typical two buffers (header & data) Tx packet */ -#define BUILD_TX_TWO_BUF_PKT_BDL(pPktCtrlBlk, pHdrBuf, uHdrLen, pDataBuf, uDataLen) \ - pPktCtrlBlk->tTxnStruct.aBuf[0] = (TI_UINT8 *) (pHdrBuf); \ - pPktCtrlBlk->tTxnStruct.aLen[0] = (TI_UINT16 ) (uHdrLen); \ - pPktCtrlBlk->tTxnStruct.aBuf[1] = (TI_UINT8 *) (pDataBuf); \ - pPktCtrlBlk->tTxnStruct.aLen[1] = (TI_UINT16 ) (uDataLen); \ - pPktCtrlBlk->tTxnStruct.aLen[2] = 0; \ - pPktCtrlBlk->tTxDescriptor.length = (TI_UINT16)((uHdrLen) + (uDataLen)); - - -/****************************************************************/ -/* MODULE PUBLIC FUNCTIONS */ -/****************************************************************/ - -/* - * The TxCtrl MAIN public functions (in txCtrl.c): - */ -TI_HANDLE txCtrl_Create (TI_HANDLE hOs); -void txCtrl_Init (TStadHandlesList *pStadHandles); -TI_STATUS txCtrl_SetDefaults (TI_HANDLE hTxCtrl, txDataInitParams_t *txDataInitParams); -TI_STATUS txCtrl_Unload (TI_HANDLE hTxCtrl); -TI_STATUS txCtrl_XmitData (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk); -TI_STATUS txCtrl_XmitMgmt (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk); -void txCtrl_UpdateQueuesMapping (TI_HANDLE hTxCtrl); -void * txCtrl_AllocPacketBuffer (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_UINT32 uPacketLen); -void txCtrl_FreePacket (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk, TI_STATUS eStatus); -TI_STATUS txCtrl_NotifyFwReset(TI_HANDLE hTxCtrl); -TI_STATUS txCtrl_CheckForTxStuck(TI_HANDLE hTxCtrl); -TI_UINT32 txCtrl_BuildDataPktHdr (TI_HANDLE hTxCtrl, TTxCtrlBlk *pPktCtrlBlk, AckPolicy_e ackPolicy); - - -/* - * The txCtrlParams.c sub-module public functions: - */ -void txCtrlParams_resetCounters(TI_HANDLE hTxCtrl); -TI_HANDLE txCtrlParams_RegNotif(TI_HANDLE hTxCtrl, - TI_UINT16 EventMask, - GeneralEventCall_t CallBack, - TI_HANDLE context, - TI_UINT32 Cookie); -TI_STATUS txCtrlParams_AddToNotifMask(TI_HANDLE hTxCtrl, TI_HANDLE Notifh, TI_UINT16 EventMask); -TI_STATUS txCtrlParams_UnRegNotif(TI_HANDLE hTxCtrl, TI_HANDLE RegEventHandle); -TI_STATUS txCtrlParams_setAdmissionCtrlParams(TI_HANDLE hTxCtrl, - TI_UINT8 acId, - TI_UINT16 mediumTime, - TI_UINT32 minimumPHYRate, - TI_BOOL admFlag); -TI_STATUS txCtrlParams_getParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo); -TI_STATUS txCtrlParams_setParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo); -TI_STATUS txCtrlParams_SetHtControl (TI_HANDLE hTxCtrl, TtxCtrlHtControl *pHtControl); -void txCtrlParams_setBssId (TI_HANDLE hTxCtrl, TMacAddr *pCurrBssId); -void txCtrlParams_setBssType (TI_HANDLE hTxCtrl, ScanBssType_e currBssType); -void txCtrlParams_setQosHeaderConverMode (TI_HANDLE hTxCtrl, EHeaderConvertMode headerConverMode); -void txCtrlParams_setCurrentPrivacyInvokedMode (TI_HANDLE hTxCtrl, TI_BOOL currentPrivacyInvokedMode); -void txCtrlParams_setEapolEncryptionStatus (TI_HANDLE hTxCtrl, TI_BOOL eapolEncryptionStatus); -void txCtrlParams_setEncryptionFieldSizes (TI_HANDLE hTxCtrl, TI_UINT8 encryptionFieldSize); -void txCtrlParams_getCurrentEncryptionInfo (TI_HANDLE hTxCtrl, - TI_BOOL *pCurrentPrivacyInvokedMode, - TI_UINT8 *pEncryptionFieldSize); -ERate txCtrlParams_GetTxRate (TI_HANDLE hTxCtrl); -void txCtrlParams_setAcAdmissionStatus (TI_HANDLE hTxCtrl, - TI_UINT8 ac, - EAdmissionState admissionRequired, - ETrafficAdmState admissionState); -void txCtrlParams_setAcMsduLifeTime (TI_HANDLE hTxCtrl, TI_UINT8 ac, TI_UINT32 msduLifeTime); -void txCtrlParams_setAcAckPolicy (TI_HANDLE hTxCtrl, TI_UINT8 ac, AckPolicy_e ackPolicy); -void txCtrlParams_updateMgmtRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac); -void txCtrlParams_updateDataRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac); -void txCtrlParams_updateTxSessionCount(TI_HANDLE hTxCtrl, TI_UINT16 txSessionCount); -#ifdef TI_DBG -void txCtrlParams_printInfo(TI_HANDLE hTxCtrl); -void txCtrlParams_printDebugCounters(TI_HANDLE hTxCtrl); -void txCtrlParams_resetDbgCounters(TI_HANDLE hTxCtrl); -#endif /* TI_DBG */ - - -/* - * The txCtrlServ.c sub-module public functions: - */ -TI_STATUS txCtrlServ_buildNullFrame(TI_HANDLE hTxCtrl, TI_UINT8* pFrame, TI_UINT32* pLength); -TI_STATUS txCtrlServ_buildWlanHeader(TI_HANDLE hTxCtrl, TI_UINT8* pFrame, TI_UINT32* pLength); - -#endif /* _TX_CTRL_API_H_ */ diff --git a/wl1271/stad/src/Data_link/txDataQueue.c b/wl1271/stad/src/Data_link/txDataQueue.c deleted file mode 100644 index ac5ef43..0000000 --- a/wl1271/stad/src/Data_link/txDataQueue.c +++ /dev/null @@ -1,823 +0,0 @@ -/* - * txDataQueue.c - * - * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 txDataQueue.c - * \brief The Tx Data Queues module. - * - * \see txDataQueue.h - */ - - -#define __FILE_ID__ FILE_ID_60 -#include "paramOut.h" -#include "osApi.h" -#include "report.h" -#include "timer.h" -#include "queue.h" -#include "context.h" -#include "Ethernet.h" -#include "TWDriver.h" -#include "DataCtrl_Api.h" -#include "txDataQueue.h" -#include "txCtrl.h" -#include "DrvMainModules.h" -#include "bmtrace_api.h" - - -/* Internal Functions prototypes */ -static void txDataQ_RunScheduler (TI_HANDLE hTxDataQ); -static void txDataQ_UpdateQueuesBusyState (TTxDataQ *pTxDataQ, TI_UINT32 uTidBitMap); -static void txDataQ_TxSendPaceTimeout (TI_HANDLE hTxDataQ, TI_BOOL bTwdInitOccured); -extern void wlanDrvIf_StopTx (TI_HANDLE hOs); -extern void wlanDrvIf_ResumeTx (TI_HANDLE hOs); - - - -/*************************************************************************** -* PUBLIC FUNCTIONS IMPLEMENTATION * -****************************************************************************/ - - -/** - * \fn txDataQ_Create - * \brief Create the module and its queues - * - * Create the Tx Data module and its queues. - * - * \note - * \param hOs - Handle to the Os Abstraction Layer - * \return Handle to the allocated Tx Data Queue module (NULL if failed) - * \sa - */ -TI_HANDLE txDataQ_Create(TI_HANDLE hOs) -{ - TTxDataQ *pTxDataQ; - - /* allocate TxDataQueue module */ - pTxDataQ = os_memoryAlloc (hOs, (sizeof(TTxDataQ))); - - if (!pTxDataQ) - { - WLAN_OS_REPORT(("Error allocating the TxDataQueue Module\n")); - return NULL; - } - - /* Reset TxDataQueue module */ - os_memoryZero (hOs, pTxDataQ, (sizeof(TTxDataQ))); - - return (TI_HANDLE)pTxDataQ; -} - - -/** - * \fn txDataQ_Init - * \brief Save required modules handles - * - * Save other modules handles. - * - * \note - * \param pStadHandles - The driver modules handles - * \return void - * \sa - */ -void txDataQ_Init (TStadHandlesList *pStadHandles) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)(pStadHandles->hTxDataQ); - TI_UINT32 uNodeHeaderOffset = TI_FIELD_OFFSET(TTxnStruct, tTxnQNode); - TI_UINT8 uQueId; - - /* save modules handles */ - pTxDataQ->hContext = pStadHandles->hContext; - pTxDataQ->hTxCtrl = pStadHandles->hTxCtrl; - pTxDataQ->hOs = pStadHandles->hOs; - pTxDataQ->hReport = pStadHandles->hReport; - pTxDataQ->hTxMgmtQ = pStadHandles->hTxMgmtQ; - pTxDataQ->hTWD = pStadHandles->hTWD; - - /* Configures the Port Default status to Close */ - pTxDataQ->bDataPortEnable = TI_FALSE; - - /* Configures the LastQueId to zero => scheduler will strart from Queue 1*/ - pTxDataQ->uLastQueId = 0; - - /* init the number of the Data queue to be used */ - pTxDataQ->uNumQueues = MAX_NUM_OF_AC; - - /* init the max size of the Data queues */ - pTxDataQ->aQueueMaxSize[QOS_AC_BE] = DATA_QUEUE_DEPTH_BE; - pTxDataQ->aQueueMaxSize[QOS_AC_BK] = DATA_QUEUE_DEPTH_BK; - pTxDataQ->aQueueMaxSize[QOS_AC_VI] = DATA_QUEUE_DEPTH_VI; - pTxDataQ->aQueueMaxSize[QOS_AC_VO] = DATA_QUEUE_DEPTH_VO; - - /* Create the tx data queues */ - for (uQueId = 0; uQueId < pTxDataQ->uNumQueues; uQueId++) - { - pTxDataQ->aQueues[uQueId] = que_Create (pTxDataQ->hOs, - pTxDataQ->hReport, - pTxDataQ->aQueueMaxSize[uQueId], - uNodeHeaderOffset); - - /* If any Queues' allocation failed, print error, free TxDataQueue module and exit */ - if (pTxDataQ->aQueues[uQueId] == NULL) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_CONSOLE , "Failed to create queue\n"); - WLAN_OS_REPORT(("Failed to create queue\n")); - os_memoryFree (pTxDataQ->hOs, pTxDataQ, sizeof(TTxDataQ)); - return; - } - - /* Configure the Queues default values */ - pTxDataQ->aQueueBusy[uQueId] = TI_FALSE; - pTxDataQ->aNetStackQueueStopped[uQueId] = TI_FALSE; - pTxDataQ->aTxSendPaceThresh[uQueId] = 1; - } - - pTxDataQ->hTxSendPaceTimer = tmr_CreateTimer (pStadHandles->hTimer); - if (pTxDataQ->hTxSendPaceTimer == NULL) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "txDataQ_Init(): Failed to create hTxSendPaceTimer!\n"); - return; - } - - /* Register to the context engine and get the client ID */ - pTxDataQ->uContextId = context_RegisterClient (pTxDataQ->hContext, - txDataQ_RunScheduler, - (TI_HANDLE)pTxDataQ, - TI_TRUE, - "TX_DATA", - sizeof("TX_DATA")); -} - - -/** - * \fn txDataQ_SetDefaults - * \brief Configure module with default settings - * - * Init the Tx Data queues. - * Register as the context-engine client. - * - * \note - * \param hTxDataQ - The object - * \param Other modules handles - * \return TI_OK on success or TI_NOK on failure - * \sa - */ -TI_STATUS txDataQ_SetDefaults (TI_HANDLE hTxDataQ, txDataInitParams_t *pTxDataInitParams) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TI_STATUS eStatus; - - /* configure the classifier sub-module */ - eStatus = txDataClsfr_Config (hTxDataQ, &pTxDataInitParams->ClsfrInitParam); - if (eStatus != TI_OK) - { - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_CONSOLE ,"FATAL ERROR: txDataQ_SetDefaults(): txDataClsfr_Config failed - Aborting\n"); - WLAN_OS_REPORT(("FATAL ERROR: txDataQ_SetDefaults(): txDataClsfr_Config failed - Aborting\n")); - return eStatus; - } - - /* Save the module's parameters settings */ - pTxDataQ->bStopNetStackTx = pTxDataInitParams->bStopNetStackTx; - pTxDataQ->aTxSendPaceThresh[QOS_AC_BE] = pTxDataInitParams->uTxSendPaceThresh; - pTxDataQ->aTxSendPaceThresh[QOS_AC_BK] = pTxDataInitParams->uTxSendPaceThresh; - pTxDataQ->aTxSendPaceThresh[QOS_AC_VI] = pTxDataInitParams->uTxSendPaceThresh; - pTxDataQ->aTxSendPaceThresh[QOS_AC_VO] = 1; /* Don't delay voice packts! */ - - TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_INIT, ".....Tx Data Queue configured successfully\n"); - - return TI_OK; -} - - -/** - * \fn txDataQ_Destroy - * \brief Destroy the module and its queues - * - * Clear and destroy the queues and then destroy the module object. - * - * \note - * \param hTxDataQ - The object - * \return TI_OK - Unload succesfull, TI_NOK - Unload unsuccesfull - * \sa - */ -TI_STATUS txDataQ_Destroy (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TI_STATUS status = TI_OK; - TI_UINT32 uQueId; - - /* Dequeue and free all queued packets */ - txDataQ_ClearQueues (hTxDataQ); - - /* Free Data queues */ - for (uQueId = 0 ; uQueId < pTxDataQ->uNumQueues ; uQueId++) - { - if (que_Destroy(pTxDataQ->aQueues[uQueId]) != TI_OK) - { - TRACE1(pTxDataQ->hReport, REPORT_SEVERITY_ERROR, "txDataQueue_unLoad: fail to free Data Queue number: %d\n",uQueId); - status = TI_NOK; - } - } - - /* free timer */ - if (pTxDataQ->hTxSendPaceTimer) - { - tmr_DestroyTimer (pTxDataQ->hTxSendPaceTimer); - } - - /* Free Tx Data Queue Module */ - os_memoryFree (pTxDataQ->hOs, pTxDataQ, sizeof(TTxDataQ)); - - return status; -} - - -/** - * \fn txDataQ_ClearQueues - * \brief Clear all queues - * - * Dequeue and free all queued packets. - * - * \note - * \param hTxDataQ - The object - * \return void - * \sa - */ -void txDataQ_ClearQueues (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TTxCtrlBlk *pPktCtrlBlk; - TI_UINT32 uQueId; - - /* Dequeue and free all queued packets */ - for (uQueId = 0 ; uQueId < pTxDataQ->uNumQueues ; uQueId++) - { - do { - context_EnterCriticalSection (pTxDataQ->hContext); - pPktCtrlBlk = (TTxCtrlBlk *) que_Dequeue(pTxDataQ->aQueues[uQueId]); - context_LeaveCriticalSection (pTxDataQ->hContext); - if (pPktCtrlBlk != NULL) { - txCtrl_FreePacket (pTxDataQ->hTxCtrl, pPktCtrlBlk, TI_NOK); - } - } while (pPktCtrlBlk != NULL); - } -} - - -/** - * \fn txDataQ_InsertPacket - * \brief Insert packet in queue and schedule task - * - * This function is called by the hard_start_xmit() callback function. - * If the packet it an EAPOL, forward it to the Mgmt-Queue. - * Otherwise, classify the packet, enqueue it and request - * context switch for handling it in the driver's context. - * - * \note - * \param hTxDataQ - The object - * \param pPktCtrlBlk - Pointer to the packet - * \param uPacketDtag - The packet priority optionaly set by the OAL - * \return TI_OK - if the packet was queued, TI_NOK - if the packet was dropped. - * \sa txDataQ_Run - */ -TI_STATUS txDataQ_InsertPacket (TI_HANDLE hTxDataQ, TTxCtrlBlk *pPktCtrlBlk, TI_UINT8 uPacketDtag) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TEthernetHeader *pEthHead = (TEthernetHeader *)(pPktCtrlBlk->tTxnStruct.aBuf[0]); - TI_STATUS eStatus; - TI_UINT32 uQueId; - TI_UINT32 uQueSize; - txCtrl_t *pTxCtrl = (txCtrl_t *)(pTxDataQ->hTxCtrl); - TI_BOOL bRequestSchedule = TI_FALSE; - TI_BOOL bStopNetStack = TI_FALSE; - CL_TRACE_START_L3(); - - /* If packet is EAPOL or from the generic Ethertype, forward it to the Mgmt-Queue and exit */ - if ((HTOWLANS(pEthHead->type) == ETHERTYPE_EAPOL) || - (HTOWLANS(pEthHead->type) == pTxCtrl->genericEthertype)) - { - pPktCtrlBlk->tTxPktParams.uPktType = TX_PKT_TYPE_EAPOL; - - return txMgmtQ_Xmit (pTxDataQ->hTxMgmtQ, pPktCtrlBlk, TI_TRUE); - /* Note: The last parameter indicates that we are running in external context */ - } - - pPktCtrlBlk->tTxPktParams.uPktType = TX_PKT_TYPE_ETHER; - - /* Enter critical section to protect classifier data and queue access */ - context_EnterCriticalSection (pTxDataQ->hContext); - - /* Call the Classify function to set the TID field */ - if (txDataClsfr_ClassifyTxPacket (hTxDataQ, pPktCtrlBlk, uPacketDtag) != TI_OK) - { -#ifdef TI_DBG - pTxDataQ->uClsfrMismatchCount++; -TRACE0(pTxDataQ->hReport, REPORT_SEVERITY_WARNING, "txDataQueue_xmit: No matching classifier found \n"); -#endif /* TI_DBG */ - } - - /* Enqueue the packet in the appropriate Queue */ - uQueId = aTidToQueueTable[pPktCtrlBlk->tTxDescriptor.tid]; - eStatus = que_Enqueue (pTxDataQ->aQueues[uQueId], (TI_HANDLE)pPktCtrlBlk); - - /* Get number of packets in current queue */ - uQueSize = que_Size (pTxDataQ->aQueues[uQueId]); - - /* If the current queue is not stopped */ - if (pTxDataQ->aQueueBusy[uQueId] == TI_FALSE) - { - /* If the queue has the desired number of packets, request switch to driver context for handling them */ - if (uQueSize == pTxDataQ->aTxSendPaceThresh[uQueId]) - { - tmr_StopTimer (pTxDataQ->hTxSendPaceTimer); - bRequestSchedule = TI_TRUE; - } - /* If below Tx-Send pacing threshold, start timer to trigger packets handling if expired */ - else if (uQueSize < pTxDataQ->aTxSendPaceThresh[uQueId]) - { - tmr_StartTimer (pTxDataQ->hTxSendPaceTimer, - txDataQ_TxSendPaceTimeout, - hTxDataQ, - TX_SEND_PACE_TIMEOUT_MSEC, - TI_FALSE); - } - } - - /* If allowed to stop network stack and the queue is full, indicate to stop network and - to schedule Tx handling (both are executed below, outside the critical section!) */ - if ((pTxDataQ->bStopNetStackTx) && (uQueSize == pTxDataQ->aQueueMaxSize[uQueId])) - { - pTxDataQ->aNetStackQueueStopped[uQueId] = TI_TRUE; - bRequestSchedule = TI_TRUE; - bStopNetStack = TI_TRUE; - } - - /* Leave critical section */ - context_LeaveCriticalSection (pTxDataQ->hContext); - - /* If needed, schedule Tx handling */ - if (bRequestSchedule) - { - context_RequestSchedule (pTxDataQ->hContext, pTxDataQ->uContextId); - } - - /* If needed, stop the network stack Tx */ - if (bStopNetStack) - { - /* Stop the network stack from sending Tx packets as we have at least one date queue full. - Note that in some of the OS's (e.g Win Mobile) it is implemented by blocking the thread*/ - wlanDrvIf_StopTx (pTxDataQ->hOs); - } - - if (eStatus != TI_OK) - { - /* If the packet can't be queued drop it */ - txCtrl_FreePacket (pTxDataQ->hTxCtrl, pPktCtrlBlk, TI_NOK); -#ifdef TI_DBG - pTxDataQ->aQueueCounters[uQueId].uDroppedPacket++; -#endif /* TI_DBG */ - } - else - { -#ifdef TI_DBG - pTxDataQ->aQueueCounters[uQueId].uEnqueuePacket++; -#endif /* TI_DBG */ - } - - CL_TRACE_END_L3 ("tiwlan_drv.ko", "INHERIT", "TX", ""); - - return eStatus; -} - - -/** - * \fn txDataQ_StopQueue - * \brief Set queue's busy indication - * - * This function is called by the txCtrl_xmitData() if the queue's backpressure - * indication is set. - * It sets the internal queue's Busy indication. - * - * \note - * \param hTxDataQ - The object - * \param uTidBitMap - The changed TIDs busy bitmap - * \return void - * \sa txDataQ_UpdateBusyMap - */ -void txDataQ_StopQueue (TI_HANDLE hTxDataQ, TI_UINT32 uTidBitMap) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - /* Set the relevant queue(s) busy flag */ - txDataQ_UpdateQueuesBusyState (pTxDataQ, uTidBitMap); -} - - -/** - * \fn txDataQ_UpdateBusyMap - * \brief Set queue's busy indication - * - * This function is called by the txCtrl if the backpressure map per TID is changed. - * This could be as a result of Tx-Complete, admission change or association. - * The function modifies the internal queue's Busy indication and calls the scheduler. - * - * \note - * \param hTxDataQ - The object - * \param uTidBitMap - The changed TIDs busy bitmap - * \return void - * \sa txDataQ_StopQueue - */ -void txDataQ_UpdateBusyMap (TI_HANDLE hTxDataQ, TI_UINT32 tidBitMap) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - /* Update the Queue(s) mode */ - txDataQ_UpdateQueuesBusyState (pTxDataQ, tidBitMap); - - /* Run the scheduler */ - txDataQ_RunScheduler (hTxDataQ); -} - - -/** - * \fn txDataQ_StopAll - * \brief Disable Data-Queue module access to Tx path. - * - * Called by the Tx-Port when the data-queue module can't access the Tx path. - * Sets stop-all-queues indication. - * - * \note - * \param hTxDataQ - The object - * \return void - * \sa txDataQ_WakeAll - */ -void txDataQ_StopAll (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - /* Disable the data Tx port */ - pTxDataQ->bDataPortEnable = TI_FALSE; -} - - -/** - * \fn txDataQ_WakeAll - * \brief Enable Data-Queue module access to Tx path. - * - * Called by the Tx-Port when the data-queue module can access the Tx path. - * Clears the stop-all-queues indication and calls the scheduler. - * - * \note - * \param hTxDataQ - The object - * \return void - * \sa txDataQ_StopAll - */ -void txDataQ_WakeAll (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - /* Enable the data Tx port */ - pTxDataQ->bDataPortEnable = TI_TRUE; - - /* Run the scheduler */ - txDataQ_RunScheduler (hTxDataQ); -} - - -/*************************************************************************** -* DEBUG FUNCTIONS IMPLEMENTATION * -****************************************************************************/ - -#ifdef TI_DBG - -/** - * \fn txDataQ_PrintModuleParams - * \brief Print Module Parameters - * - * Print Module Parameters - * - * \note - * \param hTxDataQ - The object - * \return void - * \sa - */ -void txDataQ_PrintModuleParams (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TI_UINT32 qIndex; - - WLAN_OS_REPORT(("--------- txDataQueue_printModuleParams ----------\n\n")); - - WLAN_OS_REPORT(("bStopNetStackTx = %d\n",pTxDataQ->bStopNetStackTx)); - WLAN_OS_REPORT(("bDataPortEnable = %d\n",pTxDataQ->bDataPortEnable)); - WLAN_OS_REPORT(("uNumQueues = %d\n",pTxDataQ->uNumQueues)); - WLAN_OS_REPORT(("uLastQueId = %d\n",pTxDataQ->uLastQueId)); - WLAN_OS_REPORT(("uContextId = %d\n",pTxDataQ->uContextId)); - - for (qIndex = 0; qIndex < pTxDataQ->uNumQueues; qIndex++) - { - WLAN_OS_REPORT(("aQueueBusy[%d] = %d\n", qIndex, pTxDataQ->aQueueBusy[qIndex])); - } - for (qIndex = 0; qIndex < pTxDataQ->uNumQueues; qIndex++) - { - WLAN_OS_REPORT(("aQueueMaxSize[%d] = %d\n", qIndex, pTxDataQ->aQueueMaxSize[qIndex])); - } - for (qIndex = 0; qIndex < pTxDataQ->uNumQueues; qIndex++) - { - WLAN_OS_REPORT(("aTxSendPaceThresh[%d] = %d\n", qIndex, pTxDataQ->aTxSendPaceThresh[qIndex])); - } - for (qIndex = 0; qIndex < pTxDataQ->uNumQueues; qIndex++) - { - WLAN_OS_REPORT(("aNetStackQueueStopped[%d] = %d\n", qIndex, pTxDataQ->aNetStackQueueStopped[qIndex])); - } - - WLAN_OS_REPORT(("-------------- Queues Info -----------------------\n")); - for (qIndex = 0; qIndex < MAX_NUM_OF_AC; qIndex++) - { - WLAN_OS_REPORT(("Que %d:\n", qIndex)); - que_Print (pTxDataQ->aQueues[qIndex]); - } - - WLAN_OS_REPORT(("--------------------------------------------------\n\n")); -} - - -/** - * \fn txDataQ_PrintQueueStatistics - * \brief Print queues statistics - * - * Print queues statistics - * - * \note - * \param hTxDataQ - The object - * \return void - * \sa - */ -void txDataQ_PrintQueueStatistics (TI_HANDLE hTxDataQ) -{ -#ifdef REPORT_LOG - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TI_UINT32 qIndex; - - WLAN_OS_REPORT(("-------------- txDataQueue_printStatistics -------\n\n")); - - WLAN_OS_REPORT(("uClsfrMismatchCount = %d\n",pTxDataQ->uClsfrMismatchCount)); - WLAN_OS_REPORT(("uTxSendPaceTimeoutsCount = %d\n",pTxDataQ->uTxSendPaceTimeoutsCount)); - - WLAN_OS_REPORT(("-------------- Enqueue to queues -----------------\n")); - for(qIndex = 0; qIndex < MAX_NUM_OF_AC; qIndex++) - WLAN_OS_REPORT(("Que[%d]: = %d\n",qIndex, pTxDataQ->aQueueCounters[qIndex].uEnqueuePacket)); - - WLAN_OS_REPORT(("-------------- Dequeue from queues ---------------\n")); - for(qIndex = 0; qIndex < MAX_NUM_OF_AC; qIndex++) - WLAN_OS_REPORT(("Que[%d]: = %d\n",qIndex, pTxDataQ->aQueueCounters[qIndex].uDequeuePacket)); - - WLAN_OS_REPORT(("-------------- Requeue to queues -----------------\n")); - for(qIndex = 0; qIndex < MAX_NUM_OF_AC; qIndex++) - WLAN_OS_REPORT(("Que[%d]: = %d\n",qIndex, pTxDataQ->aQueueCounters[qIndex].uRequeuePacket)); - - WLAN_OS_REPORT(("-------------- Sent to TxCtrl --------------------\n")); - for(qIndex = 0; qIndex < MAX_NUM_OF_AC; qIndex++) - WLAN_OS_REPORT(("Que[%d]: = %d\n",qIndex, pTxDataQ->aQueueCounters[qIndex].uXmittedPacket)); - - WLAN_OS_REPORT(("-------------- Dropped - Queue Full --------------\n")); - for(qIndex = 0; qIndex < MAX_NUM_OF_AC; qIndex++) - WLAN_OS_REPORT(("Que[%d]: = %d\n",qIndex, pTxDataQ->aQueueCounters[qIndex].uDroppedPacket)); - - WLAN_OS_REPORT(("--------------------------------------------------\n\n")); -#endif -} - - -/** - * \fn txDataQ_ResetQueueStatistics - * \brief Reset queues statistics - * - * Reset queues statistics - * - * \note - * \param hTxDataQ - The object - * \return void - * \sa - */ -void txDataQ_ResetQueueStatistics (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - os_memoryZero(pTxDataQ->hOs, &pTxDataQ->aQueueCounters, sizeof(pTxDataQ->aQueueCounters)); - pTxDataQ->uTxSendPaceTimeoutsCount = 0; -} - - -#endif /* TI_DBG */ - - - -/*************************************************************************** -* INTERNAL FUNCTIONS IMPLEMENTATION * -****************************************************************************/ - - -/** - * \fn txDataQ_RunScheduler - * \brief The module's Tx scheduler - * - * This function is the Data-Queue scheduler. - * It selects a packet to transmit from the tx queues and sends it to the TxCtrl. - * The queues are selected in a round-robin order. - * The function is called by one of: - * txDataQ_Run() - * txDataQ_UpdateBusyMap() - * txDataQ_WakeAll() - * - * \note - * \param hTxDataQ - The object - * \return void - * \sa - */ -static void txDataQ_RunScheduler (TI_HANDLE hTxDataQ) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - TI_UINT32 uIdleIterationsCount = 0; /* Count iterations without packet transmission (for exit criteria) */ - TI_UINT32 uQueId = pTxDataQ->uLastQueId; /* The last iteration queue */ - EStatusXmit eStatus; /* The return status of the txCtrl_xmitData function */ - TTxCtrlBlk *pPktCtrlBlk; /* Pointer to the packet to be dequeued and sent */ - - while(1) - { - /* If the Data port is closed or the scheduler couldn't send packets from - all queues, indicate end of current packets burst and exit */ - if ( !pTxDataQ->bDataPortEnable || (uIdleIterationsCount >= pTxDataQ->uNumQueues) ) - { - TWD_txXfer_EndOfBurst (pTxDataQ->hTWD); - return; - } - - /* Selecting the next queue */ - uQueId++; - if (uQueId == pTxDataQ->uNumQueues) - { - uQueId = 0; - } - pTxDataQ->uLastQueId = uQueId; - - /* Increment the idle iterations counter */ - uIdleIterationsCount++; - - /* If the queue is busy (AC is full), continue to next queue. */ - if (pTxDataQ->aQueueBusy[uQueId]) - { - continue; - } - - /* Dequeue a packet in a critical section */ - context_EnterCriticalSection (pTxDataQ->hContext); - pPktCtrlBlk = (TTxCtrlBlk *) que_Dequeue (pTxDataQ->aQueues[uQueId]); - context_LeaveCriticalSection (pTxDataQ->hContext); - - /* If the queue was empty, continue to the next queue */ - if (pPktCtrlBlk == NULL) - { - if ((pTxDataQ->bStopNetStackTx) && pTxDataQ->aNetStackQueueStopped[uQueId]) - { - pTxDataQ->aNetStackQueueStopped[uQueId] = TI_FALSE; - /*Resume the TX process as our date queues are empty*/ - wlanDrvIf_ResumeTx (pTxDataQ->hOs); - } - - continue; - } - -#ifdef TI_DBG - pTxDataQ->aQueueCounters[uQueId].uDequeuePacket++; -#endif /* TI_DBG */ - - /* Send the packet */ - eStatus = txCtrl_XmitData (pTxDataQ->hTxCtrl, pPktCtrlBlk); - - /* - * If the return status is busy it means that the packet was not sent - * so we need to requeue it for future try. - */ - if(eStatus == STATUS_XMIT_BUSY) - { - TI_STATUS eQueStatus; - - /* Requeue the packet in a critical section */ - context_EnterCriticalSection (pTxDataQ->hContext); - eQueStatus = que_Requeue (pTxDataQ->aQueues[uQueId], (TI_HANDLE)pPktCtrlBlk); - if (eQueStatus != TI_OK) - { - /* If the packet can't be queued drop it */ - /* Note: may happen only if this thread was preempted between the - dequeue and requeue and new packets were inserted into this quque */ - txCtrl_FreePacket (pTxDataQ->hTxCtrl, pPktCtrlBlk, TI_NOK); -#ifdef TI_DBG - pTxDataQ->aQueueCounters[uQueId].uDroppedPacket++; -#endif /* TI_DBG */ - } - context_LeaveCriticalSection (pTxDataQ->hContext); - -#ifdef TI_DBG - pTxDataQ->aQueueCounters[uQueId].uRequeuePacket++; -#endif /* TI_DBG */ - - continue; - } - - /* If we reach this point, a packet was sent successfully so reset the idle iterations counter. */ - uIdleIterationsCount = 0; - -#ifdef TI_DBG - pTxDataQ->aQueueCounters[uQueId].uXmittedPacket++; -#endif /* TI_DBG */ - - } /* End of while */ - - /* Unreachable code */ -} - - -/** - * \fn txDataQ_UpdateQueuesBusyState - * \brief Update queues' busy state - * - * Update the Queues Mode to Busy according to the input TidBitMap. -* Each Tid that is set indicates that the related Queue is Busy. -* - * \note - * \param hTxDataQ - The object - * \param uTidBitMap - The changed TIDs busy bitmap - * \return void - * \sa - */ -static void txDataQ_UpdateQueuesBusyState (TTxDataQ *pTxDataQ, TI_UINT32 uTidBitMap) -{ - TI_UINT32 uTidIdx; - - /* Go over the TidBitMap and update the related queue busy state */ - for (uTidIdx = 0; uTidIdx < MAX_NUM_OF_802_1d_TAGS; uTidIdx++, uTidBitMap >>= 1) - { - if (uTidBitMap & 0x1) /* this Tid is busy */ - { - pTxDataQ->aQueueBusy[aTidToQueueTable[uTidIdx]] = TI_TRUE; - } - else - { - pTxDataQ->aQueueBusy[aTidToQueueTable[uTidIdx]] = TI_FALSE; - } - } -} - - -/* - * \brief Handle Tx-Send-Pacing timeout. - * - * \param hTxDataQ - Module handle - * \param bTwdInitOccured - Indicate if TWD restart (recovery) occured - * \return void - * - * \par Description - * Call the Tx scheduler to handle the queued packets. - * - * \sa - */ -static void txDataQ_TxSendPaceTimeout (TI_HANDLE hTxDataQ, TI_BOOL bTwdInitOccured) -{ - TTxDataQ *pTxDataQ = (TTxDataQ *)hTxDataQ; - - pTxDataQ->uTxSendPaceTimeoutsCount++; - - txDataQ_RunScheduler (hTxDataQ); -} diff --git a/wl1271/stad/src/Data_link/txDataQueue.h b/wl1271/stad/src/Data_link/txDataQueue.h deleted file mode 100644 index 4f93d02..0000000 --- a/wl1271/stad/src/Data_link/txDataQueue.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * txDataQueue.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: TxDataQueue.h */ -/* PURPOSE: Tx Data Queue module Header file */ -/* */ -/***************************************************************************/ -#ifndef _TX_DATA_QUEUE_H_ -#define _TX_DATA_QUEUE_H_ - - -#include "TWDriver.h" -#include "DataCtrl_Api.h" - - -#define TX_SEND_PACE_TIMEOUT_MSEC 1 - -/* Max number of packets in each queue */ -#define DATA_QUEUE_DEPTH_BE 60 -#define DATA_QUEUE_DEPTH_BK 10 -#define DATA_QUEUE_DEPTH_VI 32 -#define DATA_QUEUE_DEPTH_VO 10 -#define DATA_QUEUE_DEPTH_TOTAL (DATA_QUEUE_DEPTH_BE + DATA_QUEUE_DEPTH_BK + DATA_QUEUE_DEPTH_VI + DATA_QUEUE_DEPTH_VO) - -/* Verify that there are enough TxCtrlBlks for all users that are queueing packets (driver + FW) */ -#if ((DATA_QUEUE_DEPTH_TOTAL + (MGMT_QUEUES_DEPTH * 2) + NUM_TX_DESCRIPTORS) > (CTRL_BLK_ENTRIES_NUM - 2)) - #error Not enough TxCtrlBlks for all users !! -#endif - -/* Tx packets handling statistics */ -typedef struct -{ - TI_UINT32 uEnqueuePacket; - TI_UINT32 uDequeuePacket; - TI_UINT32 uRequeuePacket; - TI_UINT32 uXmittedPacket; - TI_UINT32 uDroppedPacket; -} TTxDataQueueDebugCnt; - -/* The module's object */ -typedef struct -{ - TI_HANDLE hContext; - TI_HANDLE hTxCtrl; - TI_HANDLE hOs; - TI_HANDLE hReport; - TI_HANDLE hTxMgmtQ; - TI_HANDLE hTWD; - - TClsfrParams tClsfrParams; /* The classifier sub-module parameters */ - - TI_BOOL bDataPortEnable; /* Data port open or not */ - TI_UINT32 uContextId; /* ID allocated to this module on registration to context module */ - TI_HANDLE hTxSendPaceTimer; /* If queued packets number doesn't reach threshold within timeout, Tx handling is started */ - - /* Tx aQueues */ - TI_UINT32 uNumQueues; /* Indicates the number of allocated aQueues */ - TI_UINT32 aQueueMaxSize[MAX_NUM_OF_AC]; /* indicates the max size of each Data queue */ - TI_UINT32 aTxSendPaceThresh[MAX_NUM_OF_AC]; /* Number of packets to queue before scheduling Tx handling */ - TI_HANDLE aQueues[MAX_NUM_OF_AC]; /* The Tx aQueues handles */ - TI_BOOL aQueueBusy[MAX_NUM_OF_AC]; /* per queue busy indication */ - TI_UINT32 uLastQueId; /* the last queue processed by the scheduler */ - TI_BOOL aNetStackQueueStopped[MAX_NUM_OF_AC];/*indicate if the current queue was full and caused Tx network stack stop*/ - TI_BOOL bStopNetStackTx;/*Flag to enable/disable Tx stop*/ - - /* Counters */ - TTxDataQueueDebugCnt aQueueCounters[MAX_NUM_OF_AC]; /* Save Tx statistics per Tx-queue. */ - TI_UINT32 uClsfrMismatchCount; - TI_UINT32 uTxSendPaceTimeoutsCount; - -} TTxDataQ; - - -/* TIDs Mapping to Queues */ -static const TI_UINT32 aTidToQueueTable[MAX_NUM_OF_802_1d_TAGS] = {0, 1, 1, 0, 2, 2, 3, 3}; - - -#endif /* _TX_DATA_QUEUE_H_ */ diff --git a/wl1271/stad/src/Data_link/txDataQueue_Api.h b/wl1271/stad/src/Data_link/txDataQueue_Api.h deleted file mode 100644 index 1af2277..0000000 --- a/wl1271/stad/src/Data_link/txDataQueue_Api.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * txDataQueue_Api.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* */ -/* PURPOSE: Tx Data Queue module api functions header file */ -/* */ -/***************************************************************************/ - -#ifndef _TX_DATA_QUEUE_API_H_ -#define _TX_DATA_QUEUE_API_H_ - -#include "paramOut.h" -#include "TWDriver.h" -#include "DrvMainModules.h" - - -/* - * Tx-Data-Queue functions: - */ -TI_HANDLE txDataQ_Create (TI_HANDLE hOs); -void txDataQ_Init (TStadHandlesList *pStadHandles); -TI_STATUS txDataQ_SetDefaults (TI_HANDLE hTxDataQ, txDataInitParams_t *pTxDataInitParams); -TI_STATUS txDataQ_Destroy (TI_HANDLE hTxDataQ); -void txDataQ_ClearQueues (TI_HANDLE hTxDataQ); -TI_STATUS txDataQ_InsertPacket (TI_HANDLE hTxDataQ, TTxCtrlBlk *pPktCtrlBlk, TI_UINT8 uPacketDtag); -void txDataQ_StopQueue (TI_HANDLE hTxDataQ, TI_UINT32 tidBitMap); -void txDataQ_UpdateBusyMap (TI_HANDLE hTxDataQ, TI_UINT32 tidBitMap); -void txDataQ_StopAll (TI_HANDLE hTxDataQ); -void txDataQ_WakeAll (TI_HANDLE hTxDataQ); - -#ifdef TI_DBG -void txDataQ_PrintModuleParams (TI_HANDLE hTxDataQ); -void txDataQ_PrintQueueStatistics (TI_HANDLE hTxDataQ); -void txDataQ_ResetQueueStatistics (TI_HANDLE hTxDataQ); -#endif /* TI_DBG */ - - -/* - * Tx-Data-Classifier functions: - */ -TI_STATUS txDataClsfr_Config (TI_HANDLE hTxDataQ, TClsfrParams *pClsfrInitParams); -TI_STATUS txDataClsfr_ClassifyTxPacket (TI_HANDLE hTxDataQ, TTxCtrlBlk *pPktCtrlBlk, TI_UINT8 uPacketDtag); -TI_STATUS txDataClsfr_InsertClsfrEntry (TI_HANDLE hTxDataQ, TClsfrTableEntry *pNewEntry); -TI_STATUS txDataClsfr_RemoveClsfrEntry (TI_HANDLE hTxDataQ, TClsfrTableEntry *pRemEntry); -TI_STATUS txDataClsfr_SetClsfrType (TI_HANDLE hTxDataQ, EClsfrType eNewClsfrType); -TI_STATUS txDataClsfr_GetClsfrType (TI_HANDLE hTxDataQ, EClsfrType *pClsfrType); - -#ifdef TI_DBG -void txDataClsfr_PrintClsfrTable (TI_HANDLE hTxDataQ); -#endif /* TI_DBG */ - - -#endif /* _TX_DATA_QUEUE_API_H_ */ - diff --git a/wl1271/stad/src/Data_link/txMgmtQueue.c b/wl1271/stad/src/Data_link/txMgmtQueue.c deleted file mode 100644 index befc803..0000000 --- a/wl1271/stad/src/Data_link/txMgmtQueue.c +++ /dev/null @@ -1,1003 +0,0 @@ -/* - * txMgmtQueue.c - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - - -/** \file txMgmtQueue.c - * \brief The Tx Mgmt Queues module. - * - * DESCRIPTION: - * ============ - * The Management-Queues module is responsible for the following tasks: - * 1. Queue the driver generated Tx packets, including management, - * EAPOL and null packets until they are transmitted. - * The management packets are buffered in the management-queue, - * and the others in the EAPOL-queue. - * 2. Maintain a state machine that follows the queues state and - * the connection states and enables specific transmission types - * accordingly (e.g. only management). - * 3. Gain access to the Tx path when the management queues are not - * empty, and return the access to the data queues when the - * management queues are empty. - * 4. Schedule packets transmission with strict priority of the - * management queue over the EAPOL queue, and according to the - * backpressure controls from the Port (all queues) and from the - * Tx-Ctrl (per queue). - * - * \see txMgmtQueue.h - */ - -#define __FILE_ID__ FILE_ID_61 -#include "tidef.h" -#include "paramOut.h" -#include "osApi.h" -#include "TWDriver.h" -#include "DataCtrl_Api.h" -#include "report.h" -#include "queue.h" -#include "context.h" -#include "DrvMainModules.h" - - -#define MGMT_QUEUES_TID MAX_USER_PRIORITY - -typedef enum -{ - QUEUE_TYPE_MGMT, /* Mgmt-queue - high-priority, for mgmt packets only. */ - QUEUE_TYPE_EAPOL, /* EAPOL-queue - low-priority, for other internal packets (EAPOL, NULL, IAPP). */ - NUM_OF_MGMT_QUEUES -} EMgmtQueueTypes; - -/* State-Machine Events */ -typedef enum -{ - SM_EVENT_CLOSE, /* All Tx types should be closed. */ - SM_EVENT_MGMT, /* Allow only mgmt packets. */ - SM_EVENT_EAPOL, /* Allow mgmt and EAPOL packets. */ - SM_EVENT_OPEN, /* Allow all packets. */ - SM_EVENT_QUEUES_EMPTY, /* Mgmt-aQueues are now both empty. */ - SM_EVENT_QUEUES_NOT_EMPTY /* At least one of the Mgmt-aQueues is now not empty. */ -} ESmEvent; - -/* State-Machine States */ -typedef enum -{ - SM_STATE_CLOSE, /* All Tx path is closed. */ - SM_STATE_MGMT, /* Only mgmt Tx is permitted. */ - SM_STATE_EAPOL, /* Only mgmt and EAPOL Tx is permitted. */ - SM_STATE_OPEN_MGMT, /* All Tx permitted and Mgmt aQueues are currently active (date disabled). */ - SM_STATE_OPEN_DATA /* All Tx permitted and Data aQueues are currently active (mgmt disabled). */ -} ESmState; - -/* State-Machine Actions */ -typedef enum -{ - SM_ACTION_NULL, - SM_ACTION_ENABLE_DATA, - SM_ACTION_ENABLE_MGMT, - SM_ACTION_RUN_SCHEDULER -} ESmAction; - -/* TI_TRUE if both aQueues are empty. */ -#define ARE_ALL_MGMT_QUEUES_EMPTY(aQueues) ( (que_Size(aQueues[QUEUE_TYPE_MGMT] ) == 0) && \ - (que_Size(aQueues[QUEUE_TYPE_EAPOL]) == 0) ) - -typedef struct -{ - TI_UINT32 aEnqueuePackets[NUM_OF_MGMT_QUEUES]; - TI_UINT32 aDequeuePackets[NUM_OF_MGMT_QUEUES]; - TI_UINT32 aRequeuePackets[NUM_OF_MGMT_QUEUES]; - TI_UINT32 aDroppedPackets[NUM_OF_MGMT_QUEUES]; - TI_UINT32 aXmittedPackets[NUM_OF_MGMT_QUEUES]; -} TDbgCount; - -/* The module object. */ -typedef struct -{ - /* Handles */ - TI_HANDLE hOs; - TI_HANDLE hReport; - TI_HANDLE hTxCtrl; - TI_HANDLE hTxPort; - TI_HANDLE hContext; - TI_HANDLE hTWD; - - TI_BOOL bMgmtPortEnable;/* Port open for mgmt-aQueues or not. */ - ESmState eSmState; /* The current state of the SM. */ - ETxConnState eTxConnState; /* See typedef in module API. */ - TI_UINT32 uContextId; /* ID allocated to this module on registration to context module */ - - /* Mgmt aQueues */ - TI_HANDLE aQueues[NUM_OF_MGMT_QUEUES]; /* The mgmt-aQueues handles. */ - TI_BOOL aQueueBusy[NUM_OF_MGMT_QUEUES]; /* Related AC is busy. */ - TI_BOOL aQueueEnabledBySM[NUM_OF_MGMT_QUEUES]; /* Queue is enabled by the SM. */ - - /* Debug Counters */ - TDbgCount tDbgCounters; /* Save Tx statistics per mgmt-queue. */ - -} TTxMgmtQ; - -/* The module internal functions */ -static void mgmtQueuesSM (TTxMgmtQ *pTxMgmtQ, ESmEvent smEvent); -static void runSchedulerNotFromSm (TTxMgmtQ *pTxMgmtQ); -static void runScheduler (TTxMgmtQ *pTxMgmtQ); -static void updateQueuesBusyMap (TTxMgmtQ *pTxMgmtQ, TI_UINT32 tidBitMap); - -/******************************************************************************* -* PUBLIC FUNCTIONS IMPLEMENTATION * -********************************************************************************/ - - -/** - * \fn txMgmtQ_Create - * \brief Create the module and its queues - * - * Create the Tx Mgmt Queue module and its queues. - * - * \note - * \param hOs - Handle to the Os Abstraction Layer - * \return Handle to the allocated Tx Mgmt Queue module (NULL if failed) - * \sa - */ -TI_HANDLE txMgmtQ_Create (TI_HANDLE hOs) -{ - TTxMgmtQ *pTxMgmtQ; - - /* allocate TxMgmtQueue module */ - pTxMgmtQ = os_memoryAlloc (hOs, (sizeof(TTxMgmtQ))); - - if(!pTxMgmtQ) - { - WLAN_OS_REPORT(("Error allocating the TxMgmtQueue Module\n")); - return NULL; - } - - /* Reset TxMgmtQueue module */ - os_memoryZero (hOs, pTxMgmtQ, (sizeof(TTxMgmtQ))); - - return (TI_HANDLE)pTxMgmtQ; -} - - -/** - * \fn txMgmtQ_Init - * \brief Configure module with default settings -* - * Get other modules handles. - * Init the Tx Mgmt queues. - * Register as the context-engine client. - * - * \note - * \param pStadHandles - The driver modules handles - * \return void - * \sa - */ -void txMgmtQ_Init (TStadHandlesList *pStadHandles) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)(pStadHandles->hTxMgmtQ); - TI_UINT32 uNodeHeaderOffset = TI_FIELD_OFFSET(TTxnStruct, tTxnQNode); - int uQueId; - - /* configure modules handles */ - pTxMgmtQ->hOs = pStadHandles->hOs; - pTxMgmtQ->hReport = pStadHandles->hReport; - pTxMgmtQ->hTxCtrl = pStadHandles->hTxCtrl; - pTxMgmtQ->hTxPort = pStadHandles->hTxPort; - pTxMgmtQ->hContext = pStadHandles->hContext; - pTxMgmtQ->hTWD = pStadHandles->hTWD; - - pTxMgmtQ->bMgmtPortEnable = TI_TRUE; /* Port Default status is open (data-queues are disabled). */ - pTxMgmtQ->eSmState = SM_STATE_CLOSE; /* SM default state is CLOSE. */ - pTxMgmtQ->eTxConnState = TX_CONN_STATE_CLOSE; - - /* initialize tx Mgmt queues */ - for (uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - { - pTxMgmtQ->aQueues[uQueId] = que_Create (pTxMgmtQ->hOs, - pTxMgmtQ->hReport, - MGMT_QUEUES_DEPTH, - uNodeHeaderOffset); - - /* If any Queues' allocation failed, print error, free TxMgmtQueue module and exit */ - if (pTxMgmtQ->aQueues[uQueId] == NULL) - { - TRACE0(pTxMgmtQ->hReport, REPORT_SEVERITY_CONSOLE , "Failed to create queue\n"); - WLAN_OS_REPORT(("Failed to create queue\n")); - os_memoryFree (pTxMgmtQ->hOs, pTxMgmtQ, sizeof(TTxMgmtQ)); - return; - } - - pTxMgmtQ->aQueueBusy[uQueId] = TI_FALSE; /* aQueueBusy default is not busy. */ - pTxMgmtQ->aQueueEnabledBySM[uQueId] = TI_FALSE; /* Queue is disabled by the SM (state is CLOSE). */ - } - - /* Register to the context engine and get the client ID */ - pTxMgmtQ->uContextId = context_RegisterClient (pTxMgmtQ->hContext, - txMgmtQ_QueuesNotEmpty, - (TI_HANDLE)pTxMgmtQ, - TI_TRUE, - "TX_MGMT", - sizeof("TX_MGMT")); - -TRACE0(pTxMgmtQ->hReport, REPORT_SEVERITY_INIT, ".....Tx Mgmt Queue configured successfully\n"); -} - - -/** - * \fn txMgmtQ_Destroy - * \brief Destroy the module and its queues - * - * Clear and destroy the queues and then destroy the module object. - * - * \note - * \param hTxMgmtQ - The module's object - * \return TI_OK - Unload succesfull, TI_NOK - Unload unsuccesfull - * \sa - */ -TI_STATUS txMgmtQ_Destroy (TI_HANDLE hTxMgmtQ) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - TI_STATUS eStatus = TI_OK; - int uQueId; - - /* Dequeue and free all queued packets */ - txMgmtQ_ClearQueues (hTxMgmtQ); - - /* free Mgmt queues */ - for (uQueId = 0 ; uQueId < NUM_OF_MGMT_QUEUES ; uQueId++) - { - if (que_Destroy(pTxMgmtQ->aQueues[uQueId]) != TI_OK) - { - TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "txMgmtQueue_unLoad: fail to free Mgmt Queue number: %d\n",uQueId); - eStatus = TI_NOK; - } - } - - /* free Tx Mgmt Queue Module */ - os_memoryFree (pTxMgmtQ->hOs, pTxMgmtQ, sizeof(TTxMgmtQ)); - - return eStatus; -} - - -/** - * \fn txMgmtQ_ClearQueues - * \brief Clear all queues - * - * Dequeue and free all queued packets. - * - * \note - * \param hTxMgmtQ - The object - * \return void - * \sa - */ -void txMgmtQ_ClearQueues (TI_HANDLE hTxMgmtQ) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - TTxCtrlBlk *pPktCtrlBlk; - TI_UINT32 uQueId; - - /* Dequeue and free all queued packets */ - for (uQueId = 0 ; uQueId < NUM_OF_MGMT_QUEUES ; uQueId++) - { - do { - context_EnterCriticalSection (pTxMgmtQ->hContext); - pPktCtrlBlk = (TTxCtrlBlk *)que_Dequeue(pTxMgmtQ->aQueues[uQueId]); - context_LeaveCriticalSection (pTxMgmtQ->hContext); - if (pPktCtrlBlk != NULL) { - txCtrl_FreePacket (pTxMgmtQ->hTxCtrl, pPktCtrlBlk, TI_NOK); - } - } while (pPktCtrlBlk != NULL); - } -} - - -/** - * \fn txMgmtQ_Xmit - * \brief Insert non-data packet for transmission - * - * This function is used by the driver applications to send Tx packets other than the - * regular data traffic, including the following packet types: -* - Management -* - EAPOL -* - NULL -* - IAPP - * The managment packets are enqueued to the Mgmt-queue and the others to the Eapol-queue. - * EAPOL packets may be inserted from the network stack context, so it requires switching - * to the driver's context (after the packet is enqueued). - * If the selected queue was empty before the packet insertion, the SM is called - * with QUEUES_NOT_EMPTY event (in case of external context, only after the context switch). - * - * \note - * \param hTxMgmtQ - The module's object - * \param pPktCtrlBlk - Pointer to the packet CtrlBlk - * \param bExternalContext - Indicates if called from non-driver context - * \return TI_OK - if the packet was queued, TI_NOK - if the packet was dropped. - * \sa txMgmtQ_QueuesNotEmpty - */ -TI_STATUS txMgmtQ_Xmit (TI_HANDLE hTxMgmtQ, TTxCtrlBlk *pPktCtrlBlk, TI_BOOL bExternalContext) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - TI_STATUS eStatus; - TI_UINT32 uQueId; - TI_UINT32 uQueSize; - - /* Always set highest TID for mgmt-queues packets. */ - pPktCtrlBlk->tTxDescriptor.tid = MGMT_QUEUES_TID; - - /* Select queue asccording to the packet type */ - uQueId = (pPktCtrlBlk->tTxPktParams.uPktType == TX_PKT_TYPE_MGMT) ? QUEUE_TYPE_MGMT : QUEUE_TYPE_EAPOL ; - - /* Enter critical section to protect queue access */ - context_EnterCriticalSection (pTxMgmtQ->hContext); - - /* Enqueue the packet in the appropriate Queue */ - eStatus = que_Enqueue (pTxMgmtQ->aQueues[uQueId], (TI_HANDLE)pPktCtrlBlk); - - /* Get number of packets in current queue */ - uQueSize = que_Size (pTxMgmtQ->aQueues[uQueId]); - - /* Leave critical section */ - context_LeaveCriticalSection (pTxMgmtQ->hContext); - - /* If packet enqueued successfully */ - if (eStatus == TI_OK) - { - pTxMgmtQ->tDbgCounters.aEnqueuePackets[uQueId]++; - - /* If selected queue was empty before packet insertion */ - if (uQueSize == 1) - { - /* If called from external context (EAPOL from network), request switch to the driver's context. */ - if (bExternalContext) - { - context_RequestSchedule (pTxMgmtQ->hContext, pTxMgmtQ->uContextId); - } - - /* If already in the driver's context, call the SM with QUEUES_NOT_EMPTY event. */ - else - { - mgmtQueuesSM(pTxMgmtQ, SM_EVENT_QUEUES_NOT_EMPTY); - } - } - } - - else - { - /* If the packet can't be queued so drop it */ - txCtrl_FreePacket (pTxMgmtQ->hTxCtrl, pPktCtrlBlk, TI_NOK); - pTxMgmtQ->tDbgCounters.aDroppedPackets[uQueId]++; - } - - return eStatus; -} - - -/** - * \fn txMgmtQ_QueuesNotEmpty - * \brief Context-Engine Callback - * - * Context-Engine Callback for processing queues in driver's context. - * Called after driver's context scheduling was requested in txMgmtQ_Xmit(). - * Calls the SM with QUEUES_NOT_EMPTY event. - * - * \note - * \param hTxMgmtQ - The module's object - * \return void - * \sa txMgmtQ_Xmit - */ -void txMgmtQ_QueuesNotEmpty (TI_HANDLE hTxMgmtQ) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - - /* Call the SM with QUEUES_NOT_EMPTY event. */ - mgmtQueuesSM(pTxMgmtQ, SM_EVENT_QUEUES_NOT_EMPTY); -} - - -/** - * \fn txMgmtQ_StopQueue - * \brief Context-Engine Callback - * - * This function is called by the txCtrl_xmitMgmt() if the queue's backpressure indication - * is set. It sets the internal queue's Busy indication. - * - * \note - * \param hTxMgmtQ - The module's object - * \param uTidBitMap - The busy TIDs bitmap - * \return void - * \sa txMgmtQ_UpdateBusyMap - */ -void txMgmtQ_StopQueue (TI_HANDLE hTxMgmtQ, TI_UINT32 uTidBitMap) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - - /* Update the Queue(s) mode */ - updateQueuesBusyMap (pTxMgmtQ, uTidBitMap); -} - - -/** - * \fn txMgmtQ_UpdateBusyMap - * \brief Update the queues busy map - * - * This function is called by the txCtrl if the backpressure map per TID is changed. - * This could be as a result of Tx-Complete, admission change or association. - * The function modifies the internal queues Busy indication and calls the scheduler. - * - * \note - * \param hTxMgmtQ - The module's object - * \param uTidBitMap - The busy TIDs bitmap - * \return void - * \sa txMgmtQ_StopQueue - */ -void txMgmtQ_UpdateBusyMap (TI_HANDLE hTxMgmtQ, TI_UINT32 uTidBitMap) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - - /* Update the Queue(s) busy map. */ - updateQueuesBusyMap (pTxMgmtQ, uTidBitMap); - - /* If the queues are not empty, run the scheduler and if they become empty update the SM. */ - runSchedulerNotFromSm (pTxMgmtQ); -} - - -/** - * \fn txMgmtQ_StopAll - * \brief Stop all queues transmission - * - * This function is called by the Tx-Port when the whole Mgmt-queue is stopped. - * It clears the common queues enable indication. - * - * \note - * \param hTxMgmtQ - The module's object - * \return void - * \sa txMgmtQ_WakeAll - */ -void txMgmtQ_StopAll (TI_HANDLE hTxMgmtQ) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - - /* Disable the Mgmt Tx port */ - pTxMgmtQ->bMgmtPortEnable = TI_FALSE; -} - - -/** - * \fn txMgmtQ_WakeAll - * \brief Enable all queues transmission - * - * This function is called by the Tx-Port when the whole Mgmt-queue is enabled. - * It sets the common queues enable indication and calls the scheduler. - * - * \note - * \param hTxMgmtQ - The module's object - * \return void - * \sa txMgmtQ_StopAll - */ -void txMgmtQ_WakeAll (TI_HANDLE hTxMgmtQ) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - - /* Enable the Mgmt Tx port */ - pTxMgmtQ->bMgmtPortEnable = TI_TRUE; - - /* If the queues are not empty, run the scheduler and if they become empty update the SM. */ - runSchedulerNotFromSm (pTxMgmtQ); -} - - -/** - * \fn txMgmtQ_SetConnState - * \brief Enable all queues transmission - * - * Called by the connection SM and updates the connection state from Tx perspective - * (i.e. which packet types are permitted). -* Calls the local SM to handle this state change. -* - * \note - * \param hTxMgmtQ - The module's object - * \param eTxConnState - The new Tx connection state - * \return void - * \sa mgmtQueuesSM - */ -void txMgmtQ_SetConnState (TI_HANDLE hTxMgmtQ, ETxConnState eTxConnState) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - - pTxMgmtQ->eTxConnState = eTxConnState; - - /* Call the SM with the current event. */ - switch (eTxConnState) - { - case TX_CONN_STATE_CLOSE: mgmtQueuesSM(pTxMgmtQ, SM_EVENT_CLOSE); break; - case TX_CONN_STATE_MGMT: mgmtQueuesSM(pTxMgmtQ, SM_EVENT_MGMT); break; - case TX_CONN_STATE_EAPOL: mgmtQueuesSM(pTxMgmtQ, SM_EVENT_EAPOL); break; - case TX_CONN_STATE_OPEN: mgmtQueuesSM(pTxMgmtQ, SM_EVENT_OPEN); break; - - default: -TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, ": Unknown eTxConnState = %d\n", eTxConnState); - } -} - - - -/******************************************************************************* -* INTERNAL FUNCTIONS IMPLEMENTATION * -********************************************************************************/ - - -/** - * \fn mgmtQueuesSM - * \brief The module state-machine (static function) - * - * The SM follows the system management states (see ETxConnState) and the Mgmt queues - * status (empty or not), and contorls the Tx queues flow accordingly (mgmt and data queues). - * For detailed explanation, see the Tx-Path LLD document! - * - * \note To avoid recursion issues, all SM actions are done at the end of the function, - * since some of them may invoke the SM again. - * \param pTxMgmtQ - The module's object - * \param eSmEvent - The event to act upon - * \return void - * \sa txMgmtQ_SetConnState - */ -static void mgmtQueuesSM (TTxMgmtQ *pTxMgmtQ, ESmEvent eSmEvent) -{ - ESmState ePrevState = pTxMgmtQ->eSmState; - ESmAction eSmAction = SM_ACTION_NULL; - - switch(eSmEvent) - { - case SM_EVENT_CLOSE: - /* - * Tx link is closed (expected in any state), so disable both mgmt queues - * and if data-queues are active disable them via txPort module. - */ - pTxMgmtQ->eSmState = SM_STATE_CLOSE; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_MGMT] = TI_FALSE; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_EAPOL] = TI_FALSE; - if (ePrevState == SM_STATE_OPEN_DATA) - eSmAction = SM_ACTION_ENABLE_MGMT; - break; - - case SM_EVENT_MGMT: - /* - * Only Mgmt packets are permitted (expected from any state): - * - Enable the mgmt queue and disable the Eapol queue. - * - If data-queues are active disable them via txPort (this will run the scheduler). - * - Else run the scheduler (to send mgmt packets if waiting). - */ - pTxMgmtQ->eSmState = SM_STATE_MGMT; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_MGMT] = TI_TRUE; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_EAPOL] = TI_FALSE; - if (ePrevState == SM_STATE_OPEN_DATA) - eSmAction = SM_ACTION_ENABLE_MGMT; - else - eSmAction = SM_ACTION_RUN_SCHEDULER; - break; - - case SM_EVENT_EAPOL: - /* - * EAPOL packets are also permitted (expected in MGMT or CLOSE state), so enable the - * EAPOL queue and run the scheduler (to send packets from EAPOL queue if waiting). - */ - if ( (ePrevState != SM_STATE_CLOSE) && (ePrevState != SM_STATE_MGMT) ) - { -TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "mgmtQueuesSM: Got SmEvent=EAPOL when eSmState=%d\n", ePrevState); - } - pTxMgmtQ->eSmState = SM_STATE_EAPOL; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_MGMT] = TI_TRUE; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_EAPOL] = TI_TRUE; - eSmAction = SM_ACTION_RUN_SCHEDULER; - break; - - case SM_EVENT_OPEN: - /* - * All packets are now permitted (expected in EAPOL state), so if the mgmt-queues - * are empty disable them and enable the data queues via txPort module. - */ - if (ePrevState != SM_STATE_EAPOL) - { -TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "mgmtQueuesSM: Got SmEvent=OPEN when eSmState=%d\n", ePrevState); - } - if ( ARE_ALL_MGMT_QUEUES_EMPTY(pTxMgmtQ->aQueues) ) - { - pTxMgmtQ->eSmState = SM_STATE_OPEN_DATA; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_MGMT] = TI_FALSE; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_EAPOL] = TI_FALSE; - eSmAction = SM_ACTION_ENABLE_DATA; - } - else - { - pTxMgmtQ->eSmState = SM_STATE_OPEN_MGMT; - } - break; - - case SM_EVENT_QUEUES_EMPTY: - /* - * The mgmt-queues are empty, so if in OPEN_MGMT state disable the - * mgmt-queues and enable the data-queues via txPort module. - */ - if (ePrevState == SM_STATE_OPEN_MGMT) - { - pTxMgmtQ->eSmState = SM_STATE_OPEN_DATA; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_MGMT] = TI_FALSE; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_EAPOL] = TI_FALSE; - eSmAction = SM_ACTION_ENABLE_DATA; - } - else - { - /* This may happen so it's just a warning and not an error. */ -TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_WARNING, "mgmtQueuesSM: Got SmEvent=QUEUES_EMPTY when eSmState=%d\n", ePrevState); - } - break; - - case SM_EVENT_QUEUES_NOT_EMPTY: - - /* A packet was inserted to the mgmt-queues */ - - /* - * If in OPEN_DATA state, enable mgmt-queues and disable data-queues via txPort module. - * - * Note: The scheduler is not run here because the txPort will call - * txMgmtQueue_wakeAll() which will run the scheduler. - */ - if (ePrevState == SM_STATE_OPEN_DATA) - { - pTxMgmtQ->eSmState = SM_STATE_OPEN_MGMT; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_MGMT] = TI_TRUE; - pTxMgmtQ->aQueueEnabledBySM[QUEUE_TYPE_EAPOL] = TI_TRUE; - eSmAction = SM_ACTION_ENABLE_MGMT; - } - - /* - * If in MGMT or EAPOL state, run the scheduler to transmit the packet. - */ - else if ( (ePrevState == SM_STATE_MGMT) || (ePrevState == SM_STATE_EAPOL) ) - { - eSmAction = SM_ACTION_RUN_SCHEDULER; - } - - else - { - /* This may happen so it's just a warning and not an error. */ -TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_WARNING, "mgmtQueuesSM: Got SmEvent=QUEUES_NOT_EMPTY when eSmState=%d\n", ePrevState); - } - break; - - default: -TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "mgmtQueuesSM: Unknown SmEvent = %d\n", eSmEvent); - break; - } - -TRACE6( pTxMgmtQ->hReport, REPORT_SEVERITY_INFORMATION, "mgmtQueuesSM: <currentState = %d, event = %d> --> nextState = %d, action = %d, MgmtQueEnbl=%d, EapolQueEnbl=%d\n", ePrevState, eSmEvent, pTxMgmtQ->eSmState, eSmAction, pTxMgmtQ->aQueueEnabledBySM[0], pTxMgmtQ->aQueueEnabledBySM[1]); - - /* - * Execute the required action. - * Note: This is done at the end of the SM because it may start a sequence that will call the SM again! - */ - switch (eSmAction) - { - case SM_ACTION_NULL: - break; - - case SM_ACTION_ENABLE_DATA: - txPort_enableData(pTxMgmtQ->hTxPort); - break; - - case SM_ACTION_ENABLE_MGMT: - txPort_enableMgmt(pTxMgmtQ->hTxPort); - break; - - case SM_ACTION_RUN_SCHEDULER: - runScheduler(pTxMgmtQ); - break; - - default: -TRACE1(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, ": Unknown SmAction = %d\n", eSmAction); - break; - } -} - - -/** - * \fn runSchedulerNotFromSm - * \brief Run scheduler due to other events then from SM (static function) - * - * To comply with the SM behavior, this function is used for any case where the - * Mgmt-Queues scheduler may have work to do due to events external to the SM. - * If the queues are not empty, this function runs the scheduler. -* If the scheduler emptied the queues, update the SM. - * - * \note - * \param pTxMgmtQ - The module's object - * \return void - * \sa - */ -static void runSchedulerNotFromSm (TTxMgmtQ *pTxMgmtQ) -{ - /* If the queues are not empty, run the scheduler. */ - if ( !ARE_ALL_MGMT_QUEUES_EMPTY(pTxMgmtQ->aQueues) ) - { - runScheduler (pTxMgmtQ); - - /* If the queues are now both empty, call the SM with QUEUES_EMPTY event. */ - if ( ARE_ALL_MGMT_QUEUES_EMPTY(pTxMgmtQ->aQueues) ) - { - mgmtQueuesSM (pTxMgmtQ, SM_EVENT_QUEUES_EMPTY); - } - } -} - - -/** - * \fn runScheduler - * \brief The scheduler processing (static function) - * - * Loops over the mgmt-queues (high priority first) and if queue enabled and - * has packets, dequeue a packet and send it to the TxCtrl. -* Exit if the port level is disabled or if couldn't send anything from both queues. - * - * \note Protect the queues access against preemption from external context (EAPOL). - * \param pTxMgmtQ - The module's object - * \return void - * \sa - */ -static void runScheduler (TTxMgmtQ *pTxMgmtQ) -{ - TI_STATUS eStatus; - TTxCtrlBlk *pPktCtrlBlk; - TI_UINT32 uQueId = 0; /* start from highest priority queue */ - - while(1) - { - /* If the Mgmt port is closed exit. */ - if ( !pTxMgmtQ->bMgmtPortEnable ) - { - return; - } - - /* Check that the current queue is not busy and is enabled by the state-machine. */ - if ( !pTxMgmtQ->aQueueBusy[uQueId] && pTxMgmtQ->aQueueEnabledBySM[uQueId]) - { - /* Dequeue a packet in a critical section */ - context_EnterCriticalSection (pTxMgmtQ->hContext); - pPktCtrlBlk = (TTxCtrlBlk *) que_Dequeue (pTxMgmtQ->aQueues[uQueId]); - context_LeaveCriticalSection (pTxMgmtQ->hContext); - - if (pPktCtrlBlk) - { - pTxMgmtQ->tDbgCounters.aDequeuePackets[uQueId]++; - - /* Send the packet */ - eStatus = txCtrl_XmitMgmt (pTxMgmtQ->hTxCtrl, pPktCtrlBlk); - - /* In case the return status is busy it means that the packet wasn't handled - so we need to requeue the packet for future try. */ - if(eStatus == STATUS_XMIT_BUSY) - { - /* Requeue the packet in a critical section */ - context_EnterCriticalSection (pTxMgmtQ->hContext); - que_Requeue (pTxMgmtQ->aQueues[uQueId], (TI_HANDLE)pPktCtrlBlk); - context_LeaveCriticalSection (pTxMgmtQ->hContext); - - pTxMgmtQ->tDbgCounters.aRequeuePackets[uQueId]++; - } - - /* The packet was handled by the lower Tx layers. */ - else - { - pTxMgmtQ->tDbgCounters.aXmittedPackets[uQueId]++; - - /* Successful delivery so start next tx from the high priority queue (mgmt), - * giving it strict priority over the lower queue. - */ - uQueId = 0; - continue; - } - } - } - - - /* If we got here we couldn't deliver a packet from current queue, so progress to lower - * priority queue and if already in lowest queue exit. - */ - uQueId++; - if (uQueId < NUM_OF_MGMT_QUEUES) - { - continue; /* Try sending from next queue (i.e. the EAPOL queue). */ - } - else - { - /* We couldn't send from both queues so indicate end of packets burst and exit. */ - TWD_txXfer_EndOfBurst (pTxMgmtQ->hTWD); - return; - } - - } /* End of while */ - - /* Unreachable code */ -} - - -/** - * \fn updateQueuesBusyMap - * \brief Update queues busy map (static function) - * - * Set the queues busy indication on or off according to the highest TID bit - * in the tidBitMap (1 = busy). -* Note that both Mgmt and Eapol queues are mapped to TID 7. -* - * \note - * \param pTxMgmtQ - The module's object - * \param uTidBitMap - The TIDs bitmap of the queue(s) to update - * \return void - * \sa - */ -static void updateQueuesBusyMap (TTxMgmtQ *pTxMgmtQ, TI_UINT32 uTidBitMap) -{ - /* Set the queues busy indication on or off according to the highest TID bit (1 = busy). */ - if(uTidBitMap & (1 << MGMT_QUEUES_TID) ) - { - pTxMgmtQ->aQueueBusy[QUEUE_TYPE_MGMT ] = TI_TRUE; - pTxMgmtQ->aQueueBusy[QUEUE_TYPE_EAPOL] = TI_TRUE; - } - else - { - pTxMgmtQ->aQueueBusy[QUEUE_TYPE_MGMT ] = TI_FALSE; - pTxMgmtQ->aQueueBusy[QUEUE_TYPE_EAPOL] = TI_FALSE; - } -} - - - -/******************************************************************************* -* DEBUG FUNCTIONS IMPLEMENTATION * -********************************************************************************/ - -#ifdef TI_DBG - -/** - * \fn txMgmtQ_PrintModuleParams - * \brief Print module's parameters (debug) - * - * This function prints the module's parameters. - * - * \note - * \param hTxMgmtQ - The module's object - * \return void - * \sa - */ -void txMgmtQ_PrintModuleParams (TI_HANDLE hTxMgmtQ) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - TI_UINT32 uQueId; - - WLAN_OS_REPORT(("-------------- txMgmtQueue Module Params -----------------\n")); - WLAN_OS_REPORT(("==========================================================\n")); - - WLAN_OS_REPORT(("eSmState = %d\n", pTxMgmtQ->eSmState)); - WLAN_OS_REPORT(("bMgmtPortEnable = %d\n", pTxMgmtQ->bMgmtPortEnable)); - WLAN_OS_REPORT(("eTxConnState = %d\n", pTxMgmtQ->eTxConnState)); - WLAN_OS_REPORT(("uContextId = %d\n", pTxMgmtQ->uContextId)); - - WLAN_OS_REPORT(("-------------- Queues Busy (in HW) -----------------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - { - WLAN_OS_REPORT(("Que[%d]: %d\n", uQueId, pTxMgmtQ->aQueueBusy[uQueId])); - } - - WLAN_OS_REPORT(("-------------- Queues Enabled By SM ----------------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - { - WLAN_OS_REPORT(("Que[%d]: %d\n", uQueId, pTxMgmtQ->aQueueBusy[uQueId])); - } - - WLAN_OS_REPORT(("-------------- Queues Info -------------------------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - { - WLAN_OS_REPORT(("Que %d:\n", uQueId)); - que_Print (pTxMgmtQ->aQueues[uQueId]); - } - - WLAN_OS_REPORT(("==========================================================\n\n")); -} - - -/** - * \fn txMgmtQ_PrintQueueStatistics - * \brief Print queues statistics (debug) - * - * This function prints the module's Tx statistics per Queue. - * - * \note - * \param hTxMgmtQ - The module's object - * \return void - * \sa - */ -void txMgmtQ_PrintQueueStatistics (TI_HANDLE hTxMgmtQ) -{ -#ifdef REPORT_LOG - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - TI_UINT32 uQueId; - - WLAN_OS_REPORT(("-------------- Mgmt Queues Statistics -------------------\n")); - WLAN_OS_REPORT(("==========================================================\n")); - - WLAN_OS_REPORT(("-------------- Enqueue Packets ---------------------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - WLAN_OS_REPORT(("Que[%d]: %d\n", uQueId, pTxMgmtQ->tDbgCounters.aEnqueuePackets[uQueId])); - - WLAN_OS_REPORT(("-------------- Dequeue Packets ---------------------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - WLAN_OS_REPORT(("Que[%d]: %d\n", uQueId, pTxMgmtQ->tDbgCounters.aDequeuePackets[uQueId])); - - WLAN_OS_REPORT(("-------------- Requeue Packets ---------------------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - WLAN_OS_REPORT(("Que[%d]: %d\n", uQueId, pTxMgmtQ->tDbgCounters.aRequeuePackets[uQueId])); - - WLAN_OS_REPORT(("-------------- Xmitted Packets ---------------------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - WLAN_OS_REPORT(("Que[%d]: %d\n", uQueId, pTxMgmtQ->tDbgCounters.aXmittedPackets[uQueId])); - - WLAN_OS_REPORT(("-------------- Dropped Packets (queue full) --------------\n")); - for(uQueId = 0; uQueId < NUM_OF_MGMT_QUEUES; uQueId++) - WLAN_OS_REPORT(("Que[%d]: %d\n", uQueId, pTxMgmtQ->tDbgCounters.aDroppedPackets[uQueId])); - - WLAN_OS_REPORT(("==========================================================\n\n")); -#endif -} - - -/** - * \fn txMgmtQ_ResetQueueStatistics - * \brief Reset queues statistics (debug) - * - * This function Resets the module's Tx statistics per Queue. - * - * \note - * \param hTxMgmtQ - The module's object - * \return void - * \sa - */ -void txMgmtQ_ResetQueueStatistics (TI_HANDLE hTxMgmtQ) -{ - TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ *)hTxMgmtQ; - - os_memoryZero(pTxMgmtQ->hOs, (void *)&(pTxMgmtQ->tDbgCounters), sizeof(TDbgCount)); -} - -#endif /* TI_DBG */ - diff --git a/wl1271/stad/src/Data_link/txMgmtQueue_Api.h b/wl1271/stad/src/Data_link/txMgmtQueue_Api.h deleted file mode 100644 index c42f80d..0000000 --- a/wl1271/stad/src/Data_link/txMgmtQueue_Api.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * txMgmtQueue_Api.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: txMgmtQueue_Api.h */ -/* PURPOSE: Tx Mgmt Queue module API Header file */ -/* */ -/***************************************************************************/ -#ifndef _TX_MGMT_QUEUE_API_H_ -#define _TX_MGMT_QUEUE_API_H_ - -#include "DrvMainModules.h" - - -#define MGMT_QUEUES_DEPTH 4 /* Up to 4 packets per queue. */ - - -/* Tx connection states updated by the connection SM. */ -typedef enum -{ - TX_CONN_STATE_CLOSE, /* Tx closed for all packets. */ - TX_CONN_STATE_MGMT, /* Tx open only for mgmt packets. */ - TX_CONN_STATE_EAPOL, /* Tx open only for mgmt or EAPOL packets. */ - TX_CONN_STATE_OPEN /* Tx open for all packets. */ -} ETxConnState; - - -/* - * The module public functions: - */ -TI_HANDLE txMgmtQ_Create (TI_HANDLE hOs); -void txMgmtQ_Init (TStadHandlesList *pStadHandles); -TI_STATUS txMgmtQ_Destroy (TI_HANDLE hTxMgmtQ); -void txMgmtQ_ClearQueues (TI_HANDLE hTxMgmtQ); -TI_STATUS txMgmtQ_Xmit (TI_HANDLE hTxMgmtQ, TTxCtrlBlk *pPktCtrlBlk, TI_BOOL bExternalContext); -void txMgmtQ_QueuesNotEmpty (TI_HANDLE hTxMgmtQ); -void txMgmtQ_StopQueue (TI_HANDLE hTxMgmtQ, TI_UINT32 tidBitMap); -void txMgmtQ_UpdateBusyMap (TI_HANDLE hTxMgmtQ, TI_UINT32 tidBitMap); -void txMgmtQ_StopAll (TI_HANDLE hTxMgmtQ); -void txMgmtQ_WakeAll (TI_HANDLE hTxMgmtQ); -void txMgmtQ_SetConnState (TI_HANDLE hTxMgmtQ, ETxConnState txConnState); - -#ifdef TI_DBG -void txMgmtQ_PrintModuleParams (TI_HANDLE hTxMgmtQ); -void txMgmtQ_PrintQueueStatistics (TI_HANDLE hTxMgmtQ); -void txMgmtQ_ResetQueueStatistics (TI_HANDLE hTxMgmtQ); -#endif - - -#endif /* _TX_MGMT_QUEUE_API_H_ */ diff --git a/wl1271/stad/src/Data_link/txPort.c b/wl1271/stad/src/Data_link/txPort.c deleted file mode 100644 index eeba41f..0000000 --- a/wl1271/stad/src/Data_link/txPort.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * txPort.c - * - * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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: txPort.c - * - * PURPOSE: Multiplexes between the management and data queues. - * - * DESCRIPTION: - * ============ - * The Tx port state machine multiplexes between the management and data queues - * according to the management queues requests. - * - ****************************************************************************/ - -#define __FILE_ID__ FILE_ID_62 -#include "commonTypes.h" -#include "tidef.h" -#include "osApi.h" -#include "report.h" -#include "DataCtrl_Api.h" -#include "DrvMainModules.h" - - -typedef enum -{ - MUX_MGMT_QUEUES, /* The management queues have access to the Tx path. */ - MUX_DATA_QUEUES /* The data queues have access to the Tx path. */ -} EQueuesMuxState; - -typedef enum -{ - QUEUE_ACTION_NONE, - QUEUE_ACTION_STOP, - QUEUE_ACTION_WAKE -} EQueueAction; - -/* The txPort module object. */ -typedef struct -{ - TI_HANDLE hOs; - TI_HANDLE hReport; - TI_HANDLE hTxDataQ; - TI_HANDLE hTxMgmtQ; - - EQueuesMuxState queuesMuxState; - TI_BOOL txSuspended; - TI_BOOL mgmtQueueEnabled; - TI_BOOL dataQueueEnabled; -} TTxPortObj; - -/* - * The txPort local functions: - */ -static void updateQueuesStates(TTxPortObj *pTxPort); - -/**************************************************************************** - * txPort_Create() - **************************************************************************** - * DESCRIPTION: Create the txPort module object - * - * INPUTS: None - * - * OUTPUT: None - * - * RETURNS: The Created object - ****************************************************************************/ -TI_HANDLE txPort_create(TI_HANDLE hOs) -{ - TTxPortObj *pTxPort; - - pTxPort = os_memoryAlloc(hOs, sizeof(TTxPortObj)); - if (pTxPort == NULL) - return NULL; - - os_memoryZero(hOs, pTxPort, sizeof(TTxPortObj)); - - pTxPort->hOs = hOs; - - return( (TI_HANDLE)pTxPort ); -} - - -/**************************************************************************** - * txPort_unLoad() - **************************************************************************** - * DESCRIPTION: Unload the txPort module object - * - * INPUTS: hTxPort - The object to free - * - * OUTPUT: None - * - * RETURNS: TI_OK - ****************************************************************************/ -TI_STATUS txPort_unLoad(TI_HANDLE hTxPort) -{ - TTxPortObj *pTxPort = (TTxPortObj *)hTxPort; - - if (pTxPort) - os_memoryFree(pTxPort->hOs, pTxPort, sizeof(TTxPortObj)); - - return TI_OK; -} - - -/**************************************************************************** - * txPort_init() - **************************************************************************** - * DESCRIPTION: Configure the txPort module object - * - * INPUTS: The needed TI handles - * - * OUTPUT: None - * - * RETURNS: void - ****************************************************************************/ -void txPort_init (TStadHandlesList *pStadHandles) -{ - TTxPortObj *pTxPort = (TTxPortObj *)(pStadHandles->hTxPort); - - pTxPort->hReport = pStadHandles->hReport; - pTxPort->hTxDataQ = pStadHandles->hTxDataQ; - pTxPort->hTxMgmtQ = pStadHandles->hTxMgmtQ; - - pTxPort->queuesMuxState = MUX_MGMT_QUEUES; - pTxPort->txSuspended = TI_FALSE; - pTxPort->mgmtQueueEnabled = TI_TRUE; - pTxPort->dataQueueEnabled = TI_FALSE; -} - - -/**************************************************************************** - * txPort_enableData() - **************************************************************************** - * DESCRIPTION: Called by the txMgmtQueue SM when the Tx path CAN be used by the - * data-queues (i.e. it's not needed for mgmt). Update the queues accordingly. - ****************************************************************************/ -void txPort_enableData(TI_HANDLE hTxPort) -{ - TTxPortObj *pTxPort = (TTxPortObj *)hTxPort; - - pTxPort->queuesMuxState = MUX_DATA_QUEUES; - updateQueuesStates(pTxPort); -} - - -/**************************************************************************** - * txPort_enableMgmt() - **************************************************************************** - * DESCRIPTION: Called by the txMgmtQueue SM when the Tx path CAN'T be used by the - * data-queues (i.e. it's needed for mgmt). Update the queues accordingly. - ****************************************************************************/ -void txPort_enableMgmt(TI_HANDLE hTxPort) -{ - TTxPortObj *pTxPort = (TTxPortObj *)hTxPort; - - pTxPort->queuesMuxState = MUX_MGMT_QUEUES; - updateQueuesStates(pTxPort); -} - - -/**************************************************************************** - * txPort_suspendTx() - **************************************************************************** - * DESCRIPTION: Used by STAD applications (e.g. recovery) to temporarily suspend the Tx path. - ****************************************************************************/ -void txPort_suspendTx(TI_HANDLE hTxPort) -{ - TTxPortObj *pTxPort = (TTxPortObj *)hTxPort; - - pTxPort->txSuspended = TI_TRUE; - updateQueuesStates(pTxPort); -} - - -/**************************************************************************** - * txPort_resumeTx() - **************************************************************************** - * DESCRIPTION: Used by STAD applications (e.g. recovery) to resume Tx path after suspended. - ****************************************************************************/ -void txPort_resumeTx(TI_HANDLE hTxPort) -{ - TTxPortObj *pTxPort = (TTxPortObj *)hTxPort; - - pTxPort->txSuspended = TI_FALSE; - updateQueuesStates(pTxPort); -} - - -/**************************************************************************** - * updateQueuesStates() - **************************************************************************** - * DESCRIPTION: Switch the Data-Queue and Mgmt-Queue Tx on/off (stop/wake) - * according to the current port conditions. - ****************************************************************************/ -static void updateQueuesStates (TTxPortObj *pTxPort) -{ - EQueueAction mgmtQueueAction = QUEUE_ACTION_NONE; - EQueueAction dataQueueAction = QUEUE_ACTION_NONE; - - /* - * If the Tx path is not suspended: - */ - if (!pTxPort->txSuspended) - { - /* If mgmt-queues should be enabled, set required actions (awake mgmt and stop data if needed). */ - if (pTxPort->queuesMuxState == MUX_MGMT_QUEUES) - { - if ( !pTxPort->mgmtQueueEnabled ) - mgmtQueueAction = QUEUE_ACTION_WAKE; - if ( pTxPort->dataQueueEnabled ) - dataQueueAction = QUEUE_ACTION_STOP; - } - - /* If data-queues should be enabled, set required actions (stop mgmt and awake data if needed). */ - else - { - if ( pTxPort->mgmtQueueEnabled ) - mgmtQueueAction = QUEUE_ACTION_STOP; - if ( !pTxPort->dataQueueEnabled ) - dataQueueAction = QUEUE_ACTION_WAKE; - } - } - - /* - * If the Tx path is not available (Xfer is busy or suspension is requested), - * set required actions (stop mgmt and data if needed). - */ - else - { - if ( pTxPort->mgmtQueueEnabled ) - mgmtQueueAction = QUEUE_ACTION_STOP; - if ( pTxPort->dataQueueEnabled ) - dataQueueAction = QUEUE_ACTION_STOP; - } - - -#ifdef TI_DBG - TRACE1(pTxPort->hReport, REPORT_SEVERITY_INFORMATION, ": queuesMuxState = , TxSuspend = %d\n", pTxPort->txSuspended); - - TRACE2(pTxPort->hReport, REPORT_SEVERITY_INFORMATION, ": PrevMgmtEnabled = %d, PrevDataEnabled = %d, MgmtAction = , DataAction = \n", pTxPort->mgmtQueueEnabled, pTxPort->dataQueueEnabled); -#endif /* TI_DBG */ - - /* - * Execute the required actions. - * Note: This is done at the end of this function because it may start a sequence that will call it again!! - * Always do WAKE action after STOP action, since WAKE may lead to more activities!! - */ - if (mgmtQueueAction == QUEUE_ACTION_STOP) - { - pTxPort->mgmtQueueEnabled = TI_FALSE; - txMgmtQ_StopAll (pTxPort->hTxMgmtQ); - } - if (dataQueueAction == QUEUE_ACTION_STOP) - { - pTxPort->dataQueueEnabled = TI_FALSE; - txDataQ_StopAll (pTxPort->hTxDataQ); - } - if (mgmtQueueAction == QUEUE_ACTION_WAKE) - { - pTxPort->mgmtQueueEnabled = TI_TRUE; - txMgmtQ_WakeAll (pTxPort->hTxMgmtQ); - } - if (dataQueueAction == QUEUE_ACTION_WAKE) - { - pTxPort->dataQueueEnabled = TI_TRUE; - txDataQ_WakeAll (pTxPort->hTxDataQ); - } -} - diff --git a/wl1271/stad/src/Data_link/txPort_Api.h b/wl1271/stad/src/Data_link/txPort_Api.h deleted file mode 100644 index d2c837c..0000000 --- a/wl1271/stad/src/Data_link/txPort_Api.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * txPort_Api.h - * - * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Texas Instruments nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -/***************************************************************************/ -/* */ -/* MODULE: txPort_Api.h */ -/* PURPOSE: Tx-Port module API */ -/* */ -/***************************************************************************/ -#ifndef _TX_PORT_API_H_ -#define _TX_PORT_API_H_ - -#include "commonTypes.h" -#include "DrvMainModules.h" - - -/* - * Tx-Port module public functions: - */ -TI_HANDLE txPort_create (TI_HANDLE hOs); -TI_STATUS txPort_unLoad (TI_HANDLE hTxPort); -void txPort_init (TStadHandlesList *pStadHandles); -void txPort_enableData (TI_HANDLE hTxPort); -void txPort_enableMgmt (TI_HANDLE hTxPort); -void txPort_suspendTx (TI_HANDLE hTxPort); -void txPort_resumeTx (TI_HANDLE hTxPort); - - -#endif /* _TX_PORT_API_H_ */ |