From owner-svn-src-all@FreeBSD.ORG Mon Feb 24 04:44:29 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3A9D990E; Mon, 24 Feb 2014 04:44:29 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 176F11FD5; Mon, 24 Feb 2014 04:44:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1O4iSZO017038; Mon, 24 Feb 2014 04:44:28 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1O4iSJG017035; Mon, 24 Feb 2014 04:44:28 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201402240444.s1O4iSJG017035@svn.freebsd.org> From: Adrian Chadd Date: Mon, 24 Feb 2014 04:44:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262429 - head/sys/dev/etherswitch/arswitch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Feb 2014 04:44:29 -0000 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__ */