Deleted Added
full compact
arswitch.c (262208) arswitch.c (262429)
1/*-
2 * Copyright (c) 2011-2012 Stefan Bethke.
3 * Copyright (c) 2012 Adrian Chadd.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 2011-2012 Stefan Bethke.
3 * Copyright (c) 2012 Adrian Chadd.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/etherswitch/arswitch/arswitch.c 262208 2014-02-19 06:43:52Z adrian $
27 * $FreeBSD: head/sys/dev/etherswitch/arswitch/arswitch.c 262429 2014-02-24 04:44:28Z adrian $
28 */
29
30#include <sys/param.h>
31#include <sys/bus.h>
32#include <sys/errno.h>
33#include <sys/kernel.h>
34#include <sys/malloc.h>
35#include <sys/module.h>

--- 181 unchanged lines hidden (view full) ---

217 case ETHERSWITCH_VLAN_PORT:
218 sc->vlan_mode = ETHERSWITCH_VLAN_PORT;
219 break;
220 default:
221 sc->vlan_mode = 0;
222 };
223
224 /* Reset VLANs. */
28 */
29
30#include <sys/param.h>
31#include <sys/bus.h>
32#include <sys/errno.h>
33#include <sys/kernel.h>
34#include <sys/malloc.h>
35#include <sys/module.h>

--- 181 unchanged lines hidden (view full) ---

217 case ETHERSWITCH_VLAN_PORT:
218 sc->vlan_mode = ETHERSWITCH_VLAN_PORT;
219 break;
220 default:
221 sc->vlan_mode = 0;
222 };
223
224 /* Reset VLANs. */
225 arswitch_reset_vlans(sc);
225 sc->hal.arswitch_vlan_init_hw(sc);
226
227 return (0);
228}
229
230static void
231ar8xxx_port_init(struct arswitch_softc *sc, int port)
232{
233

--- 35 unchanged lines hidden (view full) ---

269 sc->page = -1;
270 strlcpy(sc->info.es_name, device_get_desc(dev),
271 sizeof(sc->info.es_name));
272
273 /* Default HAL methods */
274 sc->hal.arswitch_port_init = ar8xxx_port_init;
275 sc->hal.arswitch_port_vlan_setup = ar8xxx_port_vlan_setup;
276 sc->hal.arswitch_port_vlan_get = ar8xxx_port_vlan_get;
226
227 return (0);
228}
229
230static void
231ar8xxx_port_init(struct arswitch_softc *sc, int port)
232{
233

--- 35 unchanged lines hidden (view full) ---

269 sc->page = -1;
270 strlcpy(sc->info.es_name, device_get_desc(dev),
271 sizeof(sc->info.es_name));
272
273 /* Default HAL methods */
274 sc->hal.arswitch_port_init = ar8xxx_port_init;
275 sc->hal.arswitch_port_vlan_setup = ar8xxx_port_vlan_setup;
276 sc->hal.arswitch_port_vlan_get = ar8xxx_port_vlan_get;
277 sc->hal.arswitch_vlan_init_hw = ar8xxx_reset_vlans;
278 sc->hal.arswitch_vlan_getvgroup = ar8xxx_getvgroup;
279 sc->hal.arswitch_vlan_setvgroup = ar8xxx_setvgroup;
280 sc->hal.arswitch_vlan_get_pvid = ar8xxx_get_pvid;
281 sc->hal.arswitch_vlan_set_pvid = ar8xxx_set_pvid;
277
278 /*
279 * Attach switch related functions
280 */
281 if (AR8X16_IS_SWITCH(sc, AR7240))
282 ar7240_attach(sc);
283 else if (AR8X16_IS_SWITCH(sc, AR9340))
284 ar9340_attach(sc);

--- 248 unchanged lines hidden (view full) ---

533static int
534ar8xxx_port_vlan_get(struct arswitch_softc *sc, etherswitch_port_t *p)
535{
536 uint32_t reg;
537
538 ARSWITCH_LOCK(sc);
539
540 /* Retrieve the PVID. */
282
283 /*
284 * Attach switch related functions
285 */
286 if (AR8X16_IS_SWITCH(sc, AR7240))
287 ar7240_attach(sc);
288 else if (AR8X16_IS_SWITCH(sc, AR9340))
289 ar9340_attach(sc);

--- 248 unchanged lines hidden (view full) ---

538static int
539ar8xxx_port_vlan_get(struct arswitch_softc *sc, etherswitch_port_t *p)
540{
541 uint32_t reg;
542
543 ARSWITCH_LOCK(sc);
544
545 /* Retrieve the PVID. */
541 arswitch_get_pvid(sc, p->es_port, &p->es_pvid);
546 sc->hal.arswitch_vlan_get_pvid(sc, p->es_port, &p->es_pvid);
542
543 /* Port flags. */
544 reg = arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(p->es_port));
545 if (reg & AR8X16_PORT_CTRL_DOUBLE_TAG)
546 p->es_flags |= ETHERSWITCH_PORT_DOUBLE_TAG;
547 reg >>= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
548 if ((reg & 0x3) == AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_ADD)
549 p->es_flags |= ETHERSWITCH_PORT_ADDTAG;

--- 47 unchanged lines hidden (view full) ---

597{
598 uint32_t reg;
599 int err;
600
601 ARSWITCH_LOCK(sc);
602
603 /* Set the PVID. */
604 if (p->es_pvid != 0)
547
548 /* Port flags. */
549 reg = arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(p->es_port));
550 if (reg & AR8X16_PORT_CTRL_DOUBLE_TAG)
551 p->es_flags |= ETHERSWITCH_PORT_DOUBLE_TAG;
552 reg >>= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
553 if ((reg & 0x3) == AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_ADD)
554 p->es_flags |= ETHERSWITCH_PORT_ADDTAG;

--- 47 unchanged lines hidden (view full) ---

602{
603 uint32_t reg;
604 int err;
605
606 ARSWITCH_LOCK(sc);
607
608 /* Set the PVID. */
609 if (p->es_pvid != 0)
605 arswitch_set_pvid(sc, p->es_port, p->es_pvid);
610 sc->hal.arswitch_vlan_set_pvid(sc, p->es_port, p->es_pvid);
606
607 /* Mutually exclusive. */
608 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG &&
609 p->es_flags & ETHERSWITCH_PORT_STRIPTAG) {
610 ARSWITCH_UNLOCK(sc);
611 return (EINVAL);
612 }
613

--- 111 unchanged lines hidden (view full) ---

725 err = arswitch_set_vlan_mode(sc, conf->vlan_mode);
726 if (err != 0)
727 return (err);
728 }
729
730 return (0);
731}
732
611
612 /* Mutually exclusive. */
613 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG &&
614 p->es_flags & ETHERSWITCH_PORT_STRIPTAG) {
615 ARSWITCH_UNLOCK(sc);
616 return (EINVAL);
617 }
618

--- 111 unchanged lines hidden (view full) ---

730 err = arswitch_set_vlan_mode(sc, conf->vlan_mode);
731 if (err != 0)
732 return (err);
733 }
734
735 return (0);
736}
737
738static int
739arswitch_getvgroup(device_t dev, etherswitch_vlangroup_t *e)
740{
741 struct arswitch_softc *sc = device_get_softc(dev);
742
743 return (sc->hal.arswitch_vlan_getvgroup(sc, e));
744}
745
746static int
747arswitch_setvgroup(device_t dev, etherswitch_vlangroup_t *e)
748{
749 struct arswitch_softc *sc = device_get_softc(dev);
750
751 return (sc->hal.arswitch_vlan_setvgroup(sc, e));
752}
753
733static device_method_t arswitch_methods[] = {
734 /* Device interface */
735 DEVMETHOD(device_probe, arswitch_probe),
736 DEVMETHOD(device_attach, arswitch_attach),
737 DEVMETHOD(device_detach, arswitch_detach),
738
739 /* bus interface */
740 DEVMETHOD(bus_add_child, device_add_child_ordered),

--- 39 unchanged lines hidden ---
754static device_method_t arswitch_methods[] = {
755 /* Device interface */
756 DEVMETHOD(device_probe, arswitch_probe),
757 DEVMETHOD(device_attach, arswitch_attach),
758 DEVMETHOD(device_detach, arswitch_detach),
759
760 /* bus interface */
761 DEVMETHOD(bus_add_child, device_add_child_ordered),

--- 39 unchanged lines hidden ---