2 * Copyright (c) 2011-2012 Stefan Bethke.
3 * Copyright (c) 2012 Adrian Chadd.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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
30 #include <sys/param.h>
32 #include <sys/errno.h>
33 #include <sys/kernel.h>
34 #include <sys/malloc.h>
35 #include <sys/module.h>
36 #include <sys/socket.h>
37 #include <sys/sockio.h>
38 #include <sys/sysctl.h>
39 #include <sys/systm.h>
42 #include <net/if_var.h>
43 #include <net/if_arp.h>
44 #include <net/ethernet.h>
45 #include <net/if_dl.h>
46 #include <net/if_media.h>
47 #include <net/if_types.h>
49 #include <machine/bus.h>
50 #include <dev/iicbus/iic.h>
51 #include <dev/iicbus/iiconf.h>
52 #include <dev/iicbus/iicbus.h>
53 #include <dev/mii/mii.h>
54 #include <dev/mii/miivar.h>
55 #include <dev/etherswitch/mdio.h>
57 #include <dev/etherswitch/etherswitch.h>
59 #include <dev/etherswitch/arswitch/arswitchreg.h>
60 #include <dev/etherswitch/arswitch/arswitchvar.h>
61 #include <dev/etherswitch/arswitch/arswitch_reg.h>
62 #include <dev/etherswitch/arswitch/arswitch_phy.h>
63 #include <dev/etherswitch/arswitch/arswitch_vlans.h>
65 #include <dev/etherswitch/arswitch/arswitch_7240.h>
66 #include <dev/etherswitch/arswitch/arswitch_8216.h>
67 #include <dev/etherswitch/arswitch/arswitch_8226.h>
68 #include <dev/etherswitch/arswitch/arswitch_8316.h>
69 #include <dev/etherswitch/arswitch/arswitch_8327.h>
70 #include <dev/etherswitch/arswitch/arswitch_9340.h>
73 #include "miibus_if.h"
74 #include "etherswitch_if.h"
77 static SYSCTL_NODE(_debug, OID_AUTO, arswitch, CTLFLAG_RD, 0, "arswitch");
80 static inline int arswitch_portforphy(int phy);
81 static void arswitch_tick(void *arg);
82 static int arswitch_ifmedia_upd(struct ifnet *);
83 static void arswitch_ifmedia_sts(struct ifnet *, struct ifmediareq *);
84 static int ar8xxx_port_vlan_setup(struct arswitch_softc *sc,
85 etherswitch_port_t *p);
86 static int ar8xxx_port_vlan_get(struct arswitch_softc *sc,
87 etherswitch_port_t *p);
90 arswitch_probe(device_t dev)
92 struct arswitch_softc *sc;
94 char *chipname, desc[256];
96 sc = device_get_softc(dev);
97 bzero(sc, sizeof(*sc));
101 if (ar7240_probe(dev) == 0) {
103 sc->sc_switchtype = AR8X16_SWITCH_AR7240;
104 sc->is_internal_switch = 1;
110 if (ar9340_probe(dev) == 0) {
112 sc->sc_switchtype = AR8X16_SWITCH_AR9340;
113 sc->is_internal_switch = 1;
119 id = arswitch_readreg(dev, AR8X16_REG_MASK_CTRL);
120 sc->chip_rev = (id & AR8X16_MASK_CTRL_REV_MASK);
121 sc->chip_ver = (id & AR8X16_MASK_CTRL_VER_MASK) > AR8X16_MASK_CTRL_VER_SHIFT;
122 switch (id & (AR8X16_MASK_CTRL_VER_MASK | AR8X16_MASK_CTRL_REV_MASK)) {
125 sc->sc_switchtype = AR8X16_SWITCH_AR8216;
129 sc->sc_switchtype = AR8X16_SWITCH_AR8226;
131 /* 0x0301 - AR8236 */
135 sc->sc_switchtype = AR8X16_SWITCH_AR8316;
140 sc->sc_switchtype = AR8X16_SWITCH_AR8327;
141 sc->mii_lo_first = 1;
149 DPRINTF(dev, "chipname=%s, id=%08x\n", chipname, id);
150 if (chipname != NULL) {
151 snprintf(desc, sizeof(desc),
152 "Atheros %s Ethernet Switch",
154 device_set_desc_copy(dev, desc);
155 return (BUS_PROBE_DEFAULT);
161 arswitch_attach_phys(struct arswitch_softc *sc)
166 /* PHYs need an interface, so we generate a dummy one */
167 snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
168 for (phy = 0; phy < sc->numphys; phy++) {
169 sc->ifp[phy] = if_alloc(IFT_ETHER);
170 sc->ifp[phy]->if_softc = sc;
171 sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
172 IFF_DRV_RUNNING | IFF_SIMPLEX;
173 sc->ifname[phy] = malloc(strlen(name)+1, M_DEVBUF, M_WAITOK);
174 bcopy(name, sc->ifname[phy], strlen(name)+1);
175 if_initname(sc->ifp[phy], sc->ifname[phy],
176 arswitch_portforphy(phy));
177 err = mii_attach(sc->sc_dev, &sc->miibus[phy], sc->ifp[phy],
178 arswitch_ifmedia_upd, arswitch_ifmedia_sts, \
179 BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
180 DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n",
181 device_get_nameunit(sc->miibus[phy]),
182 sc->ifp[phy]->if_xname);
184 device_printf(sc->sc_dev,
185 "attaching PHY %d failed\n",
193 arswitch_reset(device_t dev)
196 arswitch_writereg(dev, AR8X16_REG_MASK_CTRL,
197 AR8X16_MASK_CTRL_SOFT_RESET);
199 if (arswitch_readreg(dev, AR8X16_REG_MASK_CTRL) &
200 AR8X16_MASK_CTRL_SOFT_RESET) {
201 device_printf(dev, "unable to reset switch\n");
208 arswitch_set_vlan_mode(struct arswitch_softc *sc, uint32_t mode)
211 /* Check for invalid modes. */
212 if ((mode & sc->info.es_vlan_caps) != mode)
216 case ETHERSWITCH_VLAN_DOT1Q:
217 sc->vlan_mode = ETHERSWITCH_VLAN_DOT1Q;
219 case ETHERSWITCH_VLAN_PORT:
220 sc->vlan_mode = ETHERSWITCH_VLAN_PORT;
227 sc->hal.arswitch_vlan_init_hw(sc);
233 ar8xxx_port_init(struct arswitch_softc *sc, int port)
237 if (port == AR8X16_PORT_CPU) {
238 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_STS(0),
239 (AR8X16_IS_SWITCH(sc, AR8216) ?
240 AR8X16_PORT_STS_SPEED_100 : AR8X16_PORT_STS_SPEED_1000) |
241 (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_RXFLOW) |
242 (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_TXFLOW) |
243 AR8X16_PORT_STS_RXMAC |
244 AR8X16_PORT_STS_TXMAC |
245 AR8X16_PORT_STS_DUPLEX);
246 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0),
247 arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0)) &
248 ~AR8X16_PORT_CTRL_HEADER);
250 /* Set ports to auto negotiation. */
251 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_STS(port),
252 AR8X16_PORT_STS_LINK_AUTO);
253 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_CTRL(port),
254 arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(port)) &
255 ~AR8X16_PORT_CTRL_HEADER);
260 ar8xxx_atu_flush(struct arswitch_softc *sc)
264 ret = arswitch_waitreg(sc->sc_dev,
271 device_printf(sc->sc_dev, "%s: waitreg failed\n", __func__);
274 arswitch_writereg(sc->sc_dev,
276 AR8216_ATU_OP_FLUSH);
282 arswitch_attach(device_t dev)
284 struct arswitch_softc *sc;
288 sc = device_get_softc(dev);
290 /* sc->sc_switchtype is already decided in arswitch_probe() */
292 mtx_init(&sc->sc_mtx, "arswitch", NULL, MTX_DEF);
294 strlcpy(sc->info.es_name, device_get_desc(dev),
295 sizeof(sc->info.es_name));
297 /* Default HAL methods */
298 sc->hal.arswitch_port_init = ar8xxx_port_init;
299 sc->hal.arswitch_port_vlan_setup = ar8xxx_port_vlan_setup;
300 sc->hal.arswitch_port_vlan_get = ar8xxx_port_vlan_get;
301 sc->hal.arswitch_vlan_init_hw = ar8xxx_reset_vlans;
302 sc->hal.arswitch_vlan_getvgroup = ar8xxx_getvgroup;
303 sc->hal.arswitch_vlan_setvgroup = ar8xxx_setvgroup;
304 sc->hal.arswitch_vlan_get_pvid = ar8xxx_get_pvid;
305 sc->hal.arswitch_vlan_set_pvid = ar8xxx_set_pvid;
306 sc->hal.arswitch_atu_flush = ar8xxx_atu_flush;
309 * Attach switch related functions
311 if (AR8X16_IS_SWITCH(sc, AR7240))
313 else if (AR8X16_IS_SWITCH(sc, AR9340))
315 else if (AR8X16_IS_SWITCH(sc, AR8216))
317 else if (AR8X16_IS_SWITCH(sc, AR8226))
319 else if (AR8X16_IS_SWITCH(sc, AR8316))
321 else if (AR8X16_IS_SWITCH(sc, AR8327))
326 /* Common defaults. */
327 sc->info.es_nports = 5; /* XXX technically 6, but 6th not used */
329 /* XXX Defaults for externally connected AR8316 */
336 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
337 "numphys", &sc->numphys);
338 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
339 "phy4cpu", &sc->phy4cpu);
340 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
341 "is_rgmii", &sc->is_rgmii);
342 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
343 "is_gmii", &sc->is_gmii);
344 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
345 "is_mii", &sc->is_mii);
347 if (sc->numphys > AR8X16_NUM_PHYS)
348 sc->numphys = AR8X16_NUM_PHYS;
350 /* Reset the switch. */
351 if (arswitch_reset(dev))
354 err = sc->hal.arswitch_hw_setup(sc);
358 err = sc->hal.arswitch_hw_global_setup(sc);
362 /* Initialize the switch ports. */
363 for (port = 0; port <= sc->numphys; port++) {
364 sc->hal.arswitch_port_init(sc, port);
368 * Attach the PHYs and complete the bus enumeration.
370 err = arswitch_attach_phys(sc);
374 /* Default to ingress filters off. */
375 err = arswitch_set_vlan_mode(sc, 0);
379 bus_generic_probe(dev);
380 bus_enumerate_hinted_children(dev);
381 err = bus_generic_attach(dev);
385 callout_init_mtx(&sc->callout_tick, &sc->sc_mtx, 0);
395 arswitch_detach(device_t dev)
397 struct arswitch_softc *sc = device_get_softc(dev);
400 callout_drain(&sc->callout_tick);
402 for (i=0; i < sc->numphys; i++) {
403 if (sc->miibus[i] != NULL)
404 device_delete_child(dev, sc->miibus[i]);
405 if (sc->ifp[i] != NULL)
407 free(sc->ifname[i], M_DEVBUF);
410 bus_generic_detach(dev);
411 mtx_destroy(&sc->sc_mtx);
417 * Convert PHY number to port number. PHY0 is connected to port 1, PHY1 to
421 arswitch_portforphy(int phy)
426 static inline struct mii_data *
427 arswitch_miiforport(struct arswitch_softc *sc, int port)
431 if (phy < 0 || phy >= sc->numphys)
433 return (device_get_softc(sc->miibus[phy]));
436 static inline struct ifnet *
437 arswitch_ifpforport(struct arswitch_softc *sc, int port)
441 if (phy < 0 || phy >= sc->numphys)
443 return (sc->ifp[phy]);
447 * Convert port status to ifmedia.
450 arswitch_update_ifmedia(int portstatus, u_int *media_status, u_int *media_active)
452 *media_active = IFM_ETHER;
453 *media_status = IFM_AVALID;
455 if ((portstatus & AR8X16_PORT_STS_LINK_UP) != 0)
456 *media_status |= IFM_ACTIVE;
458 *media_active |= IFM_NONE;
461 switch (portstatus & AR8X16_PORT_STS_SPEED_MASK) {
462 case AR8X16_PORT_STS_SPEED_10:
463 *media_active |= IFM_10_T;
465 case AR8X16_PORT_STS_SPEED_100:
466 *media_active |= IFM_100_TX;
468 case AR8X16_PORT_STS_SPEED_1000:
469 *media_active |= IFM_1000_T;
472 if ((portstatus & AR8X16_PORT_STS_DUPLEX) == 0)
473 *media_active |= IFM_FDX;
475 *media_active |= IFM_HDX;
476 if ((portstatus & AR8X16_PORT_STS_TXFLOW) != 0)
477 *media_active |= IFM_ETH_TXPAUSE;
478 if ((portstatus & AR8X16_PORT_STS_RXFLOW) != 0)
479 *media_active |= IFM_ETH_RXPAUSE;
483 * Poll the status for all PHYs. We're using the switch port status because
484 * thats a lot quicker to read than talking to all the PHYs. Care must be
485 * taken that the resulting ifmedia_active is identical to what the PHY will
486 * compute, or gratuitous link status changes will occur whenever the PHYs
487 * update function is called.
490 arswitch_miipollstat(struct arswitch_softc *sc)
493 struct mii_data *mii;
494 struct mii_softc *miisc;
498 ARSWITCH_LOCK_ASSERT(sc, MA_OWNED);
500 for (i = 0; i < sc->numphys; i++) {
501 if (sc->miibus[i] == NULL)
503 mii = device_get_softc(sc->miibus[i]);
504 /* XXX This would be nice to have abstracted out to be per-chip */
505 /* AR8327/AR8337 has a different register base */
506 if (AR8X16_IS_SWITCH(sc, AR8327))
507 portstatus = arswitch_readreg(sc->sc_dev,
508 AR8327_REG_PORT_STATUS(arswitch_portforphy(i)));
510 portstatus = arswitch_readreg(sc->sc_dev,
511 AR8X16_REG_PORT_STS(arswitch_portforphy(i)));
513 DPRINTF(sc->sc_dev, "p[%d]=%b\n",
516 "\20\3TXMAC\4RXMAC\5TXFLOW\6RXFLOW\7"
517 "DUPLEX\11LINK_UP\12LINK_AUTO\13LINK_PAUSE");
520 * If the current status is down, but we have a link
521 * status showing up, we need to do an ATU flush.
523 if ((mii->mii_media_status & IFM_ACTIVE) == 0 &&
524 (portstatus & AR8X16_PORT_STS_LINK_UP) != 0) {
525 device_printf(sc->sc_dev, "%s: port %d: port -> UP\n",
531 * and maybe if a port goes up->down?
533 if ((mii->mii_media_status & IFM_ACTIVE) != 0 &&
534 (portstatus & AR8X16_PORT_STS_LINK_UP) == 0) {
535 device_printf(sc->sc_dev, "%s: port %d: port -> DOWN\n",
540 arswitch_update_ifmedia(portstatus, &mii->mii_media_status,
541 &mii->mii_media_active);
542 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) {
543 if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) !=
546 mii_phy_update(miisc, MII_POLLSTAT);
550 /* If a port went from down->up, flush the ATU */
552 sc->hal.arswitch_atu_flush(sc);
556 arswitch_tick(void *arg)
558 struct arswitch_softc *sc = arg;
560 arswitch_miipollstat(sc);
561 callout_reset(&sc->callout_tick, hz, arswitch_tick, sc);
565 arswitch_lock(device_t dev)
567 struct arswitch_softc *sc = device_get_softc(dev);
569 ARSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED);
574 arswitch_unlock(device_t dev)
576 struct arswitch_softc *sc = device_get_softc(dev);
578 ARSWITCH_LOCK_ASSERT(sc, MA_OWNED);
582 static etherswitch_info_t *
583 arswitch_getinfo(device_t dev)
585 struct arswitch_softc *sc = device_get_softc(dev);
591 ar8xxx_port_vlan_get(struct arswitch_softc *sc, etherswitch_port_t *p)
597 /* Retrieve the PVID. */
598 sc->hal.arswitch_vlan_get_pvid(sc, p->es_port, &p->es_pvid);
601 reg = arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(p->es_port));
602 if (reg & AR8X16_PORT_CTRL_DOUBLE_TAG)
603 p->es_flags |= ETHERSWITCH_PORT_DOUBLE_TAG;
604 reg >>= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
605 if ((reg & 0x3) == AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_ADD)
606 p->es_flags |= ETHERSWITCH_PORT_ADDTAG;
607 if ((reg & 0x3) == AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_STRIP)
608 p->es_flags |= ETHERSWITCH_PORT_STRIPTAG;
615 arswitch_getport(device_t dev, etherswitch_port_t *p)
617 struct arswitch_softc *sc;
618 struct mii_data *mii;
619 struct ifmediareq *ifmr;
622 sc = device_get_softc(dev);
623 if (p->es_port < 0 || p->es_port > sc->numphys)
626 err = sc->hal.arswitch_port_vlan_get(sc, p);
630 mii = arswitch_miiforport(sc, p->es_port);
631 if (p->es_port == AR8X16_PORT_CPU) {
632 /* fill in fixed values for CPU port */
633 /* XXX is this valid in all cases? */
634 p->es_flags |= ETHERSWITCH_PORT_CPU;
637 ifmr->ifm_current = ifmr->ifm_active =
638 IFM_ETHER | IFM_1000_T | IFM_FDX;
640 ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID;
641 } else if (mii != NULL) {
642 err = ifmedia_ioctl(mii->mii_ifp, &p->es_ifr,
643 &mii->mii_media, SIOCGIFMEDIA);
653 ar8xxx_port_vlan_setup(struct arswitch_softc *sc, etherswitch_port_t *p)
662 sc->hal.arswitch_vlan_set_pvid(sc, p->es_port, p->es_pvid);
664 /* Mutually exclusive. */
665 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG &&
666 p->es_flags & ETHERSWITCH_PORT_STRIPTAG) {
672 if (p->es_flags & ETHERSWITCH_PORT_DOUBLE_TAG)
673 reg |= AR8X16_PORT_CTRL_DOUBLE_TAG;
674 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG)
675 reg |= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_ADD <<
676 AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
677 if (p->es_flags & ETHERSWITCH_PORT_STRIPTAG)
678 reg |= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_STRIP <<
679 AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
681 err = arswitch_modifyreg(sc->sc_dev,
682 AR8X16_REG_PORT_CTRL(p->es_port),
683 0x3 << AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT |
684 AR8X16_PORT_CTRL_DOUBLE_TAG, reg);
691 arswitch_setport(device_t dev, etherswitch_port_t *p)
694 struct arswitch_softc *sc;
696 struct mii_data *mii;
699 sc = device_get_softc(dev);
700 if (p->es_port < 0 || p->es_port > sc->numphys)
704 if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) {
705 err = sc->hal.arswitch_port_vlan_setup(sc, p);
710 /* Do not allow media changes on CPU port. */
711 if (p->es_port == AR8X16_PORT_CPU)
714 mii = arswitch_miiforport(sc, p->es_port);
718 ifp = arswitch_ifpforport(sc, p->es_port);
720 ifm = &mii->mii_media;
721 return (ifmedia_ioctl(ifp, &p->es_ifr, ifm, SIOCSIFMEDIA));
725 arswitch_statchg(device_t dev)
728 DPRINTF(dev, "%s\n", __func__);
732 arswitch_ifmedia_upd(struct ifnet *ifp)
734 struct arswitch_softc *sc = ifp->if_softc;
735 struct mii_data *mii = arswitch_miiforport(sc, ifp->if_dunit);
744 arswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
746 struct arswitch_softc *sc = ifp->if_softc;
747 struct mii_data *mii = arswitch_miiforport(sc, ifp->if_dunit);
749 DPRINTF(sc->sc_dev, "%s\n", __func__);
754 ifmr->ifm_active = mii->mii_media_active;
755 ifmr->ifm_status = mii->mii_media_status;
759 arswitch_getconf(device_t dev, etherswitch_conf_t *conf)
761 struct arswitch_softc *sc;
763 sc = device_get_softc(dev);
765 /* Return the VLAN mode. */
766 conf->cmd = ETHERSWITCH_CONF_VLAN_MODE;
767 conf->vlan_mode = sc->vlan_mode;
773 arswitch_setconf(device_t dev, etherswitch_conf_t *conf)
775 struct arswitch_softc *sc;
778 sc = device_get_softc(dev);
780 /* Set the VLAN mode. */
781 if (conf->cmd & ETHERSWITCH_CONF_VLAN_MODE) {
782 err = arswitch_set_vlan_mode(sc, conf->vlan_mode);
791 arswitch_getvgroup(device_t dev, etherswitch_vlangroup_t *e)
793 struct arswitch_softc *sc = device_get_softc(dev);
795 return (sc->hal.arswitch_vlan_getvgroup(sc, e));
799 arswitch_setvgroup(device_t dev, etherswitch_vlangroup_t *e)
801 struct arswitch_softc *sc = device_get_softc(dev);
803 return (sc->hal.arswitch_vlan_setvgroup(sc, e));
806 static device_method_t arswitch_methods[] = {
807 /* Device interface */
808 DEVMETHOD(device_probe, arswitch_probe),
809 DEVMETHOD(device_attach, arswitch_attach),
810 DEVMETHOD(device_detach, arswitch_detach),
813 DEVMETHOD(bus_add_child, device_add_child_ordered),
816 DEVMETHOD(miibus_readreg, arswitch_readphy),
817 DEVMETHOD(miibus_writereg, arswitch_writephy),
818 DEVMETHOD(miibus_statchg, arswitch_statchg),
821 DEVMETHOD(mdio_readreg, arswitch_readphy),
822 DEVMETHOD(mdio_writereg, arswitch_writephy),
824 /* etherswitch interface */
825 DEVMETHOD(etherswitch_lock, arswitch_lock),
826 DEVMETHOD(etherswitch_unlock, arswitch_unlock),
827 DEVMETHOD(etherswitch_getinfo, arswitch_getinfo),
828 DEVMETHOD(etherswitch_readreg, arswitch_readreg),
829 DEVMETHOD(etherswitch_writereg, arswitch_writereg),
830 DEVMETHOD(etherswitch_readphyreg, arswitch_readphy),
831 DEVMETHOD(etherswitch_writephyreg, arswitch_writephy),
832 DEVMETHOD(etherswitch_getport, arswitch_getport),
833 DEVMETHOD(etherswitch_setport, arswitch_setport),
834 DEVMETHOD(etherswitch_getvgroup, arswitch_getvgroup),
835 DEVMETHOD(etherswitch_setvgroup, arswitch_setvgroup),
836 DEVMETHOD(etherswitch_getconf, arswitch_getconf),
837 DEVMETHOD(etherswitch_setconf, arswitch_setconf),
842 DEFINE_CLASS_0(arswitch, arswitch_driver, arswitch_methods,
843 sizeof(struct arswitch_softc));
844 static devclass_t arswitch_devclass;
846 DRIVER_MODULE(arswitch, mdio, arswitch_driver, arswitch_devclass, 0, 0);
847 DRIVER_MODULE(miibus, arswitch, miibus_driver, miibus_devclass, 0, 0);
848 DRIVER_MODULE(mdio, arswitch, mdio_driver, mdio_devclass, 0, 0);
849 DRIVER_MODULE(etherswitch, arswitch, etherswitch_driver, etherswitch_devclass, 0, 0);
850 MODULE_VERSION(arswitch, 1);
851 MODULE_DEPEND(arswitch, miibus, 1, 1, 1); /* XXX which versions? */
852 MODULE_DEPEND(arswitch, etherswitch, 1, 1, 1); /* XXX which versions? */