/******************************************************************************* * gsysInitCPUPort * * DESCRIPTION: * This routine initializes CPU Port to required values. It is requred for Opus * * INPUTS: * cpuPort - CPU Port * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * None. * *******************************************************************************/ static GT_STATUS gsysInitCPUPort ( IN GT_QD_DEV *dev, IN GT_LPORT cpuPort ) { GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("gsysInitCPUPort Called.\n")); /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(cpuPort); if (!IS_IN_DEV_GROUP(dev,DEV_CPU_PORT_NEED_INIT)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } if (cpuPort >= dev->numOfPorts) { return GT_BAD_PARAM; } /* Initialize the CPU Port. */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PORT_CONTROL, 11, 1, 1); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } retVal = hwSetPortRegField(dev,hwPort, QD_REG_PORT_CONTROL, 8, 2, 3); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } retVal = hwSetPortRegField(dev,hwPort, QD_REG_PORT_VLAN_MAP, 0, 10, 0x7ff); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } retVal = hwSetPortRegField(dev,hwPort, QD_REG_PORT_CONTROL2, 10, 4, 0); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * gstpSetPortState * * DESCRIPTION: * This routine set the port state. * * INPUTS: * port - the logical port number. * state - the port state to set. * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * * COMMENTS: * * * GalTis: * *******************************************************************************/ GT_STATUS gstpSetPortState ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_PORT_STP_STATE state ) { GT_U8 phyPort; /* Physical port */ GT_U16 data; /* Data to write to register. */ GT_STATUS retVal; /* Functions return value. */ DBG_INFO(("gstpSetPortState Called.\n")); phyPort = GT_LPORT_2_PORT(port); data = state; /* Set the port state bits. */ retVal= hwSetPortRegField(dev,phyPort, QD_REG_PORT_CONTROL,0,2,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * gpavSetIngressMonitor * * DESCRIPTION: * This routine sets the Ingress Monitor bit in the PAV. * * INPUTS: * port - the logical port number. * mode - the ingress monitor bit in the PAV * GT_FALSE: Ingress Monitor enabled * GT_TRUE: Ingress Monitor disabled * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * * COMMENTS: * * * GalTis: * *******************************************************************************/ GT_STATUS gpavSetIngressMonitor ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL mode ) { GT_STATUS retVal; /* Functions return value. */ GT_U16 data; /* Data to be set into the */ /* register. */ GT_U8 phyPort; /* Physical port. */ DBG_INFO(("gpavSetIngressMonitorCalled.\n")); phyPort = GT_LPORT_2_PORT(port); BOOL_2_BIT(mode,data); /* check if device supports this feature */ if (!IS_IN_DEV_GROUP(dev,DEV_ENABLE_MONITORING)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } retVal = hwSetPortRegField(dev,phyPort,QD_REG_PORT_ASSOCIATION,15,1,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * gvlnSetPortVlanDBNum * * DESCRIPTION: * This routine sets the port's default VLAN database number (DBNum or * FID, Forwarding Information Database). * * INPUTS: * port - logical port number to set. * DBNum - database number for this port (or FID) * * OUTPUTS: * None. * * RETURNS:IN GT_INGRESS_MODE mode * GT_OK - on success * GT_FAIL - on error * GT_BAD_PARAM - on bad parameters * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gvlnSetPortVlanDBNum ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_U32 DBNum ) { GT_STATUS retVal; /* Functions return value. */ GT_U8 phyPort; /* Physical port. */ DBG_INFO(("gvlnSetPortVlanDBNum Called.\n")); phyPort = GT_LPORT_2_PORT(port); if(IS_IN_DEV_GROUP(dev,DEV_DBNUM_4096)) { if(DBNum > 4095) { return GT_BAD_PARAM; } retVal = hwSetPortRegField(dev,phyPort,QD_REG_PORT_CONTROL1,0,8,(GT_U16)((DBNum & 0xFF0) >> 4)); retVal = hwSetPortRegField(dev,phyPort,QD_REG_PORT_VLAN_MAP,12,4,(GT_U16)(DBNum & 0x000F)); } else if(IS_IN_DEV_GROUP(dev,DEV_DBNUM_256))
/******************************************************************************* * gvlnSetPortUserPriLsb * * DESCRIPTION: * This routine Set the user priority (VPT) LSB bit, to be added to the * user priority on the egress. * * INPUTS: * port - logical port number to set. * userPriLsb - GT_TRUE for 1, GT_FALSE for 0. * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_BAD_PARAM - on bad parameters * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gvlnSetPortUserPriLsb ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL userPriLsb ) { GT_STATUS retVal; /* Functions return value. */ GT_U16 data; /* Data to be set into the */ /* register. */ GT_U8 phyPort; /* Physical port. */ DBG_INFO(("gvlnSetPortUserPriLsb Called.\n")); /* Gigabit Switch does not support this status. */ if ((IS_IN_DEV_GROUP(dev,DEV_GIGABIT_SWITCH)) || (IS_IN_DEV_GROUP(dev,DEV_ENHANCED_FE_SWITCH)) || (IS_IN_DEV_GROUP(dev,DEV_FE_AVB_FAMILY))) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } phyPort = GT_LPORT_2_PORT(port); BOOL_2_BIT(userPriLsb,data); retVal = hwSetPortRegField(dev,phyPort,QD_REG_PVID,13,1,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * gprtSetVlanTunnel * * DESCRIPTION: * This routine sets the vlan tunnel mode. * * INPUTS: * port - the logical port number. * mode - the vlan tunnel mode. * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * * COMMENTS: * * * GalTis: * *******************************************************************************/ GT_STATUS gprtSetVlanTunnel ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL mode ) { GT_STATUS retVal; /* Functions return value. */ GT_U16 data; /* Data to be set into the */ /* register. */ GT_U8 phyPort; /* Physical port. */ DBG_INFO(("gprtSetVlanTunnel Called.\n")); phyPort = GT_LPORT_2_PORT(port); BOOL_2_BIT(mode,data); retVal = hwSetPortRegField(dev,phyPort,QD_REG_PORT_CONTROL,7,1,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * gprtSetEgressMode * * DESCRIPTION: * This routine set the egress mode. * * INPUTS: * port - the logical port number. * mode - the egress mode. * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * * COMMENTS: * * * GalTis: * *******************************************************************************/ GT_STATUS gprtSetEgressMode ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_EGRESS_MODE mode ) { GT_STATUS retVal; /* Functions return value. */ GT_U16 data; /* Data to be set into the */ /* register. */ GT_U8 phyPort; /* Physical port. */ DBG_INFO(("gprtSetEgressMode Called.\n")); phyPort = GT_LPORT_2_PORT(port); /* check if device supports this feature */ if((retVal = IS_VALID_API_CALL(dev,phyPort, DEV_TAGGING)) != GT_OK ) return retVal; switch (mode) { case (GT_UNMODIFY_EGRESS): data = 0; break; case (GT_TAGGED_EGRESS): data = 2; break; case (GT_UNTAGGED_EGRESS): data = 1; break; case (GT_ADD_TAG): if(!IS_IN_DEV_GROUP(dev,DEV_EGRESS_DOUBLE_TAGGING)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } data = 3; break; default: DBG_INFO(("Failed.\n")); return GT_FAIL; } retVal = hwSetPortRegField(dev,phyPort,QD_REG_PORT_CONTROL,12,2,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * gpcsSetPCSAnEn * * DESCRIPTION: * This routine sets Enable mode of PCS Inband Auto-Negotiation. * * INPUTS: * port - the logical port number. * mode - GT_TRUE to enable PCS AN mode or GT_FALSE otherwise * * OUTPUTS: * None * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gpcsSetPCSAnEn ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL mode ) { GT_U16 data; /* Used to poll the SWReset bit */ GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("gpcsSetPCSAnEn Called.\n")); /* check if the given Switch supports this feature. */ if (!IS_IN_DEV_GROUP(dev,DEV_PCS)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } /* translate BOOL to binary */ BOOL_2_BIT(mode, data); /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); /* check if the given port supports PCS */ if (!DOES_DEVPORT_SUPPORT_PCS(dev,hwPort)) { if (!IS_IN_DEV_GROUP(dev, DEV_INTERNAL_GPHY)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } if ((hwPort < 4) || (hwPort > 7)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } } /* Get the PCSAnEn bit. */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PCS_CONTROL,10,1,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); } else { DBG_INFO(("OK.\n")); } /* return */ return retVal; }
/******************************************************************************* * gpcsSetRGMIITimingDelay * * DESCRIPTION: * RGMII receive/transmit Timing Control. This api adds delay to RXCLK for * IND inputs and GTXCLK for OUTD outputs when port is in RGMII mode. * Change to this bit are disruptive to normal operation. Hence any changes * to this register must be done only while the port's link is down. * * INPUTS: * port - the logical port number. * rxmode - GT_FALSE for default setup, GT_TRUE for adding delay to rxclk * txmode - GT_FALSE for default setup, GT_TRUE for adding delay to txclk * * OUTPUTS: * None * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * *******************************************************************************/ GT_STATUS gpcsSetRGMIITimingDelay ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL rxmode, IN GT_BOOL txmode ) { GT_U16 data; GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("gpcsSetRGMIITimingDelay Called.\n")); if (!IS_IN_DEV_GROUP(dev,DEV_RGMII_TIMING)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); if (hwPort < (dev->maxPorts - 2)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } data = (rxmode) ? 2 : 0; data |= (txmode) ? 1 : 0; /* Set the register bit(s). */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PCS_CONTROL,14,2,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); } else { DBG_INFO(("OK.\n")); } /* return */ return retVal; }
/******************************************************************************* * gpcsSetRestartPCSAn * * DESCRIPTION: * This routine restarts PCS Inband Auto-Negotiation. * * INPUTS: * port - the logical port number. * * OUTPUTS: * None * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gpcsSetRestartPCSAn ( IN GT_QD_DEV *dev, IN GT_LPORT port ) { GT_U16 data; /* Used to poll the SWReset bit */ GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("gpcsSetRestartPCSAn Called.\n")); /* check if the given Switch supports this feature. */ if (!IS_IN_DEV_GROUP(dev,DEV_PCS)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } data = 1; /* to set RestartPCSAn bit */ /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); /* check if the given port supports PCS */ if (!DOES_DEVPORT_SUPPORT_PCS(dev,hwPort)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } /* Get the RestartPCSAn bit. */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PCS_CONTROL,9,1,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); } else { DBG_INFO(("OK.\n")); } /* return */ return retVal; }
/******************************************************************************* * gvlnSetPortVlanPorts * * DESCRIPTION: * This routine sets the port VLAN group port membership list. * * INPUTS: * port - logical port number to set. * memPorts - array of logical ports in the same vlan. * memPortsLen - number of members in memPorts array * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_BAD_PARAM - on bad parameters * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gvlnSetPortVlanPorts ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_LPORT memPorts[], IN GT_U8 memPortsLen ) { GT_STATUS retVal; /* Functions return value. */ GT_U16 data; /* Data to be set into the */ /* register. */ GT_U8 phyPort; /* Physical port. */ GT_U8 i; DBG_INFO(("gvlnSetPortVlanPorts Called.\n")); if(memPorts == NULL) { DBG_INFO(("Failed.\n")); return GT_BAD_PARAM; } phyPort = GT_LPORT_2_PORT(port); data = 0; if(memPortsLen > dev->numOfPorts) { DBG_INFO(("Failed (PortsLen Too Big).\n")); return GT_BAD_PARAM; } for(i = 0; i < memPortsLen; i++) data |= (1 << GT_LPORT_2_PORT(memPorts[i])); /* numOfPorts = 3 for fullsail, = 10 for octane, = 7 for others */ retVal = hwSetPortRegField(dev,phyPort,QD_REG_PORT_VLAN_MAP,0,dev->maxPorts,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * 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; }
/******************************************************************************* * gvlnSetPortVid * * DESCRIPTION: * This routine Set the port default vlan id. * * INPUTS: * port - logical port number to set. * vid - the port vlan id. * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_BAD_PARAM - on bad parameters * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gvlnSetPortVid ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_U16 vid ) { GT_STATUS retVal; /* Functions return value. */ GT_U8 phyPort; /* Physical port. */ DBG_INFO(("gvlnSetPortVid Called.\n")); phyPort = GT_LPORT_2_PORT(port); retVal = hwSetPortRegField(dev,phyPort,QD_REG_PVID,0,12, vid); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }
/******************************************************************************* * gpcsSetForcedFC * * DESCRIPTION: * This routine forces Flow Control. If FCValue is set to one, calling this * routine with GT_TRUE will force Flow Control to be enabled. * * INPUTS: * port - the logical port number. * state - GT_TRUE to force flow control (enable or disable), GT_FALSE otherwise * * OUTPUTS: * None * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gpcsSetForcedFC ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL state ) { GT_U16 data; /* Used to poll the SWReset bit */ GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("gpcsSetForcedFC Called.\n")); /* check if the given Switch supports this feature. */ if (!IS_IN_DEV_GROUP(dev,DEV_FC_WITH_VALUE)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } BOOL_2_BIT(state, data); /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); /* Get the ForcedFC bit. */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PCS_CONTROL,6,1,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); } else { DBG_INFO(("OK.\n")); } /* return */ return retVal; }
/******************************************************************************* * geventSetAgeIntEn * * DESCRIPTION: * This routine enables/disables Age Interrupt for a port. * When it's enabled, ATU Age Violation interrupts from this port are enabled. * An Age Violation will occur anytime a port is Locked(gprtSetLockedPort) * and the ingressing frame's SA is contained in the ATU as a non-Static * entry with a EntryState less than 0x4. * * INPUTS: * port - the logical port number * mode - GT_TRUE to enable Age Interrupt, * GT_FALUSE to disable * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * *******************************************************************************/ GT_STATUS geventSetAgeIntEn ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL mode ) { GT_U16 data; GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("geventSetAgeIntEn Called.\n")); /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); if (!IS_IN_DEV_GROUP(dev,DEV_PORT_BASED_AGE_INT)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } /* translate BOOL to binary */ BOOL_2_BIT(mode, data); /* Set Age Interrupt Enable Mode. */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PORT_ASSOCIATION,11,1,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); } else { DBG_INFO(("OK.\n")); } return retVal; }
/******************************************************************************* * gpcsSetForceSpeed * * DESCRIPTION: * This routine forces Speed. * * INPUTS: * port - the logical port number. * mode - GT_PORT_FORCED_SPEED_MODE (10, 100, 1000, or no force speed) * * OUTPUTS: * None * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gpcsSetForceSpeed ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_PORT_FORCED_SPEED_MODE mode ) { GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("gpcsSetForceSpeed Called.\n")); /* check if the given Switch supports this feature. */ if (!IS_IN_DEV_GROUP(dev,DEV_FORCE_WITH_VALUE)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); /* Set the Force Speed bits. */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PCS_CONTROL,0,2,(GT_U16)mode); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); } else { DBG_INFO(("OK.\n")); } /* return */ return retVal; }
/******************************************************************************* * gpcsSetRGMIITimingDelay * * DESCRIPTION: * RGMII receive/transmit Timing Control. This api adds delay to RXCLK for * IND inputs and GTXCLK for OUTD outputs when port is in RGMII mode. * Change to this bit are disruptive to normal operation. Hence any changes * to this register must be done only while the port's link is down. * * INPUTS: * port - the logical port number. * rxmode - GT_FALSE for default setup, GT_TRUE for adding delay to rxclk * txmode - GT_FALSE for default setup, GT_TRUE for adding delay to txclk * * OUTPUTS: * None * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * *******************************************************************************/ GT_STATUS gpcsSetRGMIITimingDelay ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_BOOL rxmode, IN GT_BOOL txmode ) { GT_U16 data; GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* the physical port number */ DBG_INFO(("gpcsSetRGMIITimingDelay Called.\n")); if (!IS_IN_DEV_GROUP(dev,DEV_RGMII_TIMING)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); if (hwPort < (dev->maxPorts - 2)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } if(((dev->devName==DEV_88E6165)||(dev->devName==DEV_88E6161))&& ((hwPort==4)||((hwPort==5)&&(dev->revision==2)))) /* 88E6123 revision A2 */ { if(hwWritePortReg(dev,4,0x1A,0x81E7) != GT_OK) { DBG_INFO(("Failed.\n")); return GT_FAIL; } if(hwReadPortReg(dev,5,0x1A,&data) != GT_OK) { DBG_INFO(("Failed.\n")); return GT_FAIL; } if((hwPort==5)&&(dev->revision==2)) /* 88E6123 revision A2 */ { data &= 0xfff9; data |= (rxmode) ? 0x2 : 0; data |= (txmode) ? 0x1: 0; } else { data &= 0xffe7; data |= (rxmode) ? 0x10 : 0; data |= (txmode) ? 0x8: 0; } if(hwWritePortReg(dev,5,0x1A, data) != GT_OK) { DBG_INFO(("Failed.\n")); return GT_FAIL; } if(hwWritePortReg(dev,4,0x1A,0xC1E7) != GT_OK) { DBG_INFO(("Failed.\n")); return GT_FAIL; } } else { data = (rxmode) ? 2 : 0; data |= (txmode) ? 1 : 0; /* Set the register bit(s). */ retVal = hwSetPortRegField(dev,hwPort, QD_REG_PCS_CONTROL,14,2,data); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); } else { DBG_INFO(("OK.\n")); } } /* return */ return retVal; }
/******************************************************************************* * gprtSetPolicy * * DESCRIPTION: * This routine sets the Policy for ports. * Supported Policies are defined as GT_FRAME_POLICY as follows: * FRAME_POLICY_NONE - normal frame switching * FRAME_POLICY_MIRROR - mirror (copy) frame to MirrorDest port * FRAME_POLICY_TRAP - trap(re-direct) frame to the CPUDest port * FRAME_POLICY_DISCARD - discard(filter) the frame * Supported Policy types are defined as GT_POLICY_TYPE: * POLICY_TYPE_DA - DA Policy Mapping * DA Policy Mapping occurs when the DA of a frame is contained in * the ATU address database with an Entry State that indicates Policy. * POLICY_TYPE_SA - SA Policy Mapping * SA Policy Mapping occurs when the SA of a frame is contained in * the ATU address database with an Entry State that indicates Policy. * POLICY_TYPE_VTU - VTU Policy Mapping * VTU Policy Mapping occurs when the VID of a frame is contained in * the VTU database with the VidPolicy is enabled. * POLICY_TYPE_ETYPE - EtherType Policy Mapping * EType Policy Mapping occurs when the EtherType of a frame matches * the PortEType (see gprtSetPortEType API) * POLICY_TYPE_PPPoE - PPPoE Policy Mapping * PPPoE Policy Mapping occurs when the EtherType of a frame matches 0x8863 * POLICY_TYPE_VBAS - VBAS Policy Mapping * VBAS Policy Mapping occurs when the EtherType of a frame matches 0x8200 * POLICY_TYPE_OPT82 - DHCP Option 82 Policy Mapping * DHCP Option 82 Policy Mapping occurs when the ingressing frame is an * IPv4 UDP with a UDP Destination port = 0x0043 or 0x0044, or an * IPv6 UDP with a UDP Destination port = 0x0223 or 0x0222 * POLICY_TYPE_UDP - UDP Policy Mapping * UDP Policy Mapping occurs when the ingressing frame is * a Broadcast IPv4 UDP or a Multicast IPv6 UDP. * * INPUTS: * port - logical port number. * type - policy type (GT_POLICY_TYPE) * policy - policy (GT_FRAME_POLICY) * * OUTPUTS: * None. * * RETURNS: * GT_OK - on success * GT_FAIL - on error * GT_BAD_PARAM - on bad parameters * GT_NOT_SUPPORTED - if current device does not support this feature. * * COMMENTS: * * GalTis: * *******************************************************************************/ GT_STATUS gprtSetPolicy ( IN GT_QD_DEV *dev, IN GT_LPORT port, IN GT_POLICY_TYPE type, IN GT_FRAME_POLICY policy ) { GT_STATUS retVal; /* Functions return value. */ GT_U8 hwPort; /* Physical port. */ GT_U8 offset; DBG_INFO(("gprtSetPolicy Called.\n")); /* translate LPORT to hardware port */ hwPort = GT_LPORT_2_PORT(port); /* check if device supports this feature */ if (!IS_IN_DEV_GROUP(dev,DEV_POLICY)) { DBG_INFO(("GT_NOT_SUPPORTED\n")); return GT_NOT_SUPPORTED; } switch (policy) { case FRAME_POLICY_NONE: case FRAME_POLICY_MIRROR: case FRAME_POLICY_TRAP: case FRAME_POLICY_DISCARD: break; default: DBG_INFO(("Bad Policy\n")); return GT_BAD_PARAM; } switch (type) { case POLICY_TYPE_DA: offset = 14; break; case POLICY_TYPE_SA: offset = 12; break; case POLICY_TYPE_VTU: offset = 10; break; case POLICY_TYPE_ETYPE: offset = 8; break; case POLICY_TYPE_PPPoE: offset = 6; break; case POLICY_TYPE_VBAS: offset = 4; break; case POLICY_TYPE_OPT82: offset = 2; break; case POLICY_TYPE_UDP: offset = 0; break; default: DBG_INFO(("Bad Parameter\n")); return GT_BAD_PARAM; } retVal = hwSetPortRegField(dev,hwPort, QD_REG_POLICY_CONTROL, offset, 2, (GT_U16)policy); if(retVal != GT_OK) { DBG_INFO(("Failed.\n")); return retVal; } DBG_INFO(("OK.\n")); return GT_OK; }