Exemplo n.º 1
0
/*
 * Set the switch VLAN mode.
 */
static int
ip175c_set_vlan_mode(struct ip17x_softc *sc, uint32_t mode)
{

	switch (mode) {
	case ETHERSWITCH_VLAN_DOT1Q:
		/* Enable VLAN tag processing. */
		ip17x_updatephy(sc->sc_dev, 30, 9, 0x80, 0x80);
		sc->vlan_mode = mode;
		break;
	case ETHERSWITCH_VLAN_PORT:
	default:
		/* Disable VLAN tag processing. */
		ip17x_updatephy(sc->sc_dev, 30, 9, 0x80, 0);
		sc->vlan_mode = ETHERSWITCH_VLAN_PORT;
		break;
	}

	/* Reset vlans. */
	ip17x_reset_vlans(sc, sc->vlan_mode);

	/* Update switch configuration. */
	ip175c_hw_setup(sc);

	return (0);
}
Exemplo n.º 2
0
/*
 * Set the switch VLAN mode.
 */
static int
ip175d_set_vlan_mode(struct ip17x_softc *sc, uint32_t mode)
{

    switch (mode) {
    case ETHERSWITCH_VLAN_DOT1Q:
        /*
         * VLAN classification rules: tag-based VLANs,
         * use VID to classify, drop packets that cannot
         * be classified.
         */
        ip17x_updatephy(sc->sc_dev, 22, 0, 0x3fff, 0x003f);
        sc->vlan_mode = mode;
        break;
    case ETHERSWITCH_VLAN_PORT:
        sc->vlan_mode = mode;
    /* fallthrough */
    default:
        /*
         * VLAN classification rules: everything off &
         * clear table.
         */
        ip17x_updatephy(sc->sc_dev, 22, 0, 0xbfff, 0x8000);
        sc->vlan_mode = 0;
        break;
    };

    if (sc->vlan_mode != 0) {
        /*
         * Ingress rules: CFI=1 dropped, null VID is untagged, VID=1 passed,
         * VID=0xfff discarded, admin both tagged and untagged, ingress
         * filters enabled.
         */
        ip17x_updatephy(sc->sc_dev, 22, 1, 0x0fff, 0x0c3f);

        /* Egress rules: IGMP processing off, keep VLAN header off. */
        ip17x_updatephy(sc->sc_dev, 22, 2, 0x0fff, 0x0000);
    } else {
        ip17x_updatephy(sc->sc_dev, 22, 1, 0x0fff, 0x043f);
        ip17x_updatephy(sc->sc_dev, 22, 2, 0x0fff, 0x0020);
    }

    /* Reset vlans. */
    ip17x_reset_vlans(sc, sc->vlan_mode);

    /* Update switch configuration. */
    ip175d_hw_setup(sc);

    return (0);
}