/* @func ret_t | rtl8370_getAsicPortIngressBandwidth | Get per-port total ingress bandwidth. @parm uint32 | port | The port number. @parm uint32* | bandwidth | The total ingress bandwidth (unit: 8Kbps), 0x1FFFF:disable. @parm uint32* | preifg | Include preamble and IFG, 0:Exclude, 1:Include. @parm uint32* | enableFC | Action when input rate exceeds. 0: Drop 1: Flow Control @rvalue RT_ERR_OK | Success. @rvalue RT_ERR_SMI | SMI access error. @rvalue RT_ERR_PORT_ID | Invalid port number. @rvalue RT_ERR_INPUT | Invalid input parameter. @comm The API can set port ingress bandwidth. Port ingress bandwidth = (bandwidth+1)*8Kbps. To disable port ingress bandwidth control, the parameter 'bandwidth' should be set as 0x1FFFF. */ ret_t rtl8370_getAsicPortIngressBandwidth( uint32 port, uint32* pBandwidth, uint32* pPreifg, uint32* pEnableFC ) { uint32 retVal; uint32 regData; uint32 regAddr; /* Invalid input parameter */ if(port >=RTL8370_PORTNO) return RT_ERR_PORT_ID; regAddr = RTL8370_INGRESSBW_PORT_RATE_LSB_REG(port); retVal = rtl8370_getAsicReg(regAddr, ®Data); if(retVal != RT_ERR_OK) return retVal; *pBandwidth = regData; regAddr += 1; retVal = rtl8370_getAsicRegBit(regAddr, 0, ®Data); if(retVal != RT_ERR_OK) return retVal; *pBandwidth |= (regData << RTL8370_QOS_GRANULARTY_MSB_OFFSET); regAddr = RTL8370_PORT_MISC_CFG_REG(port); retVal = rtl8370_getAsicRegBit(regAddr, RTL8370_INGRESSBW_PORT_IFG_OFFSET, pPreifg); if(retVal != RT_ERR_OK) return retVal; regAddr = RTL8370_PORT_MISC_CFG_REG(port); return rtl8370_getAsicRegBit(regAddr, RTL8370_INGRESSBW_PORT_FLOWCRTL_ENABLE_OFFSET, pEnableFC); }
/* @func ret_t | rtl8370_getAsicSpecialCongestModeConfig | Get ASIC special congest mode configuration. @parm uint32 | port | port number (0~8). @uint32* | sustain | sustain timer (0-15). @rvalue RT_ERR_OK | Success. @rvalue RT_ERR_SMI | SMI access error. @rvalue RT_ERR_PORT_ID | Invalid port number. @comm The API can get ASIC special congest mode setup per port. */ ret_t rtl8370_getAsicSpecialCongestModeConfig(uint32 port, uint32 *sustain) { if(port >= RTL8370_PORTNO) return RT_ERR_PORT_ID; return rtl8370_getAsicRegBits(RTL8370_PORT_MISC_CFG_REG(port), RTL8370_SPECIALCONGEST_SUSTAIN_TIMER_MASK, sustain); }
/* @func ret_t | rtl8370_getAsicVlanEgressTagMode | Get CVLAN egress tag mode @parm uint32 | port | The EGRESS port number @parm rtl8370_egtagmode* | ptr_tag_mode | The egress tag mode. Including Original mode, Keep tag mode and Priority tag mode. @rvalue RT_ERR_OK | Success. @rvalue RT_ERR_SMI | SMI access error. @rvalue RT_ERR_INPUT | Invalid input parameter. @rvalue RT_ERR_PORT_ID | Invalid port number. @comm The API can Get Egress tag mode. There are 3 mode for egress tag: Original mode : Output frame will follow VLAN untag setting. Keep tag mode : Output frame will keep VLAN original format. Priority tag mode : Output frame will be priority tag. */ ret_t rtl8370_getAsicVlanEgressTagMode( uint32 port, rtl8370_egtagmode *ptr_tag_mode) { if(port > RTL8370_PORTIDMAX) return RT_ERR_PORT_ID; if(NULL == ptr_tag_mode) return RT_ERR_INPUT; return rtl8370_getAsicRegBits(RTL8370_PORT_MISC_CFG_REG(port), RTL8370_VLAN_EGRESS_MDOE_MASK, (uint32*)ptr_tag_mode); }
/* @func ret_t | rtl8370_setAsicPortIngressBandwidth | Set per-port total ingress bandwidth. @parm uint32 | port | The port number. @parm uint32 | bandwidth | The total ingress bandwidth (unit: 8Kbps), 0x1FFFF:disable. @parm uint32 | preifg | Include preamble and IFG, 0:Exclude, 1:Include. @parm uint32 | enableFC | Action when input rate exceeds. 0: Drop 1: Flow Control @rvalue RT_ERR_OK | Success. @rvalue RT_ERR_SMI | SMI access error. @rvalue RT_ERR_PORT_ID | Invalid port number. @rvalue RT_ERR_INPUT | Invalid input parameter. @rvalue RT_ERR_INBW_RATE | Invalid input rate parameter. @comm The API can set port ingress bandwidth. Port ingress bandwidth = (bandwidth+1)*8Kbps. To disable port ingress bandwidth control, the parameter 'bandwidth' should be set as 0x1FFFF. */ ret_t rtl8370_setAsicPortIngressBandwidth( uint32 port, uint32 bandwidth, uint32 preifg, uint32 enableFC) { uint32 retVal; uint32 regData; uint32 regAddr; /* Invalid input parameter */ if(port >= RTL8370_PORTNO) return RT_ERR_PORT_ID; if(bandwidth > RTL8370_QOS_GRANULARTY_MAX) return RT_ERR_INBW_RATE; if((enableFC > 1) || (preifg > 1)) return RT_ERR_INPUT; regAddr = RTL8370_INGRESSBW_PORT_RATE_LSB_REG(port); regData = bandwidth & RTL8370_QOS_GRANULARTY_LSB_MASK; retVal = rtl8370_setAsicReg(regAddr, regData); if (retVal != RT_ERR_OK) return retVal; regAddr += 1; regData = (bandwidth & RTL8370_QOS_GRANULARTY_MSB_MASK) >> RTL8370_QOS_GRANULARTY_MSB_OFFSET; retVal = rtl8370_setAsicRegBit(regAddr, 0, regData); if (retVal != RT_ERR_OK) return retVal; regAddr = RTL8370_PORT_MISC_CFG_REG(port); retVal = rtl8370_setAsicRegBit(regAddr, RTL8370_INGRESSBW_PORT_IFG_OFFSET, preifg); if (retVal != RT_ERR_OK) return retVal; regAddr = RTL8370_PORT_MISC_CFG_REG(port); return rtl8370_setAsicRegBit(regAddr, RTL8370_INGRESSBW_PORT_FLOWCRTL_ENABLE_OFFSET, enableFC); }
/* @func ret_t | rtl8370_setAsicVlanEgressTagMode | Set CVLAN egress tag mode @parm uint32 | port | The EGRESS port number @parm rtl8370_egtagmode | tag_mode | The egress tag mode. Including Original mode, Keep tag mode and Priority tag mode. @rvalue RT_ERR_OK | Success. @rvalue RT_ERR_SMI | SMI access error. @rvalue RT_ERR_INPUT | Invalid input parameter. @rvalue RT_ERR_PORT_ID | Invalid port number. @comm The API can Set Egress tag mode. There are 3 mode for egress tag: Original mode : Output frame will follow VLAN untag setting. Keep tag mode : Output frame will keep VLAN original format. Priority tag mode : Output frame will be priority tag. */ ret_t rtl8370_setAsicVlanEgressTagMode( uint32 port, rtl8370_egtagmode tag_mode) { ret_t retVal; if(port > RTL8370_PORTIDMAX) return RT_ERR_PORT_ID; if(tag_mode >= EG_TAG_MODE_MAX_BOUND) return RT_ERR_INPUT; retVal = rtl8370_setAsicRegBits(RTL8370_PORT_MISC_CFG_REG(port), RTL8370_VLAN_EGRESS_MDOE_MASK, tag_mode); if(retVal != RT_ERR_OK) return retVal; return RT_ERR_OK; }