FreeBSD/sys/dev/etherswitch/ip17x/ip17x_vlans.c
/*
 * Reset vlans to default state.
 */
Reset vlans to default state.
Reset vlans to default state .
int
ip17x_reset_vlans(struct ip17x_softc *sc, uint32_t vlan_mode)
{
	struct ip17x_vlan *v;
	int i, j, phy;
	sc->addtag = 0;
	sc->striptag = 0;
	memset(sc->vlan, 0, sizeof(sc->vlan));
	memset(sc->pvid, 0, sizeof(uint32_t) * sc->numports);
	if (vlan_mode == ETHERSWITCH_VLAN_PORT) {
		for (i = 0, phy = 0; phy < MII_NPHY; phy++) {
			if (((1 << phy) & sc->phymask) == 0)
				continue;
			v = &sc->vlan[i];
			v->vlanid = i++ | ETHERSWITCH_VID_VALID;
			v->ports = (1 << sc->cpuport);
			for (j = 0; j < MII_NPHY; j++) {
				if (((1 << j) & sc->phymask) == 0)
					continue;
				v->ports |= (1 << j);
			}
		}
	} else if (vlan_mode == ETHERSWITCH_VLAN_DOT1Q) {
		v = &sc->vlan[0];
		v->vlanid = 1 | ETHERSWITCH_VID_VALID;
		for (i = 0; i < sc->numports; i++)
			sc->pvid[i] = 1;
		for (i = 0; i < MII_NPHY; i++) {
			if ((sc->phymask & (1 << i)) == 0)
				continue;
			v->ports |= (1 << i);
		}
	}
	return (0);
}
int ip17x_reset_vlans ( struct ip17x_softc * sc , uint32_t vlan_mode ) { struct ip17x_vlan * v ; int i , j , phy ; sc -> addtag = 0 ; sc -> striptag = 0 ; memset ( sc -> vlan , 0 , sizeof ( sc -> vlan ) ) ; memset ( sc -> pvid , 0 , sizeof ( uint32_t ) * sc -> numports ) ; if ( vlan_mode == ETHERSWITCH_VLAN_PORT ) { for ( i = 0 , phy = 0 ; phy < MII_NPHY ; phy ++ ) { if ( ( ( 1 << phy ) & sc -> phymask ) == 0 ) continue ; v = & sc -> vlan [ i ] ; v -> vlanid = i ++ | ETHERSWITCH_VID_VALID ; v -> ports = ( 1 << sc -> cpuport ) ; for ( j = 0 ; j < MII_NPHY ; j ++ ) { if ( ( ( 1 << j ) & sc -> phymask ) == 0 ) continue ; v -> ports |= ( 1 << j ) ; } } } else if ( vlan_mode == ETHERSWITCH_VLAN_DOT1Q ) { v = & sc -> vlan [ 0 ] ; v -> vlanid = 1 | ETHERSWITCH_VID_VALID ; for ( i = 0 ; i < sc -> numports ; i ++ ) sc -> pvid [ i ] = 1 ; for ( i = 0 ; i < MII_NPHY ; i ++ ) { if ( ( sc -> phymask & ( 1 << i ) ) == 0 ) continue ; v -> ports |= ( 1 << i ) ; } } return ( 0 ) ; }
Reset vlans to default state.
Reset vlans to default state .
/* Do not add or strip vlan tags on any port. */ /* Reset all vlan data. */ /* Initialize port based vlans. */ /*
		 * Setup vlan 1 as PVID for all switch ports.  Add all ports as
		 * members of vlan 1.
		 */ /* Set PVID to 1 for everyone. */