Date: Mon, 24 Feb 2014 04:44:28 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262429 - head/sys/dev/etherswitch/arswitch Message-ID: <201402240444.s1O4iSJG017035@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: adrian Date: Mon Feb 24 04:44:28 2014 New Revision: 262429 URL: http://svnweb.freebsd.org/changeset/base/262429 Log: Methodize the arswitch VLAN routines. These differ per chipset family in subtle and evil ways. It becomes very noticable on the AR8327 where the layout is just plain wrong. Modified: head/sys/dev/etherswitch/arswitch/arswitch.c head/sys/dev/etherswitch/arswitch/arswitch_vlans.c head/sys/dev/etherswitch/arswitch/arswitch_vlans.h Modified: head/sys/dev/etherswitch/arswitch/arswitch.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch.c Mon Feb 24 04:43:23 2014 (r262428) +++ head/sys/dev/etherswitch/arswitch/arswitch.c Mon Feb 24 04:44:28 2014 (r262429) @@ -222,7 +222,7 @@ arswitch_set_vlan_mode(struct arswitch_s }; /* Reset VLANs. */ - arswitch_reset_vlans(sc); + sc->hal.arswitch_vlan_init_hw(sc); return (0); } @@ -274,6 +274,11 @@ arswitch_attach(device_t dev) sc->hal.arswitch_port_init = ar8xxx_port_init; sc->hal.arswitch_port_vlan_setup = ar8xxx_port_vlan_setup; sc->hal.arswitch_port_vlan_get = ar8xxx_port_vlan_get; + sc->hal.arswitch_vlan_init_hw = ar8xxx_reset_vlans; + sc->hal.arswitch_vlan_getvgroup = ar8xxx_getvgroup; + sc->hal.arswitch_vlan_setvgroup = ar8xxx_setvgroup; + sc->hal.arswitch_vlan_get_pvid = ar8xxx_get_pvid; + sc->hal.arswitch_vlan_set_pvid = ar8xxx_set_pvid; /* * Attach switch related functions @@ -538,7 +543,7 @@ ar8xxx_port_vlan_get(struct arswitch_sof ARSWITCH_LOCK(sc); /* Retrieve the PVID. */ - arswitch_get_pvid(sc, p->es_port, &p->es_pvid); + sc->hal.arswitch_vlan_get_pvid(sc, p->es_port, &p->es_pvid); /* Port flags. */ reg = arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(p->es_port)); @@ -602,7 +607,7 @@ ar8xxx_port_vlan_setup(struct arswitch_s /* Set the PVID. */ if (p->es_pvid != 0) - arswitch_set_pvid(sc, p->es_port, p->es_pvid); + sc->hal.arswitch_vlan_set_pvid(sc, p->es_port, p->es_pvid); /* Mutually exclusive. */ if (p->es_flags & ETHERSWITCH_PORT_ADDTAG && @@ -730,6 +735,22 @@ arswitch_setconf(device_t dev, etherswit return (0); } +static int +arswitch_getvgroup(device_t dev, etherswitch_vlangroup_t *e) +{ + struct arswitch_softc *sc = device_get_softc(dev); + + return (sc->hal.arswitch_vlan_getvgroup(sc, e)); +} + +static int +arswitch_setvgroup(device_t dev, etherswitch_vlangroup_t *e) +{ + struct arswitch_softc *sc = device_get_softc(dev); + + return (sc->hal.arswitch_vlan_setvgroup(sc, e)); +} + static device_method_t arswitch_methods[] = { /* Device interface */ DEVMETHOD(device_probe, arswitch_probe), Modified: head/sys/dev/etherswitch/arswitch/arswitch_vlans.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch_vlans.c Mon Feb 24 04:43:23 2014 (r262428) +++ head/sys/dev/etherswitch/arswitch/arswitch_vlans.c Mon Feb 24 04:44:28 2014 (r262429) @@ -171,7 +171,7 @@ arswitch_set_port_vlan(struct arswitch_s * Reset vlans to default state. */ void -arswitch_reset_vlans(struct arswitch_softc *sc) +ar8xxx_reset_vlans(struct arswitch_softc *sc) { uint32_t ports; int i, j; @@ -220,7 +220,7 @@ arswitch_reset_vlans(struct arswitch_sof sc->vid[0] = 1; /* Set PVID for everyone. */ for (i = 0; i <= sc->numphys; i++) - arswitch_set_pvid(sc, i, sc->vid[0]); + sc->hal.arswitch_vlan_set_pvid(sc, i, sc->vid[0]); ports = 0; for (i = 0; i <= sc->numphys; i++) ports |= (1 << i); @@ -259,12 +259,10 @@ arswitch_reset_vlans(struct arswitch_sof } int -arswitch_getvgroup(device_t dev, etherswitch_vlangroup_t *vg) +ar8xxx_getvgroup(struct arswitch_softc *sc, etherswitch_vlangroup_t *vg) { - struct arswitch_softc *sc; int err; - sc = device_get_softc(dev); ARSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED); if (vg->es_vlangroup > sc->info.es_nvlangroups) @@ -305,12 +303,10 @@ arswitch_getvgroup(device_t dev, ethersw } int -arswitch_setvgroup(device_t dev, etherswitch_vlangroup_t *vg) +ar8xxx_setvgroup(struct arswitch_softc *sc, etherswitch_vlangroup_t *vg) { - struct arswitch_softc *sc; int err, vid; - sc = device_get_softc(dev); ARSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED); /* Check VLAN mode. */ @@ -362,7 +358,7 @@ arswitch_setvgroup(device_t dev, ethersw } int -arswitch_get_pvid(struct arswitch_softc *sc, int port, int *pvid) +ar8xxx_get_pvid(struct arswitch_softc *sc, int port, int *pvid) { uint32_t reg; @@ -373,7 +369,7 @@ arswitch_get_pvid(struct arswitch_softc } int -arswitch_set_pvid(struct arswitch_softc *sc, int port, int pvid) +ar8xxx_set_pvid(struct arswitch_softc *sc, int port, int pvid) { ARSWITCH_LOCK_ASSERT(sc, MA_OWNED); Modified: head/sys/dev/etherswitch/arswitch/arswitch_vlans.h ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch_vlans.h Mon Feb 24 04:43:23 2014 (r262428) +++ head/sys/dev/etherswitch/arswitch/arswitch_vlans.h Mon Feb 24 04:44:28 2014 (r262429) @@ -29,10 +29,10 @@ #ifndef __ARSWITCH_VLANS_H__ #define __ARSWITCH_VLANS_H__ -void arswitch_reset_vlans(struct arswitch_softc *); -int arswitch_getvgroup(device_t, etherswitch_vlangroup_t *); -int arswitch_setvgroup(device_t, etherswitch_vlangroup_t *); -int arswitch_get_pvid(struct arswitch_softc *, int, int *); -int arswitch_set_pvid(struct arswitch_softc *, int, int); +void ar8xxx_reset_vlans(struct arswitch_softc *); +int ar8xxx_getvgroup(struct arswitch_softc *, etherswitch_vlangroup_t *); +int ar8xxx_setvgroup(struct arswitch_softc *, etherswitch_vlangroup_t *); +int ar8xxx_get_pvid(struct arswitch_softc *, int, int *); +int ar8xxx_set_pvid(struct arswitch_softc *, int, int); #endif /* __ARSWITCH_VLANS_H__ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402240444.s1O4iSJG017035>