示例#1
0
/*******************************************************************************
* gpavSetPAV
*
* DESCRIPTION:
*       This routine sets the Port Association Vector
*
* INPUTS:
*       port    - logical port number.
*       pav     - Port Association Vector
*
* OUTPUTS:
*       None.
*
* RETURNS:
*       GT_OK               - on success
*       GT_FAIL             - on error
*       GT_BAD_PARAM        - on bad parameters
*
* COMMENTS:
*
* GalTis:
*
*******************************************************************************/
GT_STATUS gpavSetPAV
(
    IN GT_QD_DEV *dev,
    IN GT_LPORT     port,
    IN GT_U16     pav
)
{

    GT_STATUS       retVal;         /* Functions return value.      */
    GT_U8           phyPort;        /* Physical port.               */
    GT_U16            hwPav;

    DBG_INFO(("gpavSetPAV Called.\n"));

    phyPort = GT_LPORT_2_PORT(port);

    /* check if device supports this feature */
    if((retVal = IS_VALID_API_CALL(dev,phyPort, DEV_PORT_MONITORING)) != GT_OK )
        return retVal;

    /*
     * translate Logical Port Vector to Physical Port Vector.
     */
    hwPav = (GT_U16)GT_LPORTVEC_2_PORTVEC(pav);

    if(hwPav == (GT_U16)GT_INVALID_PORT_VEC)
    {
        return GT_BAD_PARAM;
    }

    /* there are 7 ports in the switch */
    retVal = hwSetPortRegField(dev,phyPort,QD_REG_PORT_ASSOCIATION,0,dev->maxPorts,hwPav);
    if(retVal != GT_OK)
    {
        DBG_INFO(("Failed.\n"));
        return retVal;
    }
    DBG_INFO(("OK.\n"));
    return GT_OK;
}
/*******************************************************************************
* gstpSetMode
*
* DESCRIPTION:
*       This routine Enable the Spanning tree.
*
* INPUTS:
*       en - GT_TRUE for enable, GT_FALSE for disable.
*
* OUTPUTS:
*       None.
*
* RETURNS:
*       GT_OK   - on success
*       GT_FAIL - on error
*
* COMMENTS:
*       when enabled, this function sets all port to blocking state, and inserts
*       the BPDU MAC into the ATU to be captured to CPU, on disable all port are
*       being modified to be in forwarding state.
*
* GalTis:
*
*******************************************************************************/
GT_STATUS gstpSetMode
(
    IN GT_QD_DEV *dev,
    IN GT_BOOL  en
)
{
    GT_STATUS       retVal = GT_OK; /* Functions return value.      */
    GT_ATU_ENTRY        atuEntry;   /* The ATU entry data to be set */
    GT_U32          i, dbNum;

    DBG_INFO(("gstpSetMode Called.\n"));
    if(dev->deviceId == GT_88E6051)
    {
        DBG_INFO(("Failed.\n"));
        return GT_FAIL;
    }

    if((en == GT_TRUE) && (dev->stpMode == 1))
    {
        DBG_INFO(("OK.\n"));
        return GT_OK;
    }

	switch(dev->deviceId)
	{
		case GT_88E6051:
		case GT_88E6052:
			dbNum = 1;
			break;
		case GT_FF_HG:
		case GT_FF_EG:
		case GT_88E6021:
		case GT_88E6060:
		case GT_88E6031:
		case GT_88E6061:
		case GT_88E6063:
		case GT_FH_VPN:
		case GT_88E6083:
		case GT_88E6153:
		case GT_88E6181:
		case GT_88E6183:
		case GT_88E6093:
			dbNum = 16;
			break;
		case GT_88E6035:
		case GT_88E6055:
		case GT_88E6065:
			dbNum = 64;
			break;
		default:
			if (!IS_IN_DEV_GROUP(dev,DEV_ENHANCED_MULTICAST))
			{
				dbNum = 64;
			}
			else
			{
				dbNum = 0;
				retVal = enhancedBPDUSet(dev,en);
			}
			break;
	}

	for (i=0; i<dbNum; i++)
	{
	    /* Set the Atu entry parameters.    */
    	atuEntry.macAddr.arEther[0] = 0x01;
	    atuEntry.macAddr.arEther[1] = 0x80;
    	atuEntry.macAddr.arEther[2] = 0xC2;
	    atuEntry.macAddr.arEther[3] = 0x00;
    	atuEntry.macAddr.arEther[4] = 0x00;
	    atuEntry.macAddr.arEther[5] = 0x00;
    	atuEntry.portVec = GT_LPORTVEC_2_PORTVEC((1<<dev->cpuPortNum));
		if(IS_IN_DEV_GROUP(dev,DEV_ATU_EXT_PRI))
		{
			if(IS_IN_DEV_GROUP(dev,DEV_FQPRI_IN_TABLE))
			{
				atuEntry.exPrio.useMacFPri = GT_TRUE;
				atuEntry.exPrio.macFPri = 7;
			}
			else
			{
				atuEntry.exPrio.useMacFPri = 0;
				atuEntry.exPrio.macFPri = 0;
			}
			atuEntry.exPrio.macQPri = 3;
		    atuEntry.prio    = 0;
		}
		else
		{
		    atuEntry.prio    = 3;
			atuEntry.exPrio.useMacFPri = 0;
			atuEntry.exPrio.macFPri = 0;
			atuEntry.exPrio.macQPri = 0;
		}
		atuEntry.DBNum = (GT_U8)i;
	    atuEntry.entryState.mcEntryState = GT_MC_PRIO_MGM_STATIC;

    	if(en == GT_TRUE)
	    {
    	    retVal = gfdbAddMacEntry(dev,&atuEntry);
	    }
    	else
		{
			if(dev->stpMode == 0)
				break;
        	retVal = gfdbDelAtuEntry(dev,&atuEntry);
		}

		if (retVal != GT_OK)
			break;
	}

    if(retVal == GT_OK)
	{
	    if(en == GT_TRUE)
    	    dev->stpMode = 1;
	    else
    	    dev->stpMode = 2;
        DBG_INFO(("OK.\n"));
	}
    else
	{
   	    dev->stpMode = 0;
        DBG_INFO(("Failed.\n"));
	}


    return retVal;
}