1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

Add a new flag (ETHERSWITCH_VID_VALID) to say what vlangroups are in use.

This fix the case when etherswitch is printing the information of port 0
vlan group (in port based vlan mode) with no member ports.

Add the ETHERSWITCH_VID_VALID support to ip17x driver.

Add the ETHERSWITCH_VID_VALID support to rt8366 driver.

arswitch doesn't need to be updated as it doesn't support vlans management
yet.

Approved by:	adrian (mentor)
This commit is contained in:
Luiz Otavio O Souza 2013-07-23 13:56:38 +00:00
parent da2a0dcb7a
commit cc320e372e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253569
6 changed files with 35 additions and 12 deletions

View File

@ -471,8 +471,9 @@ print_vlangroup(struct cfg *cfg, int vlangroup)
vg.es_vlangroup = vlangroup;
if (ioctl(cfg->fd, IOETHERSWITCHGETVLANGROUP, &vg) != 0)
err(EX_OSERR, "ioctl(IOETHERSWITCHGETVLANGROUP)");
if (vg.es_vid == 0 && vg.es_member_ports == 0)
if ((vg.es_vid & ETHERSWITCH_VID_VALID) == 0)
return;
vg.es_vid &= ETHERSWITCH_VID_MASK;
printf("vlangroup%d:\n", vlangroup);
if (cfg->conf.vlan_mode == ETHERSWITCH_VLAN_PORT)
printf("\tport: %d\n", vg.es_vid);

View File

@ -26,6 +26,8 @@ struct etherswitch_phyreg {
typedef struct etherswitch_phyreg etherswitch_phyreg_t;
#define ETHERSWITCH_NAMEMAX 64
#define ETHERSWITCH_VID_MASK 0xfff
#define ETHERSWITCH_VID_VALID (1 << 12)
#define ETHERSWITCH_VLAN_ISL (1 << 0) /* ISL */
#define ETHERSWITCH_VLAN_PORT (1 << 1) /* Port based vlan */
#define ETHERSWITCH_VLAN_DOT1Q (1 << 2) /* 802.1q */

View File

@ -147,9 +147,9 @@ ip175c_dot1q_vlan_setup(struct ip17x_softc *sc)
memset(vlans, 0, sizeof(vlans));
for (i = 0; i < IP17X_MAX_VLANS; i++) {
v = &sc->vlan[i];
if (v->vlanid == 0)
if ((v->vlanid & ETHERSWITCH_VID_VALID) == 0)
continue;
vlans[v->vlanid] = v->ports;
vlans[v->vlanid & ETHERSWITCH_VID_MASK] = v->ports;
}
for (j = 0, i = 1; i <= IP17X_MAX_VLANS / 2; i++) {

View File

@ -94,7 +94,8 @@ ip175d_hw_setup(struct ip17x_softc *sc)
striptag[i] = 0;
v = &sc->vlan[i];
if (v->vlanid == 0 || sc->vlan_mode == 0) {
if ((v->vlanid & ETHERSWITCH_VID_VALID) == 0 ||
sc->vlan_mode == 0) {
/* Vlangroup disabled. Reset the filter. */
ip17x_writephy(sc->sc_dev, 22, 14 + i, i + 1);
ports[i] = 0x3f;
@ -105,7 +106,8 @@ ip175d_hw_setup(struct ip17x_softc *sc)
ports[i] = v->ports;
/* Setup the filter, write the VLAN id. */
ip17x_writephy(sc->sc_dev, 22, 14 + i, v->vlanid);
ip17x_writephy(sc->sc_dev, 22, 14 + i,
v->vlanid & ETHERSWITCH_VID_MASK);
for (j = 0; j < MII_NPHY; j++) {
if ((ports[i] & (1 << j)) == 0)

View File

@ -74,7 +74,7 @@ ip17x_reset_vlans(struct ip17x_softc *sc, uint32_t vlan_mode)
if (((1 << phy) & sc->phymask) == 0)
continue;
v = &sc->vlan[i];
v->vlanid = 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)
@ -90,10 +90,10 @@ ip17x_reset_vlans(struct ip17x_softc *sc, uint32_t vlan_mode)
* members of vlan 1.
*/
v = &sc->vlan[0];
v->vlanid = 1;
/* Set PVID for everyone. */
v->vlanid = 1 | ETHERSWITCH_VID_VALID;
/* Set PVID to 1 for everyone. */
for (i = 0; i < sc->numports; i++)
sc->pvid[i] = v->vlanid;
sc->pvid[i] = 1;
for (i = 0; i < MII_NPHY; i++) {
if ((sc->phymask & (1 << i)) == 0)
continue;
@ -148,11 +148,29 @@ ip17x_setvgroup(device_t dev, etherswitch_vlangroup_t *vg)
return (EINVAL);
/* IP175C don't support VLAN IDs > 15. */
if (IP17X_IS_SWITCH(sc, IP175C) && vg->es_vid > IP175C_LAST_VLAN)
if (IP17X_IS_SWITCH(sc, IP175C) &&
(vg->es_vid & ETHERSWITCH_VID_MASK) > IP175C_LAST_VLAN)
return (EINVAL);
/* Vlan ID. */
sc->vlan[vg->es_vlangroup].vlanid = vg->es_vid;
if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) {
for (i = 0; i < sc->info.es_nvlangroups; i++) {
/* Is this Vlan ID already set in another vlangroup ? */
if (i != vg->es_vlangroup &&
sc->vlan[i].vlanid & ETHERSWITCH_VID_VALID &&
(sc->vlan[i].vlanid & ETHERSWITCH_VID_MASK) ==
(vg->es_vid & ETHERSWITCH_VID_MASK))
return (EINVAL);
}
sc->vlan[vg->es_vlangroup].vlanid = vg->es_vid &
ETHERSWITCH_VID_MASK;
/* Setting the vlanid to zero disables the vlangroup. */
if (sc->vlan[vg->es_vlangroup].vlanid == 0) {
sc->vlan[vg->es_vlangroup].ports = 0;
return (sc->hal.ip17x_hw_setup(sc));
}
sc->vlan[vg->es_vlangroup].vlanid |= ETHERSWITCH_VID_VALID;
}
/* Member Ports. */
sc->vlan[vg->es_vlangroup].ports = 0;

View File

@ -619,7 +619,7 @@ rtl_getvgroup(device_t dev, etherswitch_vlangroup_t *vg)
for (i=0; i<3; i++)
vmcr[i] = rtl_readreg(dev, RTL8366RB_VMCR(i, vg->es_vlangroup));
vg->es_vid = RTL8366RB_VMCR_VID(vmcr);
vg->es_vid = RTL8366RB_VMCR_VID(vmcr) | ETHERSWITCH_VID_VALID;
vg->es_member_ports = RTL8366RB_VMCR_MEMBER(vmcr);
vg->es_untagged_ports = RTL8366RB_VMCR_UNTAG(vmcr);
vg->es_fid = RTL8366RB_VMCR_FID(vmcr);