?? zl5011xpkcclassify.c
字號(hào):
Uint32T address;
Uint32T wrapAddress, bitShift;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKC_FN_ID,
"zl5011xPkcClassifyEnableEntry: match %3d",
matchNum, 0, 0, 0, 0, 0);
/* check classifier entry number is in range */
if (matchNum >= ZL5011X_PKC_NUM_CLASSIFY_ENTRIES)
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
/* disable the PW interrupt before enabling the classifier rule */
status = zl5011xPkcSetPWInterrupt(zl5011xParams, (Uint32T)ZL5011X_INVALID_CONTEXT, matchNum,
(ZL5011X_1BIT_MASK << ZL5011X_PKC_PW_INT_DISABLE_BIT) | ( 0xff << ZL5011X_PKC_PW_STATUS_MASK_BITS));
}
if (status == ZL5011X_OK)
{
/* mark the classifier entry as in use in the structure */
zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyInUse = ZL5011X_TRUE;
zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyReserved = ZL5011X_TRUE;
/* if the match number is greater than 32, then need to increment
the address for every multiple of 32 */
wrapAddress = matchNum / 32;
bitShift = matchNum % 32;
address = ZL5011X_PKC_CLASSIFY_ENABLE + (wrapAddress * sizeof(Uint32T));
/* set the bit to enable the classifier entry */
status = zl5011xReadModWrite(zl5011xParams, address,
ZL5011X_1BIT_MASK << bitShift,
ZL5011X_1BIT_MASK << bitShift);
}
return status;
}
/*******************************************************************************
Function:
zl5011xPkcClassifyDisableEntry
Description:
Disables a classifier entry. The entry is marked as free, to allow it to
be allocated again.
Inputs:
zl5011xParams Pointer to the structure for this device instance
matchNum the number of the entry to disable
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkcClassifyDisableEntry(zl5011xParamsS *zl5011xParams,
Uint32T matchNum)
{
Uint32T address;
Uint32T wrapAddress, bitShift;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKC_FN_ID,
"zl5011xPkcClassifyDisableEntry: match %3d",
matchNum, 0, 0, 0, 0, 0);
/* check classifier entry number is in range */
if (matchNum >= ZL5011X_PKC_NUM_CLASSIFY_ENTRIES)
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
/* mark the classifier entry as unused in the structure */
zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyInUse = ZL5011X_FALSE;
/* if the match number is greater than 32, then need to increment
the address for every multiple of 32 */
wrapAddress = matchNum / 32;
bitShift = matchNum % 32;
address = ZL5011X_PKC_CLASSIFY_ENABLE + (wrapAddress * sizeof(Uint32T));
/* clear the bit to disable the classifier entry */
status = zl5011xReadModWrite(zl5011xParams, address,
0,
ZL5011X_1BIT_MASK << bitShift);
}
if (status == ZL5011X_OK)
{
/* disable the PW interrupt */
status = zl5011xPkcSetPWInterrupt(zl5011xParams, (Uint32T)ZL5011X_INVALID_CONTEXT, matchNum,
(ZL5011X_1BIT_MASK << ZL5011X_PKC_PW_INT_DISABLE_BIT) | ( 0xff << ZL5011X_PKC_PW_STATUS_MASK_BITS));
}
return status;
}
/*******************************************************************************
Function:
zl5011xPkcClassifyDeleteEntry
Description:
Deletes a classifier entry. The entry is marked as free, to allow it to
be allocated again.
Inputs:
zl5011xParams Pointer to the structure for this device instance
matchNum the number of the entry to delete
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkcClassifyDeleteEntry(zl5011xParamsS *zl5011xParams,
Uint32T matchNum)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKC_FN_ID,
"zl5011xPkcClassifyDeleteEntry: match %3d",
matchNum, 0, 0, 0, 0, 0);
status = zl5011xPkcClassifyDisableEntry(zl5011xParams, matchNum);
/* if the disable was okay, then free the protocol match by clearing
the reserved flag */
if (status == ZL5011X_OK)
{
zl5011xParams->packetIf.packetRx.pkcClassify[matchNum].classifyReserved = ZL5011X_FALSE;
}
return status;
}
/*******************************************************************************
Function:
zl5011xPkcClassifySetMatchField
Description:
Sets the match bytes in the classifier. There is also a mask field, that is
used to control which of the bits in these mask bytes are compared.
The pre-classifier determines the protocol type (1 of 8 matches in the pre
classifier).
Each classifier match corresponds to protocol match.
Inputs:
zl5011xParams Pointer to the structure for this device instance
matchNum the number of the entry to set
matchIndex array of bytes to be used
protocolNum the protocol entry that this match corresponds to
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkcClassifySetMatchField(zl5011xParamsS *zl5011xParams,
Uint32T matchNum, Uint8T *matchIndex, Uint8T protocolNum)
{
Uint32T tempWord[(ZL5011X_PKC_CLASSIFY_MATCH_SIZE / 4) + 1];
Uint8T tempPos = 0;
Uint8T index = 0;
Uint32T address;
Uint32T loop;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKC_FN_ID,
"zl5011xPkcClassifySetMatchField: match %3d, protocol %d",
matchNum, protocolNum, 0, 0, 0, 0);
address = ZL5011X_PKC_CLASSIFY_MATCH +
(matchNum * ZL5011X_PKC_CLASSIFY_MATCH_SIZE);
/* assemble the classify match entries into 32 bit words and
then write them to the device */
for (loop = 0; loop < ZL5011X_PKC_CLASSIFY_NUM_MATCH_FIELDS; loop++)
{
if (status != ZL5011X_OK)
break;
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
matchIndex[loop], ZL5011X_PKC_CLASSIFY_SIZE_MATCH_FIELD);
}
/* the last field to be added is the protocol match that this classify
entry is valid for. */
if (status == ZL5011X_OK)
{
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
(protocolNum*2), ZL5011X_PKC_CLASSIFY_SIZE_PROTOCOL_FIELD);
}
if (status == ZL5011X_OK)
{
status = zl5011xWriteAssembledBitFields(zl5011xParams, tempWord,
index, tempPos, address);
}
return status;
}
/*******************************************************************************
Function:
zl5011xPkcClassifySetMaskField
Description:
Sets the masck bytes in the classifier. These are used to control which of
the bits in the match bytes are compared.
Inputs:
zl5011xParams Pointer to the structure for this device instance
matchNum the number of the entry to set
maskIndex array of bytes to be used for masking
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkcClassifySetMaskField(zl5011xParamsS *zl5011xParams,
Uint32T matchNum, Uint8T *maskIndex)
{
Uint32T tempWord[(ZL5011X_PKC_CLASSIFY_MASK_SIZE / 4) + 1];
Uint8T tempPos = 0;
Uint8T index = 0;
Uint32T address;
Uint32T loop;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKC_FN_ID,
"zl5011xPkcClassifySetMaskField: match %3d",
matchNum, 0, 0, 0, 0, 0);
address = ZL5011X_PKC_CLASSIFY_MASK +
(matchNum * ZL5011X_PKC_CLASSIFY_MASK_SIZE);
/* assemble the classify mask entries into 32 bit words and
then write them to the device */
for (loop = 0; loop < ZL5011X_PKC_CLASSIFY_NUM_MATCH_FIELDS; loop++)
{
if (status != ZL5011X_OK)
break;
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
maskIndex[loop], ZL5011X_PKC_CLASSIFY_SIZE_MASK_FIELD);
}
if (status == ZL5011X_OK)
{
status = zl5011xWriteAssembledBitFields(zl5011xParams, tempWord,
index, tempPos, address);
}
return status;
}
/*******************************************************************************
Function:
zl5011xPkcClassifySetCheckField
Description:
Once a match has been determined using the match and mask fields, a check
is performed to ensure that the match is correct. This function sets the
check bytes. The check mask and the check bytes that are extracted from the
header are controlled by the pre-classifier.
Inputs:
zl5011xParams Pointer to the structure for this device instance
matchNum the number of the entry to disable
checkBytes array of bytes to be used for checking
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xPkcClassifySetCheckField(zl5011xParamsS *zl5011xParams,
Uint32T matchNum, Uint8T *checkBytes)
{
Uint32T tempWord[(ZL5011X_PKC_CLASSIFY_CHECK_SIZE / 4) + 1];
Uint8T tempPos = 0;
Uint8T index = 0;
Uint32T address;
Uint32T loop;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_PKC_FN_ID,
"zl5011xPkcClassifySetCheckField: match %3d",
matchNum, 0, 0, 0, 0, 0);
address = ZL5011X_PKC_CLASSIFY_CHECK +
(matchNum * ZL5011X_PKC_CLASSIFY_CHECK_SIZE);
/* assemble the check entries into 32 bit words and
then write them to the device */
for (loop = 0; loop < ZL5011X_PKC_CLASSIFY_NUM_CHECK_FIELDS; loop++)
{
if (status != ZL5011X_OK)
break;
status = zl5011xAssembleBitFields(tempWord, &index, &tempPos,
checkBytes[loop], ZL5011X_PKC_CLASSIFY_SIZE_CHECK_FIELD);
}
if (status == ZL5011X_OK)
{
status = zl5011xWriteAssembledBitFields(zl5011xParams, tempWord,
index, tempPos, address);
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -