/* Function Name:
 *      rtl8367b_getAsicVlanEgressTagMode
 * Description:
 *      Get CVLAN egress tag mode
 * Input:
 *      port 		- Physical port number (0~7)
 *      pTagMode 	- The egress tag mode. Including Original mode, Keep tag mode and Priority tag mode
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 		- Success
 *      RT_ERR_SMI  	- SMI access error
 *      RT_ERR_PORT_ID  - Invalid port number
 * Note:
 *      None
 */
ret_t rtl8367b_getAsicVlanEgressTagMode(rtk_uint32 port, rtl8367b_egtagmode *pTagMode)
{
    if(port > RTL8367B_PORTIDMAX)
        return RT_ERR_PORT_ID;

    return rtl8367b_getAsicRegBits(RTL8367B_PORT_MISC_CFG_REG(port), RTL8367B_VLAN_EGRESS_MDOE_MASK, pTagMode);
}
示例#2
0
/* Function Name:
 *      rtl8367b_getAsicPortLoopback
 * Description:
 *      Set MAC loopback
 * Input:
 *      port 	- Physical port number (0~7)
 * Output:
 *      pEnable - 0: Disable, 1: enable
 * Return:
 *      RT_ERR_OK 		- Success
 *      RT_ERR_SMI  	- SMI access error
 *      RT_ERR_PORT_ID  - Invalid port number
 * Note:
 *      None
 */
ret_t rtl8367b_getAsicPortLoopback(rtk_uint32 port, rtk_uint32 *pEnable)
{
    if(port >= RTL8367B_PORTNO)
		return RT_ERR_PORT_ID;

    return rtl8367b_getAsicRegBit(RTL8367B_PORT_MISC_CFG_REG(port), RTL8367B_PORT0_MISC_CFG_MAC_LOOPBACK_OFFSET, pEnable);
}
/* Function Name:
 *      rtl8367b_setAsicVlanEgressTagMode
 * Description:
 *      Set CVLAN egress tag mode
 * Input:
 *      port 		- Physical port number (0~7)
 *      tagMode 	- The egress tag mode. Including Original mode, Keep tag mode and Priority tag mode
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 		- Success
 *      RT_ERR_SMI  	- SMI access error
 *      RT_ERR_INPUT  	- Invalid input parameter
 *      RT_ERR_PORT_ID  - Invalid port number
 * Note:
 *      None
 */
ret_t rtl8367b_setAsicVlanEgressTagMode(rtk_uint32 port, rtl8367b_egtagmode tagMode)
{
    if(port > RTL8367B_PORTIDMAX)
        return RT_ERR_PORT_ID;

    if(tagMode >= EG_TAG_MODE_END)
        return RT_ERR_INPUT;

    return rtl8367b_setAsicRegBits(RTL8367B_PORT_MISC_CFG_REG(port), RTL8367B_VLAN_EGRESS_MDOE_MASK, tagMode);
}
/* Function Name:
 *      rtl8367b_setAsicPortIngressBandwidth
 * Description:
 *      Set per-port total ingress bandwidth
 * Input:
 *      port 		- Physical port number (0~7)
 *      bandwidth 	- The total ingress bandwidth (unit: 8Kbps), 0x1FFFF:disable
 *      preifg 		- Include preamble and IFG, 0:Exclude, 1:Include
 *      enableFC 	- Action when input rate exceeds. 0: Drop	1: Flow Control
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 			- Success
 *      RT_ERR_SMI  		- SMI access error
 *      RT_ERR_PORT_ID  	- Invalid port number
 *      RT_ERR_OUT_OF_RANGE - input parameter out of range
 * Note:
 *      None
 */
ret_t rtl8367b_setAsicPortIngressBandwidth(rtk_uint32 port, rtk_uint32 bandwidth, rtk_uint32 preifg, rtk_uint32 enableFC)
{
    ret_t retVal;
    rtk_uint32 regData;
    rtk_uint32 regAddr;

    /* Invalid input parameter */
    if(port >= RTL8367B_PORTNO)
        return RT_ERR_PORT_ID;

    if(bandwidth > RTL8367B_QOS_GRANULARTY_MAX)
        return RT_ERR_OUT_OF_RANGE;

    regAddr = RTL8367B_INGRESSBW_PORT_RATE_LSB_REG(port);
    regData = bandwidth & RTL8367B_QOS_GRANULARTY_LSB_MASK;
    retVal = rtl8367b_setAsicReg(regAddr, regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    regAddr += 1;
    regData = (bandwidth & RTL8367B_QOS_GRANULARTY_MSB_MASK) >> RTL8367B_QOS_GRANULARTY_MSB_OFFSET;
    retVal = rtl8367b_setAsicRegBit(regAddr, 0, regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    regAddr = RTL8367B_PORT_MISC_CFG_REG(port);
    retVal = rtl8367b_setAsicRegBit(regAddr, RTL8367B_PORT0_MISC_CFG_INGRESSBW_IFG_OFFSET, preifg);
    if(retVal != RT_ERR_OK)
        return retVal;

    regAddr = RTL8367B_PORT_MISC_CFG_REG(port);
    retVal = rtl8367b_setAsicRegBit(regAddr, RTL8367B_PORT0_MISC_CFG_INGRESSBW_FLOWCTRL_OFFSET, enableFC);
    if(retVal != RT_ERR_OK)
        return retVal;

    return RT_ERR_OK;
}
/* Function Name:
 *      rtl8367b_getAsicPortIngressBandwidth
 * Description:
 *      Get per-port total ingress bandwidth
 * Input:
 *      port 		- Physical port number (0~7)
 *      pBandwidth 	- The total ingress bandwidth (unit: 8Kbps), 0x1FFFF:disable
 *      pPreifg 		- Include preamble and IFG, 0:Exclude, 1:Include
 *      pEnableFC 	- Action when input rate exceeds. 0: Drop	1: Flow Control
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 			- Success
 *      RT_ERR_SMI  		- SMI access error
 *      RT_ERR_PORT_ID  	- Invalid port number
 * Note:
 *      None
 */
ret_t rtl8367b_getAsicPortIngressBandwidth(rtk_uint32 port, rtk_uint32* pBandwidth, rtk_uint32* pPreifg, rtk_uint32* pEnableFC)
{
    ret_t retVal;
    rtk_uint32 regData;
    rtk_uint32 regAddr;

    /* Invalid input parameter */
    if(port >= RTL8367B_PORTNO)
        return RT_ERR_PORT_ID;

    regAddr = RTL8367B_INGRESSBW_PORT_RATE_LSB_REG(port);
    retVal = rtl8367b_getAsicReg(regAddr, &regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    *pBandwidth = regData;

    regAddr += 1;
    retVal = rtl8367b_getAsicRegBit(regAddr, 0, &regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    *pBandwidth |= (regData << RTL8367B_QOS_GRANULARTY_MSB_OFFSET);

    regAddr = RTL8367B_PORT_MISC_CFG_REG(port);
    retVal = rtl8367b_getAsicRegBit(regAddr, RTL8367B_PORT0_MISC_CFG_INGRESSBW_IFG_OFFSET, pPreifg);
    if(retVal != RT_ERR_OK)
        return retVal;

    regAddr = RTL8367B_PORT_MISC_CFG_REG(port);
    retVal = rtl8367b_getAsicRegBit(regAddr, RTL8367B_PORT0_MISC_CFG_INGRESSBW_FLOWCTRL_OFFSET, pEnableFC);
    if(retVal != RT_ERR_OK)
        return retVal;

    return RT_ERR_OK;
}