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;
139 sc->sc_switchtype = AR8X16_SWITCH_AR8327;
140 sc->mii_lo_first = 1;
148 DPRINTF(dev, "chipname=%s, id=%08x\n", chipname, id);
149 if (chipname != NULL) {
150 snprintf(desc, sizeof(desc),
151 "Atheros %s Ethernet Switch",
153 device_set_desc_copy(dev, desc);
154 return (BUS_PROBE_DEFAULT);
160 arswitch_attach_phys(struct arswitch_softc *sc)
165 /* PHYs need an interface, so we generate a dummy one */
166 snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
167 for (phy = 0; phy < sc->numphys; phy++) {
168 sc->ifp[phy] = if_alloc(IFT_ETHER);
169 sc->ifp[phy]->if_softc = sc;
170 sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
171 IFF_DRV_RUNNING | IFF_SIMPLEX;
172 sc->ifname[phy] = malloc(strlen(name)+1, M_DEVBUF, M_WAITOK);
173 bcopy(name, sc->ifname[phy], strlen(name)+1);
174 if_initname(sc->ifp[phy], sc->ifname[phy],
175 arswitch_portforphy(phy));
176 err = mii_attach(sc->sc_dev, &sc->miibus[phy], sc->ifp[phy],
177 arswitch_ifmedia_upd, arswitch_ifmedia_sts, \
178 BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
179 DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n",
180 device_get_nameunit(sc->miibus[phy]),
181 sc->ifp[phy]->if_xname);
183 device_printf(sc->sc_dev,
184 "attaching PHY %d failed\n",
192 arswitch_reset(device_t dev)
195 arswitch_writereg(dev, AR8X16_REG_MASK_CTRL,
196 AR8X16_MASK_CTRL_SOFT_RESET);
198 if (arswitch_readreg(dev, AR8X16_REG_MASK_CTRL) &
199 AR8X16_MASK_CTRL_SOFT_RESET) {
200 device_printf(dev, "unable to reset switch\n");
207 arswitch_set_vlan_mode(struct arswitch_softc *sc, uint32_t mode)
210 /* Check for invalid modes. */
211 if ((mode & sc->info.es_vlan_caps) != mode)
215 case ETHERSWITCH_VLAN_DOT1Q:
216 sc->vlan_mode = ETHERSWITCH_VLAN_DOT1Q;
218 case ETHERSWITCH_VLAN_PORT:
219 sc->vlan_mode = ETHERSWITCH_VLAN_PORT;
226 sc->hal.arswitch_vlan_init_hw(sc);
232 ar8xxx_port_init(struct arswitch_softc *sc, int port)
236 if (port == AR8X16_PORT_CPU) {
237 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_STS(0),
238 (AR8X16_IS_SWITCH(sc, AR8216) ?
239 AR8X16_PORT_STS_SPEED_100 : AR8X16_PORT_STS_SPEED_1000) |
240 (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_RXFLOW) |
241 (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_TXFLOW) |
242 AR8X16_PORT_STS_RXMAC |
243 AR8X16_PORT_STS_TXMAC |
244 AR8X16_PORT_STS_DUPLEX);
245 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0),
246 arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0)) &
247 ~AR8X16_PORT_CTRL_HEADER);
249 /* Set ports to auto negotiation. */
250 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_STS(port),
251 AR8X16_PORT_STS_LINK_AUTO);
252 arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_CTRL(port),
253 arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(port)) &
254 ~AR8X16_PORT_CTRL_HEADER);
259 ar8xxx_atu_flush(struct arswitch_softc *sc)
263 ret = arswitch_waitreg(sc->sc_dev,
270 device_printf(sc->sc_dev, "%s: waitreg failed\n", __func__);
273 arswitch_writereg(sc->sc_dev,
275 AR8216_ATU_OP_FLUSH);
281 arswitch_attach(device_t dev)
283 struct arswitch_softc *sc;
287 sc = device_get_softc(dev);
289 /* sc->sc_switchtype is already decided in arswitch_probe() */
291 mtx_init(&sc->sc_mtx, "arswitch", NULL, MTX_DEF);
293 strlcpy(sc->info.es_name, device_get_desc(dev),
294 sizeof(sc->info.es_name));
296 /* Default HAL methods */
297 sc->hal.arswitch_port_init = ar8xxx_port_init;
298 sc->hal.arswitch_port_vlan_setup = ar8xxx_port_vlan_setup;
299 sc->hal.arswitch_port_vlan_get = ar8xxx_port_vlan_get;
300 sc->hal.arswitch_vlan_init_hw = ar8xxx_reset_vlans;
301 sc->hal.arswitch_vlan_getvgroup = ar8xxx_getvgroup;
302 sc->hal.arswitch_vlan_setvgroup = ar8xxx_setvgroup;
303 sc->hal.arswitch_vlan_get_pvid = ar8xxx_get_pvid;
304 sc->hal.arswitch_vlan_set_pvid = ar8xxx_set_pvid;
305 sc->hal.arswitch_atu_flush = ar8xxx_atu_flush;
308 * Attach switch related functions
310 if (AR8X16_IS_SWITCH(sc, AR7240))
312 else if (AR8X16_IS_SWITCH(sc, AR9340))
314 else if (AR8X16_IS_SWITCH(sc, AR8216))
316 else if (AR8X16_IS_SWITCH(sc, AR8226))
318 else if (AR8X16_IS_SWITCH(sc, AR8316))
320 else if (AR8X16_IS_SWITCH(sc, AR8327))
325 /* Common defaults. */
326 sc->info.es_nports = 5; /* XXX technically 6, but 6th not used */
328 /* XXX Defaults for externally connected AR8316 */
335 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
336 "numphys", &sc->numphys);
337 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
338 "phy4cpu", &sc->phy4cpu);
339 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
340 "is_rgmii", &sc->is_rgmii);
341 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
342 "is_gmii", &sc->is_gmii);
343 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
344 "is_mii", &sc->is_mii);
346 if (sc->numphys > AR8X16_NUM_PHYS)
347 sc->numphys = AR8X16_NUM_PHYS;
349 /* Reset the switch. */
350 if (arswitch_reset(dev))
353 err = sc->hal.arswitch_hw_setup(sc);
357 err = sc->hal.arswitch_hw_global_setup(sc);
361 /* Initialize the switch ports. */
362 for (port = 0; port <= sc->numphys; port++) {
363 sc->hal.arswitch_port_init(sc, port);
367 * Attach the PHYs and complete the bus enumeration.
369 err = arswitch_attach_phys(sc);
373 /* Default to ingress filters off. */
374 err = arswitch_set_vlan_mode(sc, 0);
378 bus_generic_probe(dev);
379 bus_enumerate_hinted_children(dev);
380 err = bus_generic_attach(dev);
384 callout_init_mtx(&sc->callout_tick, &sc->sc_mtx, 0);
394 arswitch_detach(device_t dev)
396 struct arswitch_softc *sc = device_get_softc(dev);
399 callout_drain(&sc->callout_tick);
401 for (i=0; i < sc->numphys; i++) {
402 if (sc->miibus[i] != NULL)
403 device_delete_child(dev, sc->miibus[i]);
404 if (sc->ifp[i] != NULL)
406 free(sc->ifname[i], M_DEVBUF);
409 bus_generic_detach(dev);
410 mtx_destroy(&sc->sc_mtx);
416 * Convert PHY number to port number. PHY0 is connected to port 1, PHY1 to
420 arswitch_portforphy(int phy)
425 static inline struct mii_data *
426 arswitch_miiforport(struct arswitch_softc *sc, int port)
430 if (phy < 0 || phy >= sc->numphys)
432 return (device_get_softc(sc->miibus[phy]));
435 static inline struct ifnet *
436 arswitch_ifpforport(struct arswitch_softc *sc, int port)
440 if (phy < 0 || phy >= sc->numphys)
442 return (sc->ifp[phy]);
446 * Convert port status to ifmedia.
449 arswitch_update_ifmedia(int portstatus, u_int *media_status, u_int *media_active)
451 *media_active = IFM_ETHER;
452 *media_status = IFM_AVALID;
454 if ((portstatus & AR8X16_PORT_STS_LINK_UP) != 0)
455 *media_status |= IFM_ACTIVE;
457 *media_active |= IFM_NONE;
460 switch (portstatus & AR8X16_PORT_STS_SPEED_MASK) {
461 case AR8X16_PORT_STS_SPEED_10:
462 *media_active |= IFM_10_T;
464 case AR8X16_PORT_STS_SPEED_100:
465 *media_active |= IFM_100_TX;
467 case AR8X16_PORT_STS_SPEED_1000:
468 *media_active |= IFM_1000_T;
471 if ((portstatus & AR8X16_PORT_STS_DUPLEX) == 0)
472 *media_active |= IFM_FDX;
474 *media_active |= IFM_HDX;
475 if ((portstatus & AR8X16_PORT_STS_TXFLOW) != 0)
476 *media_active |= IFM_ETH_TXPAUSE;
477 if ((portstatus & AR8X16_PORT_STS_RXFLOW) != 0)
478 *media_active |= IFM_ETH_RXPAUSE;
482 * Poll the status for all PHYs. We're using the switch port status because
483 * thats a lot quicker to read than talking to all the PHYs. Care must be
484 * taken that the resulting ifmedia_active is identical to what the PHY will
485 * compute, or gratuitous link status changes will occur whenever the PHYs
486 * update function is called.
489 arswitch_miipollstat(struct arswitch_softc *sc)
492 struct mii_data *mii;
493 struct mii_softc *miisc;
497 ARSWITCH_LOCK_ASSERT(sc, MA_OWNED);
499 for (i = 0; i < sc->numphys; i++) {
500 if (sc->miibus[i] == NULL)
502 mii = device_get_softc(sc->miibus[i]);
503 /* XXX This would be nice to have abstracted out to be per-chip */
504 /* AR8327/AR8337 has a different register base */
505 if (AR8X16_IS_SWITCH(sc, AR8327))
506 portstatus = arswitch_readreg(sc->sc_dev,
507 AR8327_REG_PORT_STATUS(arswitch_portforphy(i)));
509 portstatus = arswitch_readreg(sc->sc_dev,
510 AR8X16_REG_PORT_STS(arswitch_portforphy(i)));
512 DPRINTF(sc->sc_dev, "p[%d]=%b\n",
515 "\20\3TXMAC\4RXMAC\5TXFLOW\6RXFLOW\7"
516 "DUPLEX\11LINK_UP\12LINK_AUTO\13LINK_PAUSE");
519 * If the current status is down, but we have a link
520 * status showing up, we need to do an ATU flush.
522 if ((mii->mii_media_status & IFM_ACTIVE) == 0 &&
523 (portstatus & AR8X16_PORT_STS_LINK_UP) != 0) {
524 device_printf(sc->sc_dev, "%s: port %d: port -> UP\n",
530 * and maybe if a port goes up->down?
532 if ((mii->mii_media_status & IFM_ACTIVE) != 0 &&
533 (portstatus & AR8X16_PORT_STS_LINK_UP) == 0) {
534 device_printf(sc->sc_dev, "%s: port %d: port -> DOWN\n",
539 arswitch_update_ifmedia(portstatus, &mii->mii_media_status,
540 &mii->mii_media_active);
541 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) {
542 if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) !=
545 mii_phy_update(miisc, MII_POLLSTAT);
549 /* If a port went from down->up, flush the ATU */
551 sc->hal.arswitch_atu_flush(sc);
555 arswitch_tick(void *arg)
557 struct arswitch_softc *sc = arg;
559 arswitch_miipollstat(sc);
560 callout_reset(&sc->callout_tick, hz, arswitch_tick, sc);
564 arswitch_lock(device_t dev)
566 struct arswitch_softc *sc = device_get_softc(dev);
568 ARSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED);
573 arswitch_unlock(device_t dev)
575 struct arswitch_softc *sc = device_get_softc(dev);
577 ARSWITCH_LOCK_ASSERT(sc, MA_OWNED);
581 static etherswitch_info_t *
582 arswitch_getinfo(device_t dev)
584 struct arswitch_softc *sc = device_get_softc(dev);
590 ar8xxx_port_vlan_get(struct arswitch_softc *sc, etherswitch_port_t *p)
596 /* Retrieve the PVID. */
597 sc->hal.arswitch_vlan_get_pvid(sc, p->es_port, &p->es_pvid);
600 reg = arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(p->es_port));
601 if (reg & AR8X16_PORT_CTRL_DOUBLE_TAG)
602 p->es_flags |= ETHERSWITCH_PORT_DOUBLE_TAG;
603 reg >>= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
604 if ((reg & 0x3) == AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_ADD)
605 p->es_flags |= ETHERSWITCH_PORT_ADDTAG;
606 if ((reg & 0x3) == AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_STRIP)
607 p->es_flags |= ETHERSWITCH_PORT_STRIPTAG;
614 arswitch_getport(device_t dev, etherswitch_port_t *p)
616 struct arswitch_softc *sc;
617 struct mii_data *mii;
618 struct ifmediareq *ifmr;
621 sc = device_get_softc(dev);
622 if (p->es_port < 0 || p->es_port > sc->numphys)
625 err = sc->hal.arswitch_port_vlan_get(sc, p);
629 mii = arswitch_miiforport(sc, p->es_port);
630 if (p->es_port == AR8X16_PORT_CPU) {
631 /* fill in fixed values for CPU port */
632 /* XXX is this valid in all cases? */
633 p->es_flags |= ETHERSWITCH_PORT_CPU;
636 ifmr->ifm_current = ifmr->ifm_active =
637 IFM_ETHER | IFM_1000_T | IFM_FDX;
639 ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID;
640 } else if (mii != NULL) {
641 err = ifmedia_ioctl(mii->mii_ifp, &p->es_ifr,
642 &mii->mii_media, SIOCGIFMEDIA);
652 ar8xxx_port_vlan_setup(struct arswitch_softc *sc, etherswitch_port_t *p)
661 sc->hal.arswitch_vlan_set_pvid(sc, p->es_port, p->es_pvid);
663 /* Mutually exclusive. */
664 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG &&
665 p->es_flags & ETHERSWITCH_PORT_STRIPTAG) {
671 if (p->es_flags & ETHERSWITCH_PORT_DOUBLE_TAG)
672 reg |= AR8X16_PORT_CTRL_DOUBLE_TAG;
673 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG)
674 reg |= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_ADD <<
675 AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
676 if (p->es_flags & ETHERSWITCH_PORT_STRIPTAG)
677 reg |= AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_STRIP <<
678 AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT;
680 err = arswitch_modifyreg(sc->sc_dev,
681 AR8X16_REG_PORT_CTRL(p->es_port),
682 0x3 << AR8X16_PORT_CTRL_EGRESS_VLAN_MODE_SHIFT |
683 AR8X16_PORT_CTRL_DOUBLE_TAG, reg);
690 arswitch_setport(device_t dev, etherswitch_port_t *p)
693 struct arswitch_softc *sc;
695 struct mii_data *mii;
698 sc = device_get_softc(dev);
699 if (p->es_port < 0 || p->es_port > sc->numphys)
703 if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) {
704 err = sc->hal.arswitch_port_vlan_setup(sc, p);
709 /* Do not allow media changes on CPU port. */
710 if (p->es_port == AR8X16_PORT_CPU)
713 mii = arswitch_miiforport(sc, p->es_port);
717 ifp = arswitch_ifpforport(sc, p->es_port);
719 ifm = &mii->mii_media;
720 return (ifmedia_ioctl(ifp, &p->es_ifr, ifm, SIOCSIFMEDIA));
724 arswitch_statchg(device_t dev)
727 DPRINTF(dev, "%s\n", __func__);
731 arswitch_ifmedia_upd(struct ifnet *ifp)
733 struct arswitch_softc *sc = ifp->if_softc;
734 struct mii_data *mii = arswitch_miiforport(sc, ifp->if_dunit);
743 arswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
745 struct arswitch_softc *sc = ifp->if_softc;
746 struct mii_data *mii = arswitch_miiforport(sc, ifp->if_dunit);
748 DPRINTF(sc->sc_dev, "%s\n", __func__);
753 ifmr->ifm_active = mii->mii_media_active;
754 ifmr->ifm_status = mii->mii_media_status;
758 arswitch_getconf(device_t dev, etherswitch_conf_t *conf)
760 struct arswitch_softc *sc;
762 sc = device_get_softc(dev);
764 /* Return the VLAN mode. */
765 conf->cmd = ETHERSWITCH_CONF_VLAN_MODE;
766 conf->vlan_mode = sc->vlan_mode;
772 arswitch_setconf(device_t dev, etherswitch_conf_t *conf)
774 struct arswitch_softc *sc;
777 sc = device_get_softc(dev);
779 /* Set the VLAN mode. */
780 if (conf->cmd & ETHERSWITCH_CONF_VLAN_MODE) {
781 err = arswitch_set_vlan_mode(sc, conf->vlan_mode);
790 arswitch_getvgroup(device_t dev, etherswitch_vlangroup_t *e)
792 struct arswitch_softc *sc = device_get_softc(dev);
794 return (sc->hal.arswitch_vlan_getvgroup(sc, e));
798 arswitch_setvgroup(device_t dev, etherswitch_vlangroup_t *e)
800 struct arswitch_softc *sc = device_get_softc(dev);
802 return (sc->hal.arswitch_vlan_setvgroup(sc, e));
805 static device_method_t arswitch_methods[] = {
806 /* Device interface */
807 DEVMETHOD(device_probe, arswitch_probe),
808 DEVMETHOD(device_attach, arswitch_attach),
809 DEVMETHOD(device_detach, arswitch_detach),
812 DEVMETHOD(bus_add_child, device_add_child_ordered),
815 DEVMETHOD(miibus_readreg, arswitch_readphy),
816 DEVMETHOD(miibus_writereg, arswitch_writephy),
817 DEVMETHOD(miibus_statchg, arswitch_statchg),
820 DEVMETHOD(mdio_readreg, arswitch_readphy),
821 DEVMETHOD(mdio_writereg, arswitch_writephy),
823 /* etherswitch interface */
824 DEVMETHOD(etherswitch_lock, arswitch_lock),
825 DEVMETHOD(etherswitch_unlock, arswitch_unlock),
826 DEVMETHOD(etherswitch_getinfo, arswitch_getinfo),
827 DEVMETHOD(etherswitch_readreg, arswitch_readreg),
828 DEVMETHOD(etherswitch_writereg, arswitch_writereg),
829 DEVMETHOD(etherswitch_readphyreg, arswitch_readphy),
830 DEVMETHOD(etherswitch_writephyreg, arswitch_writephy),
831 DEVMETHOD(etherswitch_getport, arswitch_getport),
832 DEVMETHOD(etherswitch_setport, arswitch_setport),
833 DEVMETHOD(etherswitch_getvgroup, arswitch_getvgroup),
834 DEVMETHOD(etherswitch_setvgroup, arswitch_setvgroup),
835 DEVMETHOD(etherswitch_getconf, arswitch_getconf),
836 DEVMETHOD(etherswitch_setconf, arswitch_setconf),
841 DEFINE_CLASS_0(arswitch, arswitch_driver, arswitch_methods,
842 sizeof(struct arswitch_softc));
843 static devclass_t arswitch_devclass;
845 DRIVER_MODULE(arswitch, mdio, arswitch_driver, arswitch_devclass, 0, 0);
846 DRIVER_MODULE(miibus, arswitch, miibus_driver, miibus_devclass, 0, 0);
847 DRIVER_MODULE(mdio, arswitch, mdio_driver, mdio_devclass, 0, 0);
848 DRIVER_MODULE(etherswitch, arswitch, etherswitch_driver, etherswitch_devclass, 0, 0);
849 MODULE_VERSION(arswitch, 1);
850 MODULE_DEPEND(arswitch, miibus, 1, 1, 1); /* XXX which versions? */
851 MODULE_DEPEND(arswitch, etherswitch, 1, 1, 1); /* XXX which versions? */