Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jul 2013 13:56:38 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r253569 - in head: sbin/etherswitchcfg sys/dev/etherswitch sys/dev/etherswitch/ip17x sys/dev/etherswitch/rtl8366
Message-ID:  <201307231356.r6NDuc4I029458@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Tue Jul 23 13:56:38 2013
New Revision: 253569
URL: http://svnweb.freebsd.org/changeset/base/253569

Log:
  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)

Modified:
  head/sbin/etherswitchcfg/etherswitchcfg.c
  head/sys/dev/etherswitch/etherswitch.h
  head/sys/dev/etherswitch/ip17x/ip175c.c
  head/sys/dev/etherswitch/ip17x/ip175d.c
  head/sys/dev/etherswitch/ip17x/ip17x_vlans.c
  head/sys/dev/etherswitch/rtl8366/rtl8366rb.c

Modified: head/sbin/etherswitchcfg/etherswitchcfg.c
==============================================================================
--- head/sbin/etherswitchcfg/etherswitchcfg.c	Tue Jul 23 13:40:26 2013	(r253568)
+++ head/sbin/etherswitchcfg/etherswitchcfg.c	Tue Jul 23 13:56:38 2013	(r253569)
@@ -471,8 +471,9 @@ print_vlangroup(struct cfg *cfg, int vla
 	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);

Modified: head/sys/dev/etherswitch/etherswitch.h
==============================================================================
--- head/sys/dev/etherswitch/etherswitch.h	Tue Jul 23 13:40:26 2013	(r253568)
+++ head/sys/dev/etherswitch/etherswitch.h	Tue Jul 23 13:56:38 2013	(r253569)
@@ -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 */

Modified: head/sys/dev/etherswitch/ip17x/ip175c.c
==============================================================================
--- head/sys/dev/etherswitch/ip17x/ip175c.c	Tue Jul 23 13:40:26 2013	(r253568)
+++ head/sys/dev/etherswitch/ip17x/ip175c.c	Tue Jul 23 13:56:38 2013	(r253569)
@@ -147,9 +147,9 @@ ip175c_dot1q_vlan_setup(struct ip17x_sof
 	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++) {

Modified: head/sys/dev/etherswitch/ip17x/ip175d.c
==============================================================================
--- head/sys/dev/etherswitch/ip17x/ip175d.c	Tue Jul 23 13:40:26 2013	(r253568)
+++ head/sys/dev/etherswitch/ip17x/ip175d.c	Tue Jul 23 13:56:38 2013	(r253569)
@@ -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)

Modified: head/sys/dev/etherswitch/ip17x/ip17x_vlans.c
==============================================================================
--- head/sys/dev/etherswitch/ip17x/ip17x_vlans.c	Tue Jul 23 13:40:26 2013	(r253568)
+++ head/sys/dev/etherswitch/ip17x/ip17x_vlans.c	Tue Jul 23 13:56:38 2013	(r253569)
@@ -74,7 +74,7 @@ ip17x_reset_vlans(struct ip17x_softc *sc
 			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
 		 * 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, etherswitc
 		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;

Modified: head/sys/dev/etherswitch/rtl8366/rtl8366rb.c
==============================================================================
--- head/sys/dev/etherswitch/rtl8366/rtl8366rb.c	Tue Jul 23 13:40:26 2013	(r253568)
+++ head/sys/dev/etherswitch/rtl8366/rtl8366rb.c	Tue Jul 23 13:56:38 2013	(r253569)
@@ -619,7 +619,7 @@ rtl_getvgroup(device_t dev, etherswitch_
 	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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307231356.r6NDuc4I029458>