Home | History | Annotate | Download | only in Data_link
      1 /*
      2  * txCtrlParams.c
      3  *
      4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  *
     11  *  * Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  *  * Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in
     15  *    the documentation and/or other materials provided with the
     16  *    distribution.
     17  *  * Neither the name Texas Instruments nor the names of its
     18  *    contributors may be used to endorse or promote products derived
     19  *    from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /*******************************************************************************/
     35 /*                                                                             */
     36 /*      MODULE: txCtrlParams.c                                                 */
     37 /*    PURPOSE:  The txCtrl module parameters handling.                         */
     38 /*              This is a part of the txCtrl module (using the same object).   */
     39 /*                                                                             */
     40 /*******************************************************************************/
     41 
     42 #define __FILE_ID__  FILE_ID_57
     43 #include "tidef.h"
     44 #include "report.h"
     45 #include "paramOut.h"
     46 #include "osApi.h"
     47 #include "timer.h"
     48 #include "EvHandler.h"
     49 #include "txCtrl.h"
     50 
     51 
     52 
     53 
     54 
     55 /***********************************************************************
     56  *                        calcCreditFromTimer
     57  ***********************************************************************
     58 DESCRIPTION:    This function is called when credit calculation timer
     59 				is expired. it calculate the credit for the admission ctrl
     60 				credit algorithm
     61 
     62 
     63 INPUT:	    hTxCtrl         - handle to the ts data object
     64             bTwdInitOccured - Indicates if TWDriver recovery occured since timer started
     65 
     66 OUTPUT:     None
     67 
     68 RETURN:     void
     69 ************************************************************************/
     70 static void calcCreditFromTimer(TI_HANDLE hTxCtrl, TI_BOOL bTwdInitOccured)
     71 {
     72 	OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS	mediumTimeCross;
     73 	txCtrl_t	*pTxCtrl = (txCtrl_t *)hTxCtrl;
     74 	TI_UINT32		ac;
     75 	TI_INT32		prevCredit;
     76 	TI_INT32		highCreditThreshold;
     77 	TI_INT32		lowCreditThreshold;
     78 	TI_INT32		usageRatio;
     79 	TI_INT32		currUsage;
     80 	TI_INT32		prevUsage;
     81 	TI_UINT32		currentTimeStamp = os_timeStampMs(pTxCtrl->hOs);  /* get current time stamp */
     82 
     83 	/*
     84 	 *  For each AC under admission control calculate the new usage and credit time,
     85 	 *     and send events if a threshold is crossed.
     86 	 */
     87 	for(ac = 0 ; ac < MAX_NUM_OF_AC ; ac++)
     88 	{
     89 		/* check if this queue is under admission ctrl operation */
     90 		if(pTxCtrl->mediumTime[ac] == 0)
     91 		{
     92 TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, ": ac = %d mediumTime = 0 \n", ac);
     93 
     94 			continue;
     95 		}
     96 
     97 		/* in case of wraparound */
     98 		if(currentTimeStamp < pTxCtrl->lastCreditCalcTimeStamp[ac])
     99 			pTxCtrl->lastCreditCalcTimeStamp[ac] = 0;
    100 
    101 		/* store prev credit */
    102 		prevCredit = pTxCtrl->credit[ac];
    103 
    104 		/* Calculate the medium usage ratio:    totalUsedTime / mediumTime * 1000
    105 		   Note that since the totalUsedTime is in usec and not msec we don't multiply by 1000.	 */
    106 		usageRatio = pTxCtrl->totalUsedTime[ac] / pTxCtrl->mediumTime[ac];
    107 
    108 		/* calculate credit */
    109 		pTxCtrl->credit[ac] += (currentTimeStamp - pTxCtrl->lastCreditCalcTimeStamp[ac]) - usageRatio;
    110 
    111 		/* update last time stamp */
    112 		pTxCtrl->lastCreditCalcTimeStamp[ac] = currentTimeStamp;
    113 
    114 		/* in case credit is bigger than mediumTime -> set credit to medium time */
    115 		if (pTxCtrl->credit[ac] > (TI_INT32)(pTxCtrl->mediumTime[ac]) )
    116 			pTxCtrl->credit[ac] = pTxCtrl->mediumTime[ac];
    117 
    118        TRACE2(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "credit = %d  | TotalUsedTime = %d\n", pTxCtrl->credit[ac], pTxCtrl->totalUsedTime[ac]/1000);
    119 
    120 		/* Check medium-usage threshold cross events */
    121 		/*********************************************/
    122 		/*
    123 		 * The medium-usage events are defined as follows:
    124 		 * The high threshold triggers event only when crossed upward (traffic increased above threshold).
    125 		 * The low threshold triggers event only when crossed downward (traffic decreased below threshold).
    126 		 * Thus, the two thresholds provide hysteresis and prevent multiple triggering.
    127 		 * The high threshold should be greater than the low threshold.
    128 		 *
    129 		 *   Note:	The driver doesn't delay traffic even if violating the usage limit!
    130 		 *			It only indicates the user application about the thresholds crossing.
    131 		 */
    132 
    133 		highCreditThreshold = (TI_INT32)((pTxCtrl->mediumTime[ac])*(pTxCtrl->highMediumUsageThreshold[ac])/100);
    134 		lowCreditThreshold  = (TI_INT32)((pTxCtrl->mediumTime[ac])*(pTxCtrl->lowMediumUsageThreshold[ac])/100);
    135 
    136 		/* The credit is getting more negative as we get closer to the medium usage limit, so we invert
    137 		     it before comparing to the thresholds (lower credit means higher usage). */
    138 		currUsage = -pTxCtrl->credit[ac];
    139 		prevUsage = -prevCredit;
    140 
    141 		/* crossing below the low threshold */
    142 		if ( (currUsage < lowCreditThreshold) && (prevUsage >= lowCreditThreshold) )
    143 		{
    144 			/* send event */
    145 			mediumTimeCross.uAC = ac;
    146 			mediumTimeCross.uHighOrLowThresholdFlag = (TI_UINT32)LOW_THRESHOLD_CROSS;
    147 			mediumTimeCross.uAboveOrBelowFlag = (TI_UINT32)CROSS_BELOW;
    148 
    149 			EvHandlerSendEvent(pTxCtrl->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS,
    150 				(TI_UINT8 *)&mediumTimeCross, sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
    151 
    152             TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "crossed below low threshold !!! prevUsage = %d, currUsage = %d, lowCreditThreshold = %d\n",				prevUsage, currUsage, lowCreditThreshold);
    153 		}
    154 
    155 		/* crossing above the high threshold */
    156 		else if ( (currUsage > highCreditThreshold) && (prevUsage <= highCreditThreshold) )
    157 		{
    158 			/* send event */
    159 			mediumTimeCross.uAC = ac;
    160 			mediumTimeCross.uHighOrLowThresholdFlag = (TI_UINT32)HIGH_THRESHOLD_CROSS;
    161 			mediumTimeCross.uAboveOrBelowFlag = (TI_UINT32)CROSS_ABOVE;
    162 
    163 			EvHandlerSendEvent(pTxCtrl->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS,
    164 				(TI_UINT8 *)&mediumTimeCross, sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
    165 
    166             TRACE3(pTxCtrl->hReport, REPORT_SEVERITY_INFORMATION, "crossed above high threshold !!! prevUsage = %d, currUsage = %d, highCreditThreshold = %d\n",				prevUsage, currUsage, highCreditThreshold);
    167 		}
    168 
    169 		/* reset totalUsedTime */
    170 		pTxCtrl->totalUsedTime[ac] = 0;
    171 	}
    172 }
    173 
    174 
    175 /****************************************************************************
    176  *                      updateDataPktPrototype()
    177  ****************************************************************************
    178  * DESCRIPTION:	Updates the data packet prototype values according to
    179 				changed parameters (e.g. rate policy change).
    180  ****************************************************************************/
    181 static void updateDataPktPrototype(txCtrl_t *pTxCtrl)
    182 {
    183 	pTxCtrl->dataPktDescAttrib = pTxCtrl->txSessionCount << TX_ATTR_OFST_SESSION_COUNTER;
    184 }
    185 
    186 
    187 /***************************************************************************
    188 *                       txCtrlParams_resetCounters
    189 ****************************************************************************
    190 * DESCRIPTION:  Reset the tx data module counters
    191 *
    192 * INPUTS:       hTxCtrl - the object
    193 *
    194 * OUTPUT:
    195 *
    196 * RETURNS:
    197 ***************************************************************************/
    198 void txCtrlParams_resetCounters(TI_HANDLE hTxCtrl)
    199 {
    200     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    201 
    202     os_memoryZero(pTxCtrl->hOs, &pTxCtrl->txDataCounters, sizeof(TTxDataCounters) * MAX_NUM_OF_AC);
    203     os_memoryZero(pTxCtrl->hOs, &pTxCtrl->SumTotalDelayUs, sizeof(pTxCtrl->SumTotalDelayUs));
    204 	pTxCtrl->currentConsecutiveRetryFail = 0;
    205 }
    206 
    207 
    208 /***************************************************************************
    209 *                       txCtrlParams_RegNotif                                    *
    210 ****************************************************************************/
    211 TI_HANDLE txCtrlParams_RegNotif(TI_HANDLE hTxCtrl, TI_UINT16 EventMask, GeneralEventCall_t CallBack,
    212 						  TI_HANDLE context, TI_UINT32 Cookie)
    213 {
    214     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    215     if (!hTxCtrl)
    216         return NULL;
    217     return DistributorMgr_Reg(pTxCtrl->TxEventDistributor,EventMask,(TI_HANDLE)CallBack,context,Cookie);
    218 }
    219 
    220 
    221 /***************************************************************************
    222 *                       txCtrlParams_AddToNotifMask                              *
    223 ****************************************************************************/
    224 TI_STATUS txCtrlParams_AddToNotifMask(TI_HANDLE hTxCtrl, TI_HANDLE Notifh, TI_UINT16 EventMask)
    225 {
    226     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    227     if (!hTxCtrl)
    228         return TI_NOK;
    229     return DistributorMgr_AddToMask(pTxCtrl->TxEventDistributor, Notifh, EventMask);
    230 }
    231 
    232 
    233 /***************************************************************************
    234 *                       txCtrlParams_UnRegNotif                                  *
    235 ****************************************************************************/
    236 TI_STATUS txCtrlParams_UnRegNotif(TI_HANDLE hTxCtrl, TI_HANDLE RegEventHandle)
    237 {
    238     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    239 
    240     if (!hTxCtrl)
    241         return TI_NOK;
    242 
    243     return (DistributorMgr_UnReg(pTxCtrl->TxEventDistributor,RegEventHandle));
    244 }
    245 
    246 
    247 /***********************************************************************
    248  *                        txCtrlParams_setAdmissionCtrlParams
    249  ***********************************************************************
    250 DESCRIPTION:    This function is called for add/delete a tspec in order
    251 				to update parameters.
    252 
    253 INPUT:			hTxCtrl - handale to the ts data object
    254 				acId - the AC of the tspec
    255 				mediumTime	- tha alocated medium time for this UP
    256 				minimumPHYRate - the min phy rate to send a packet of this UP
    257 				admFlag - indicate if the its addition or deletion of tspec
    258 
    259 OUTPUT:     None
    260 
    261 RETURN:     void
    262 ************************************************************************/
    263 TI_STATUS txCtrlParams_setAdmissionCtrlParams(TI_HANDLE hTxCtrl, TI_UINT8 acId, TI_UINT16 mediumTime,
    264 											  TI_UINT32 minimumPHYRate, TI_BOOL admFlag)
    265 {
    266 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    267 	TI_UINT32	i;
    268 
    269 	if(admFlag == TI_TRUE)
    270 	{
    271 		/* tspec added */
    272 		pTxCtrl->mediumTime[acId] = mediumTime;
    273         pTxCtrl->admissionState[acId] = AC_ADMITTED;
    274 		pTxCtrl->useAdmissionAlgo[acId] = TI_TRUE;
    275 		pTxCtrl->lastCreditCalcTimeStamp[acId] = os_timeStampMs(pTxCtrl->hOs);
    276 		pTxCtrl->credit[acId] = mediumTime;
    277 	}
    278 	else
    279 	{
    280 		/* tspaec deleted */
    281 		pTxCtrl->mediumTime[acId] = 0;
    282         pTxCtrl->admissionState[acId] = AC_NOT_ADMITTED;
    283 		pTxCtrl->useAdmissionAlgo[acId] = TI_FALSE;
    284 		pTxCtrl->lastCreditCalcTimeStamp[acId] = 0;
    285 		pTxCtrl->credit[acId] = 0;
    286 	}
    287 
    288 	/* Update the Tx queues mapping after admission change. */
    289 	txCtrl_UpdateQueuesMapping (hTxCtrl);
    290 
    291 	/* If the timer was not enabled in registry than we will never set it */
    292 	if (pTxCtrl->bCreditCalcTimerEnabled)
    293 	{
    294     	/* enable disable credit calculation timer */
    295     	for (i = 0; i < MAX_NUM_OF_AC; i++)
    296     	{
    297     		if (pTxCtrl->useAdmissionAlgo[i])
    298     		{
    299     			if (!pTxCtrl->bCreditCalcTimerRunning)
    300     			{
    301     				pTxCtrl->bCreditCalcTimerRunning = TI_TRUE;
    302                     tmr_StartTimer (pTxCtrl->hCreditTimer,
    303                                     calcCreditFromTimer,
    304                                     (TI_HANDLE)pTxCtrl,
    305                                     pTxCtrl->creditCalculationTimeout,
    306                                     TI_TRUE);
    307     			}
    308 
    309     			return TI_OK;
    310     		}
    311     	}
    312 
    313     	/* in all queues useAdmissionAlgo is not TRUE, so stop timer if running */
    314         if (pTxCtrl->bCreditCalcTimerRunning)
    315         {
    316             tmr_StopTimer (pTxCtrl->hCreditTimer);
    317             pTxCtrl->bCreditCalcTimerRunning = TI_FALSE;
    318         }
    319     }
    320 
    321 	return TI_OK;
    322 }
    323 
    324 
    325 /***************************************************************************
    326 *                           txCtrlParams_getParam
    327 ****************************************************************************
    328 * DESCRIPTION:  Get a specific parameter by an external user application.
    329 *
    330 * OUTPUT:       pParamInfo - structure which include the value of
    331 *               the requested parameter
    332 ***************************************************************************/
    333 TI_STATUS txCtrlParams_getParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo)
    334 {
    335 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    336 	TI_UINT32 ac;
    337 
    338     if(pTxCtrl == NULL)  /* check handle validity */
    339     {
    340         return TI_NOK;
    341     }
    342 
    343     switch (pParamInfo->paramType)
    344     {
    345     case TX_CTRL_COUNTERS_PARAM:
    346 		/* Convert total-delays units from usec to mSec. */
    347 		for(ac = 0 ; ac < MAX_NUM_OF_AC ; ac++)
    348 		{
    349 			pTxCtrl->txDataCounters[ac].SumTotalDelayMs = pTxCtrl->SumTotalDelayUs[ac] / 1000;
    350 		}
    351         os_memoryCopy( pTxCtrl->hOs, pParamInfo->content.pTxDataCounters, &(pTxCtrl->txDataCounters[0]),
    352                        sizeof(TTxDataCounters) * MAX_NUM_OF_AC);
    353 		pParamInfo->paramLength = sizeof(TTxDataCounters) * MAX_NUM_OF_AC;
    354         break;
    355 
    356 	case TX_CTRL_GET_DATA_FRAME_COUNTER:
    357 		pParamInfo->content.txPacketsCount = 0;
    358 		for (ac = 0; ac < MAX_NUM_OF_AC; ac++)
    359         	pParamInfo->content.txPacketsCount += pTxCtrl->txDataCounters[ac].XmitOk;
    360         break;
    361 
    362 	case TX_CTRL_REPORT_TS_STATISTICS:
    363 		ac = pParamInfo->content.tsMetricsCounters.acID;
    364 		os_memoryCopy(pTxCtrl->hOs,
    365 					  pParamInfo->content.tsMetricsCounters.pTxDataCounters,
    366 					  &(pTxCtrl->txDataCounters[ac]),
    367 					  sizeof(TTxDataCounters));
    368 		os_memoryZero(pTxCtrl->hOs, &(pTxCtrl->txDataCounters[ac]), sizeof(TTxDataCounters));
    369 		break;
    370 
    371 	case TX_CTRL_GENERIC_ETHERTYPE:
    372 		pParamInfo->content.txGenericEthertype = pTxCtrl->genericEthertype;
    373 		break;
    374 
    375 
    376     default:
    377         TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": PARAMETER NOT SUPPORTED\n");
    378         return PARAM_NOT_SUPPORTED;
    379     }
    380 
    381     return TI_OK;
    382 }
    383 
    384 
    385 /***************************************************************************
    386 *                           txCtrlParams_setParam
    387 ****************************************************************************
    388 * DESCRIPTION:  Set a specific parameter by an external user application.
    389 *
    390 * INPUTS:       hTxCtrl - the object
    391 *               pParamInfo - structure which include the value to set for
    392 *               the requested parameter
    393 ***************************************************************************/
    394 TI_STATUS txCtrlParams_setParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo)
    395 {
    396 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    397 	TI_UINT8 acID;
    398 
    399     if(pTxCtrl == NULL)  /* check handle validity */
    400     {
    401         return TI_NOK;
    402     }
    403 
    404     switch (pParamInfo->paramType)
    405     {
    406     case TX_CTRL_SET_MEDIUM_USAGE_THRESHOLD:
    407 		acID = (TI_UINT8)pParamInfo->content.txDataMediumUsageThreshold.uAC;
    408 		if(acID < MAX_NUM_OF_AC)
    409 		{
    410 			pTxCtrl->highMediumUsageThreshold[acID] =
    411 				pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold;
    412 			pTxCtrl->lowMediumUsageThreshold[acID] =
    413 				pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold;
    414 		}
    415 		else
    416 TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": Wrong AC (AC=%d > 3)\n", acID);
    417 		break;
    418 
    419     case TX_CTRL_GET_MEDIUM_USAGE_THRESHOLD:
    420 		/* Note: SET operation is used for GET, because AC parameter should be supplied from Utility-
    421 	         Adapter to driver (copy of user supplied block of data is only performed in SetParam calls). */
    422 		acID = (TI_UINT8)pParamInfo->content.txDataMediumUsageThreshold.uAC;
    423 		pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold = pTxCtrl->highMediumUsageThreshold[acID];
    424 		pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold  = pTxCtrl->lowMediumUsageThreshold[acID];
    425 		break;
    426 
    427     case TX_CTRL_POLL_AP_PACKETS_FROM_AC:
    428        TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": Poll-AP is not supported in this version!!\n");
    429        return PARAM_NOT_SUPPORTED;
    430 
    431 	case TX_CTRL_RESET_COUNTERS_PARAM:
    432 		txCtrlParams_resetCounters(hTxCtrl);
    433 		break;
    434 
    435 	case TX_CTRL_GENERIC_ETHERTYPE:
    436         pTxCtrl->genericEthertype = pParamInfo->content.txGenericEthertype;
    437 		{
    438 				paramInfo_t param;
    439 				param.paramType = RX_DATA_GENERIC_ETHERTYPE_PARAM;
    440 				param.content.rxGenericEthertype = pTxCtrl->genericEthertype;
    441 				rxData_setParam(pTxCtrl->hRxData, &param);
    442 		}
    443 		break;
    444 
    445 
    446     default:
    447         TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": PARAMETER NOT SUPPORTED\n");
    448         return PARAM_NOT_SUPPORTED;
    449     }
    450 
    451     return TI_OK;
    452 }
    453 
    454 
    455 /***********************************************************************
    456  *                        txCtrlParams_setBssId
    457  ***********************************************************************
    458 DESCRIPTION:    Update the BSS-ID.
    459 ************************************************************************/
    460 void txCtrlParams_setBssId (TI_HANDLE hTxCtrl, TMacAddr *pCurrBssId)
    461 {
    462 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    463 
    464 	MAC_COPY (pTxCtrl->currBssId, *pCurrBssId);
    465 }
    466 
    467 
    468 /***********************************************************************
    469  *                        txCtrlParams_setBssType
    470  ***********************************************************************
    471 DESCRIPTION:    Update the BSS type.
    472 ************************************************************************/
    473 void txCtrlParams_setBssType (TI_HANDLE hTxCtrl, ScanBssType_e currBssType)
    474 {
    475 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    476 
    477 	pTxCtrl->currBssType = currBssType;
    478 }
    479 
    480 
    481 /***********************************************************************
    482  *                        txCtrlParams_setQosHeaderConverMode
    483  ***********************************************************************
    484 DESCRIPTION:    Update the BSS type.
    485 ************************************************************************/
    486 void txCtrlParams_setQosHeaderConverMode (TI_HANDLE hTxCtrl, EHeaderConvertMode  headerConverMode)
    487 {
    488 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    489 
    490 	pTxCtrl->headerConverMode = headerConverMode;
    491 
    492 	updateDataPktPrototype(pTxCtrl);  /* Needed due to QoS mode change. */
    493 }
    494 
    495 /**
    496  * \fn     txCtrlParams_SetHtControl()
    497  * \brief  Update The HT Control Field on txCtrl module.
    498  *
    499  * \note
    500  * \param  hTxCtrl - the hTxCtrl handle.
    501  * \param  pHtCapabilitiesIe - input structure.
    502  * \return TI_OK on success or TI_NOK on failure
    503  * \sa
    504  */
    505 TI_STATUS txCtrlParams_SetHtControl (TI_HANDLE hTxCtrl, TtxCtrlHtControl *pHtControl)
    506 {
    507     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    508 
    509     pTxCtrl->tTxCtrlHtControl.bHtEnable = pHtControl->bHtEnable;
    510 
    511     return TI_OK;
    512 }
    513 
    514 /***********************************************************************
    515  *                        txCtrlParams_setCurrentPrivacyInvokedMode
    516  ***********************************************************************
    517 DESCRIPTION:    Update the current privacy invoked mode.
    518 ************************************************************************/
    519 void txCtrlParams_setCurrentPrivacyInvokedMode (TI_HANDLE hTxCtrl, TI_BOOL currentPrivacyInvokedMode)
    520 {
    521 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    522 
    523 	pTxCtrl->currentPrivacyInvokedMode = currentPrivacyInvokedMode;
    524 }
    525 
    526 
    527 /***********************************************************************
    528  *                        txCtrlParams_setEapolEncryptionStatus
    529  ***********************************************************************
    530 DESCRIPTION:    Update the Eapol Encryption Status.
    531 ************************************************************************/
    532 void txCtrlParams_setEapolEncryptionStatus (TI_HANDLE hTxCtrl, TI_BOOL eapolEncryptionStatus)
    533 {
    534 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    535 
    536 	pTxCtrl->eapolEncryptionStatus = eapolEncryptionStatus;
    537 }
    538 
    539 
    540 /***********************************************************************
    541  *                        txCtrlParams_setEncryptionFieldSizes
    542  ***********************************************************************
    543 DESCRIPTION:    Update the encryption field size for the header padding.
    544 ************************************************************************/
    545 void txCtrlParams_setEncryptionFieldSizes (TI_HANDLE hTxCtrl, TI_UINT8 encryptionFieldSize)
    546 {
    547 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    548 
    549 	pTxCtrl->encryptionFieldSize = encryptionFieldSize;
    550 }
    551 
    552 
    553 /***********************************************************************
    554  *                        txCtrlParams_getCurrentEncryptionInfo
    555  ***********************************************************************
    556 DESCRIPTION:    Provide the current encryption mode and padding size.
    557 ************************************************************************/
    558 void txCtrlParams_getCurrentEncryptionInfo (TI_HANDLE hTxCtrl,
    559                                             TI_BOOL    *pCurrentPrivacyInvokedMode,
    560                                             TI_UINT8   *pEncryptionFieldSize)
    561 {
    562 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    563 
    564     *pCurrentPrivacyInvokedMode = pTxCtrl->currentPrivacyInvokedMode;
    565     *pEncryptionFieldSize = pTxCtrl->encryptionFieldSize;
    566 }
    567 
    568 
    569 /***********************************************************************
    570  *                        txCtrlParams_GetTxRate
    571  ***********************************************************************
    572 DESCRIPTION:    Provide the last successfull data packet Tx rate.
    573 ************************************************************************/
    574 ERate txCtrlParams_GetTxRate (TI_HANDLE hTxCtrl)
    575 {
    576 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    577 
    578     return pTxCtrl->eCurrentTxRate;
    579 }
    580 
    581 
    582 /***********************************************************************
    583  *                        txCtrlParams_setAcAdmissionStatus
    584  ***********************************************************************
    585 DESCRIPTION:    Update the AC admission status - required or not and admitted or not.
    586 				Update also the queues mapping in case it should change.
    587 ************************************************************************/
    588 void txCtrlParams_setAcAdmissionStatus (TI_HANDLE hTxCtrl,
    589                                         TI_UINT8 ac,
    590                                         EAdmissionState admissionRequired,
    591 										ETrafficAdmState admissionState)
    592 {
    593 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    594 
    595 	pTxCtrl->admissionRequired[ac] = admissionRequired;
    596 	pTxCtrl->admissionState[ac]    = admissionState;
    597 
    598 	/* Update the Tx queues mapping after admission change. */
    599 	txCtrl_UpdateQueuesMapping (hTxCtrl);
    600 }
    601 
    602 
    603 /***********************************************************************
    604  *                        txCtrlParams_setAcMsduLifeTime
    605  ***********************************************************************
    606 DESCRIPTION:    Update the AC MSDU lifetime. The units are TUs (1024 usec).
    607 ************************************************************************/
    608 void txCtrlParams_setAcMsduLifeTime (TI_HANDLE hTxCtrl, TI_UINT8 ac, TI_UINT32 uMsduLifeTimeTu)
    609 {
    610 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    611 
    612 	pTxCtrl->aMsduLifeTimeTu[ac] = (TI_UINT16)uMsduLifeTimeTu;
    613 }
    614 
    615 
    616 /***********************************************************************
    617  *                        txCtrlParams_setAcAckPolicy
    618  ***********************************************************************
    619 DESCRIPTION:    Update the AC Ack policy.
    620 ************************************************************************/
    621 void txCtrlParams_setAcAckPolicy (TI_HANDLE hTxCtrl, TI_UINT8 ac, AckPolicy_e ackPolicy)
    622 {
    623 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    624 
    625 	pTxCtrl->ackPolicy[ac] = ackPolicy;
    626 }
    627 
    628 
    629 /***********************************************************************
    630  *                     txCtrlParams_updateMgmtRateAttributes
    631  ***********************************************************************
    632 DESCRIPTION:    Update per AC the rate policy for Mgmnt packets or IBSS BCAST packets.
    633 ************************************************************************/
    634 void txCtrlParams_updateMgmtRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac)
    635 {
    636 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    637 
    638 	pTxCtrl->mgmtRatePolicy[ac] = ratePolicyId;
    639 }
    640 
    641 
    642 /***********************************************************************
    643  *                     txCtrlParams_updateDataRateAttributes
    644  ***********************************************************************
    645 DESCRIPTION:    Update per AC the rate policy for regular data packets (excluding IBSS BCAST packets).
    646 ************************************************************************/
    647 void txCtrlParams_updateDataRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac)
    648 {
    649 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    650 
    651 	pTxCtrl->dataRatePolicy[ac] = ratePolicyId;
    652 }
    653 
    654 
    655 /***********************************************************************
    656  *                     txCtrlParams_updateTxSessionCount
    657  ***********************************************************************
    658 DESCRIPTION:    Update the current Tx-session index configured to FW.
    659 ************************************************************************/
    660 void txCtrlParams_updateTxSessionCount(TI_HANDLE hTxCtrl, TI_UINT16 txSessionCount)
    661 {
    662 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    663 
    664 	pTxCtrl->txSessionCount = txSessionCount;
    665 
    666 	updateDataPktPrototype(pTxCtrl);
    667 }
    668 
    669 
    670 
    671 
    672 /********************************************************************************
    673 *																				*
    674 *                       DEBUG  FUNCTIONS  IMPLEMENTATION						*
    675 *																				*
    676 *********************************************************************************/
    677 
    678 #ifdef TI_DBG
    679 
    680 /***********************************************************************
    681  *                     txCtrlParams_printInfo
    682  ***********************************************************************
    683 DESCRIPTION:    Print module internal information.
    684 ************************************************************************/
    685 void txCtrlParams_printInfo(TI_HANDLE hTxCtrl)
    686 {
    687 #ifdef REPORT_LOG
    688     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    689 
    690     WLAN_OS_REPORT(("-------------- Tx-Ctrl Module Information --------------\n"));
    691     WLAN_OS_REPORT(("========================================================\n"));
    692 
    693     WLAN_OS_REPORT(("ACs Mapping:\n"));
    694     WLAN_OS_REPORT(("------------\n"));
    695     WLAN_OS_REPORT(("admissionRequired[3,2,1,0]   =  %d,   %d,   %d,   %d\n",
    696 		pTxCtrl->admissionRequired[3], pTxCtrl->admissionRequired[2],
    697 		pTxCtrl->admissionRequired[1], pTxCtrl->admissionRequired[0]));
    698     WLAN_OS_REPORT(("admissionState[3,2,1,0]      =  %d,   %d,   %d,   %d\n",
    699 		pTxCtrl->admissionState[3], pTxCtrl->admissionState[2],
    700 		pTxCtrl->admissionState[1], pTxCtrl->admissionState[0]));
    701     WLAN_OS_REPORT(("highestAdmittedAc[3,2,1,0]   =  %d,   %d,   %d,   %d\n",
    702 		pTxCtrl->highestAdmittedAc[3], pTxCtrl->highestAdmittedAc[2],
    703 		pTxCtrl->highestAdmittedAc[1], pTxCtrl->highestAdmittedAc[0]));
    704     WLAN_OS_REPORT(("admittedAcToTidMap[3,2,1,0]  =  0x%x, 0x%x, 0x%x, 0x%x\n",
    705 		pTxCtrl->admittedAcToTidMap[3], pTxCtrl->admittedAcToTidMap[2],
    706 		pTxCtrl->admittedAcToTidMap[1], pTxCtrl->admittedAcToTidMap[0]));
    707     WLAN_OS_REPORT(("busyAcBitmap                 = 0x%x\n", pTxCtrl->busyAcBitmap));
    708     WLAN_OS_REPORT(("busyTidBitmap                = 0x%x\n", pTxCtrl->busyTidBitmap));
    709     WLAN_OS_REPORT(("--------------------------------------------------------\n"));
    710 
    711     WLAN_OS_REPORT(("Tx Attributes:\n"));
    712     WLAN_OS_REPORT(("--------------\n"));
    713     WLAN_OS_REPORT(("mgmtRatePolicy[3,2,1,0]      =  %d,   %d,   %d,   %d\n",
    714 		pTxCtrl->mgmtRatePolicy[3], pTxCtrl->mgmtRatePolicy[2],
    715 		pTxCtrl->mgmtRatePolicy[1], pTxCtrl->mgmtRatePolicy[0]));
    716     WLAN_OS_REPORT(("dataRatePolicy[3,2,1,0]      =  %d,   %d,   %d,   %d\n",
    717 		pTxCtrl->dataRatePolicy[3], pTxCtrl->dataRatePolicy[2],
    718 		pTxCtrl->dataRatePolicy[1], pTxCtrl->dataRatePolicy[0]));
    719     WLAN_OS_REPORT(("dataPktDescAttrib            = 0x%x\n", pTxCtrl->dataPktDescAttrib));
    720     WLAN_OS_REPORT(("--------------------------------------------------------\n"));
    721 
    722     WLAN_OS_REPORT(("Parameters:\n"));
    723     WLAN_OS_REPORT(("----------\n"));
    724     WLAN_OS_REPORT(("headerConverMode             = %d\n", pTxCtrl->headerConverMode));
    725     WLAN_OS_REPORT(("currentPrivacyInvokedMode    = %d\n", pTxCtrl->currentPrivacyInvokedMode));
    726     WLAN_OS_REPORT(("eapolEncryptionStatus        = %d\n", pTxCtrl->eapolEncryptionStatus));
    727     WLAN_OS_REPORT(("encryptionFieldSize          = %d\n", pTxCtrl->encryptionFieldSize));
    728     WLAN_OS_REPORT(("currBssType                  = %d\n", pTxCtrl->currBssType));
    729     WLAN_OS_REPORT(("========================================================\n\n"));
    730 #endif
    731 }
    732 
    733 
    734 /***********************************************************************
    735  *                     txCtrlParams_printDebugCounters
    736  ***********************************************************************
    737 DESCRIPTION:    Print Tx statistics debug counters.
    738 ************************************************************************/
    739 void txCtrlParams_printDebugCounters(TI_HANDLE hTxCtrl)
    740 {
    741 #ifdef REPORT_LOG
    742     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    743     TI_UINT32 ac;
    744 
    745     WLAN_OS_REPORT(("-------------- Tx-Ctrl Statistics Per AC ---------------\n"));
    746     WLAN_OS_REPORT(("========================================================\n"));
    747 
    748     WLAN_OS_REPORT(("---------- Packets Sent To Tx-Ctrl ---------------------\n"));
    749     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    750         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsSent[ac]));
    751 
    752     WLAN_OS_REPORT(("---------- Number of Queue-Stop (BP) -------------------\n"));
    753     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    754         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsBackpressure[ac]));
    755 
    756     WLAN_OS_REPORT(("---------- Number of AC Busy (Requeue pkt) -------------\n"));
    757     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    758         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsBusy[ac]));
    759 
    760     WLAN_OS_REPORT(("---------- Packets Sent to Xfer ------------------------\n"));
    761     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    762         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsXfered[ac]));
    763 
    764     WLAN_OS_REPORT(("----------- Xfer rc = Success --------------------------\n"));
    765     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    766         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsSuccess[ac]));
    767 
    768     WLAN_OS_REPORT(("----------- Xfer rc = Pending --------------------------\n"));
    769     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    770         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsPending[ac]));
    771 
    772     WLAN_OS_REPORT(("----------- Xfer rc = Error ----------------------------\n"));
    773     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    774         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsError[ac]));
    775 
    776     WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets --------------\n"));
    777     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    778         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmplt[ac]));
    779 
    780     WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets TI_OK -----------\n"));
    781     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    782         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltOk[ac]));
    783 
    784     WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets Fails --------\n"));
    785     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    786         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltError[ac]));
    787 
    788     WLAN_OS_REPORT(("----------- Number of Tx-Complete Bytes TI_OK -------------\n"));
    789     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
    790         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltOkBytes[ac]));
    791     WLAN_OS_REPORT(("--------------------------------------------------------\n"));
    792 
    793     WLAN_OS_REPORT(("Total Number of Xfer-Complete Events = %d\n", pTxCtrl->dbgCounters.dbgNumXferCmplt));
    794     WLAN_OS_REPORT(("Total Number of Xfer-Pending  Events = %d\n",
    795 		pTxCtrl->dbgCounters.dbgNumPktsPending[0] +	pTxCtrl->dbgCounters.dbgNumPktsPending[1] +
    796 		pTxCtrl->dbgCounters.dbgNumPktsPending[2] +	pTxCtrl->dbgCounters.dbgNumPktsPending[3]));
    797     WLAN_OS_REPORT(("========================================================\n\n"));
    798 #endif
    799 }
    800 
    801 
    802 /***************************************************************************
    803 *                       txCtrlParams_resetDbgCounters
    804 ****************************************************************************
    805 * DESCRIPTION:  Reset the tx data module debug counters
    806 ***************************************************************************/
    807 void txCtrlParams_resetDbgCounters(TI_HANDLE hTxCtrl)
    808 {
    809     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
    810 
    811     os_memoryZero(pTxCtrl->hOs, &pTxCtrl->dbgCounters, sizeof(txDataDbgCounters_t));
    812 }
    813 
    814 
    815 
    816 #endif   /* TI_DBG */
    817