/*
@func ret_t | rtl8370_getAsicPortBasedFid | Get port based FID
@parm uint32 | port | Physical port number (0~15).
@parm uint32* | fid | Port based fid(0~0xFFF)
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_L2_FID | Invalid FID (0~4095).
@rvalue RT_ERR_PORT_ID | Invalid port number.
@comm
    This API can get Port-Based FID.There are three FID sources of receiving packet.
*/    
ret_t rtl8370_getAsicPortBasedFid(uint32 port, uint32* fid)
{
    if(port > RTL8370_PORTIDMAX)
        return RT_ERR_PORT_ID;

    return rtl8370_getAsicReg(RTL8370_PORT_PBFID_REG(port),fid);
}
Ejemplo n.º 2
0
/*
@func ret_t | rtl8370_getAsicShareMeterBucketSize | Get meter related leaky bucket threshold
@parm uint32 | index | Shared meter index (0-63) of 64 shared meter index
@parm uint32 | lbthreshold | Leaky bucket threshold of this meter
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_FILTER_METER_ID | Invalid meter
@comm
    The API can get shared meter leaky bucket threshold for each meter.     
 */
ret_t rtl8370_getAsicShareMeterBucketSize(uint32 index, uint32 *lbthreshold)
{
    if(index > RTL8370_METERMAX)
        return RT_ERR_FILTER_METER_ID;

    return rtl8370_getAsicReg(RTL8370_METER_BUCKET_SIZE_REG(index), lbthreshold);
}
/*
@func ret_t | rtl8370_getAsicVlanProtocolBasedGroupData | Get protocol and port based group database.
@parm uint32 | index | Index of protocol and port based database index (0~7).
@parm rtl8370_protocolgdatacfg* | ptr_pbcfg | Protocol and port based group database entry.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_OUT_OF_RANGE | input out of range.
@comm
    This API can get protocol and port based group database.
    System supported only 4 entries and 3 types of frame format. Supported frame types are defined 
    as Ethernet (frame type = 0b00, Ether type > 0x05FF), RFC 1042 (frame type = 0b01,6 bytes after 
    Type/Length = AA-AA-03-00-00-00) and LLC other(frame type = 0b10). ASIC has available setting of
    each frame type per port and available system setting each defined frame type. If per system 
    frame type is set to invalid, then per port frame setting is take no effect. There is contained 
    valid bit setting in each group database.    
*/
ret_t rtl8370_getAsicVlanProtocolBasedGroupData(uint32 index, rtl8370_protocolgdatacfg *ptr_pbcfg)
{
    uint32  frame_type;
    uint32  ether_type;
    ret_t    retVal;

    /* Error Checking */
    if(index > RTL8370_PROTOVLAN_GIDX_MAX)
        return RT_ERR_OUT_OF_RANGE;

    if(NULL == ptr_pbcfg)
        return RT_ERR_INPUT;

    /* Read Frame type */
    retVal = rtl8370_getAsicRegBits(RTL8370SG_VLAN_PPB_FRAMETYPE_REG(index), RTL8370SG_VLAN_PPB_FRAMETYPE_MASK, &frame_type);
    if(retVal != RT_ERR_OK)
        return retVal;

    /* Read Ether type */
    retVal = rtl8370_getAsicReg(RTL8370_VLAN_PPB_ETHERTYPR_REG(index), &ether_type);
    if(retVal != RT_ERR_OK)
        return retVal;


    ptr_pbcfg->frame_type = frame_type;
    ptr_pbcfg->ether_type = ether_type;
    return RT_ERR_OK;
}
Ejemplo n.º 4
0
/*
@func ret_t | rtl8370_getAsicPortForceLinkExt | Get external interface force linking configuration.
@parm uint32 | id | external interface id (0~1).
@parm rtl8370_port_ability_t* | portability | port ability configuration
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_FAILED | Invalid parameter.
@comm
      This API can get external interface force mode properties. 
 */
ret_t rtl8370_getAsicPortForceLinkExt(uint32 id, rtl8370_port_ability_t *portability)
{
    ret_t retVal;
    uint32 regData;
    uint16 *accessPtr;
    rtl8370_port_ability_t ability;

    /* Invalid input parameter */
    if(id >= RTL8370_EXTNO)
        return RT_ERR_PORT_ID;
    
    memset(&ability,0x00,sizeof(rtl8370_port_ability_t));


    accessPtr =  (uint16*)&ability;
 
    retVal = rtl8370_getAsicReg(RTL8370_REG_DIGITIAL_INTERFACE0_FORCE + id, &regData);
    if(retVal !=  RT_ERR_OK)
        return retVal;
    
    *accessPtr = regData;

    memcpy(portability, &ability, sizeof(rtl8370_port_ability_t));        
    
    return RT_ERR_OK;  
}
/*
@func ret_t | rtl8370_getAsicVlanMemberConfig | Get 32 VLAN member configurations.
@parm uint32 | index | VLAN member configuration index (0~31).
@parm rtl8370_vlanconfiguser* | ptr_vlancfg | VLAN member configuration. 
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@rvalue RT_ERR_VLAN_ENTRY_NOT_FOUND | Invalid VLAN member configuration index (0~31).
@comm
    The API can get 32 VLAN member configuration.
    
*/
ret_t rtl8370_getAsicVlanMemberConfig(uint32 index, rtl8370_vlanconfiguser *ptr_vlancfg)
{
    ret_t  retVal;
    uint32 page_idx;
    uint32 regAddr;
    uint32 regData;
    uint16 *tableAddr;
    rtl8370_vlanconfigsmi  smi_vlancfg;

    if(index > RTL8370_CVIDXMAX)
        return RT_ERR_VLAN_ENTRY_NOT_FOUND;

    if(NULL == ptr_vlancfg)
        return RT_ERR_INPUT;

    memset(&smi_vlancfg, 0x00, sizeof(rtl8370_vlanconfigsmi));
    tableAddr  = (uint16*)&smi_vlancfg;

    for(page_idx = 0; page_idx < 4; page_idx++)  /* 4 pages per VLAN Member Config */
    {
        regAddr = RTL8370_VLAN_MEMBER_CONFIGURATION_BASE + (index*4) + page_idx;

        retVal = rtl8370_getAsicReg(regAddr, &regData);
        if(retVal != RT_ERR_OK)
            return retVal;
        
        *tableAddr = (uint16)regData;
        tableAddr++;
    }

    _rtl8370_VlanMCStSmi2User(&smi_vlancfg, ptr_vlancfg);
    return RT_ERR_OK;
}
Ejemplo n.º 6
0
ret_t _rtl8370_getAsicEeelldpFrameDataReg(uint32 regAddr, uint32 dataLength, int8 *readDataPtr)
{
    ret_t ret;
    uint32 i;
    uint32 regData;
    uint16 *accessPtr;

    accessPtr = (uint16*)readDataPtr;

    for(i=0; i < dataLength / 2; i++)
    {
        ret = rtl8370_getAsicReg(regAddr + i, &regData);
        if(RT_ERR_OK != ret)
            return ret;
        
        *accessPtr = (int16)regData;
        accessPtr++;
    }
    
    if (dataLength & 0x1)
    {
        ret = rtl8370_getAsicRegBits(regAddr + dataLength / 2, 0xFF, &regData);
        if (RT_ERR_OK != ret)
            return ret;

        *accessPtr = (int16)regData;
    }

    return RT_ERR_OK;
}
Ejemplo n.º 7
0
/*
@func ret_t | rtl8370_getAsicEeeGiga | Get eee RX meter.
@parm uint32 | port | The port number.
@parm uint32* | enabled | 1: enabled, 0: disabled.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
    This API get the 100M EEE function.
*/
ret_t rtl8370_getAsicEeeRxMeter(uint32 port, uint32 *cnt)
{
    if(port >= RTL8370_PORTNO)
        return RT_ERR_PORT_ID;

    return rtl8370_getAsicReg(RTL8370_PORT_EEE_RX_METER_REG(port), cnt);
}
/*
@func ret_t | rtl8370_getAsicSvlanMC2SConf| Get configure system 32 S-tag content
@parm uint32 | index | index of 32 Multicast to SVLAN configuration
@parm rtl8370_svlan_mc2s_t* | svlanMC2SConf | SVLAN Multicast to SVLAN member configuration
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
    The API can get system 32 Mutlicast to SVID configuration. If upstream packet is L2 multicast or IPv4 multicast
    packet and DMAC/DIP is matched MC2S configuration, ASIC will assign egress SVID to the packet.

*/
ret_t rtl8370_getAsicSvlanMC2SConf(uint32 index,rtl8370_svlan_mc2s_t* svlanMC2SConf)
{
    ret_t retVal;
    uint32 regData;
    uint16 *accessPtr;
    uint32 i;

    rtl8370_svlan_mc2s_smi_t smiSvlanMC2S;

    if(index > RTL8370_MC2SIDXMAX)
        return RT_ERR_OUT_OF_RANGE;

    memset(&smiSvlanMC2S, 0x00, sizeof(smiSvlanMC2S));

    accessPtr = (uint16*)&smiSvlanMC2S;

    for(i = 0; i < 5; i++)
    {
        retVal = rtl8370_getAsicReg(RTL8370SG_SVLAN_MCAST2S_ENTRY_BASE_REG+(index*5)+i,&regData);
        if(retVal !=  RT_ERR_OK)
            return retVal;

        *accessPtr = regData;

        accessPtr ++;
    }


    _rtl8370_svlanMc2sStSmi2User(svlanMC2SConf,&smiSvlanMC2S);

    return RT_ERR_OK;
}
/*
@func ret_t | rtl8370_getAsicSvlanSP2CConf| Get configure system 128 SP2C content
@parm uint32 | index | index of 128 SVLAN & Port to CVLAN configuration
@parm rtl8370_svlan_mc2s_t* | svlanSP2CConf | SVLAN & Port to CVLAN configuration
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
 The API can get system 128 SVID & Destination Port to CVLAN configuration. 

*/
ret_t rtl8370_getAsicSvlanSP2CConf(uint32 index,rtl8370_svlan_s2c_t* svlanSP2CConf)
{
    ret_t retVal;
    uint32 regData;
    uint16 *accessPtr;
    uint32 i;

    rtl8370_svlan_s2c_smi_t smiSvlanSP2C;

    if(index > RTL8370_SP2CMAX)
        return RT_ERR_OUT_OF_RANGE;

    memset(&smiSvlanSP2C,0x00,sizeof(smiSvlanSP2C));

    accessPtr = (uint16*)&smiSvlanSP2C;

    for(i=0;i<5;i++)
    {
        retVal = rtl8370_getAsicReg(RTL8370_SVLAN_S2C_ENTRY_BASE_REG+(index*2)+i,&regData);
        if(retVal !=  RT_ERR_OK)
            return retVal;

        *accessPtr = regData;

        accessPtr ++;
    }


    _rtl8370_svlanSp2cStSmi2User(svlanSP2CConf,&smiSvlanSP2C);

    return RT_ERR_OK;
}
/*
@func ret_t | rtl8370_getAsicInterruptRelatedStatus | get interrupt status
@parm uint32 | type | per port Learn over, per-port speed change, per-port special congest, share meter exceed status
@parm uint32* | status | per port Learn over, per-port speed change, per-port special congest, share meter exceed status
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_INPUT | Invalid input value
@comm
    This API can be used to get ASIC interrupt per port related status and share meter exceed status. All status will be clear by READ.
*/
ret_t rtl8370_getAsicInterruptRelatedStatus(uint32 type,uint32* status)
{
    if(type >= INTRST_MAX )
        return RT_ERR_INPUT;
    
    return rtl8370_getAsicReg(RTL8370_INTR_INDICATOR_BASED + type, status);
}
/*
@func ret_t | rtl8370_setAsicLedIndicateInfoConfig | Set Leds indicated information mode
@parm uint32 | ledno | LED group number. There are 1 to 1 led mapping to each port in each led group.
@parm enum RTL8370_LEDCONF | config | Support 16 types configuration.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@comm
    The API can set LED indicated information configuration for each LED group with 1 to 1 led mapping to each port.
    Definition        LED Statuses            Description
    0000        LED_Off                LED pin Tri-State.
    0001        Dup/Col                Collision, Full duplex Indicator. Blinking every 43ms when collision happens. Low for full duplex, and high for half duplex mode.
    0010        Link/Act               Link, Activity Indicator. Low for link established. Link/Act Blinks every 43ms when the corresponding port is transmitting or receiving.
    0011        Spd1000                1000Mb/s Speed Indicator. Low for 1000Mb/s.
    0100        Spd100                 100Mb/s Speed Indicator. Low for 100Mb/s.
    0101        Spd10                  10Mb/s Speed Indicator. Low for 10Mb/s.
    0110        Spd1000/Act            1000Mb/s Speed/Activity Indicator. Low for 1000Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
    0111        Spd100/Act             100Mb/s Speed/Activity Indicator. Low for 100Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
    1000        Spd10/Act              10Mb/s Speed/Activity Indicator. Low for 10Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
    1001        Spd100 (10)/Act        10/100Mb/s Speed/Activity Indicator. Low for 10/100Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
    1010        Fiber                  Fiber link Indicator. Low for Fiber.
    1011        Fault                  Auto-negotiation     Fault Indicator. Low for Fault.
    1100        Link/Rx                Link, Activity Indicator. Low for link established. Link/Rx Blinks every 43ms when the corresponding port is transmitting.
    1101        Link/Tx                Link, Activity Indicator. Low for link established. Link/Tx Blinks every 43ms when the corresponding port is receiving.
    1110        Master                 Link on Master Indicator. Low for link Master established.
    1111        Act                    Activity Indicator. Low for link established.
 */
ret_t rtl8370_setAsicLedIndicateInfoConfig(uint32 ledno, enum RTL8370_LEDCONF config)
{
    ret_t retVal;
    uint32 regData;
    CONST_T uint16 bits[RTL8370_LEDGROUPMAX+1]= { RTL8370_LED0_CFG_MASK, RTL8370_LED1_CFG_MASK, RTL8370_LED2_CFG_MASK};
    CONST_T uint16 offsets[RTL8370_LEDGROUPMAX+1]= { RTL8370_LED0_CFG_OFFSET, RTL8370_LED1_CFG_OFFSET, RTL8370_LED2_CFG_OFFSET};

    if(ledno > RTL8370_LEDGROUPMAX)
        return RT_ERR_INPUT;

    if(config > LEDCONF_ACT)
        return RT_ERR_INPUT;

    retVal = rtl8370_getAsicReg(RTL8370_REG_LED_CONFIGURATION,&regData);
	if( retVal !=  RT_ERR_OK)
		return retVal;

    regData = regData & (~RTL8370_LED_CONFIG_SEL_MASK);
    regData = regData & (~bits[ledno]);
    regData = regData | ((config & RTL8370_LED0_CFG_MASK)<<offsets[ledno]);

    retVal = rtl8370_setAsicReg(RTL8370_REG_LED_CONFIGURATION,regData);

    return retVal;
}
/*
@func ret_t | rtl8370_getAsicSvlanMemberConfiguration| Get SVLAN member Configure.
@parm uint32 | index | index of 8 s-tag configuration
@parm rtl8370_svlan_memconf_t* | svlanMemConf | SVLAN member configuration
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_SVLAN_ENTRY_INDEX | Invalid SVLAN configuration index.
@comm
    The API can get system 64 accepted s-tag frame format. Only 64 SVID S-tag frame will be accpeted
    to receiving from uplink ports. Other SVID S-tag frame or S-untagged frame will be droped.

*/
ret_t rtl8370_getAsicSvlanMemberConfiguration(uint32 index,rtl8370_svlan_memconf_t* svlanMemConf)
{
    ret_t retVal;
    uint32 regData;
    uint16 *accessPtr;
    uint32 i;

    rtl8370_svlan_memconf_smi_t smiSvlanMemConf;

    if(index > RTL8370_SVIDXMAX)
        return RT_ERR_SVLAN_ENTRY_INDEX;

    memset(&smiSvlanMemConf,0x00,sizeof(smiSvlanMemConf));

    accessPtr = (uint16*)&smiSvlanMemConf;

    for(i = 0; i < 4; i++)
    {
        retVal = rtl8370_getAsicReg(RTL8370_SVLAN_MEMBERCFG_BASE_REG+(index<<2)+i,&regData);
        if(retVal !=  RT_ERR_OK)
            return retVal;

        *accessPtr = regData;

        accessPtr ++;
    }


    _rtl8370_svlanConfStSmi2User(svlanMemConf,&smiSvlanMemConf);

    return RT_ERR_OK;
}
Ejemplo n.º 13
0
/*
@func ret_t | rtl8370_setAsicRrcp | Set RRCP function enable/disable.
@parm uint32 | vOneEnable | 1: enabled, 0: disabled.
@parm uint32 | vTwoEnable | 1: enabled, 0: disabled.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error. 
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
    Enable / Disable RRCPv1 and RRCPv2 function
    Note that RRCPv1 and RRCPv2 shall not be enabled together
    Only one is needed.
*/
ret_t rtl8370_setAsicRrcp(uint32 vOneEnable, uint32 vTwoEnable)
{
    ret_t  retVal;    
	uint32 tmp;

    if((vOneEnable > 1) || (vTwoEnable > 1))
        return RT_ERR_INPUT;

    retVal = rtl8370_getAsicReg(RTL8370_RRCP_CTRL0_REG, &tmp);
    if(retVal != RT_ERR_OK)
        return RT_ERR_FAILED;

    tmp &= ~(1 << RTL8370_RRCP_V1_EN_OFFSET);
	tmp &= ~(1 << RTL8370_RRCP_V2_EN_OFFSET);

	tmp |= ((vOneEnable & 1) << RTL8370_RRCP_V1_EN_OFFSET);
	tmp |= ((vTwoEnable & 1) << RTL8370_RRCP_V2_EN_OFFSET);

    retVal = rtl8370_setAsicReg(RTL8370_RRCP_CTRL0_REG, tmp);
    if(retVal != RT_ERR_OK)
        return RT_ERR_FAILED;
    
    retVal = rtl8370_setAsicReg(RTL8370_OLD_RRCP_CTRL, tmp);
    if(retVal != RT_ERR_OK)
        return RT_ERR_FAILED;
    
    return RT_ERR_OK;
}
Ejemplo n.º 14
0
/*
@func ret_t | rtl8370_getAsicLutLearnLimitNo | Get per-Port auto learning limit number
@parm uint32 | port | The port number
@parm uint32* | number | ASIC auto learning entries limit number
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_PORT_ID | Invalid port number.
@common
    The API can get per-port ASIC auto learning limit number
*/
ret_t rtl8370_getAsicLutLearnLimitNo(uint32 port,uint32* number)
{
    if(port > RTL8370_PORTIDMAX)
        return RT_ERR_PORT_ID;

    return rtl8370_getAsicReg(RTL8370_LUT_PORT_LEARN_LIMITNO_REG(port), number);
}
/*
@func ret_t | rtl8370_getAsicPortIsolationPermittedPortmask | Get permitted port isolation portmask
@parm uint32 | port | Physical port number (0~15).
@parm uint32* | permitPortmask | portmask (0~0xFFFF)
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error. 
@rvalue RT_ERR_PORT_ID | Invalid port number.
@comm
    This API get the port mask that a port can trasmit packet to of each port
    A port can only transmit packet to ports included in permitted portmask
*/
ret_t rtl8370_getAsicPortIsolationPermittedPortmask(uint32 port, uint32 *permitPortmask)
{
    if(port >= RTL8370_PORTNO)
        return RT_ERR_PORT_ID;
    
    return rtl8370_getAsicReg(RTL8370_PORT_ISOLATION_PORT_MASK_REG(port), permitPortmask);
}
Ejemplo n.º 16
0
/*
@func ret_t | rtl8370_getAsicPortForceLink | Get port force linking configuration.
@parm uint32 | port | port number.
@parm rtl8370_port_ability_t* | portability | port ability configuration
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_FAILED | Invalid parameter.
@comm
      This API can get Port/MAC force mode properties. 
 */
ret_t rtl8370_getAsicPortForceLink(uint32 port, rtl8370_port_ability_t *portability)
{
    ret_t retVal;
    uint32 regData;
    uint16 *accessPtr;
    rtl8370_port_ability_t ability;

    /* Invalid input parameter */
    if(port >=RTL8370_PORTNO)
        return RT_ERR_PORT_ID;
    
    memset(&ability, 0x00, sizeof(rtl8370_port_ability_t));


    accessPtr =  (uint16*)&ability;
 
    retVal = rtl8370_getAsicReg(RTL8370_REG_MAC0_FORCE_SELECT+port,&regData);
    if(retVal !=  RT_ERR_OK)
        return retVal;
    
    *accessPtr = regData;

    memcpy(portability, &ability, sizeof(rtl8370_port_ability_t));        
    
    return RT_ERR_OK;  
}
Ejemplo n.º 17
0
/*
@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, &regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    *pBandwidth = regData;
    
    regAddr += 1;
    retVal = rtl8370_getAsicRegBit(regAddr, 0, &regData);
    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);
}
Ejemplo n.º 18
0
/*
@func ret_t | rtl8370_getAsicPortStatus | Get port link status.
@parm uint32 | port | port number.
@parm rtl8370_port_ability_t* | portability | port ability configuration
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_FAILED | Invalid parameter.
@comm
      This API can get Port/PHY properties. 
 */
ret_t rtl8370_getAsicPortStatus(uint32 port, rtl8370_port_status_t *portstatus)
{
    ret_t retVal;
    uint32 regData;
    uint16 *accessPtr;
    rtl8370_port_status_t status;

    /* Invalid input parameter */
    if(port >= RTL8370_PORTNO)
        return RT_ERR_PORT_ID;
    
    memset(&status, 0x00, sizeof(rtl8370_port_status_t));


    accessPtr =  (uint16*)&status;
 
    retVal = rtl8370_getAsicReg(RTL8370_REG_PORT0_STATUS + port, &regData);
    if(retVal !=  RT_ERR_OK)
        return retVal;
    
    *accessPtr = regData;

    memcpy(portstatus, &status, sizeof(rtl8370_port_status_t));        
    
    return RT_ERR_OK;  
}
Ejemplo n.º 19
0
/*
@func ret_t | rtl8370_getAsicWFQBurstSize | Set WFQ leaky bucket burst size.
@parm uint32* | burstsize | Leaky bucket burst size, unit byte
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@comm
    The API can set WFQ leaky bucket burst size(aka high threshold) 
 */
ret_t rtl8370_getAsicWFQBurstSize(uint32 *burstsize)
{
    ret_t retVal;

    retVal = rtl8370_getAsicReg(RTL8370_SCHEDULE_WFQ_BURST_SIZE_REG, burstsize);
    
    return retVal;
}
Ejemplo n.º 20
0
/*
@func ret_t | rtl8370_getAsicVlan4kEntry | Get VID mapped entry to 4K VLAN table. 
@parm rtl8370_user_vlan4kentry* | ptr_vlan4kEntry | VLAN entry seting for 4K table. There is VID field in entry structure and  entry is directly mapping to 4K table location (1 to 1).
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter.
@rvalue RT_ERR_VLAN_VID | Invalid VID parameter (0~4095).
@comm
    The API can get entry of 4k VLAN table. Software must prepare the retrieving VID first at writing data and used control word to access desired VLAN entry.
    
*/
ret_t rtl8370_getAsicVlan4kEntry(rtl8370_user_vlan4kentry *ptr_vlan4kEntry )
{
#if defined(DISABLE_VLAN_SHADOW)
    rtl8370_vlan4kentrysmi vlan_4k_entry;
    uint32                    page_idx;
    uint16                    *tableAddr;
    ret_t                     retVal;
    uint32                     regData;

    if(NULL == ptr_vlan4kEntry)     
        return RT_ERR_INPUT;

    /* Write Address (VLAN_ID) */
    regData = ptr_vlan4kEntry->vid;
    retVal = rtl8370_setAsicReg(RTL8370_TABLE_ACCESS_ADDR_REG, regData);
    if(retVal !=  RT_ERR_OK)
        return retVal;

    /* Read Command */
    retVal = rtl8370_setAsicReg(RTL8370_TABLE_ACCESS_CTRL_REG, RTL8370_TABLE_ACCESS_REG_DATA(TB_OP_READ,TB_TARGET_CVLAN));
    if(retVal !=  RT_ERR_OK)
        return retVal;

    /* Check ASIC Command */

    /* Read VLAN data from register */
    tableAddr = (uint16 *)&vlan_4k_entry;
    for(page_idx = 0; page_idx < (sizeof(rtl8370_vlan4kentrysmi) / 2); page_idx++)
    {
        retVal = rtl8370_getAsicReg(RTL8370_TABLE_ACCESS_DATA_BASE + page_idx, &regData);
        if(retVal !=  RT_ERR_OK)
            return retVal;

        *tableAddr = regData;
        tableAddr++;
    }

    _rtl8370_Vlan4kStSmi2User(&vlan_4k_entry, ptr_vlan4kEntry);

#else

    uint16  vid;

    if(ptr_vlan4kEntry->vid > RTL8370_VIDMAX)
        return RT_ERR_VLAN_VID;

    vid = ptr_vlan4kEntry->vid;
    memcpy(ptr_vlan4kEntry, &user_4kvlan[ptr_vlan4kEntry->vid], sizeof(rtl8370_user_vlan4kentry));
    ptr_vlan4kEntry->vid = vid;

#endif

#if defined(CONFIG_RTL8370_ASICDRV_TEST)
    _rtl8370_Vlan4kStSmi2User(&Rtl8370sVirtualVlanTable[ptr_vlan4kEntry->vid], ptr_vlan4kEntry);
#endif

    return RT_ERR_OK;
}
Ejemplo n.º 21
0
/*
@func ret_t | rtl8370_getAsicPHYReg | Set PHY registers .
@parm uint32 | phyNo | PHY number (0~7).
@parm uint32 | phyAddr | PHY address (0~31).
@parm uint32* | data | Read data.
@rvalue RT_ERR_OK | 
@rvalue RT_ERR_FAILED | invalid parameter
@rvalue RT_ERR_PHY_REG_ID | invalid PHY address
@rvalue RT_ERR_PORT_ID | iinvalid port id
@rvalue RT_ERR_BUSYWAIT_TIMEOUT | PHY access busy
@comm
     The API can get internal PHY register 0~31. There are 8 internal PHYs in switch and each PHY can be
    accessed by software.
 */
ret_t rtl8370_getAsicPHYReg( uint32 phyNo, uint32 phyAddr, uint32 *data )
{
    ret_t retVal;
    uint32 regData;
    uint32 busyFlag,checkCounter;

    if(phyNo > RTL8370_PHY_INTERNALNOMAX)
        return RT_ERR_PORT_ID;

    if(phyAddr > RTL8370_PHY_REGNOMAX)
        return RT_ERR_PHY_REG_ID;

    /*Check internal phy access busy or not*/
    retVal = rtl8370_getAsicRegBit(RTL8370_REG_INDRECT_ACCESS_STATUS, RTL8370_PHY_BUSY_OFFSET,&busyFlag);
    if(retVal !=  RT_ERR_OK)
        return retVal;

    if(busyFlag)
        return RT_ERR_BUSYWAIT_TIMEOUT;

    /*prepare access address*/
    regData = RTL8370_PHY_BASE | (phyNo<<RTL8370_PHY_OFFSET) | phyAddr; 
    
    retVal = rtl8370_setAsicReg(RTL8370_REG_INDRECT_ACCESS_ADDRESS, regData);
    if(retVal !=  RT_ERR_OK)
        return retVal;

    /*Set READ Command*/
    retVal = rtl8370_setAsicReg(RTL8370_REG_INDRECT_ACCESS_CRTL, RTL8370_CMD_MASK );
    if(retVal !=  RT_ERR_OK)
        return retVal;

    checkCounter = 5;
    while(checkCounter)
    {
        retVal = rtl8370_getAsicRegBit(RTL8370_REG_INDRECT_ACCESS_STATUS, RTL8370_PHY_BUSY_OFFSET,&busyFlag);
        if(retVal !=  RT_ERR_OK)
        {
            checkCounter --;
            if(0 == checkCounter)
                return retVal;
        }
        else
        {
            checkCounter = 0;
        }        
    }

    /*get PHY register*/
    retVal = rtl8370_getAsicReg(RTL8370_REG_INDRECT_ACCESS_READ_DATA, &regData);
    if(retVal !=  RT_ERR_OK)
        return retVal;

    *data = regData;

    return RT_ERR_OK;
}
Ejemplo n.º 22
0
/*
@func ret_t | rtl8370_getAsicRldpLoopStatePara | Get retry count and retry period of loop state.
@parm uint32* | retryCount | 0~0xFF (times)
@parm uint32 | retryPeriod | 0~0xFFFF (ms)
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error. 
@rvalue RT_ERR_INPUT | Invalid input parameter.
@comm
    This API et the retry count and retry period of loop state
    Retry count and retry period decide the times Switch sends RLDP frame and 
    the interval between two transmission respecitively in loop state.
*/
ret_t rtl8370_getAsicRldpLoopStatePara(uint32 *retryCount, uint32 *retryPeriod)
{
    ret_t ret;

    ret = rtl8370_getAsicRegBits(RTL8370_RLDP_RETRY_COUNT_REG, RTL8370_RLDP_RETRY_COUNT_LOOPSTATE_READ_MASK, retryCount);
    if(RT_ERR_OK != ret)
        return ret;

    return rtl8370_getAsicReg(RTL8370_RLDP_RETRY_PERIOD_LOOPSTATE_REG, retryPeriod);
}
Ejemplo n.º 23
0
ret_t rtl8370_getAsicAclAct( uint32 index, rtl8370_acl_act_t *aclAct)
{
    rtl8370_acl_act_smi_t aclActSmi;
    ret_t retVal;
    uint32 regAddr, regData;
    uint16* tableAddr;
    uint32 i;
    
    if(index > RTL8370_ACLRULEMAX)
        return RT_ERR_FILTER_ENTRYIDX;
    
    memset(&aclActSmi,0x00,sizeof(rtl8370_acl_act_smi_t));


    /* Write ACS_ADR register for data bits */
    regAddr = RTL8370_TABLE_ACCESS_ADDR_REG;
    regData = index;
    retVal = rtl8370_setAsicReg(regAddr, regData);
    if(retVal !=RT_ERR_OK)
        return retVal;
    

    /* Write ACS_CMD register */
    regAddr = RTL8370_TABLE_ACCESS_CTRL_REG;
    regData = RTL8370_TABLE_ACCESS_REG_DATA(TB_OP_READ, TB_TARGET_ACLACT);
    retVal = rtl8370_setAsicReg(regAddr, regData);
    if(retVal !=RT_ERR_OK)
        return retVal;
    

    /* Read Data Bits */
    regAddr = RTL8370_TABLE_ACCESS_DATA_BASE;
    tableAddr = (uint16*)&aclActSmi;
    for(i=0;i<RTL8370_ACLACTTBLEN;i++)
    {
        retVal = rtl8370_getAsicReg(regAddr, &regData);
        if(retVal !=RT_ERR_OK)
            return retVal;

        *tableAddr = regData;
        
        regAddr ++;
        tableAddr ++;
    }

     _rtl8370_aclActStSmi2User(aclAct, &aclActSmi);
     
#ifdef CONFIG_RTL8370_ASICDRV_TEST
    Rtl8370sVirtualAclActTable[index] = aclActSmi;
#endif

    return RT_ERR_OK;
}
Ejemplo n.º 24
0
/*
@func ret_t | rtl8370_getAsicShareMeter | Get meter configuration
@parm uint32 | index | Shared meter index (0-63) of 64 shared meter index
@parm uint32* | rate | 17-bits rate of share meter, unit is 8Kpbs
@parm uint32* | ifg | Rate's calculation including IFG 1:include 0:exclude 
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_FILTER_METER_ID | Invalid meter
@comm
    The API can get shared meter rate and ifg include for each meter. Rate unit is 8Kbps.    
 */
ret_t rtl8370_getAsicShareMeter(uint32 index, uint32 *rate ,uint32 *ifg)
{
    uint32 regData;
    uint32 regData2;
    ret_t retVal;

    if(index > RTL8370_METERMAX)
        return RT_ERR_FILTER_METER_ID;

    /*17-bits Rate*/
    retVal = rtl8370_getAsicReg(RTL8370_METER_RATE_REG(index), &regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    retVal = rtl8370_getAsicReg(RTL8370_METER_RATE_REG(index)+1, &regData2);
    if(retVal != RT_ERR_OK)
        return retVal;

    *rate = ((regData2 << 16) & 0x10000) | regData;
    /*IFG*/
    return rtl8370_getAsicRegBit(RTL8370_METER_IFG_CTRL_REG(index), RTL8370_METER_IFG_OFFSET(index), ifg);
}
Ejemplo n.º 25
0
/*
@func int32 | rtl8370_getAsicPHYReg | Set PHY registers .
@parm uint32 | phyNo | PHY number (0~7).
@parm uint32 | phyAddr | PHY address (0~31).
@parm uint32* | data | Read data.
@rvalue RT_ERR_OK | 
@rvalue RT_ERR_FAILED | invalid parameter
@rvalue RT_ERR_PHY_REG_ID | invalid PHY address
@rvalue RT_ERR_PORT_ID | iinvalid port id
@rvalue RT_ERR_BUSYWAIT_TIMEOUT | PHY access busy
@comm
     The API can get internal PHY register 0~31. There are 8 internal PHYs in switch and each PHY can be
    accessed by software.
 */
ret_t rtl8370_getAsicPHYReg( uint32 phyNo, uint32 phyAddr, uint32 *value)
{
	uint32 regAddr;

    if(phyNo > RTL8370_PHY_INTERNALNOMAX)
        return RT_ERR_PORT_ID;

    if(phyAddr > RTL8370_PHY_REGNOMAX)
        return RT_ERR_PHY_REG_ID;

    regAddr = 0x2000 + (phyNo << 5) + phyAddr;

    return rtl8370_getAsicReg(regAddr, value);
}
/*
@func ret_t | rtl8370_getAsicIgmp | Set IGMP/MLD trap function
@parm enum rtl8370_igmp_t* | igmpcfg | IGMP configuration for trapping frame type setting.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@comm
    This API can set both IPv4 IGMP/IPv6 MLD with/without PPPoE header trapping function.
    All 4 kinds of IGMP/MLD function can be set seperately.
*/
ret_t rtl8370_getAsicIgmp( rtl8370_igmp_t* igmpcfg)
{
    ret_t retVal;
    uint32 regData;
    uint16 regData16;

    retVal = rtl8370_getAsicReg(RTL8370_IGMP_CTRL_REG,&regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    regData16 = (uint16)(regData&0xFFFF);
    *igmpcfg = *(rtl8370_igmp_t*)(&regData16);

    return RT_ERR_OK;
}
Ejemplo n.º 27
0
/*
@func ret_t | rtl8370_getAsicGreenPortPage | Set per-Port ingress page usage per second
@parm uint32 | port | The port number
@parm uint32* | page | page number of ingress packet occuping per second
@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 ingress traffic occuping page number per second for high layer green feature usage
*/
ret_t rtl8370_getAsicGreenPortPage(uint32 port, uint32* page)
{
    ret_t retVal;
    uint32 regData;
    uint32 pageMeter;
    
    if(port > RTL8370_PORTIDMAX)
        return RT_ERR_PORT_ID;

    retVal = rtl8370_getAsicReg(RTL8370_PAGEMETER_PORT_REG(port) , &regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    pageMeter = regData;

    retVal = rtl8370_getAsicReg(RTL8370_PAGEMETER_PORT_REG(port) + 1 , &regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    pageMeter = pageMeter + (regData <<16);

    *page = pageMeter;     
    return RT_ERR_OK;
}
Ejemplo n.º 28
0
/*
@func ret_t | rtl8370_getAsicLutAgeTimerSpeed | Set LUT agging out speed
@parm uint32* | timer | Agging out timer 0:Has been aged out.
@parm uint32* | speed | Agging out speed 0-fastest 3-slowest.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@comm
     The API can get LUT agging out period for each entry. 
 */
ret_t rtl8370_getAsicLutAgeTimerSpeed( uint32* timer, uint32* speed)
{
    uint32 regData;
    ret_t retVal;

    retVal = rtl8370_getAsicReg(RTL8370_REG_LUT_CFG,&regData);
    if(retVal != RT_ERR_OK)
        return retVal;

    *timer =  (regData & RTL8370_AGE_TIMER_MASK) >> RTL8370_AGE_TIMER_OFFSET;
    
    *speed =  (regData & RTL8370_AGE_SPEED_MASK) >> RTL8370_AGE_SPEED_OFFSET;

    return RT_ERR_OK;

}
/*
@func ret_t | rtl8370_getAsicForceLed | Turn on/off Led of dedicated port
@parm uint32* | mode | LED mode, 0b00:normal mode, 0b01:force blink, 0b10:force off, 0b11:force on.
@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 value.
@comm
    The API can turn on/off leds of dedicated port while indicated information configuration of LED group is set to force mode.
 */
ret_t rtl8370_getAsicLedGroupMode(uint32* mode)
{
    ret_t retVal;
	uint32 regData;

    retVal = rtl8370_getAsicReg(RTL8370_REG_LED_CONFIGURATION,&regData);
    if (retVal !=  RT_ERR_OK)
        return retVal;

	if ((regData&RTL8370_LED_CONFIG_SEL_MASK)!=RTL8370_LED_CONFIG_SEL_MASK)
		return RT_ERR_FAILED;

    *mode = (regData&RTL8370_DATA_LED_MASK)>>RTL8370_DATA_LED_OFFSET;

    return retVal;
}
Ejemplo n.º 30
0
/*
@func ret_t | rtl8370_getAsicWFQWeight | Get weight of WFQ.
@parm uint32 | port | The port number.
@parm uint32 | qid | The queue ID wanted to set.
@parm uint32* | qWeight | Pointer to the returned weight value.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_PORT_ID | Invalid port number.
@rvalue RT_ERR_QUEUE_ID | Invalid queue id.
@comm
    The API can get weight of the specified queue.  Parameter 'qweight' is only used in queueType = strict priority.  
    If queue type is strict priority, the parameter 'qweight' can be ignored.  
 */
ret_t rtl8370_getAsicWFQWeight(uint32 port, uint32 qid, uint32 *qWeight)
{
    ret_t retVal;


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

    if(qid > RTL8370_QIDMAX)
        return RT_ERR_QUEUE_ID;


    retVal = rtl8370_getAsicReg(RTL8370_SCHEDULE_PORT_QUEUE_WFQ_WEIGHT_REG(port, qid), qWeight);    

    return retVal;
}