?? zl5011xpkcclassify.c
字號(hào):
}
return status;
}
/*******************************************************************************
Function:
zl5011xPkcClassifySetGeneralMatch
Description:
This function is used to setup a classifier match for a non-context packet.
That is a control packet destined for the host.
For host connection, the mpid would be set to indicate one of the CPU queues
(0 to 3).
Inputs:
zl5011xParams Pointer to the structure for this device instance
matchNum the number of the entry to disable
match structure containing the classifier match settings
flow the flow type to be used for the matched packet
mpid the MPID to be used for the matched packet.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkcClassifySetGeneralMatch(zl5011xParamsS *zl5011xParams,
Uint32T matchNum, zl5011xPacketClassifyMatchS *match,
zl5011xFlowTypeE flow, Uint32T mpid)
{
Uint32T tempWord[(ZL5011X_PKC_CLASSIFY_OUTPUT_RAM_SIZE / 4) + 1];
Uint8T tempPos = 0;
Uint8T index = 0;
Uint32T address;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKC_FN_ID,
"zl5011xPkcClassifySetGeneralMatch: match %3d, flow %d, mpid %3d",
matchNum, flow, mpid, 0, 0, 0);
/* check that the parameters are okay */
if ((matchNum >= ZL5011X_PKC_NUM_CLASSIFY_ENTRIES) ||
(match == NULL))
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
if (match->protocolMatchNum >= ZL5011X_PKC_NUM_PROTOCOL_ENTRIES)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_FLOW_TYPE(flow);
}
/* setup the match, mask and check fields for the recognition
stage of the classifier */
if (status == ZL5011X_OK)
{
status = zl5011xPkcClassifySetMatchField(zl5011xParams, matchNum,
match->classifyMatchBytes, match->protocolMatchNum);
}
if (status == ZL5011X_OK)
{
status = zl5011xPkcClassifySetMaskField(zl5011xParams,
matchNum, match->classifyMaskBytes);
}
if (status == ZL5011X_OK)
{
status = zl5011xPkcClassifySetCheckField(zl5011xParams,
matchNum, match->classifyCheckBytes);
}
/* set up the output Ram */
address = ZL5011X_PKC_CLASSIFY_OUTPUT_RAM +
(matchNum * ZL5011X_PKC_CLASSIFY_OUTPUT_RAM_SIZE);
if (status == ZL5011X_OK)
{
/* the first field in the output RAM is the flow type */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
flow, ZL5011X_PKC_CLASSIFY_SIZE_FLOW_FIELD);
}
if (status == ZL5011X_OK)
{
/* the next field is the MPID */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
mpid, ZL5011X_PKC_CLASSIFY_SIZE_MPID_FIELD);
}
if (status == ZL5011X_OK)
{
/* fill the header offset and length fields with 0 */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
0,
ZL5011X_PKC_CLASSIFY_SIZE_OFFSET_FIELD +
ZL5011X_PKC_CLASSIFY_SIZE_LENGTH_FIELD);
}
if (status == ZL5011X_OK)
{
/* set the raw packet length field to 1, since the packet length will
be used for transfer to the host */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
1, ZL5011X_PKC_CLASSIFY_SIZE_RAW_LENGTH_FIELD);
}
if (status == ZL5011X_OK)
{
/* fill all of the remaining fields with 0 */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
0,
ZL5011X_PKC_CLASSIFY_SIZE_LENGTH_CHG_FIELD +
ZL5011X_PKC_CLASSIFY_SIZE_LENGTH_SIZE_FIELD +
ZL5011X_PKC_CLASSIFY_SIZE_RTP_FIELD);
}
if (status == ZL5011X_OK)
{
status = zl5011xWriteAssembledBitFields(zl5011xParams, tempWord,
index, tempPos, address);
}
/* need to store all of these settings into the device structure */
if (status == ZL5011X_OK)
{
memcpy(&zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyMatch,
match, sizeof(zl5011xPacketClassifyMatchS));
}
return status;
}
/*******************************************************************************
Function:
zl5011xPkcClassifySetContextMatch
Description:
This function is used to setup a classifier match for a context.
Inputs:
zl5011xParams Pointer to the structure for this device instance
matchNum the number of the entry to disable
match structure containing the classifier match settings
output structure containing the classifier output settings.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkcClassifySetContextMatch(zl5011xParamsS *zl5011xParams,
Uint32T context, Uint32T matchNum, zl5011xPacketClassifyMatchS *match,
zl5011xPacketClassifyOutputS *output)
{
Uint32T tempWord[(ZL5011X_PKC_CLASSIFY_OUTPUT_RAM_SIZE / 4) + 1];
Uint8T tempPos = 0;
Uint8T index = 0;
Uint32T address;
Uint32T bits;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE_CONTEXT(ZL5011X_PKC_FN_ID, context,
"zl5011xPkcClassifySetContextMatch: ctxt %3d, match %3d",
context, matchNum, 0, 0, 0, 0);
/* check that the parameters are okay */
if ((matchNum >= ZL5011X_PKC_NUM_CLASSIFY_ENTRIES) ||
(match == NULL) ||
(output == NULL))
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
if (match->protocolMatchNum >= ZL5011X_PKC_NUM_PROTOCOL_ENTRIES)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
/* check that the output parameters are okay */
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_BOOLEAN(output->classifyLengthNoCalc);
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_BOOLEAN(output->classifyTwoByteLength);
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_BOOLEAN(output->classifyLengthFromPacket);
}
if ((status == ZL5011X_OK) &&
(((output->classifyLengthModifier & ~ZL5011X_PKC_CLASSIFY_LENGTH_MASK) != 0) ||
((output->classifyHeaderOffset & ~ZL5011X_PKC_CLASSIFY_OFFSET_MASK) != 0)))
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
status = ZL5011X_CHECK_FLOW_TYPE(output->classifyFlow);
}
/* setup the match, mask and check fields for the recognition
stage of the classifier */
if (status == ZL5011X_OK)
{
status = zl5011xPkcClassifySetMatchField(zl5011xParams, matchNum,
match->classifyMatchBytes, match->protocolMatchNum);
}
if (status == ZL5011X_OK)
{
status = zl5011xPkcClassifySetMaskField(zl5011xParams,
matchNum, match->classifyMaskBytes);
}
if (status == ZL5011X_OK)
{
status = zl5011xPkcClassifySetCheckField(zl5011xParams,
matchNum, match->classifyCheckBytes);
}
/* set up the output Ram */
address = ZL5011X_PKC_CLASSIFY_OUTPUT_RAM +
(matchNum * ZL5011X_PKC_CLASSIFY_OUTPUT_RAM_SIZE);
if (status == ZL5011X_OK)
{
/* the first field in the output RAM is the flow type */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
output->classifyFlow, ZL5011X_PKC_CLASSIFY_SIZE_FLOW_FIELD);
}
if (status == ZL5011X_OK)
{
/* the next field is the MPID */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
output->classifyMpid, ZL5011X_PKC_CLASSIFY_SIZE_MPID_FIELD);
}
if (status == ZL5011X_OK)
{
/* the next field is the header offset */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
output->classifyHeaderOffset, ZL5011X_PKC_CLASSIFY_SIZE_OFFSET_FIELD);
}
if (status == ZL5011X_OK)
{
/* the next field is the length modifier */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
output->classifyLengthModifier, ZL5011X_PKC_CLASSIFY_SIZE_LENGTH_FIELD);
}
if (status == ZL5011X_OK)
{
/* set the raw packet length field to 0, since the packet length will
be specified or use fields in the header */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
output->classifyLengthFromPacket, ZL5011X_PKC_CLASSIFY_SIZE_RAW_LENGTH_FIELD);
}
/* carry on adding the remaining fields */
if (status == ZL5011X_OK)
{
/* the next field is the length selection field. When the variable is
TRUE, the length inthe length modifier field is used directly as the
length of the message. When it is FALSE, the length modifier setting
is subtracted from the packet length to get the message length. */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
output->classifyLengthNoCalc, ZL5011X_PKC_CLASSIFY_SIZE_LENGTH_CHG_FIELD);
}
if (status == ZL5011X_OK)
{
/* the next field is the size of the length field - 1 or 2 bytes */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
output->classifyTwoByteLength, ZL5011X_PKC_CLASSIFY_SIZE_LENGTH_SIZE_FIELD);
}
if (status == ZL5011X_OK)
{
/* if the flow is being set to an RTP flow then enable the RTP stats */
switch (output->classifyFlow)
{
case ZL5011X_FLOW_PKT_PE_WAN:
case ZL5011X_FLOW_PKT_PE_PKT:
case ZL5011X_FLOW_PKT_TS_WAN:
bits = ZL5011X_1BIT_MASK;
break;
default:
bits = 0;
break;
}
/* the next field is the RTP stats enable */
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
bits, ZL5011X_PKC_CLASSIFY_SIZE_RTP_FIELD);
}
/* need to write the 2nd word to the device */
if (status == ZL5011X_OK)
{
status = zl5011xWriteAssembledBitFields(zl5011xParams, tempWord,
index, tempPos, address);
}
/* need to store all of these settings into the device structure */
if (status == ZL5011X_OK)
{
zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyContext = context;
memcpy(&zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyMatch,
match, sizeof(zl5011xPacketClassifyMatchS));
memcpy(&zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyOutput,
output, sizeof(zl5011xPacketClassifyOutputS));
}
return status;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -