?? zl5011xcpq.c
字號:
/*******************************************************************************
*
* File name: zl5011xCpq.c
*
* Version: 21
*
* Author: LCW
*
* Date created: 11/04/2002
*
* Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
* All rights reserved.
*
* Module Description:
* This file contains all the functions that will initialise and control
* the CPQ block.
*
* Revision History:
*
* Rev: Date: Author: Comments:
* 1 15/04/2002 LCW Created
* 2 15/04/2002 LCW Minor mods
* 3 19/04/2002 LCW Prepared for code review
* 4 19/04/2002 LCW Minor mods
* 5 19/04/2002 LCW Minor mods
* 6 19/04/2002 LCW Minor mods
* 7 01/05/2002 LCW Minor mods
* 8 07/05/2002 LCW Minor mods
* 9 07/05/2002 LCW Minor mods
* 10 08/05/2002 LCW Minor mods
* 11 16/05/2002 LCW Minor mods
* 12 16/05/2002 LCW Minor mods
* 13 12/06/2002 MRC Update
* 14 12/07/2002 MRC Rationalised the 2 enums for CPU queues
* 15 19/09/2002 MRC Tidied up register addresses
* 16 01/10/2002 DJA ZL5011X_TRACE messages fixed up
* 17 18/10/2002 PJE interruptEnable/Disable updated
* 18 31/10/2002 MRC Added variants + minor fixes
* 19 07/04/2003 ARW Added new function zl5011xCpqPacketsToReceive
* 20 07/04/2003 ARW Fixed bug found in zl5011xCpqSetOverrunMode
* 21 15/02/2005 MRC Corrected a few comments
*
*******************************************************************************/
/***************** INCLUDE FILES ******************************************/
#include "zl5011x.h"
#include "zl5011xCpqMap.h"
#include "zl5011xCpq.h"
#include "zl5011xRdWr.h"
#include "zl5011xUtilLib.h"
/***************** # DEFINES **********************************************/
/***************** STATIC FUNCTION DECLARATIONS ***************************/
/***************** STATIC GLOBAL VARIABLES ********************************/
/***************** EXPORTED GLOBAL VARIABLES ******************************/
/***************** FUNCTION DEFINTIONS ************************************/
/*******************************************************************************
Function:
zl5011xCpqInit
Description:
Initialises the CPQ block.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xCpqInit(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
Uint32T loop;
ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqInit:", 0, 0, 0, 0, 0, 0);
/* set up defaults for the queue depths */
for (loop = 0; loop < ZL5011X_CPQ_QUEUES; loop++)
{
status = zl5011xCpqConfigureQueue(zl5011xParams, (zl5011xQueueE)loop,
ZL5011X_CPQ_DEFAULT_GRAN_THLD, ZL5011X_CPQ_DEFAULT_PACKET_DROP_MODE);
}
/* set a default for the maximum number of grnaules to be used in the
CPU queues */
if(status == ZL5011X_OK)
{
status = zl5011xCpqSetGranuleUsage(zl5011xParams, ZL5011X_CPQ_DEFAULT_GRAN_THLD);
}
return status;
}
/*******************************************************************************
Function:
zl5011xCpqConfigureQueue
Description:
Sets the queue overrun threshold and maximum queue size. If the queue is
configured to drop packets when the threshold is reached, then the maximum
size in terms of granules will never be reached.
Inputs:
zl5011xParams Pointer to the structure for this device instance
queue The queue on which to set the threshold
overrunThld Overrun threshold
enablePacketDrop Enables/disables packet dropping mode
maxGranUsage Sets the maximum number of granules to be held in the
queue
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xCpqConfigureQueue(zl5011xParamsS *zl5011xParams,
zl5011xQueueE queue, Uint32T overrunThld,
zl5011xBooleanE enablePacketDrop)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqConfigureQueue: Queue %d, Threshold %d, Drop Mode %d",
queue, overrunThld, enablePacketDrop, 0, 0, 0);
/* Check enum parameter is within range */
status = ZL5011X_CHECK_QUEUE_NUMBER(queue);
if(status == ZL5011X_OK)
{
status = ZL5011X_CHECK_BOOLEAN(enablePacketDrop);
}
if(status == ZL5011X_OK)
{
/* Set overrun threshold */
status = zl5011xCpqSetOverrunThreshold(zl5011xParams, queue,
overrunThld);
}
if(status == ZL5011X_OK)
{
/* Set packet dropping mode */
status = zl5011xCpqSetOverrunMode(zl5011xParams, queue, enablePacketDrop);
}
return status;
}
/*******************************************************************************
Function:
zl5011xCpqSetOverrunThreshold
Description:
Sets the overrun threshold.
Inputs:
zl5011xParams Pointer to the structure for this device instance
queue The queue to be configured
overrunThld QoS parameter used to limit the capacity of queues
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xCpqSetOverrunThreshold(zl5011xParamsS *zl5011xParams,
zl5011xQueueE queue, Uint32T overrunThld)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_CPQ_FN_ID,"zl5011xCpqSetOverrunThreshold: Queue %d,Threshold %d",
queue, overrunThld, 0, 0, 0, 0);
/* Check queue number is within range */
status = ZL5011X_CHECK_QUEUE_NUMBER(queue);
/* Check parameter for illegal value */
if (status == ZL5011X_OK)
{
if ((overrunThld & ~ZL5011X_CPQ_OVERRUN_THLD_CHECK) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
/* Set overrun threshold to a queue */
status = zl5011xWrite(zl5011xParams,
ZL5011X_CPQ_OVERFLOW + (queue * sizeof(Uint32T)), overrunThld);
/* Record parameters to device structure */
zl5011xParams->cpuIf.overrunThreshold[queue] = overrunThld;
}
return status;
}
/*******************************************************************************
Function:
zl5011xCpqSetOverrunMode
Description:
Enables or disables packet dropping. When in enabled mode, packets will
be dropped when overrun threshold is exceeded.
Inputs:
zl5011xParams Pointer to the structure for this device instance
queue The queue on which to set overrun mode
enablePacketDrop ZL5011X_TRUE to drop packets when the threshold is
exceeded or ZL5011X_FALSE to continue
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xCpqSetOverrunMode(zl5011xParamsS *zl5011xParams,
zl5011xQueueE queue, zl5011xBooleanE enablePacketDrop)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits, bitMask;
ZL5011X_TRACE(ZL5011X_CPQ_FN_ID, "zl5011xCpqSetOverrunMode: Queue %d, Mode %d",
queue, enablePacketDrop, 0, 0, 0, 0);
/* Check enum parameter is within range */
status = ZL5011X_CHECK_QUEUE_NUMBER(queue);
if(status == ZL5011X_OK)
{
status = ZL5011X_CHECK_BOOLEAN(enablePacketDrop);
}
/* Set packet dropping */
if (status == ZL5011X_OK)
{
bitMask = ZL5011X_1BIT_MASK << (queue +ZL5011X_CPQ_ENABLE_THRES_DROP0);
if (enablePacketDrop == ZL5011X_TRUE)
{
bits = bitMask;
}
else
{
bits = 0;
}
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_CPQ_CONTROL,
bits, bitMask);
/* Record parameters in device structure */
zl5011xParams -> cpuIf.enablePacketDrop[queue] = enablePacketDrop;
}
return status;
}
/*******************************************************************************
Function:
zl5011xCpqSetGranuleUsage
Description:
Controls the maximum number of granules that can be used by the CPQ.
Inputs:
zl5011xParams Pointer to the structure for this device instance
maxNumberOfGranules Maximum number of granules used by CPQ.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -