?? zl5011xpkq.c
字號:
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkqSetGranuleThreshold(zl5011xParamsS *zl5011xParams,
Uint8T portNumber,
Uint8T queueNumber,
Uint32T granuleThreshold)
{
zlStatusE status = ZL5011X_OK;
Uint32T registerOffset;
ZL5011X_TRACE(ZL5011X_PKQ_FN_ID,
"zl5011xPkqSetGranuleThreshold: Port %ld, Queue %ld, Threshold %ld",
portNumber, queueNumber, granuleThreshold, 0, 0, 0);
if ((granuleThreshold >= zl5011xParams->pkq.totalGranuleThreshold) ||
(granuleThreshold > ZL5011X_PKQ_MAX_GRAN_THLD))
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
/* check queue number is in range */
if (queueNumber >= ZL5011X_PKQ_NUM_QUEUES)
{
status= ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
/* Calculate register address */
registerOffset = ZL5011X_PKQ_GTA0 +
((portNumber * ZL5011X_PKQ_NUM_QUEUES) + queueNumber) * sizeof(Uint32T);
/* Set granule threshold */
status = zl5011xWrite(zl5011xParams, registerOffset, granuleThreshold);
}
/* Store set up values in device structure */
zl5011xParams->pkq.granuleThreshold[portNumber][queueNumber] = granuleThreshold;
return (status);
}
/*******************************************************************************
Function:
zl5011xPkqSetThresholdMode
Description:
Sets the packet dropping mode for a particular queue.
Inputs:
zl5011xParams Pointer to the structure for this device instance
portNumber LAN port number
queueNumber Queue number
thresholdMode ZL5011X_TRUE to drop packets when granule threshold is
exceeded. ZL5011X_FALSE to continue.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkqSetThresholdMode(zl5011xParamsS *zl5011xParams,
Uint8T portNumber,
Uint8T queueNumber,
zl5011xBooleanE thresholdMode)
{
zlStatusE status = ZL5011X_OK;
Uint32T bitMask, bits;
ZL5011X_TRACE(ZL5011X_PKQ_FN_ID,
"zl5011xPkqSetThresholdMode: Port %ld, Queue %ld, Mode %ld",
portNumber, queueNumber, thresholdMode, 0, 0, 0);
if (status == ZL5011X_OK)
{
/* check queue number is in range */
if (queueNumber >= ZL5011X_PKQ_NUM_QUEUES)
{
status= ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_BOOLEAN(thresholdMode);
}
bitMask = ZL5011X_1BIT_MASK <<
((portNumber * ZL5011X_PKQ_NUM_QUEUES) + queueNumber);
if (thresholdMode == ZL5011X_TRUE)
{
bits = bitMask;
}
else
{
bits = 0;
}
if (status == ZL5011X_OK)
{
/* control the queue dropping */
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_PKQ_QDER,
bits, bitMask);
}
/* Store set up values in device structure */
zl5011xParams->pkq.thresholdMode[portNumber][queueNumber] = thresholdMode;
return (status);
}
/*******************************************************************************
Function:
zl5011xPkqSetTotalGranuleThreshold
Description:
Sets maximum granule memory allowed to be used for all of the queues.
Inputs:
zl5011xParams Pointer to the structure for this device instance
totalGranuleThreshold Total granule threshold for all queues.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkqSetTotalGranuleThreshold(zl5011xParamsS *zl5011xParams,
Uint32T totalGranuleThreshold)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKQ_FN_ID,
"zl5011xPkqSetTotalGranuleThreshold: Threshold %ld",
totalGranuleThreshold, 0, 0, 0, 0, 0);
if (totalGranuleThreshold > ZL5011X_PKQ_MAX_GRAN_THLD)
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
/* Set granule threshold */
status = zl5011xWrite(zl5011xParams, ZL5011X_PKQ_TGTR, totalGranuleThreshold);
/* Store set up values in device structure */
zl5011xParams->pkq.totalGranuleThreshold = totalGranuleThreshold;
}
return (status);
}
/*******************************************************************************
Function:
zl5011xPkqSetTotalThresholdMode
Description:
Sets the packet dropping mode for all queues.
Inputs:
zl5011xParams Pointer to the structure for this device instance
totalThresholdMode ZL5011X_TRUE to drop packets when total granule threshold
is exceeded. ZL5011X_FALSE to continue.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkqSetTotalThresholdMode(zl5011xParamsS *zl5011xParams,
zl5011xBooleanE totalThresholdMode)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKQ_FN_ID,
"zl5011xPkqSetTotalThresholdMode: mode %ld",
totalThresholdMode, 0, 0, 0, 0, 0);
status = ZL5011X_CHECK_BOOLEAN(totalThresholdMode);
if (status == ZL5011X_OK)
{
if (totalThresholdMode == ZL5011X_TRUE)
{
/* Enable total threshold mode */
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_PKQ_QDER,
ZL5011X_PKQ_TOTAL_THLD_MODE, ZL5011X_PKQ_TOTAL_THLD_MODE);
}
else
{
/* Disable total threshold mode */
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_PKQ_QDER,
~ZL5011X_PKQ_TOTAL_THLD_MODE, ZL5011X_PKQ_TOTAL_THLD_MODE);
}
}
/* Store set up values in device structure */
zl5011xParams->pkq.totalThresholdMode = totalThresholdMode;
return (status);
}
/*******************************************************************************
Function:
zl5011xPkqSetMpidConnection
Description:
Sets the output queue on a per context basis. In the device, the mapping from
context in the WAN Rx to MPID in the PKQ is a simple 1:1.
16 further MPID's are also defined, for use in host Tx.
Inputs:
zl5011xParams Pointer to the structure for this device instance
mpid MPID number
portNumber LAN port number to be assigned to the MPID
queueNumber Queue number to be assigned to the MPID
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkqSetMpidConnection(zl5011xParamsS *zl5011xParams, Uint32T mpid,
Uint8T portNumber,
Uint8T queueNumber)
{
zlStatusE status = ZL5011X_OK;
Uint32T data, bitMask, regAddress;
ZL5011X_TRACE(ZL5011X_PKQ_FN_ID,"zl5011xPkqSetMpidConnection: MPID %ld, Port %ld, Queue %ld",
mpid, portNumber, queueNumber, 0, 0, 0);
/* Check MPID is within range */
if (mpid >= (ZL5011X_PKT_TX_NUM_CONTEXT_HEADERS + ZL5011X_PKT_TX_NUM_HOST_HEADERS))
{
status = ZL5011X_PARAMETER_INVALID;
}
/* Check enumerated parameters are within range */
if (status == ZL5011X_OK)
{
/* check queue number is in range */
if (queueNumber >= ZL5011X_PKQ_NUM_QUEUES)
{
status= ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
/* Calculate register address in context table */
regAddress = ZL5011X_PKQ_CONTEXT_TABLE +
((mpid / ZL5011X_PKQ_NUM_OF_CT_FIELDS) * sizeof(Uint32T));
/* Calculate data and position of data to be written into context table */
data = portNumber << ZL5011X_PKQ_PORT_SHIFT;
data |= queueNumber;
data = data << ((mpid % ZL5011X_PKQ_NUM_OF_CT_FIELDS) *
ZL5011X_SIZE_OF_PORT_AND_QUEUE_FIELD);
/* Enable bits to be written into context table word */
bitMask = ZL5011X_4BIT_MASK << ((mpid % ZL5011X_PKQ_NUM_OF_CT_FIELDS) *
ZL5011X_SIZE_OF_PORT_AND_QUEUE_FIELD);
status = zl5011xReadModWrite(zl5011xParams, regAddress, data, bitMask);
/* note the port and queue settings */
zl5011xParams->pkq.wanRxPortNum[mpid] = portNumber;
zl5011xParams->pkq.wanRxQueueNum[mpid] = queueNumber;
}
return (status);
}
/*******************************************************************************
Function:
zl5011xPkqGetMpidConnection
Description:
Gets the output port / queue on a per context basis.
Inputs:
zl5011xParams Pointer to the structure for this device instance
mpid MPID number
Outputs:
portNumber LAN port number assigned to the MPID
queueNumber Queue number assigned to the MPID
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkqGetMpidConnection(zl5011xParamsS *zl5011xParams, Uint32T mpid,
Uint8T *portNumber,
Uint8T *queueNumber)
{
zlStatusE status = ZL5011X_OK;
Uint32T data, bitMask, regAddress;
ZL5011X_TRACE(ZL5011X_PKQ_FN_ID,"zl5011xPkqGetMpidConnection: MPID %ld",
mpid, 0, 0, 0, 0, 0);
/* Check MPID is within range */
if (mpid >= (ZL5011X_PKT_TX_NUM_CONTEXT_HEADERS + ZL5011X_PKT_TX_NUM_HOST_HEADERS))
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
/* Calculate register address in context table */
regAddress = ZL5011X_PKQ_CONTEXT_TABLE +
((mpid / ZL5011X_PKQ_NUM_OF_CT_FIELDS) * sizeof(Uint32T));
/* Enable bits to be written into context table word */
bitMask = ZL5011X_4BIT_MASK << ((mpid % ZL5011X_PKQ_NUM_OF_CT_FIELDS) *
ZL5011X_SIZE_OF_PORT_AND_QUEUE_FIELD);
status = zl5011xRead(zl5011xParams, regAddress, &data);
/* Calculate data and position of data to be written into context table */
data = data >> ((mpid % ZL5011X_PKQ_NUM_OF_CT_FIELDS) *
ZL5011X_SIZE_OF_PORT_AND_QUEUE_FIELD);
*portNumber = (Uint8T)(data >> ZL5011X_PKQ_PORT_SHIFT) & 0x3;
*queueNumber = (Uint8T)data & 0x3;
}
return (status);
}
/*******************************************************************************
Function:
zl5011xPkqGetDropStatus
Description:
This function reads back the interrupt status register
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
ptr to Status value returned
Returns:
zlStatusE
Remarks:
*******************************************************************************/
zlStatusE zl5011xPkqGetDropStatus(zl5011xParamsS *zl5011xParams,
Uint32T *pStatus)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKQ_FN_ID, "zl5011xPkqGetDropStatus:",0, 0, 0, 0, 0, 0);
if( pStatus== NULL)
{
status= ZL5011X_PARAMETER_INVALID;
}
if( status== ZL5011X_OK)
{
status = zl5011xRead(zl5011xParams, ZL5011X_PKQ_QDR, pStatus);
}
if( status== ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_PKC_FN_ID, "zl5011xPkqGetDropStatus: reads status 0x%.08lx",
*pStatus, 0, 0, 0, 0, 0);
}
return (status);
}
/***************** END ****************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -