static void ar8327_reset_vlans(struct arswitch_softc *sc) { int i; uint32_t mode, t; /* * For now, let's default to one portgroup, just so traffic * flows. All ports can see other ports. */ for (i = 0; i < AR8327_NUM_PORTS; i++) { /* set pvid = i */ t = i << AR8327_PORT_VLAN0_DEF_SVID_S; t |= i << AR8327_PORT_VLAN0_DEF_CVID_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN0(i), t); /* set egress == out_keep */ mode = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH; t = AR8327_PORT_VLAN1_PORT_VLAN_PROP; t |= mode << AR8327_PORT_VLAN1_OUT_MODE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN1(i), t); /* Set ingress = out_keep; members = 0x3f for all ports */ t = 0x3f; /* all ports */ t |= AR8327_PORT_LOOKUP_LEARN; /* in_port_only, forward */ t |= AR8X16_PORT_VLAN_MODE_PORT_ONLY << AR8327_PORT_LOOKUP_IN_MODE_S; t |= AR8X16_PORT_CTRL_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(i), t); } }
static void ar8327_reset_vlans(struct arswitch_softc *sc) { int i; uint32_t mode, t; /* * Disable mirroring. */ arswitch_modifyreg(sc->sc_dev, AR8327_REG_FWD_CTRL0, AR8327_FWD_CTRL0_MIRROR_PORT, (0xF << AR8327_FWD_CTRL0_MIRROR_PORT_S)); /* * For now, let's default to one portgroup, just so traffic * flows. All ports can see other ports. */ for (i = 0; i < AR8327_NUM_PORTS; i++) { /* set pvid = i */ t = i << AR8327_PORT_VLAN0_DEF_SVID_S; t |= i << AR8327_PORT_VLAN0_DEF_CVID_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN0(i), t); /* set egress == out_keep */ mode = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH; t = AR8327_PORT_VLAN1_PORT_VLAN_PROP; t |= mode << AR8327_PORT_VLAN1_OUT_MODE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN1(i), t); /* Set ingress = out_keep; members = 0x3f for all ports */ t = (0x3f & ~(1 << i)); /* all ports besides us */ t |= AR8327_PORT_LOOKUP_LEARN; /* in_port_only, forward */ t |= AR8X16_PORT_VLAN_MODE_PORT_ONLY << AR8327_PORT_LOOKUP_IN_MODE_S; t |= AR8X16_PORT_CTRL_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(i), t); /* * Disable port mirroring entirely. */ arswitch_modifyreg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(i), AR8327_PORT_LOOKUP_ING_MIRROR_EN, 0); arswitch_modifyreg(sc->sc_dev, AR8327_REG_PORT_HOL_CTRL1(i), AR8327_PORT_HOL_CTRL1_EG_MIRROR_EN, 0); } }
/* * Port setup. Called at attach time. */ static void ar8327_port_init(struct arswitch_softc *sc, int port) { uint32_t t; int ports; /* For now, port can see all other ports */ ports = 0x7f; if (port == AR8X16_PORT_CPU) t = sc->ar8327.port0_status; else if (port == 6) t = sc->ar8327.port6_status; else t = AR8X16_PORT_STS_LINK_AUTO; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_STATUS(port), t); arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_HEADER(port), 0); /* * Default to 1 port group. */ t = 1 << AR8327_PORT_VLAN0_DEF_SVID_S; t |= 1 << AR8327_PORT_VLAN0_DEF_CVID_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN0(port), t); t = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH << AR8327_PORT_VLAN1_OUT_MODE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN1(port), t); /* * This doesn't configure any ports which this port can "see". * bits 0-6 control which ports a frame coming into this port * can be sent out to. * * So by doing this, we're making it impossible to send frames out * to that port. */ t = AR8327_PORT_LOOKUP_LEARN; t |= AR8X16_PORT_CTRL_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; /* So this allows traffic to any port except ourselves */ t |= (ports & ~(1 << port)); arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(port), t); }
/* * Port setup. */ static void ar8327_port_init(struct arswitch_softc *sc, int port) { uint32_t t; if (port == AR8X16_PORT_CPU) t = sc->ar8327.port0_status; else if (port == 6) t = sc->ar8327.port6_status; else #if 0 /* XXX DB120 - hard-code port0 to 1000/full */ if (port == 0) { t = AR8X16_PORT_STS_SPEED_1000; t |= AR8X16_PORT_STS_TXMAC | AR8X16_PORT_STS_RXMAC; t |= AR8X16_PORT_STS_DUPLEX; t |= AR8X16_PORT_STS_RXFLOW; t |= AR8X16_PORT_STS_TXFLOW; } else #endif t = AR8X16_PORT_STS_LINK_AUTO; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_STATUS(port), t); arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_HEADER(port), 0); t = 1 << AR8327_PORT_VLAN0_DEF_SVID_S; t |= 1 << AR8327_PORT_VLAN0_DEF_CVID_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN0(port), t); t = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH << AR8327_PORT_VLAN1_OUT_MODE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN1(port), t); t = AR8327_PORT_LOOKUP_LEARN; t |= AR8X16_PORT_CTRL_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(port), t); }
static void ar8327_reset_vlans(struct arswitch_softc *sc) { int i; uint32_t t; int ports; ARSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED); ARSWITCH_LOCK(sc); /* Clear the existing VLAN configuration */ memset(sc->vid, 0, sizeof(sc->vid)); /* * Disable mirroring. */ arswitch_modifyreg(sc->sc_dev, AR8327_REG_FWD_CTRL0, AR8327_FWD_CTRL0_MIRROR_PORT, (0xF << AR8327_FWD_CTRL0_MIRROR_PORT_S)); /* * XXX TODO: disable any Q-in-Q port configuration, * tagging, egress filters, etc. */ /* * For now, let's default to one portgroup, just so traffic * flows. All ports can see other ports. There are two CPU GMACs * (GMAC0, GMAC6), GMAC1..GMAC5 are external PHYs. * * (ETHERSWITCH_VLAN_PORT) */ ports = 0x7f; /* * XXX TODO: set things up correctly for vlans! */ for (i = 0; i < AR8327_NUM_PORTS; i++) { int egress, ingress; if (sc->vlan_mode == ETHERSWITCH_VLAN_PORT) { sc->vid[i] = i | ETHERSWITCH_VID_VALID; /* set egress == out_keep */ ingress = AR8X16_PORT_VLAN_MODE_PORT_ONLY; /* in_port_only, forward */ egress = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH; } else if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) { ingress = AR8X16_PORT_VLAN_MODE_SECURE; egress = AR8327_PORT_VLAN1_OUT_MODE_UNMOD; } else { /* set egress == out_keep */ ingress = AR8X16_PORT_VLAN_MODE_PORT_ONLY; /* in_port_only, forward */ egress = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH; } /* set pvid = 1; there's only one vlangroup to start with */ t = 1 << AR8327_PORT_VLAN0_DEF_SVID_S; t |= 1 << AR8327_PORT_VLAN0_DEF_CVID_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN0(i), t); t = AR8327_PORT_VLAN1_PORT_VLAN_PROP; t |= egress << AR8327_PORT_VLAN1_OUT_MODE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN1(i), t); /* Ports can see other ports */ /* XXX not entirely true for dot1q? */ t = (ports & ~(1 << i)); /* all ports besides us */ t |= AR8327_PORT_LOOKUP_LEARN; t |= ingress << AR8327_PORT_LOOKUP_IN_MODE_S; t |= AR8X16_PORT_CTRL_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(i), t); } /* * Disable port mirroring entirely. */ for (i = 0; i < AR8327_NUM_PORTS; i++) { ar8327_port_disable_mirror(sc, i); } /* * If dot1q - set pvid; dot1q, etc. */ if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) { sc->vid[0] = 1; for (i = 0; i < AR8327_NUM_PORTS; i++) { /* Each port - pvid 1 */ sc->hal.arswitch_vlan_set_pvid(sc, i, sc->vid[0]); } /* Initialise vlan1 - all ports, untagged */ sc->hal.arswitch_set_dot1q_vlan(sc, ports, ports, sc->vid[0]); sc->vid[0] |= ETHERSWITCH_VID_VALID; } ARSWITCH_UNLOCK(sc); }