📄 zl5011xtfq.c
字号:
Outputs:
active ZL5011X_TRUE if the queue is active
Returns:
zlStatusE
Remarks:
Checks that the queue has resumed - bit is clear. But, if the queue hasn't
even been started (resume bit set) then the return will be meaningless.
*******************************************************************************/
zlStatusE zl5011xTfqGetQueueStatus(zl5011xParamsS *zl5011xParams, Uint32T context, zl5011xBooleanE *active)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits, regAddress;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqGetQueueStatus: ctxt %3ld",
context, 0, 0, 0, 0, 0);
regAddress = ZL5011X_TFQ_CTXT_STATIC_SETUP + (context * ZL5011X_TFQ_CTXT_CONTROL_SIZE);
/* read the current state of the register, to check that neither
flush or resume are already set */
status = zl5011xRead(zl5011xParams, regAddress, &bits);
if (status == ZL5011X_OK)
{
if ((bits & (ZL5011X_1BIT_MASK << ZL5011X_TFQ_RESUME_BIT)) == 0)
{
*active = ZL5011X_TRUE;
}
else
{
*active = ZL5011X_FALSE;
}
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTfqResetLengths
Description:
The minimum and maximum queue lengths are continually monitored by the device.
The value is used in the adaptive clocking algorithm (for asynchronous WAN
operation).
The measurements will generally be reset when reading the queue depths.
A reset cannot take place if any of the following actions is already in
progress:-
* reset of min or max length
* extend / reduce of the queue depth.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context to use
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTfqResetLengths(zl5011xParamsS *zl5011xParams, Uint32T context)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits, regAddress, checkMask;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqResetLengths: ctxt %3ld",
context, 0, 0, 0, 0, 0);
regAddress = ZL5011X_TFQ_CTXT_DYNAMIC_SETUP + (context * ZL5011X_TFQ_CTXT_CONTROL_SIZE);
/* read the current state of the register, to check that none of the
following bits are already set: extend, reduce, reset min / max lengths */
status = zl5011xRead(zl5011xParams, regAddress, &bits);
if (status == ZL5011X_OK)
{
checkMask = (ZL5011X_1BIT_MASK << ZL5011X_TFQ_EXTEND_QUEUE_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TFQ_REDUCE_QUEUE_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TFQ_CLEAR_MIN_LENGTH_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TFQ_CLEAR_MAX_LENGTH_BIT);
if ((bits & checkMask) != 0)
{
status = ZL5011X_WAN_QUEUE_LENGTH_BUSY;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqResetLengths: ctxt %3ld, BUSY - mask =0x%08lx",
context, bits, 0, 0, 0, 0);
}
}
if (status == ZL5011X_OK)
{
bits |= (ZL5011X_1BIT_MASK << ZL5011X_TFQ_CLEAR_MIN_LENGTH_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TFQ_CLEAR_MAX_LENGTH_BIT);
status = zl5011xWrite(zl5011xParams, regAddress, bits);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTfqExtendQueueDepth
Description:
The queue depth may be modified during operation, to control the size of
the jitter buffer.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context to use
packet changes the queue depth by a packet when ZL5011X_TRUE,
uses the byte parameter when ZL5011X_FALSE
bytes number of bytes to change the queue depth by
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTfqExtendQueueDepth(zl5011xParamsS *zl5011xParams, Uint32T context,
zl5011xBooleanE packet, Uint32T bytes)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqExtendQueueDepth: ctxt %3ld, mode %d, len %d",
context, packet, bytes, 0, 0, 0);
/* call the function that does the checking and setting of bits */
status = zl5011xTfqChangeQueueDepth(zl5011xParams, context, packet, bytes,
ZL5011X_TFQ_EXTEND_QUEUE_BIT, ZL5011X_TFQ_EXTEND_SIZE_BITS,
ZL5011X_TFQ_EXTEND_SIZE_MASK);
return(status);
}
/*******************************************************************************
Function:
zl5011xTfqReduceQueueDepth
Description:
The queue depth may be modified during operation, to control the size of
the jitter buffer.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context to use
packet changes the queue depth by a packet when ZL5011X_TRUE,
uses the byte parameter when ZL5011X_FALSE
bytes number of bytes to change the queue depth by
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTfqReduceQueueDepth(zl5011xParamsS *zl5011xParams, Uint32T context,
zl5011xBooleanE packet, Uint32T bytes)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqReduceQueueDepth: ctxt %3ld, mode %d, len %d",
context, packet, bytes, 0, 0, 0);
/* call the function that does the checking and setting of bits */
status = zl5011xTfqChangeQueueDepth(zl5011xParams, context, packet, bytes,
ZL5011X_TFQ_REDUCE_QUEUE_BIT, ZL5011X_TFQ_REDUCE_SIZE_BITS,
ZL5011X_TFQ_REDUCE_SIZE_MASK);
return(status);
}
/*******************************************************************************
Function:
zl5011xTfqChangeQueueDepth
Description:
This function is used by both the extend and reduce queue depth functions.
The bit positions for the extend and reduce are passed in as parameters to
this function.
A queue length modification cannot take place if any of the following
actions is already in progress:-
* reset of min or max length
* extend / reduce of the queue depth.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context to use
packet changes the queue depth by a packet when ZL5011X_TRUE,
uses the byte parameter when ZL5011X_FALSE
bytes number of bytes to change the queue depth by
bitPos position of the enable field for this modification
lengthPos position of the length field for this modification
lengthMask bit mask for the length field
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTfqChangeQueueDepth(zl5011xParamsS *zl5011xParams, Uint32T context,
zl5011xBooleanE packet, Uint32T bytes,
Uint32T bitPos, Uint32T lengthPos, Uint32T lengthMask)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits, regAddress, checkMask;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqChangeQueueDepth: ctxt %3ld, bit pos %d, len pos %d, len mask %d",
context, bitPos, lengthPos, lengthMask, 0, 0);
regAddress = ZL5011X_TFQ_CTXT_STATIC_SETUP + (context * ZL5011X_TFQ_CTXT_CONTROL_SIZE);
/* read the current state of the register, to check that neither
flush or resume are already set */
status = zl5011xRead(zl5011xParams, regAddress, &bits);
if (status == ZL5011X_OK)
{
if ((bits & (ZL5011X_1BIT_MASK << ZL5011X_TFQ_RESUME_BIT)) != 0)
{
status = ZL5011X_WAN_QUEUE_IN_RESUME;
}
if ((bits & (ZL5011X_1BIT_MASK << ZL5011X_TFQ_FLUSH_BIT)) != 0)
{
status = ZL5011X_WAN_QUEUE_IN_FLUSH;
}
}
if (status == ZL5011X_OK)
{
regAddress = ZL5011X_TFQ_CTXT_DYNAMIC_SETUP +
(context * ZL5011X_TFQ_CTXT_CONTROL_SIZE);
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_BOOLEAN(packet);
}
/* read the current state of the register, to check that none of the
following bits are already set:
extend, reduce, reset min and max lengths */
if (status == ZL5011X_OK)
{
status = zl5011xRead(zl5011xParams, regAddress, &bits);
}
if (status == ZL5011X_OK)
{
checkMask = (ZL5011X_1BIT_MASK << ZL5011X_TFQ_EXTEND_QUEUE_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TFQ_REDUCE_QUEUE_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TFQ_CLEAR_MIN_LENGTH_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TFQ_CLEAR_MAX_LENGTH_BIT);
if ((bits & checkMask) != 0)
{
status = ZL5011X_WAN_QUEUE_LENGTH_BUSY;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqChangeQueueDepth: ctxt %3ld, BUSY - mask = 0x%08lx",
context, bits, 0, 0, 0, 0);
}
}
if (status == ZL5011X_OK)
{
/* clear the length field and set the extend bit */
bits &= ~(lengthMask << lengthPos);
bits |= ZL5011X_1BIT_MASK << bitPos;
/* need to set the length if not changing by a complete packet */
if (packet == ZL5011X_FALSE)
{
if ((bytes & ~lengthMask) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
bits |= (bytes << lengthPos);
}
}
}
if (status == ZL5011X_OK)
{
status = zl5011xWrite(zl5011xParams, regAddress, bits);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTfqSetGranuleUsage
Description:
Controls the maximum number of granules that can be used by the TFQ.
Inputs:
zl5011xParams Pointer to the structure for this device instance
maxNumberOfGranules Maximum number of granules used by TFQ.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTfqSetGranuleUsage(zl5011xParamsS *zl5011xParams,
Uint32T maxNumberOfGranules)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TFQ_FN_ID, "zl5011xTfqSetGranuleUsage: max granules %d",
maxNumberOfGranules, 0, 0, 0, 0, 0);
/* Check for valid parameter value */
if((maxNumberOfGranules & ~ZL5011X_TFQ_MAX_NUM_GRANULES_MASK) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
if(status == ZL5011X_OK)
{
/* Set maximum queue size in granules */
status = zl5011xWrite(zl5011xParams, ZL5011X_TFQ_MAX_QUEUE_SIZE,
maxNumberOfGranules << ZL5011X_TFQ_MAX_NUM_GRANULES_BITS);
/* Record paramter value in device structure */
zl5011xParams->wanIf.txQueueMaxNumberOfGranules = maxNumberOfGranules;
}
return status;
}
/*******************************************************************************
Function:
zl5011xTfqGetMinMaxLengths
Description:
This function is used to read the min and max queue lengths from the device.
The lengths are used in the adaptive clocking algorithm (for asynchronous
WAN operation). These would inidcate the bursty nature of the link, and show
if the queue was approaching either end.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context to use
Outputs:
minLength min length of the queue
maxLength max length of the queue
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTfqGetMinMaxLengths(zl5011xParamsS *zl5011xParams, Uint32T context,
Uint32T *minLength, Uint32T *maxLength)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits, regAddress;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqGetMinMaxLengths: ctxt %3ld",
context, 0, 0, 0, 0, 0);
regAddress = ZL5011X_TFQ_CTXT_MIN_MAX_LENGTH + (context * ZL5011X_TFQ_CTXT_CONTROL_SIZE);
/* read the register that holds the length bits */
status = zl5011xRead(zl5011xParams, regAddress, &bits);
if (status == ZL5011X_OK)
{
/* extract the bits from the register for the length fields */
*minLength = (bits >> ZL5011X_TFQ_MIN_QUEUE_LENGTH_BITS) &
ZL5011X_TFQ_QUEUE_LENGTH_MASK;
*maxLength = (bits >> ZL5011X_TFQ_MAX_QUEUE_LENGTH_BITS) &
ZL5011X_TFQ_QUEUE_LENGTH_MASK;
(*maxLength)++;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqGetMinMaxLengths: ctxt %3ld, min %d, max %d",
context, *minLength, *maxLength, 0, 0, 0);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTfqGetAvgLength
Description:
This function is used to read the average queue length from the device.
The length is used to keep track of the latency and avoid the queue running
out of bounds.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context to use
Outputs:
avgLength average length of the queue
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTfqGetAvgLength(zl5011xParamsS *zl5011xParams, Uint32T context,
Uint32T *avgLength)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits, regAddress, mask, maxQueue;
ZL5011X_TRACE_CONTEXT(ZL5011X_TFQ_FN_ID, context, "zl5011xTfqGetAvgLength: ctxt %3ld",
context, 0, 0, 0, 0, 0);
regAddress = ZL5011X_TFQ_CTXT_AVG_LENGTH + (context * ZL5011X_TFQ_CTXT_CONTROL_SIZE);
/* read the register that holds the length bits */
status = zl5011xRead(zl5011xParams, regAddress, &bits);
if (status == ZL5011X_OK)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -