ip17x_vlans.c (250386) | ip17x_vlans.c (253569) |
---|---|
1/*- 2 * Copyright (c) 2013 Luiz Otavio O Souza. 3 * Copyright (c) 2011-2012 Stefan Bethke. 4 * Copyright (c) 2012 Adrian Chadd. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 2013 Luiz Otavio O Souza. 3 * Copyright (c) 2011-2012 Stefan Bethke. 4 * Copyright (c) 2012 Adrian Chadd. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/dev/etherswitch/ip17x/ip17x_vlans.c 250386 2013-05-08 20:58:41Z adrian $ | 28 * $FreeBSD: head/sys/dev/etherswitch/ip17x/ip17x_vlans.c 253569 2013-07-23 13:56:38Z loos $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/bus.h> 33#include <sys/errno.h> 34#include <sys/kernel.h> 35#include <sys/systm.h> 36#include <sys/socket.h> --- 32 unchanged lines hidden (view full) --- 69 70 if (vlan_mode == ETHERSWITCH_VLAN_PORT) { 71 72 /* Initialize port based vlans. */ 73 for (i = 0, phy = 0; phy < MII_NPHY; phy++) { 74 if (((1 << phy) & sc->phymask) == 0) 75 continue; 76 v = &sc->vlan[i]; | 29 */ 30 31#include <sys/param.h> 32#include <sys/bus.h> 33#include <sys/errno.h> 34#include <sys/kernel.h> 35#include <sys/systm.h> 36#include <sys/socket.h> --- 32 unchanged lines hidden (view full) --- 69 70 if (vlan_mode == ETHERSWITCH_VLAN_PORT) { 71 72 /* Initialize port based vlans. */ 73 for (i = 0, phy = 0; phy < MII_NPHY; phy++) { 74 if (((1 << phy) & sc->phymask) == 0) 75 continue; 76 v = &sc->vlan[i]; |
77 v->vlanid = i++; | 77 v->vlanid = i++ | ETHERSWITCH_VID_VALID; |
78 v->ports = (1 << sc->cpuport); 79 for (j = 0; j < MII_NPHY; j++) { 80 if (((1 << j) & sc->phymask) == 0) 81 continue; 82 v->ports |= (1 << j); 83 } 84 } 85 86 } else if (vlan_mode == ETHERSWITCH_VLAN_DOT1Q) { 87 88 /* 89 * Setup vlan 1 as PVID for all switch ports. Add all ports as 90 * members of vlan 1. 91 */ 92 v = &sc->vlan[0]; | 78 v->ports = (1 << sc->cpuport); 79 for (j = 0; j < MII_NPHY; j++) { 80 if (((1 << j) & sc->phymask) == 0) 81 continue; 82 v->ports |= (1 << j); 83 } 84 } 85 86 } else if (vlan_mode == ETHERSWITCH_VLAN_DOT1Q) { 87 88 /* 89 * Setup vlan 1 as PVID for all switch ports. Add all ports as 90 * members of vlan 1. 91 */ 92 v = &sc->vlan[0]; |
93 v->vlanid = 1; 94 /* Set PVID for everyone. */ | 93 v->vlanid = 1 | ETHERSWITCH_VID_VALID; 94 /* Set PVID to 1 for everyone. */ |
95 for (i = 0; i < sc->numports; i++) | 95 for (i = 0; i < sc->numports; i++) |
96 sc->pvid[i] = v->vlanid; | 96 sc->pvid[i] = 1; |
97 for (i = 0; i < MII_NPHY; i++) { 98 if ((sc->phymask & (1 << i)) == 0) 99 continue; 100 v->ports |= (1 << i); 101 } 102 } 103 104 return (0); --- 38 unchanged lines hidden (view full) --- 143 144 sc = device_get_softc(dev); 145 146 /* Check VLAN mode. */ 147 if (sc->vlan_mode == 0) 148 return (EINVAL); 149 150 /* IP175C don't support VLAN IDs > 15. */ | 97 for (i = 0; i < MII_NPHY; i++) { 98 if ((sc->phymask & (1 << i)) == 0) 99 continue; 100 v->ports |= (1 << i); 101 } 102 } 103 104 return (0); --- 38 unchanged lines hidden (view full) --- 143 144 sc = device_get_softc(dev); 145 146 /* Check VLAN mode. */ 147 if (sc->vlan_mode == 0) 148 return (EINVAL); 149 150 /* IP175C don't support VLAN IDs > 15. */ |
151 if (IP17X_IS_SWITCH(sc, IP175C) && vg->es_vid > IP175C_LAST_VLAN) | 151 if (IP17X_IS_SWITCH(sc, IP175C) && 152 (vg->es_vid & ETHERSWITCH_VID_MASK) > IP175C_LAST_VLAN) |
152 return (EINVAL); 153 154 /* Vlan ID. */ | 153 return (EINVAL); 154 155 /* Vlan ID. */ |
155 sc->vlan[vg->es_vlangroup].vlanid = vg->es_vid; | 156 if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) { 157 for (i = 0; i < sc->info.es_nvlangroups; i++) { 158 /* Is this Vlan ID already set in another vlangroup ? */ 159 if (i != vg->es_vlangroup && 160 sc->vlan[i].vlanid & ETHERSWITCH_VID_VALID && 161 (sc->vlan[i].vlanid & ETHERSWITCH_VID_MASK) == 162 (vg->es_vid & ETHERSWITCH_VID_MASK)) 163 return (EINVAL); 164 } 165 sc->vlan[vg->es_vlangroup].vlanid = vg->es_vid & 166 ETHERSWITCH_VID_MASK; 167 /* Setting the vlanid to zero disables the vlangroup. */ 168 if (sc->vlan[vg->es_vlangroup].vlanid == 0) { 169 sc->vlan[vg->es_vlangroup].ports = 0; 170 return (sc->hal.ip17x_hw_setup(sc)); 171 } 172 sc->vlan[vg->es_vlangroup].vlanid |= ETHERSWITCH_VID_VALID; 173 } |
156 157 /* Member Ports. */ 158 sc->vlan[vg->es_vlangroup].ports = 0; 159 for (i = 0; i < sc->numports; i++) { 160 if ((vg->es_member_ports & (1 << i)) == 0) 161 continue; 162 phy = sc->portphy[i]; 163 sc->vlan[vg->es_vlangroup].ports |= (1 << phy); 164 } 165 166 return (sc->hal.ip17x_hw_setup(sc)); 167} | 174 175 /* Member Ports. */ 176 sc->vlan[vg->es_vlangroup].ports = 0; 177 for (i = 0; i < sc->numports; i++) { 178 if ((vg->es_member_ports & (1 << i)) == 0) 179 continue; 180 phy = sc->portphy[i]; 181 sc->vlan[vg->es_vlangroup].ports |= (1 << phy); 182 } 183 184 return (sc->hal.ip17x_hw_setup(sc)); 185} |