?? zl5011xtm.c
字號:
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTmWriteLookUpRam(zl5011xParamsS *zl5011xParams,
zl5011xFlowTypeE flow, zl5011xTmSrcPortE srcPort, zl5011xTmDestPortE destPort)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits;
AddressT address;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmWriteLookUpRam: flow %d, src port %d, dest port %d",
flow, srcPort, destPort, 0, 0, 0);
status = ZL5011X_CHECK_FLOW_TYPE(flow);
/* check that the port ID's are valid */
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_SRC_PORT(srcPort);
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_DEST_PORT(destPort);
}
if (status == ZL5011X_OK)
{
/* the address within the lookup RAM is determined by the flow.
Which lookup RAM to use, is determined by the source port, and the
address offset of the lookup RAM is
number of entries in the RAM x size of each entry x 2
The 2 is because the lookup RAM's are spaced in memory by a complete RAM,
which is not implemented */
address = ZL5011X_TM_LOOKUP_RAM + (flow * ZL5011X_TM_LOOKUP_RAM_SIZE) +
(srcPort * (2 * ZL5011X_TM_LOOKUP_RAM_SIZE * ZL5011X_TM_NUM_LOOKUP_RAM_ENTRIES));
bits = (destPort & ZL5011X_TM_LOOKUP_RAM_MASK) << ZL5011X_TM_LOOKUP_RAM_BITS;
status = zl5011xWrite(zl5011xParams, address, bits);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTmConfigureInputBuffer
Description:
This configures the destination queue sizes with in the input source port.
Each TM message uses 16 bytes (4 words), and the total queue size is
2048 bytes (512 words). In addition, there is a maximum size for each queue.
Inputs:
zl5011xParams Pointer to the structure for this device instance
srcPort TM source port
cpuSize size for the destination queue in the source port
tfqSize size for the destination queue in the source port
rtpSize size for the destination queue in the source port
pkqSize size for the destination queue in the source port
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTmConfigureInputBuffer(zl5011xParamsS *zl5011xParams,
zl5011xTmSrcPortE srcPort, Uint32T cpuSize, Uint32T tfqSize,
Uint32T rtpSize, Uint32T pkqSize)
{
zlStatusE status = ZL5011X_OK;
AddressT startAddress, endAddress;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmConfigureInputBuffer: src port %d, cpu %d, tfq %d, rtp %d, pkq %d",
srcPort, cpuSize, tfqSize, rtpSize, pkqSize, 0);
/* check the requested size of each of the queues */
status = ZL5011X_CHECK_TM_PORT_SIZE(cpuSize);
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_PORT_SIZE(tfqSize);
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_PORT_SIZE(rtpSize);
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_PORT_SIZE(pkqSize);
}
/* check the total size of the queues, to check that they are in limits */
if (status == ZL5011X_OK)
{
if ((cpuSize + tfqSize + rtpSize + pkqSize) > ZL5011X_TM_PORT_TOTAL_QUEUE_SIZE)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
/* set the start, end address and size for the CPU segment of the input port */
if (status == ZL5011X_OK)
{
startAddress = 0;
endAddress = cpuSize * ZL5011X_TM_MESSAGE_SIZE_WORDS;
/* set the addresses */
status = zl5011xTmSetInputBufferAddress(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_CPU, startAddress, endAddress - 1);
/* set the size of the queue */
if (status == ZL5011X_OK)
{
status = zl5011xTmSetInputBufferSize(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_CPU, cpuSize * ZL5011X_TM_MESSAGE_SIZE_WORDS);
}
}
/* set the start, end address and size for the TFQ segment of the input port */
if (status == ZL5011X_OK)
{
startAddress = endAddress;
endAddress += tfqSize * ZL5011X_TM_MESSAGE_SIZE_WORDS;
/* set the addresses */
status = zl5011xTmSetInputBufferAddress(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_TFQ, startAddress, endAddress - 1);
/* set the size of the queue */
if (status == ZL5011X_OK)
{
status = zl5011xTmSetInputBufferSize(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_TFQ, tfqSize * ZL5011X_TM_MESSAGE_SIZE_WORDS);
}
}
/* set the start, end address and size for the RTP segment of the input port */
if (status == ZL5011X_OK)
{
startAddress = endAddress;
endAddress += rtpSize * ZL5011X_TM_MESSAGE_SIZE_WORDS;
/* set the addresses */
status = zl5011xTmSetInputBufferAddress(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_RTP, startAddress, endAddress - 1);
/* set the size of the queue */
if (status == ZL5011X_OK)
{
status = zl5011xTmSetInputBufferSize(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_RTP, rtpSize * ZL5011X_TM_MESSAGE_SIZE_WORDS);
}
}
/* set the start, end address and size for the PKQ segment of the input port */
if (status == ZL5011X_OK)
{
startAddress = endAddress;
endAddress += pkqSize * ZL5011X_TM_MESSAGE_SIZE_WORDS;
/* set the addresses */
status = zl5011xTmSetInputBufferAddress(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_PKQ, startAddress, endAddress - 1);
/* set the size of the queue */
if (status == ZL5011X_OK)
{
status = zl5011xTmSetInputBufferSize(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_PKQ, pkqSize * ZL5011X_TM_MESSAGE_SIZE_WORDS);
}
}
/* set the start, end address and size for the unused segment
of the input port */
if (status == ZL5011X_OK)
{
startAddress = endAddress;
endAddress += 1 * ZL5011X_TM_MESSAGE_SIZE_WORDS;
status = zl5011xTmSetInputBufferAddress(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_UNUSED, startAddress, endAddress - 1);
/* set the size of the queue */
if (status == ZL5011X_OK)
{
status = zl5011xTmSetInputBufferSize(zl5011xParams, srcPort,
ZL5011X_TM_DEST_PORT_UNUSED, 1 * ZL5011X_TM_MESSAGE_SIZE_WORDS);
}
}
if (status == ZL5011X_OK)
{
/* update the device structure */
zl5011xParams->taskManager.portSizes[srcPort][ZL5011X_TM_DEST_PORT_CPU] = cpuSize;
zl5011xParams->taskManager.portSizes[srcPort][ZL5011X_TM_DEST_PORT_TFQ] = tfqSize;
zl5011xParams->taskManager.portSizes[srcPort][ZL5011X_TM_DEST_PORT_RTP] = rtpSize;
zl5011xParams->taskManager.portSizes[srcPort][ZL5011X_TM_DEST_PORT_PKQ] = pkqSize;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTmSetInputBufferAddress
Description:
This sets the start and end address for the queue (within the input port).
The address is specified in 32 bit words, and a TM message is 4 x 32 bit
words. The queue must be able to hold at least 1 message.
Inputs:
zl5011xParams Pointer to the structure for this device instance
srcPort TM source port
destPort TM destination port
startAddress start address for the queue in words (32 bits)
endAddress end address for the queue in words (32 bits)
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTmSetInputBufferAddress(zl5011xParamsS *zl5011xParams,
zl5011xTmSrcPortE srcPort, zl5011xTmDestPortE destPort,
AddressT startAddress, AddressT endAddress)
{
zlStatusE status = ZL5011X_OK;
AddressT address;
Uint32T bits;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmSetInputBufferAddress: src port %d, dest port %d, start %d, end %d",
srcPort, destPort, startAddress, endAddress, 0, 0);
/* check that the port ID's are valid */
status = ZL5011X_CHECK_TM_SRC_PORT(srcPort);
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_DEST_PORT(destPort);
}
/* check that the addresses are valid */
if (status == ZL5011X_OK)
{
if ((startAddress & ~ZL5011X_TM_INPUT_SEG_ADDRESS_MASK) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
if ((endAddress & ~ZL5011X_TM_INPUT_SEG_ADDRESS_MASK) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
if (endAddress < (startAddress + ZL5011X_TM_MESSAGE_SIZE_WORDS - 1))
{
status = ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
/* program the new addresses */
bits = (startAddress << ZL5011X_TM_INPUT_SEG_START_BITS) |
(endAddress << ZL5011X_TM_INPUT_SEG_END_BITS);
/* get the base address for the input port registers */
address = ZL5011X_TM_PORT0_BASE + (srcPort * ZL5011X_TM_PORT_REG_SIZE);
/* get the address of the segment offset for the destination port */
address += ZL5011X_TM_SEG_ADDRESS_OFFSET + (destPort * sizeof(Uint32T));
status = zl5011xWrite(zl5011xParams, address, bits);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTmSetInputBufferSize
Description:
This sets the size of the queue (within the input port).
The size is specified in 32 bit words, and a TM message is 4 x 32 bit
words.
The queue size for odd and even numbered queues is stored in the high
and low 16 bits of a shared register.
Inputs:
zl5011xParams Pointer to the structure for this device instance
srcPort TM source port
destPort TM destination port
size size of the queue in words (32 bits)
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTmSetInputBufferSize(zl5011xParamsS *zl5011xParams,
zl5011xTmSrcPortE srcPort, zl5011xTmDestPortE destPort, Uint32T size)
{
zlStatusE status = ZL5011X_OK;
AddressT address;
Uint32T bits, bitMask;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmSetInputBufferSize: src port %d, dest port %d, size %d",
srcPort, destPort, size, 0, 0, 0);
/* check that the port ID's are valid */
status = ZL5011X_CHECK_TM_SRC_PORT(srcPort);
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_DEST_PORT(destPort);
}
if (status == ZL5011X_OK)
{
bits = size;
bitMask = ZL5011X_TM_SEG_SPACE_MASK;
/* the odd and even ports share the same register for the buffer size,
so need to use a different shift for odd bits */
if ((destPort & 1) == 0)
{
/* this is an even numbered port */
bits <<= ZL5011X_TM_EVEN_SEG_SPACE_BITS;
bitMask <<= ZL5011X_TM_EVEN_SEG_SPACE_BITS;
}
else
{
/* this is an odd numbered port */
bits <<= ZL5011X_TM_ODD_SEG_SPACE_BITS;
bitMask <<= ZL5011X_TM_ODD_SEG_SPACE_BITS;
}
/* get the base address for the input port registers */
address = ZL5011X_TM_PORT0_BASE + (srcPort * ZL5011X_TM_PORT_REG_SIZE);
/* get the address of the segment offset for the destination port */
address += ZL5011X_TM_SEG_SPACE_OFFSET + ((destPort / 2) * sizeof(Uint32T));
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -