📄 le1veconfig.c
字号:
/*设置提取数据在分类引擎中使用*/
for(i=0; i<ZL5011X_IP_SIZE; i++)
{
lanRxSetProtocolMatch.output.extractClassifyBytes[i] = ARP_SOURCE_IP_POS+i;
}
for(i=0; i<ZL5011X_IP_SIZE; i++)
{
lanRxSetProtocolMatch.output.extractClassifyBytes[i+ZL5011X_IP_SIZE] = ARP_DEST_IP_POS+i;
}
lanRxSetProtocolMatch.output.discardUdpCheckFails = ZL5011X_FALSE;
lanRxSetProtocolMatch.output.protocolIpv4 = ZL5011X_FALSE;
}
else if(par->protocolType == LE1VE_FORWORD_ICMP)
{
lanRxSetProtocolMatch.matchNum = ZL5011X_PKC_NUM_PROTOCOL_ENTRIES - 2;
/*ICMP 协议位为1*/
lanRxSetProtocolMatch.match.protocolMatchBytes[PROTOCOL_ICMP_POS]= 0x01;
lanRxSetProtocolMatch.match.protocolMaskBytes[PROTOCOL_ICMP_POS] = 0x00;
/*设置提取数据在分类引擎中使用*/
for(i=0; i<ZL5011X_IP_SIZE; i++)
{
lanRxSetProtocolMatch.output.extractClassifyBytes[i] = ICMP_SOURCE_IP_POS+i;
}
for(i=0; i<ZL5011X_IP_SIZE; i++)
{
lanRxSetProtocolMatch.output.extractClassifyBytes[i+ZL5011X_IP_SIZE] = ICMP_DEST_IP_POS+i;
}
lanRxSetProtocolMatch.output.discardUdpCheckFails = ZL5011X_FALSE;
lanRxSetProtocolMatch.output.protocolIpv4 = ZL5011X_FALSE;
}
status = zl5011xLanRxSetProtocolMatch(zl5011xParams,&lanRxSetProtocolMatch);
}
if(status == ZL5011X_OK)
{
par->protocolMatchNum=lanRxSetProtocolMatch.matchNum ;
}
return status;
}
/******************************
*drv_Le1veLanArp- ARP protocol process
*Description:
* this process build two context to deal with
* the input and output ARP packets
*Arguemnet:
* IN: slot , par->protocolType
*
*Return:
* OK or ERROR
*------------------------------
*modification history
*------------------------------
*2005.7.4 shf created
*
*******************************/
zlStatusE drv_Le1veLanArp(int slot, Le1vePacketForwardConfigs *par)
{
zlStatusE status = ZL5011X_OK;
zl5011xParamsS *pZl5011xParams;
pZl5011xParams = le1ve_Zl5011xParams[slot - 1];
if(par == NULL)
return ZL5011X_ERROR;
status=ZL5011X_CHECK_SLOTNUM(slot, pZl5011xParams);
if (status != ZL5011X_OK)
return ZL5011X_ERROR;
/*建立ARP 协议的pre-classifier*/
if(status == ZL5011X_OK)
{
status = drv_Le1vePacketForwardSetProtocol(pZl5011xParams,par);
}
/*建立处理出方向ARP context Rx*/
if(status == ZL5011X_OK)
{
/* Create the Lan-to-Lan context */
zl5011xContextCreateS contextCreateStruct;
status = zl5011xLanLanContextCreateStructInit(pZl5011xParams, &contextCreateStruct);
contextCreateStruct.context = LE1VE_ARP_OUT_CONTEXT_NUM;
contextCreateStruct.flow = ZL5011X_FLOW_PKT_PKT;
status = zl5011xLanLanContextCreate(pZl5011xParams, &contextCreateStruct);
}
if (status == ZL5011X_OK)
{
par->forwardDirction = DIRECTION_OUT;
status = drv_Le1vePacketForwardRxSet(pZl5011xParams, par);
}
/* 出方向TX头部设置*/
if(status == ZL5011X_OK)
{
par->context = LE1VE_ARP_OUT_CONTEXT_NUM;
par->portNum = 0;
par->queueNum = par->context & 0x3;
par->ethernetSrcAddressFromMac = ZL5011X_FALSE;
/*par->header = ???????*/
status = drv_Le1vePacketForwardTxSetHeader(pZl5011xParams, par);
}
if(status == ZL5011X_OK)
{
/* Update the lan-to-lan context */
zl5011xContextS contextStruct;
status = zl5011xLanLanContextUpdateStructInit(pZl5011xParams,
&contextStruct);
contextStruct.context = LE1VE_ARP_OUT_CONTEXT_NUM;
status = zl5011xLanLanContextUpdate(pZl5011xParams, &contextStruct);
}
/*建立处理入方向ARP context Rx*/
if(status == ZL5011X_OK)
{
/* Create the Lan-to-Lan context */
zl5011xContextCreateS contextCreateStruct;
status = zl5011xLanLanContextCreateStructInit(pZl5011xParams, &contextCreateStruct);
contextCreateStruct.context = LE1VE_ARP_IN_CONTEXT_NUM;
contextCreateStruct.flow = ZL5011X_FLOW_PKT_PKT;
status = zl5011xLanLanContextCreate(pZl5011xParams, &contextCreateStruct);
}
if(status == ZL5011X_OK)
{
par->forwardDirction = DIRECTION_IN;
status = drv_Le1vePacketForwardRxSet(pZl5011xParams, par);
}
/*入方向Tx头部设置*/
if (status == ZL5011X_OK)
{
par->context = LE1VE_ARP_IN_CONTEXT_NUM;
par->portNum = 1;
par->queueNum = par->context & 0x3;
par->ethernetSrcAddressFromMac = ZL5011X_FALSE;
/*par->header = ???????*/
status = drv_Le1vePacketForwardTxSetHeader(pZl5011xParams, par);
}
if(status == ZL5011X_OK)
{
/* Update the lan-to-lan context */
zl5011xContextS contextStruct;
status = zl5011xLanLanContextUpdateStructInit(pZl5011xParams,
&contextStruct);
contextStruct.context = LE1VE_ARP_IN_CONTEXT_NUM;
status = zl5011xLanLanContextUpdate(pZl5011xParams, &contextStruct);
}
return status;
}
/*******************************
*drv_Le1veLanIcmp() - ICMP protocol process
*Description:
* this process build two context to deal with
* the input and output ICMP packets
*Agruement:
* IN: slot, par->protocolType
*
*Return:
* OK or ERROR
*-------------------------------
*modification history
*-------------------------------
*2005.7.5 shf created
********************************/\
zlStatusE drv_Le1veLanIcmp(int slot, Le1vePacketForwardConfigs *par)
{
zlStatusE status = ZL5011X_OK;
zl5011xParamsS *pZl5011xParams;
pZl5011xParams = le1ve_Zl5011xParams[slot - 1];
status=ZL5011X_CHECK_SLOTNUM(slot, pZl5011xParams);
if (status != ZL5011X_OK)
return ZL5011X_ERROR;
/*创建ICMP接受设置*/
if(status == ZL5011X_OK)
{
/*设置协议匹配*/
status = drv_Le1vePacketForwardSetProtocol(pZl5011xParams, par);
}
if(status == ZL5011X_OK)
{
/* Create the Lan-to-Lan context */
zl5011xContextCreateS contextCreateStruct;
status = zl5011xLanLanContextCreateStructInit(pZl5011xParams, &contextCreateStruct);
contextCreateStruct.context = LE1VE_ICMP_OUT_CONTEXT_NUM;
contextCreateStruct.flow = ZL5011X_FLOW_PKT_PKT;
status = zl5011xLanLanContextCreate(pZl5011xParams, &contextCreateStruct);
}
if(status == ZL5011X_OK)
{
/*设置ICMP 出方向RX*/
par->forwardDirction = DIRECTION_OUT;
status = drv_Le1vePacketForwardRxSet(pZl5011xParams, par);
}
if(status == ZL5011X_OK)
{
/*设置ICMP出方向TX*/
par->context = LE1VE_ICMP_OUT_CONTEXT_NUM;
par->portNum = 0;
par->queueNum= par->context & 0x3;
par->ethernetSrcAddressFromMac = ZL5011X_FALSE;
/*par->header需要调整*/
/*par->header = ???????*/
status = drv_Le1vePacketForwardTxSetHeader(pZl5011xParams, par);
}
if(status == ZL5011X_OK)
{
/* Update the lan-to-lan context */
zl5011xContextS contextStruct;
status = zl5011xLanLanContextUpdateStructInit(pZl5011xParams,
&contextStruct);
contextStruct.context = LE1VE_ICMP_OUT_CONTEXT_NUM;
status = zl5011xLanLanContextUpdate(pZl5011xParams, &contextStruct);
}
if(status == ZL5011X_OK)
{
/* Create the Lan-to-Lan context */
zl5011xContextCreateS contextCreateStruct;
status = zl5011xLanLanContextCreateStructInit(pZl5011xParams, &contextCreateStruct);
contextCreateStruct.context = LE1VE_ICMP_IN_CONTEXT_NUM;
contextCreateStruct.flow = ZL5011X_FLOW_PKT_PKT;
status = zl5011xLanLanContextCreate(pZl5011xParams, &contextCreateStruct);
}
if(status == ZL5011X_OK)
{
/*设置ICMP入方向RX*/
par->forwardDirction = DIRECTION_IN;
status = drv_Le1vePacketForwardRxSet(pZl5011xParams, par);
}
if(status == ZL5011X_OK)
{
/*设置ICMP入方向TX*/
par->context = LE1VE_ICMP_IN_CONTEXT_NUM;
par->portNum = 1;
par->queueNum= par->context & 0x3;
par->ethernetSrcAddressFromMac = ZL5011X_FALSE;
/*par->header = ????*/
status = drv_Le1vePacketForwardTxSetHeader(pZl5011xParams, par);
}
if(status == ZL5011X_OK)
{
/* Update the lan-to-lan context */
zl5011xContextS contextStruct;
status = zl5011xLanLanContextUpdateStructInit(pZl5011xParams,
&contextStruct);
contextStruct.context = LE1VE_ICMP_IN_CONTEXT_NUM;
status = zl5011xLanLanContextUpdate(pZl5011xParams, &contextStruct);
}
return status;
}
/*-----------------------------
* drv_Le1veLanLoopBack - Ethernet port loopback
*
* Argument:
* int slot - slot number
* int port - port number(1 or 2)
* int mode - enable or disable
*
*Return:
* OK or ERROR
* modification history
*------------------------------
* 2004-07-10 ZhengQiShan: Created
*/
zlStatusE drv_Le1veLanLoopBack(int slot, int port, int mode)
{
UINT32 pkiAddress, regValue;
zlStatusE rc = ZL5011X_OK;
zl5011xParamsS *pZl5011xParams;
pZl5011xParams = le1ve_Zl5011xParams[slot - 1];
rc =ZL5011X_CHECK_SLOTNUM(slot, pZl5011xParams);
if ((rc != ZL5011X_OK) || (port < 1) || (port > 2))
return ZL5011X_ERROR;
pkiAddress = ZL5011X_PKI0_CTRL+ ((port - 1) * sizeof( Uint32T));
zl5011xRead(pZl5011xParams, pkiAddress, (Uint32T *)®Value);
if (LE1VE_LOCAL_LOOP_ENABLE == mode)
zl5011xWrite(pZl5011xParams, pkiAddress, regValue | (ZL5011X_1BIT_MASK << ZL5011X_PKI_CTRL_REG_ILPBK));
else
zl5011xWrite(pZl5011xParams, pkiAddress, regValue &( ~(ZL5011X_1BIT_MASK << ZL5011X_PKI_CTRL_REG_ILPBK)));
return (rc);
}
zlStatusE drv_le1veTdmLoopback(int slot, int contextNum, int mode)
{
zl5011xParamsS *pZl5011xParams;
zlStatusE result = ZL5011X_OK;
contextNum --;
pZl5011xParams = le1ve_Zl5011xParams[slot - 1];
result =ZL5011X_CHECK_SLOTNUM(slot, pZl5011xParams);
/* Give a little stimulate */
if (result == ZL5011X_OK)
{
/* the queue has not been started - no packet reception so force
packets to get it going */
if (LE1VE_LOCAL_LOOP_ENABLE == mode)
(void)zl5011xPlaSetFlowType(pZl5011xParams, contextNum , ZL5011X_FLOW_WAN_WAN, contextNum);
else
/*modified by shf 2005.10.19 to test WAN_PE_WAN*/
(void)zl5011xPlaSetFlowType(pZl5011xParams, contextNum , ZL5011X_FLOW_WAN_PE_WAN, contextNum);
}
return result;
}
/*-----------------------------
* drv_delTxContext - 删除Tx context,但不释放以太头的缓冲区,便于修改以太头有参数
*
*Argument:
* UINT32 gPort - global port
*
* 说明:如果要彻底删除context,调用此函数后应该释放以太头的缓冲区
*
* Return:
* ZL5011X_OK if all right.
**/
LOCAL zlStatusE drv_delTxContext(UINT32 gPort)
{
int slot, contextNum;
zl5011xParamsS *pZl5011xParams;
zl5011xBooleanE queueActive;
zl5011xContextDeleteS contextDelete ;
zl5011xContextS contextTake;
zlStatusE result = ZL5011X_OK;
slot = LE1VE_SLOT_NUM(gPort);
contextNum = LE1VE_CHAN_NUM(gPort) - 1;
pZl5011xParams = le1ve_Zl5011xParams[slot - 1];
result =ZL5011X_CHECK_SLOTNUM(slot, pZl5011xParams);
if (ZL5011X_OK != result)
return ZL5011X_ERROR_SLOT_NUM;
/*删除Context时,如果Context使用adaptive clock ,就disable掉
但是必须要保证该槽位上已经使用CET,否则将导致删除不彻底*/
if((1==le1veCetDevAdded[slot-1]) && (g_contextAttribTbl[slot-1][contextNum].adaptiveClock == LE1VE_ADAPTIVE_CLOCK_ENABLE))
{
result = drv_Le1veAdaptiveClock(pZl5011xParams, gPort, LE1VE_ADAPTIVE_CLOCK_DISABLE);
}
/* Give a little
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -