• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * txCtrlParams.c
3  *
4  * Copyright(c) 1998 - 2009 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 ************************************************************************/
calcCreditFromTimer(TI_HANDLE hTxCtrl,TI_BOOL bTwdInitOccured)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  ****************************************************************************/
updateDataPktPrototype(txCtrl_t * pTxCtrl)181 static void updateDataPktPrototype(txCtrl_t *pTxCtrl)
182 {
183 	pTxCtrl->dataPktDescAttrib = pTxCtrl->txSessionCount << TX_ATTR_OFST_SESSION_COUNTER;
184 	if (pTxCtrl->headerConverMode == HDR_CONVERT_QOS)
185     {
186 		pTxCtrl->dataPktDescAttrib |= TX_ATTR_HEADER_PAD;
187     }
188 }
189 
190 
191 /***************************************************************************
192 *                       txCtrlParams_resetCounters
193 ****************************************************************************
194 * DESCRIPTION:  Reset the tx data module counters
195 *
196 * INPUTS:       hTxCtrl - the object
197 *
198 * OUTPUT:
199 *
200 * RETURNS:
201 ***************************************************************************/
txCtrlParams_resetCounters(TI_HANDLE hTxCtrl)202 void txCtrlParams_resetCounters(TI_HANDLE hTxCtrl)
203 {
204     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
205 
206     os_memoryZero(pTxCtrl->hOs, &pTxCtrl->txDataCounters, sizeof(TTxDataCounters) * MAX_NUM_OF_AC);
207     os_memoryZero(pTxCtrl->hOs, &pTxCtrl->SumTotalDelayUs, sizeof(pTxCtrl->SumTotalDelayUs));
208 	pTxCtrl->currentConsecutiveRetryFail = 0;
209 }
210 
211 
212 /***************************************************************************
213 *                       txCtrlParams_RegNotif                                    *
214 ****************************************************************************/
txCtrlParams_RegNotif(TI_HANDLE hTxCtrl,TI_UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,TI_UINT32 Cookie)215 TI_HANDLE txCtrlParams_RegNotif(TI_HANDLE hTxCtrl, TI_UINT16 EventMask, GeneralEventCall_t CallBack,
216 						  TI_HANDLE context, TI_UINT32 Cookie)
217 {
218     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
219     if (!hTxCtrl)
220         return NULL;
221     return DistributorMgr_Reg(pTxCtrl->TxEventDistributor,EventMask,(TI_HANDLE)CallBack,context,Cookie);
222 }
223 
224 
225 /***************************************************************************
226 *                       txCtrlParams_AddToNotifMask                              *
227 ****************************************************************************/
txCtrlParams_AddToNotifMask(TI_HANDLE hTxCtrl,TI_HANDLE Notifh,TI_UINT16 EventMask)228 TI_STATUS txCtrlParams_AddToNotifMask(TI_HANDLE hTxCtrl, TI_HANDLE Notifh, TI_UINT16 EventMask)
229 {
230     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
231     if (!hTxCtrl)
232         return TI_NOK;
233     return DistributorMgr_AddToMask(pTxCtrl->TxEventDistributor, Notifh, EventMask);
234 }
235 
236 
237 /***************************************************************************
238 *                       txCtrlParams_UnRegNotif                                  *
239 ****************************************************************************/
txCtrlParams_UnRegNotif(TI_HANDLE hTxCtrl,TI_HANDLE RegEventHandle)240 TI_STATUS txCtrlParams_UnRegNotif(TI_HANDLE hTxCtrl, TI_HANDLE RegEventHandle)
241 {
242     TI_STATUS status;
243     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
244 
245     if (!hTxCtrl)
246         return TI_NOK;
247 
248     return (status = DistributorMgr_UnReg(pTxCtrl->TxEventDistributor,RegEventHandle));
249 }
250 
251 
252 /***********************************************************************
253  *                        txCtrlParams_setAdmissionCtrlParams
254  ***********************************************************************
255 DESCRIPTION:    This function is called for add/delete a tspec in order
256 				to update parameters.
257 
258 INPUT:			hTxCtrl - handale to the ts data object
259 				acId - the AC of the tspec
260 				mediumTime	- tha alocated medium time for this UP
261 				minimumPHYRate - the min phy rate to send a packet of this UP
262 				admFlag - indicate if the its addition or deletion of tspec
263 
264 OUTPUT:     None
265 
266 RETURN:     void
267 ************************************************************************/
txCtrlParams_setAdmissionCtrlParams(TI_HANDLE hTxCtrl,TI_UINT8 acId,TI_UINT16 mediumTime,TI_UINT32 minimumPHYRate,TI_BOOL admFlag)268 TI_STATUS txCtrlParams_setAdmissionCtrlParams(TI_HANDLE hTxCtrl, TI_UINT8 acId, TI_UINT16 mediumTime,
269 											  TI_UINT32 minimumPHYRate, TI_BOOL admFlag)
270 {
271 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
272 	TI_UINT32	i;
273 
274 	if(admFlag == TI_TRUE)
275 	{
276 		/* tspec added */
277 		pTxCtrl->mediumTime[acId] = mediumTime;
278         pTxCtrl->admissionState[acId] = AC_ADMITTED;
279 		pTxCtrl->useAdmissionAlgo[acId] = TI_TRUE;
280 		pTxCtrl->lastCreditCalcTimeStamp[acId] = os_timeStampMs(pTxCtrl->hOs);
281 		pTxCtrl->credit[acId] = mediumTime;
282 	}
283 	else
284 	{
285 		/* tspaec deleted */
286 		pTxCtrl->mediumTime[acId] = 0;
287         pTxCtrl->admissionState[acId] = AC_NOT_ADMITTED;
288 		pTxCtrl->useAdmissionAlgo[acId] = TI_FALSE;
289 		pTxCtrl->lastCreditCalcTimeStamp[acId] = 0;
290 		pTxCtrl->credit[acId] = 0;
291 	}
292 
293 	/* Update the Tx queues mapping after admission change. */
294 	txCtrl_UpdateQueuesMapping (hTxCtrl);
295 
296 	/* If the timer was not enabled in registry than we will never set it */
297 	if (pTxCtrl->bCreditCalcTimerEnabled)
298 	{
299     	/* enable disable credit calculation timer */
300     	for (i = 0; i < MAX_NUM_OF_AC; i++)
301     	{
302     		if (pTxCtrl->useAdmissionAlgo[i])
303     		{
304     			if (!pTxCtrl->bCreditCalcTimerRunning)
305     			{
306     				pTxCtrl->bCreditCalcTimerRunning = TI_TRUE;
307                     tmr_StartTimer (pTxCtrl->hCreditTimer,
308                                     calcCreditFromTimer,
309                                     (TI_HANDLE)pTxCtrl,
310                                     pTxCtrl->creditCalculationTimeout,
311                                     TI_TRUE);
312     			}
313 
314     			return TI_OK;
315     		}
316     	}
317 
318     	/* in all queues useAdmissionAlgo is not TRUE, so stop timer if running */
319         if (pTxCtrl->bCreditCalcTimerRunning)
320         {
321             tmr_StopTimer (pTxCtrl->hCreditTimer);
322             pTxCtrl->bCreditCalcTimerRunning = TI_FALSE;
323         }
324     }
325 
326 	return TI_OK;
327 }
328 
329 
330 /***************************************************************************
331 *                           txCtrlParams_getParam
332 ****************************************************************************
333 * DESCRIPTION:  Get a specific parameter by an external user application.
334 *
335 * OUTPUT:       pParamInfo - structure which include the value of
336 *               the requested parameter
337 ***************************************************************************/
txCtrlParams_getParam(TI_HANDLE hTxCtrl,paramInfo_t * pParamInfo)338 TI_STATUS txCtrlParams_getParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo)
339 {
340 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
341 	TI_UINT32 ac;
342 
343     if(pTxCtrl == NULL)  /* check handle validity */
344     {
345         return TI_NOK;
346     }
347 
348     switch (pParamInfo->paramType)
349     {
350     case TX_CTRL_COUNTERS_PARAM:
351 		/* Convert total-delays units from usec to mSec. */
352 		for(ac = 0 ; ac < MAX_NUM_OF_AC ; ac++)
353 		{
354 			pTxCtrl->txDataCounters[ac].SumTotalDelayMs = pTxCtrl->SumTotalDelayUs[ac] / 1000;
355 		}
356         os_memoryCopy( pTxCtrl->hOs, pParamInfo->content.pTxDataCounters, &(pTxCtrl->txDataCounters[0]),
357                        sizeof(TTxDataCounters) * MAX_NUM_OF_AC);
358 		pParamInfo->paramLength = sizeof(TTxDataCounters) * MAX_NUM_OF_AC;
359         break;
360 
361 	case TX_CTRL_GET_DATA_FRAME_COUNTER:
362 		pParamInfo->content.txPacketsCount = 0;
363 		for (ac = 0; ac < MAX_NUM_OF_AC; ac++)
364         	pParamInfo->content.txPacketsCount += pTxCtrl->txDataCounters[ac].XmitOk;
365         break;
366 
367 	case TX_CTRL_REPORT_TS_STATISTICS:
368 		ac = pParamInfo->content.tsMetricsCounters.acID;
369 		os_memoryCopy(pTxCtrl->hOs,
370 					  pParamInfo->content.tsMetricsCounters.pTxDataCounters,
371 					  &(pTxCtrl->txDataCounters[ac]),
372 					  sizeof(TTxDataCounters));
373 		os_memoryZero(pTxCtrl->hOs, &(pTxCtrl->txDataCounters[ac]), sizeof(TTxDataCounters));
374 		break;
375 
376 
377     default:
378         TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": PARAMETER NOT SUPPORTED\n");
379         return PARAM_NOT_SUPPORTED;
380         break;
381     }
382 
383     return TI_OK;
384 }
385 
386 
387 /***************************************************************************
388 *                           txCtrlParams_setParam
389 ****************************************************************************
390 * DESCRIPTION:  Set a specific parameter by an external user application.
391 *
392 * INPUTS:       hTxCtrl - the object
393 *               pParamInfo - structure which include the value to set for
394 *               the requested parameter
395 ***************************************************************************/
txCtrlParams_setParam(TI_HANDLE hTxCtrl,paramInfo_t * pParamInfo)396 TI_STATUS txCtrlParams_setParam(TI_HANDLE hTxCtrl, paramInfo_t *pParamInfo)
397 {
398 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
399 	TI_UINT8 acID;
400 
401     if(pTxCtrl == NULL)  /* check handle validity */
402     {
403         return TI_NOK;
404     }
405 
406     switch (pParamInfo->paramType)
407     {
408     case TX_CTRL_SET_MEDIUM_USAGE_THRESHOLD:
409 		acID = (TI_UINT8)pParamInfo->content.txDataMediumUsageThreshold.uAC;
410 		if(acID < MAX_NUM_OF_AC)
411 		{
412 			pTxCtrl->highMediumUsageThreshold[acID] =
413 				pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold;
414 			pTxCtrl->lowMediumUsageThreshold[acID] =
415 				pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold;
416 		}
417 		else
418 TRACE1(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": Wrong AC (AC=%d > 3)\n", acID);
419 		break;
420 
421     case TX_CTRL_GET_MEDIUM_USAGE_THRESHOLD:
422 		/* Note: SET operation is used for GET, because AC parameter should be supplied from Utility-
423 	         Adapter to driver (copy of user supplied block of data is only performed in SetParam calls). */
424 		acID = (TI_UINT8)pParamInfo->content.txDataMediumUsageThreshold.uAC;
425 		pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold = pTxCtrl->highMediumUsageThreshold[acID];
426 		pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold  = pTxCtrl->lowMediumUsageThreshold[acID];
427 		break;
428 
429     case TX_CTRL_POLL_AP_PACKETS_FROM_AC:
430        TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": Poll-AP is not supported in this version!!\n");
431        return PARAM_NOT_SUPPORTED;
432 
433 	case TX_CTRL_RESET_COUNTERS_PARAM:
434 		txCtrlParams_resetCounters(hTxCtrl);
435 		break;
436 
437     default:
438         TRACE0(pTxCtrl->hReport, REPORT_SEVERITY_ERROR, ": PARAMETER NOT SUPPORTED\n");
439         return PARAM_NOT_SUPPORTED;
440     }
441 
442     return TI_OK;
443 }
444 
445 
446 /***********************************************************************
447  *                        txCtrlParams_setBssId
448  ***********************************************************************
449 DESCRIPTION:    Update the BSS-ID.
450 ************************************************************************/
txCtrlParams_setBssId(TI_HANDLE hTxCtrl,TMacAddr * pCurrBssId)451 void txCtrlParams_setBssId (TI_HANDLE hTxCtrl, TMacAddr *pCurrBssId)
452 {
453 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
454 
455 	MAC_COPY (pTxCtrl->currBssId, *pCurrBssId);
456 }
457 
458 
459 /***********************************************************************
460  *                        txCtrlParams_setBssType
461  ***********************************************************************
462 DESCRIPTION:    Update the BSS type.
463 ************************************************************************/
txCtrlParams_setBssType(TI_HANDLE hTxCtrl,ScanBssType_e currBssType)464 void txCtrlParams_setBssType (TI_HANDLE hTxCtrl, ScanBssType_e currBssType)
465 {
466 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
467 
468 	pTxCtrl->currBssType = currBssType;
469 }
470 
471 
472 /***********************************************************************
473  *                        txCtrlParams_setQosHeaderConverMode
474  ***********************************************************************
475 DESCRIPTION:    Update the BSS type.
476 ************************************************************************/
txCtrlParams_setQosHeaderConverMode(TI_HANDLE hTxCtrl,EHeaderConvertMode headerConverMode)477 void txCtrlParams_setQosHeaderConverMode (TI_HANDLE hTxCtrl, EHeaderConvertMode  headerConverMode)
478 {
479 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
480 
481 	pTxCtrl->headerConverMode = headerConverMode;
482 
483 	updateDataPktPrototype(pTxCtrl);  /* Needed due to QoS mode change. */
484 }
485 
486 /**
487  * \fn     txCtrlParams_SetHtControl()
488  * \brief  Update The HT Control Field on txCtrl module.
489  *
490  * \note
491  * \param  hTxCtrl - the hTxCtrl handle.
492  * \param  pHtCapabilitiesIe - input structure.
493  * \return TI_OK on success or TI_NOK on failure
494  * \sa
495  */
txCtrlParams_SetHtControl(TI_HANDLE hTxCtrl,TtxCtrlHtControl * pHtControl)496 TI_STATUS txCtrlParams_SetHtControl (TI_HANDLE hTxCtrl, TtxCtrlHtControl *pHtControl)
497 {
498     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
499 
500     pTxCtrl->tTxCtrlHtControl.bHtEnable = pHtControl->bHtEnable;
501 
502     return TI_OK;
503 }
504 
505 /***********************************************************************
506  *                        txCtrlParams_setCurrentPrivacyInvokedMode
507  ***********************************************************************
508 DESCRIPTION:    Update the current privacy invoked mode.
509 ************************************************************************/
txCtrlParams_setCurrentPrivacyInvokedMode(TI_HANDLE hTxCtrl,TI_BOOL currentPrivacyInvokedMode)510 void txCtrlParams_setCurrentPrivacyInvokedMode (TI_HANDLE hTxCtrl, TI_BOOL currentPrivacyInvokedMode)
511 {
512 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
513 
514 	pTxCtrl->currentPrivacyInvokedMode = currentPrivacyInvokedMode;
515 }
516 
517 
518 /***********************************************************************
519  *                        txCtrlParams_setEapolEncryptionStatus
520  ***********************************************************************
521 DESCRIPTION:    Update the Eapol Encryption Status.
522 ************************************************************************/
txCtrlParams_setEapolEncryptionStatus(TI_HANDLE hTxCtrl,TI_BOOL eapolEncryptionStatus)523 void txCtrlParams_setEapolEncryptionStatus (TI_HANDLE hTxCtrl, TI_BOOL eapolEncryptionStatus)
524 {
525 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
526 
527 	pTxCtrl->eapolEncryptionStatus = eapolEncryptionStatus;
528 }
529 
530 
531 /***********************************************************************
532  *                        txCtrlParams_setEncryptionFieldSizes
533  ***********************************************************************
534 DESCRIPTION:    Update the encryption field size for the header padding.
535 ************************************************************************/
txCtrlParams_setEncryptionFieldSizes(TI_HANDLE hTxCtrl,TI_UINT8 encryptionFieldSize)536 void txCtrlParams_setEncryptionFieldSizes (TI_HANDLE hTxCtrl, TI_UINT8 encryptionFieldSize)
537 {
538 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
539 
540 	pTxCtrl->encryptionFieldSize = encryptionFieldSize;
541 }
542 
543 
544 /***********************************************************************
545  *                        txCtrlParams_getCurrentEncryptionInfo
546  ***********************************************************************
547 DESCRIPTION:    Provide the current encryption mode and padding size.
548 ************************************************************************/
txCtrlParams_getCurrentEncryptionInfo(TI_HANDLE hTxCtrl,TI_BOOL * pCurrentPrivacyInvokedMode,TI_UINT8 * pEncryptionFieldSize)549 void txCtrlParams_getCurrentEncryptionInfo (TI_HANDLE hTxCtrl,
550                                             TI_BOOL    *pCurrentPrivacyInvokedMode,
551                                             TI_UINT8   *pEncryptionFieldSize)
552 {
553 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
554 
555     *pCurrentPrivacyInvokedMode = pTxCtrl->currentPrivacyInvokedMode;
556     *pEncryptionFieldSize = pTxCtrl->encryptionFieldSize;
557 }
558 
559 
560 /***********************************************************************
561  *                        txCtrlParams_GetTxRate
562  ***********************************************************************
563 DESCRIPTION:    Provide the last successfull data packet Tx rate.
564 ************************************************************************/
txCtrlParams_GetTxRate(TI_HANDLE hTxCtrl)565 ERate txCtrlParams_GetTxRate (TI_HANDLE hTxCtrl)
566 {
567 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
568 
569     return pTxCtrl->eCurrentTxRate;
570 }
571 
572 
573 /***********************************************************************
574  *                        txCtrlParams_setAcAdmissionStatus
575  ***********************************************************************
576 DESCRIPTION:    Update the AC admission status - required or not and admitted or not.
577 				Update also the queues mapping in case it should change.
578 ************************************************************************/
txCtrlParams_setAcAdmissionStatus(TI_HANDLE hTxCtrl,TI_UINT8 ac,EAdmissionState admissionRequired,ETrafficAdmState admissionState)579 void txCtrlParams_setAcAdmissionStatus (TI_HANDLE hTxCtrl,
580                                         TI_UINT8 ac,
581                                         EAdmissionState admissionRequired,
582 										ETrafficAdmState admissionState)
583 {
584 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
585 
586 	pTxCtrl->admissionRequired[ac] = admissionRequired;
587 	pTxCtrl->admissionState[ac]    = admissionState;
588 
589 	/* Update the Tx queues mapping after admission change. */
590 	txCtrl_UpdateQueuesMapping (hTxCtrl);
591 }
592 
593 
594 /***********************************************************************
595  *                        txCtrlParams_setAcMsduLifeTime
596  ***********************************************************************
597 DESCRIPTION:    Update the AC MSDU lifetime. The units are TUs (1024 usec).
598 ************************************************************************/
txCtrlParams_setAcMsduLifeTime(TI_HANDLE hTxCtrl,TI_UINT8 ac,TI_UINT32 uMsduLifeTimeTu)599 void txCtrlParams_setAcMsduLifeTime (TI_HANDLE hTxCtrl, TI_UINT8 ac, TI_UINT32 uMsduLifeTimeTu)
600 {
601 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
602 
603 	pTxCtrl->aMsduLifeTimeTu[ac] = (TI_UINT16)uMsduLifeTimeTu;
604 }
605 
606 
607 /***********************************************************************
608  *                        txCtrlParams_setAcAckPolicy
609  ***********************************************************************
610 DESCRIPTION:    Update the AC Ack policy.
611 ************************************************************************/
txCtrlParams_setAcAckPolicy(TI_HANDLE hTxCtrl,TI_UINT8 ac,AckPolicy_e ackPolicy)612 void txCtrlParams_setAcAckPolicy (TI_HANDLE hTxCtrl, TI_UINT8 ac, AckPolicy_e ackPolicy)
613 {
614 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
615 
616 	pTxCtrl->ackPolicy[ac] = ackPolicy;
617 }
618 
619 
620 /***********************************************************************
621  *                     txCtrlParams_updateMgmtRateAttributes
622  ***********************************************************************
623 DESCRIPTION:    Update per AC the rate policy for Mgmnt packets or IBSS BCAST packets.
624 ************************************************************************/
txCtrlParams_updateMgmtRateAttributes(TI_HANDLE hTxCtrl,TI_UINT8 ratePolicyId,TI_UINT8 ac)625 void txCtrlParams_updateMgmtRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac)
626 {
627 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
628 
629 	pTxCtrl->mgmtRatePolicy[ac] = ratePolicyId;
630 }
631 
632 
633 /***********************************************************************
634  *                     txCtrlParams_updateDataRateAttributes
635  ***********************************************************************
636 DESCRIPTION:    Update per AC the rate policy for regular data packets (excluding IBSS BCAST packets).
637 ************************************************************************/
txCtrlParams_updateDataRateAttributes(TI_HANDLE hTxCtrl,TI_UINT8 ratePolicyId,TI_UINT8 ac)638 void txCtrlParams_updateDataRateAttributes(TI_HANDLE hTxCtrl, TI_UINT8 ratePolicyId, TI_UINT8 ac)
639 {
640 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
641 
642 	pTxCtrl->dataRatePolicy[ac] = ratePolicyId;
643 }
644 
645 
646 /***********************************************************************
647  *                     txCtrlParams_updateTxSessionCount
648  ***********************************************************************
649 DESCRIPTION:    Update the current Tx-session index configured to FW.
650 ************************************************************************/
txCtrlParams_updateTxSessionCount(TI_HANDLE hTxCtrl,TI_UINT16 txSessionCount)651 void txCtrlParams_updateTxSessionCount(TI_HANDLE hTxCtrl, TI_UINT16 txSessionCount)
652 {
653 	txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
654 
655 	pTxCtrl->txSessionCount = txSessionCount;
656 
657 	updateDataPktPrototype(pTxCtrl);
658 }
659 
660 
661 
662 
663 /********************************************************************************
664 *																				*
665 *                       DEBUG  FUNCTIONS  IMPLEMENTATION						*
666 *																				*
667 *********************************************************************************/
668 
669 #ifdef TI_DBG
670 
671 /***********************************************************************
672  *                     txCtrlParams_printInfo
673  ***********************************************************************
674 DESCRIPTION:    Print module internal information.
675 ************************************************************************/
txCtrlParams_printInfo(TI_HANDLE hTxCtrl)676 void txCtrlParams_printInfo(TI_HANDLE hTxCtrl)
677 {
678 #ifdef REPORT_LOG
679     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
680 
681     WLAN_OS_REPORT(("-------------- Tx-Ctrl Module Information --------------\n"));
682     WLAN_OS_REPORT(("========================================================\n"));
683 
684     WLAN_OS_REPORT(("ACs Mapping:\n"));
685     WLAN_OS_REPORT(("------------\n"));
686     WLAN_OS_REPORT(("admissionRequired[3,2,1,0]   =  %d,   %d,   %d,   %d\n",
687 		pTxCtrl->admissionRequired[3], pTxCtrl->admissionRequired[2],
688 		pTxCtrl->admissionRequired[1], pTxCtrl->admissionRequired[0]));
689     WLAN_OS_REPORT(("admissionState[3,2,1,0]      =  %d,   %d,   %d,   %d\n",
690 		pTxCtrl->admissionState[3], pTxCtrl->admissionState[2],
691 		pTxCtrl->admissionState[1], pTxCtrl->admissionState[0]));
692     WLAN_OS_REPORT(("highestAdmittedAc[3,2,1,0]   =  %d,   %d,   %d,   %d\n",
693 		pTxCtrl->highestAdmittedAc[3], pTxCtrl->highestAdmittedAc[2],
694 		pTxCtrl->highestAdmittedAc[1], pTxCtrl->highestAdmittedAc[0]));
695     WLAN_OS_REPORT(("admittedAcToTidMap[3,2,1,0]  =  0x%x, 0x%x, 0x%x, 0x%x\n",
696 		pTxCtrl->admittedAcToTidMap[3], pTxCtrl->admittedAcToTidMap[2],
697 		pTxCtrl->admittedAcToTidMap[1], pTxCtrl->admittedAcToTidMap[0]));
698     WLAN_OS_REPORT(("busyAcBitmap                 = 0x%x\n", pTxCtrl->busyAcBitmap));
699     WLAN_OS_REPORT(("busyTidBitmap                = 0x%x\n", pTxCtrl->busyTidBitmap));
700     WLAN_OS_REPORT(("--------------------------------------------------------\n"));
701 
702     WLAN_OS_REPORT(("Tx Attributes:\n"));
703     WLAN_OS_REPORT(("--------------\n"));
704     WLAN_OS_REPORT(("mgmtRatePolicy[3,2,1,0]      =  %d,   %d,   %d,   %d\n",
705 		pTxCtrl->mgmtRatePolicy[3], pTxCtrl->mgmtRatePolicy[2],
706 		pTxCtrl->mgmtRatePolicy[1], pTxCtrl->mgmtRatePolicy[0]));
707     WLAN_OS_REPORT(("dataRatePolicy[3,2,1,0]      =  %d,   %d,   %d,   %d\n",
708 		pTxCtrl->dataRatePolicy[3], pTxCtrl->dataRatePolicy[2],
709 		pTxCtrl->dataRatePolicy[1], pTxCtrl->dataRatePolicy[0]));
710     WLAN_OS_REPORT(("dataPktDescAttrib            = 0x%x\n", pTxCtrl->dataPktDescAttrib));
711     WLAN_OS_REPORT(("--------------------------------------------------------\n"));
712 
713     WLAN_OS_REPORT(("Parameters:\n"));
714     WLAN_OS_REPORT(("----------\n"));
715     WLAN_OS_REPORT(("headerConverMode             = %d\n", pTxCtrl->headerConverMode));
716     WLAN_OS_REPORT(("currentPrivacyInvokedMode    = %d\n", pTxCtrl->currentPrivacyInvokedMode));
717     WLAN_OS_REPORT(("eapolEncryptionStatus        = %d\n", pTxCtrl->eapolEncryptionStatus));
718     WLAN_OS_REPORT(("encryptionFieldSize          = %d\n", pTxCtrl->encryptionFieldSize));
719     WLAN_OS_REPORT(("currBssType                  = %d\n", pTxCtrl->currBssType));
720     WLAN_OS_REPORT(("========================================================\n\n"));
721 #endif
722 }
723 
724 
725 /***********************************************************************
726  *                     txCtrlParams_printDebugCounters
727  ***********************************************************************
728 DESCRIPTION:    Print Tx statistics debug counters.
729 ************************************************************************/
txCtrlParams_printDebugCounters(TI_HANDLE hTxCtrl)730 void txCtrlParams_printDebugCounters(TI_HANDLE hTxCtrl)
731 {
732 #ifdef REPORT_LOG
733     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
734     TI_UINT32 ac;
735 
736     WLAN_OS_REPORT(("-------------- Tx-Ctrl Statistics Per AC ---------------\n"));
737     WLAN_OS_REPORT(("========================================================\n"));
738 
739     WLAN_OS_REPORT(("---------- Packets Sent To Tx-Ctrl ---------------------\n"));
740     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
741         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsSent[ac]));
742 
743     WLAN_OS_REPORT(("---------- Number of Queue-Stop (BP) -------------------\n"));
744     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
745         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsBackpressure[ac]));
746 
747     WLAN_OS_REPORT(("---------- Number of AC Busy (Requeue pkt) -------------\n"));
748     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
749         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsBusy[ac]));
750 
751     WLAN_OS_REPORT(("---------- Packets Sent to Xfer ------------------------\n"));
752     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
753         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsXfered[ac]));
754 
755     WLAN_OS_REPORT(("----------- Xfer rc = Success --------------------------\n"));
756     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
757         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsSuccess[ac]));
758 
759     WLAN_OS_REPORT(("----------- Xfer rc = Pending --------------------------\n"));
760     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
761         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsPending[ac]));
762 
763     WLAN_OS_REPORT(("----------- Xfer rc = Error ----------------------------\n"));
764     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
765         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumPktsError[ac]));
766 
767     WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets --------------\n"));
768     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
769         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmplt[ac]));
770 
771     WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets TI_OK -----------\n"));
772     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
773         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltOk[ac]));
774 
775     WLAN_OS_REPORT(("----------- Number of Tx-Complete Packets Fails --------\n"));
776     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
777         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltError[ac]));
778 
779     WLAN_OS_REPORT(("----------- Number of Tx-Complete Bytes TI_OK -------------\n"));
780     for(ac = 0; ac < MAX_NUM_OF_AC; ac++)
781         WLAN_OS_REPORT(("AC %d = %d\n", ac, pTxCtrl->dbgCounters.dbgNumTxCmpltOkBytes[ac]));
782     WLAN_OS_REPORT(("--------------------------------------------------------\n"));
783 
784     WLAN_OS_REPORT(("Total Number of Xfer-Complete Events = %d\n", pTxCtrl->dbgCounters.dbgNumXferCmplt));
785     WLAN_OS_REPORT(("Total Number of Xfer-Pending  Events = %d\n",
786 		pTxCtrl->dbgCounters.dbgNumPktsPending[0] +	pTxCtrl->dbgCounters.dbgNumPktsPending[1] +
787 		pTxCtrl->dbgCounters.dbgNumPktsPending[2] +	pTxCtrl->dbgCounters.dbgNumPktsPending[3]));
788     WLAN_OS_REPORT(("========================================================\n\n"));
789 #endif
790 }
791 
792 
793 /***************************************************************************
794 *                       txCtrlParams_resetDbgCounters
795 ****************************************************************************
796 * DESCRIPTION:  Reset the tx data module debug counters
797 ***************************************************************************/
txCtrlParams_resetDbgCounters(TI_HANDLE hTxCtrl)798 void txCtrlParams_resetDbgCounters(TI_HANDLE hTxCtrl)
799 {
800     txCtrl_t *pTxCtrl = (txCtrl_t *)hTxCtrl;
801 
802     os_memoryZero(pTxCtrl->hOs, &pTxCtrl->dbgCounters, sizeof(txDataDbgCounters_t));
803 }
804 
805 
806 
807 #endif   /* TI_DBG */
808