2 * Copyright (c) 1997, 1998, 1999, 2000
3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
6 * Alfred Perlstein <alfred@freebsd.org>. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Bill Paul.
19 * 4. Neither the name of the author nor the names of any co-contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD$");
40 * ADMtek AN986 Pegasus and AN8511 Pegasus II USB to ethernet driver.
41 * Datasheet is available from http://www.admtek.com.tw.
43 * Written by Bill Paul <wpaul@ee.columbia.edu>
44 * Electrical Engineering Department
45 * Columbia University, New York City
47 * SMP locking by Alfred Perlstein <alfred@freebsd.org>.
52 * The Pegasus chip uses four USB "endpoints" to provide 10/100 ethernet
53 * support: the control endpoint for reading/writing registers, burst
54 * read endpoint for packet reception, burst write for packet transmission
55 * and one for "interrupts." The chip uses the same RX filter scheme
56 * as the other ADMtek ethernet parts: one perfect filter entry for the
57 * the station address and a 64-bit multicast hash table. The chip supports
58 * both MII and HomePNA attachments.
60 * Since the maximum data transfer speed of USB is supposed to be 12Mbps,
61 * you're never really going to get 100Mbps speeds from this device. I
62 * think the idea is to allow the device to connect to 10 or 100Mbps
63 * networks, not necessarily to provide 100Mbps performance. Also, since
64 * the controller uses an external PHY chip, it's possible that board
65 * designers might simply choose a 10Mbps PHY.
67 * Registers are accessed using usbd_do_request(). Packet transfers are
68 * done using usbd_transfer() and friends.
71 #include <sys/param.h>
72 #include <sys/systm.h>
73 #include <sys/sockio.h>
75 #include <sys/malloc.h>
76 #include <sys/kernel.h>
79 #include <sys/module.h>
80 #include <sys/socket.h>
82 #include <sys/taskqueue.h>
85 #include <net/if_arp.h>
86 #include <net/ethernet.h>
87 #include <net/if_dl.h>
88 #include <net/if_media.h>
89 #include <net/if_types.h>
94 #include <machine/bus.h>
96 #include <dev/usb/usb.h>
97 #include <dev/usb/usbdi.h>
98 #include <dev/usb/usbdi_util.h>
99 #include <dev/usb/usbdivar.h>
101 #include <dev/usb/usb_ethersubr.h>
103 #include <dev/mii/mii.h>
104 #include <dev/mii/miivar.h>
106 #include <dev/usb/if_auereg.h>
108 MODULE_DEPEND(aue, usb, 1, 1, 1);
109 MODULE_DEPEND(aue, ether, 1, 1, 1);
110 MODULE_DEPEND(aue, miibus, 1, 1, 1);
112 /* "device miibus" required. See GENERIC if you get errors here. */
113 #include "miibus_if.h"
116 * Various supported device vendors/products.
119 struct usb_devno aue_dev;
121 #define LSYS 0x0001 /* use Linksys reset */
122 #define PNA 0x0002 /* has Home PNA */
123 #define PII 0x0004 /* Pegasus II chip */
126 static const struct aue_type aue_devs[] = {
127 {{ USB_VENDOR_3COM, USB_PRODUCT_3COM_3C460B}, PII },
128 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1}, PNA|PII },
129 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX2}, PII },
130 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_UFE1000}, LSYS },
131 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX4}, PNA },
132 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX5}, PNA },
133 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX6}, PII },
134 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX7}, PII },
135 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX8}, PII },
136 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX9}, PNA },
137 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX10}, 0 },
138 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_DSB650TX_PNA}, 0 },
139 {{ USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_USB320_EC}, 0 },
140 {{ USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_SS1001}, PII },
141 {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS}, PNA },
142 {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII}, PII },
143 {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_2}, PII },
144 {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_3}, PII },
145 {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_4}, PII },
146 {{ USB_VENDOR_AEI, USB_PRODUCT_AEI_FASTETHERNET}, PII },
147 {{ USB_VENDOR_ALLIEDTELESYN, USB_PRODUCT_ALLIEDTELESYN_ATUSB100}, PII },
148 {{ USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC110T}, PII },
149 {{ USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_USB2LAN}, PII },
150 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100}, 0 },
151 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBLP100}, PNA },
152 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBEL100}, 0 },
153 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBE100}, PII },
154 {{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX}, 0 },
155 {{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXS},PII },
156 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX4}, LSYS|PII },
157 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX1}, LSYS },
158 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX}, LSYS },
159 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA}, PNA },
160 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX3}, LSYS|PII },
161 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX2}, LSYS|PII },
162 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650}, LSYS },
163 {{ USB_VENDOR_ELCON, USB_PRODUCT_ELCON_PLAN}, PNA|PII },
164 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSB20}, PII },
165 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX0}, 0 },
166 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX1}, LSYS },
167 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX2}, 0 },
168 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX3}, LSYS },
169 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBLTX}, PII },
170 {{ USB_VENDOR_ELSA, USB_PRODUCT_ELSA_USB2ETHERNET}, 0 },
171 {{ USB_VENDOR_GIGABYTE, USB_PRODUCT_GIGABYTE_GNBR402W}, 0 },
172 {{ USB_VENDOR_HAWKING, USB_PRODUCT_HAWKING_UF100}, PII },
173 {{ USB_VENDOR_HP, USB_PRODUCT_HP_HN210E}, PII },
174 {{ USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX}, 0 },
175 {{ USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTXS}, PII },
176 {{ USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX}, 0 },
177 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX1}, LSYS|PII },
178 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10T}, LSYS },
179 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX}, LSYS },
180 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1}, LSYS|PNA },
181 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA}, LSYS },
182 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX2}, LSYS|PII },
183 {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1}, 0 },
184 {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5}, 0 },
185 {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUA2TX5}, PII },
186 {{ USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_MN110}, PII },
187 {{ USB_VENDOR_NETGEAR, USB_PRODUCT_NETGEAR_FA101}, PII },
188 {{ USB_VENDOR_SIEMENS, USB_PRODUCT_SIEMENS_SPEEDSTREAM}, PII },
189 {{ USB_VENDOR_SIIG2, USB_PRODUCT_SIIG2_USBTOETHER}, PII },
190 {{ USB_VENDOR_SMARTBRIDGES, USB_PRODUCT_SMARTBRIDGES_SMARTNIC},PII },
191 {{ USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB}, 0 },
192 {{ USB_VENDOR_SMC, USB_PRODUCT_SMC_2206USB}, PII },
193 {{ USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB100}, 0 },
194 {{ USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB110}, PII },
196 #define aue_lookup(v, p) ((const struct aue_type *)usb_lookup(aue_devs, v, p))
198 static device_probe_t aue_match;
199 static device_attach_t aue_attach;
200 static device_detach_t aue_detach;
201 static device_shutdown_t aue_shutdown;
202 static miibus_readreg_t aue_miibus_readreg;
203 static miibus_writereg_t aue_miibus_writereg;
204 static miibus_statchg_t aue_miibus_statchg;
206 static void aue_reset_pegasus_II(struct aue_softc *sc);
207 static int aue_encap(struct aue_softc *, struct mbuf *, int);
209 static void aue_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
211 static void aue_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
212 static void aue_rxeof_thread(struct aue_softc *sc);
213 static void aue_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
214 static void aue_txeof_thread(struct aue_softc *);
215 static void aue_task_sched(struct aue_softc *, int);
216 static void aue_task(void *xsc, int pending);
217 static void aue_tick(void *);
218 static void aue_rxstart(struct ifnet *);
219 static void aue_rxstart_thread(struct aue_softc *);
220 static void aue_start(struct ifnet *);
221 static void aue_start_thread(struct aue_softc *);
222 static int aue_ioctl(struct ifnet *, u_long, caddr_t);
223 static void aue_init(void *);
224 static void aue_init_body(struct aue_softc *);
225 static void aue_stop(struct aue_softc *);
226 static void aue_watchdog(struct aue_softc *);
227 static int aue_ifmedia_upd(struct ifnet *);
228 static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
230 static void aue_eeprom_getword(struct aue_softc *, int, u_int16_t *);
231 static void aue_read_eeprom(struct aue_softc *, caddr_t, int, int, int);
233 static void aue_setmulti(struct aue_softc *);
234 static void aue_reset(struct aue_softc *);
236 static int aue_csr_read_1(struct aue_softc *, int);
237 static int aue_csr_write_1(struct aue_softc *, int, int);
238 static int aue_csr_read_2(struct aue_softc *, int);
239 static int aue_csr_write_2(struct aue_softc *, int, int);
241 static device_method_t aue_methods[] = {
242 /* Device interface */
243 DEVMETHOD(device_probe, aue_match),
244 DEVMETHOD(device_attach, aue_attach),
245 DEVMETHOD(device_detach, aue_detach),
246 DEVMETHOD(device_shutdown, aue_shutdown),
249 DEVMETHOD(bus_print_child, bus_generic_print_child),
250 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
253 DEVMETHOD(miibus_readreg, aue_miibus_readreg),
254 DEVMETHOD(miibus_writereg, aue_miibus_writereg),
255 DEVMETHOD(miibus_statchg, aue_miibus_statchg),
260 static driver_t aue_driver = {
263 sizeof(struct aue_softc)
266 static devclass_t aue_devclass;
268 DRIVER_MODULE(aue, uhub, aue_driver, aue_devclass, usbd_driver_load, 0);
269 DRIVER_MODULE(miibus, aue, miibus_driver, miibus_devclass, 0, 0);
271 #define AUE_SETBIT(sc, reg, x) \
272 aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x))
274 #define AUE_CLRBIT(sc, reg, x) \
275 aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x))
278 aue_csr_read_1(struct aue_softc *sc, int reg)
280 usb_device_request_t req;
284 AUE_SXASSERTLOCKED(sc);
286 req.bmRequestType = UT_READ_VENDOR_DEVICE;
287 req.bRequest = AUE_UR_READREG;
288 USETW(req.wValue, 0);
289 USETW(req.wIndex, reg);
290 USETW(req.wLength, 1);
292 err = usbd_do_request(sc->aue_udev, &req, &val);
302 aue_csr_read_2(struct aue_softc *sc, int reg)
304 usb_device_request_t req;
308 AUE_SXASSERTLOCKED(sc);
310 req.bmRequestType = UT_READ_VENDOR_DEVICE;
311 req.bRequest = AUE_UR_READREG;
312 USETW(req.wValue, 0);
313 USETW(req.wIndex, reg);
314 USETW(req.wLength, 2);
316 err = usbd_do_request(sc->aue_udev, &req, &val);
326 aue_csr_write_1(struct aue_softc *sc, int reg, int val)
328 usb_device_request_t req;
331 AUE_SXASSERTLOCKED(sc);
333 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
334 req.bRequest = AUE_UR_WRITEREG;
335 USETW(req.wValue, val);
336 USETW(req.wIndex, reg);
337 USETW(req.wLength, 1);
339 err = usbd_do_request(sc->aue_udev, &req, &val);
349 aue_csr_write_2(struct aue_softc *sc, int reg, int val)
351 usb_device_request_t req;
354 AUE_SXASSERTLOCKED(sc);
356 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
357 req.bRequest = AUE_UR_WRITEREG;
358 USETW(req.wValue, val);
359 USETW(req.wIndex, reg);
360 USETW(req.wLength, 2);
362 err = usbd_do_request(sc->aue_udev, &req, &val);
372 * Read a word of data stored in the EEPROM at address 'addr.'
375 aue_eeprom_getword(struct aue_softc *sc, int addr, u_int16_t *dest)
380 aue_csr_write_1(sc, AUE_EE_REG, addr);
381 aue_csr_write_1(sc, AUE_EE_CTL, AUE_EECTL_READ);
383 for (i = 0; i < AUE_TIMEOUT; i++) {
384 if (aue_csr_read_1(sc, AUE_EE_CTL) & AUE_EECTL_DONE)
388 if (i == AUE_TIMEOUT) {
389 printf("aue%d: EEPROM read timed out\n",
393 word = aue_csr_read_2(sc, AUE_EE_DATA);
400 * Read a sequence of words from the EEPROM.
403 aue_read_eeprom(struct aue_softc *sc, caddr_t dest, int off, int cnt, int swap)
406 u_int16_t word = 0, *ptr;
408 for (i = 0; i < cnt; i++) {
409 aue_eeprom_getword(sc, off + i, &word);
410 ptr = (u_int16_t *)(dest + (i * 2));
421 aue_miibus_readreg(device_t dev, int phy, int reg)
423 struct aue_softc *sc = device_get_softc(dev);
428 * The Am79C901 HomePNA PHY actually contains
429 * two transceivers: a 1Mbps HomePNA PHY and a
430 * 10Mbps full/half duplex ethernet PHY with
431 * NWAY autoneg. However in the ADMtek adapter,
432 * only the 1Mbps PHY is actually connected to
433 * anything, so we ignore the 10Mbps one. It
434 * happens to be configured for MII address 3,
435 * so we filter that out.
437 if (sc->aue_vendor == USB_VENDOR_ADMTEK &&
438 sc->aue_product == USB_PRODUCT_ADMTEK_PEGASUS) {
447 aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
448 aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_READ);
450 for (i = 0; i < AUE_TIMEOUT; i++) {
451 if (aue_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE)
455 if (i == AUE_TIMEOUT) {
456 printf("aue%d: MII read timed out\n", sc->aue_unit);
459 val = aue_csr_read_2(sc, AUE_PHY_DATA);
465 aue_miibus_writereg(device_t dev, int phy, int reg, int data)
467 struct aue_softc *sc = device_get_softc(dev);
473 aue_csr_write_2(sc, AUE_PHY_DATA, data);
474 aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
475 aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_WRITE);
477 for (i = 0; i < AUE_TIMEOUT; i++) {
478 if (aue_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE)
482 if (i == AUE_TIMEOUT) {
483 printf("aue%d: MII read timed out\n",
491 aue_miibus_statchg(device_t dev)
493 struct aue_softc *sc = device_get_softc(dev);
494 struct mii_data *mii = GET_MII(sc);
496 AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB);
497 if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) {
498 AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL);
500 AUE_CLRBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL);
503 if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
504 AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX);
506 AUE_CLRBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX);
508 AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB);
511 * Set the LED modes on the LinkSys adapter.
512 * This turns on the 'dual link LED' bin in the auxmode
513 * register of the Broadcom PHY.
515 if (sc->aue_flags & LSYS) {
517 auxmode = aue_miibus_readreg(dev, 0, 0x1b);
518 aue_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04);
527 aue_setmulti(struct aue_softc *sc)
530 struct ifmultiaddr *ifma;
532 u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
534 AUE_SXASSERTLOCKED(sc);
537 if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
538 AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
542 AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
544 /* now program new ones */
546 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link)
548 if (ifma->ifma_addr->sa_family != AF_LINK)
550 h = ether_crc32_le(LLADDR((struct sockaddr_dl *)
551 ifma->ifma_addr), ETHER_ADDR_LEN) & ((1 << AUE_BITS) - 1);
552 hashtbl[(h >> 3)] |= 1 << (h & 0x7);
556 /* write the hashtable */
557 for (i = 0; i < 8; i++)
558 aue_csr_write_1(sc, AUE_MAR0 + i, hashtbl[i]);
564 aue_reset_pegasus_II(struct aue_softc *sc)
566 /* Magic constants taken from Linux driver. */
567 aue_csr_write_1(sc, AUE_REG_1D, 0);
568 aue_csr_write_1(sc, AUE_REG_7B, 2);
570 if ((sc->aue_flags & HAS_HOME_PNA) && mii_mode)
571 aue_csr_write_1(sc, AUE_REG_81, 6);
574 aue_csr_write_1(sc, AUE_REG_81, 2);
578 aue_reset(struct aue_softc *sc)
582 AUE_SXASSERTLOCKED(sc);
583 AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_RESETMAC);
585 for (i = 0; i < AUE_TIMEOUT; i++) {
586 if (!(aue_csr_read_1(sc, AUE_CTL1) & AUE_CTL1_RESETMAC))
590 if (i == AUE_TIMEOUT)
591 printf("aue%d: reset failed\n", sc->aue_unit);
594 * The PHY(s) attached to the Pegasus chip may be held
595 * in reset until we flip on the GPIO outputs. Make sure
596 * to set the GPIO pins high so that the PHY(s) will
599 * Note: We force all of the GPIO pins low first, *then*
600 * enable the ones we want.
602 aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0);
603 aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0|AUE_GPIO_SEL1);
605 if (sc->aue_flags & LSYS) {
606 /* Grrr. LinkSys has to be different from everyone else. */
607 aue_csr_write_1(sc, AUE_GPIO0,
608 AUE_GPIO_SEL0 | AUE_GPIO_SEL1);
609 aue_csr_write_1(sc, AUE_GPIO0,
610 AUE_GPIO_SEL0 | AUE_GPIO_SEL1 | AUE_GPIO_OUT0);
613 if (sc->aue_flags & PII)
614 aue_reset_pegasus_II(sc);
616 /* Wait a little while for the chip to get its brains in order. */
623 * Probe for a Pegasus chip.
626 aue_match(device_t self)
628 struct usb_attach_arg *uaa = device_get_ivars(self);
630 if (uaa->iface != NULL)
631 return (UMATCH_NONE);
633 return (aue_lookup(uaa->vendor, uaa->product) != NULL ?
634 UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
638 * Attach the interface. Allocate softc structures, do ifmedia
639 * setup and ethernet/BPF attach.
642 aue_attach(device_t self)
644 struct aue_softc *sc = device_get_softc(self);
645 struct usb_attach_arg *uaa = device_get_ivars(self);
646 u_char eaddr[ETHER_ADDR_LEN];
648 usbd_interface_handle iface;
650 usb_interface_descriptor_t *id;
651 usb_endpoint_descriptor_t *ed;
655 sc->aue_udev = uaa->device;
656 sc->aue_unit = device_get_unit(self);
658 if (usbd_set_config_no(sc->aue_udev, AUE_CONFIG_NO, 0)) {
659 device_printf(self, "getting interface handle failed\n");
663 err = usbd_device2interface_handle(uaa->device, AUE_IFACE_IDX, &iface);
665 device_printf(self, "getting interface handle failed\n");
669 sc->aue_iface = iface;
670 sc->aue_flags = aue_lookup(uaa->vendor, uaa->product)->aue_flags;
672 sc->aue_product = uaa->product;
673 sc->aue_vendor = uaa->vendor;
675 id = usbd_get_interface_descriptor(sc->aue_iface);
677 /* Find endpoints. */
678 for (i = 0; i < id->bNumEndpoints; i++) {
679 ed = usbd_interface2endpoint_descriptor(iface, i);
681 device_printf(self, "couldn't get ep %d\n", i);
684 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
685 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
686 sc->aue_ed[AUE_ENDPT_RX] = ed->bEndpointAddress;
687 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
688 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
689 sc->aue_ed[AUE_ENDPT_TX] = ed->bEndpointAddress;
690 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
691 UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
692 sc->aue_ed[AUE_ENDPT_INTR] = ed->bEndpointAddress;
696 mtx_init(&sc->aue_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK,
697 MTX_DEF | MTX_RECURSE);
698 sx_init(&sc->aue_sx, device_get_nameunit(self));
699 TASK_INIT(&sc->aue_task, 0, aue_task, sc);
700 usb_ether_task_init(self, 0, &sc->aue_taskqueue);
703 /* Reset the adapter. */
707 * Get station address from the EEPROM.
709 aue_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 0);
711 ifp = sc->aue_ifp = if_alloc(IFT_ETHER);
713 device_printf(self, "can not if_alloc()\n");
715 mtx_destroy(&sc->aue_mtx);
716 sx_destroy(&sc->aue_sx);
717 usb_ether_task_destroy(&sc->aue_taskqueue);
721 if_initname(ifp, "aue", sc->aue_unit);
722 ifp->if_mtu = ETHERMTU;
723 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
724 ifp->if_ioctl = aue_ioctl;
725 ifp->if_start = aue_start;
726 ifp->if_init = aue_init;
727 IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
728 ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
729 IFQ_SET_READY(&ifp->if_snd);
733 * NOTE: Doing this causes child devices to be attached to us,
734 * which we would normally disconnect at in the detach routine
735 * using device_delete_child(). However the USB code is set up
736 * such that when this driver is removed, all children devices
737 * are removed as well. In effect, the USB code ends up detaching
738 * all of our children for us, so we don't have to do is ourselves
739 * in aue_detach(). It's important to point this out since if
740 * we *do* try to detach the child devices ourselves, we will
741 * end up getting the children deleted twice, which will crash
744 if (mii_phy_probe(self, &sc->aue_miibus,
745 aue_ifmedia_upd, aue_ifmedia_sts)) {
746 device_printf(self, "MII without any PHY!\n");
749 mtx_destroy(&sc->aue_mtx);
750 sx_destroy(&sc->aue_sx);
751 usb_ether_task_destroy(&sc->aue_taskqueue);
755 sc->aue_qdat.ifp = ifp;
756 sc->aue_qdat.if_rxstart = aue_rxstart;
759 * Call MI attach routine.
761 ether_ifattach(ifp, eaddr);
762 usb_register_netisr();
771 aue_detach(device_t dev)
773 struct aue_softc *sc;
776 sc = device_get_softc(dev);
782 callout_drain(&sc->aue_tick_callout);
783 usb_ether_task_drain(&sc->aue_taskqueue, &sc->aue_task);
784 usb_ether_task_destroy(&sc->aue_taskqueue);
787 if (sc->aue_ep[AUE_ENDPT_TX] != NULL)
788 usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]);
789 if (sc->aue_ep[AUE_ENDPT_RX] != NULL)
790 usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_RX]);
792 if (sc->aue_ep[AUE_ENDPT_INTR] != NULL)
793 usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_INTR]);
796 mtx_destroy(&sc->aue_mtx);
797 sx_destroy(&sc->aue_sx);
803 aue_rxstart(struct ifnet *ifp)
805 struct aue_softc *sc = ifp->if_softc;
806 aue_task_sched(sc, AUE_TASK_RXSTART);
810 aue_rxstart_thread(struct aue_softc *sc)
818 AUE_SXASSERTLOCKED(sc);
819 c = &sc->aue_cdata.ue_rx_chain[sc->aue_cdata.ue_rx_prod];
821 c->ue_mbuf = usb_ether_newbuf();
822 if (c->ue_mbuf == NULL) {
823 device_printf(sc->aue_dev, "no memory for rx list -- packet "
830 /* Setup new transfer. */
831 usbd_setup_xfer(c->ue_xfer, sc->aue_ep[AUE_ENDPT_RX],
832 c, mtod(c->ue_mbuf, char *), UE_BUFSZ, USBD_SHORT_XFER_OK,
833 USBD_NO_TIMEOUT, aue_rxeof);
834 usbd_transfer(c->ue_xfer);
840 * A frame has been uploaded: pass the resulting mbuf chain up to
841 * the higher level protocols.
844 aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
846 struct ue_chain *c = priv;
847 c->ue_status = status;
848 aue_task_sched(c->ue_sc, AUE_TASK_RXEOF);
852 aue_rxeof_thread(struct aue_softc *sc)
854 struct ue_chain *c = &(sc->aue_cdata.ue_rx_chain[0]);
859 usbd_status status = c->ue_status;
862 AUE_SXASSERTLOCKED(sc);
865 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
869 if (status != USBD_NORMAL_COMPLETION) {
870 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
873 if (usbd_ratecheck(&sc->aue_rx_notice))
874 device_printf(sc->aue_dev, "usb error on rx: %s\n",
875 usbd_errstr(status));
876 if (status == USBD_STALLED)
877 usbd_clear_endpoint_stall(sc->aue_ep[AUE_ENDPT_RX]);
881 usbd_get_xfer_status(c->ue_xfer, NULL, NULL, &total_len, NULL);
883 if (total_len <= 4 + ETHER_CRC_LEN) {
889 bcopy(mtod(m, char *) + total_len - 4, (char *)&r, sizeof(r));
891 /* Turn off all the non-error bits in the rx status word. */
892 r.aue_rxstat &= AUE_RXSTAT_MASK;
899 /* No errors; receive the packet. */
900 total_len -= (4 + ETHER_CRC_LEN);
903 m->m_pkthdr.rcvif = (void *)&sc->aue_qdat;
904 m->m_pkthdr.len = m->m_len = total_len;
906 /* Put the packet on the special USB input queue. */
911 /* Setup new transfer. */
912 usbd_setup_xfer(c->ue_xfer, sc->aue_ep[AUE_ENDPT_RX],
913 c, mtod(c->ue_mbuf, char *), UE_BUFSZ, USBD_SHORT_XFER_OK,
914 USBD_NO_TIMEOUT, aue_rxeof);
915 usbd_transfer(c->ue_xfer);
921 * A frame was downloaded to the chip. It's safe for us to clean up
926 aue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
928 struct ue_chain *c = priv;
929 c->ue_status = status;
930 aue_task_sched(c->ue_sc, AUE_TASK_TXEOF);
934 aue_txeof_thread(struct aue_softc *sc)
936 struct ue_chain *c = &(sc->aue_cdata.ue_tx_chain[0]);
938 usbd_status err, status;
940 AUE_SXASSERTLOCKED(sc);
941 status = c->ue_status;
944 if (status != USBD_NORMAL_COMPLETION) {
945 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
948 device_printf(sc->aue_dev, "usb error on tx: %s\n",
949 usbd_errstr(status));
950 if (status == USBD_STALLED)
951 usbd_clear_endpoint_stall(sc->aue_ep[AUE_ENDPT_TX]);
956 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
957 usbd_get_xfer_status(c->ue_xfer, NULL, NULL, NULL, &err);
959 if (c->ue_mbuf != NULL) {
960 c->ue_mbuf->m_pkthdr.rcvif = ifp;
961 usb_tx_done(c->ue_mbuf);
976 struct aue_softc *sc = xsc;
978 aue_task_sched(sc, AUE_TASK_TICK);
982 aue_tick_thread(struct aue_softc *sc)
985 struct mii_data *mii;
987 AUE_SXASSERTLOCKED(sc);
990 * If a timer is set (non-zero) then decrement it
991 * and if it hits zero, then call the watchdog routine.
993 if (sc->aue_timer != 0 && --sc->aue_timer == 0) {
996 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
1006 if (!sc->aue_link && mii->mii_media_status & IFM_ACTIVE &&
1007 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
1009 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
1010 aue_start_thread(sc);
1013 (void) callout_reset(&sc->aue_tick_callout, hz, aue_tick, sc);
1018 aue_encap(struct aue_softc *sc, struct mbuf *m, int idx)
1024 AUE_SXASSERTLOCKED(sc);
1026 c = &sc->aue_cdata.ue_tx_chain[idx];
1029 * Copy the mbuf data into a contiguous buffer, leaving two
1030 * bytes at the beginning to hold the frame length.
1032 m_copydata(m, 0, m->m_pkthdr.len, c->ue_buf + 2);
1035 total_len = m->m_pkthdr.len + 2;
1038 * The ADMtek documentation says that the packet length is
1039 * supposed to be specified in the first two bytes of the
1040 * transfer, however it actually seems to ignore this info
1041 * and base the frame size on the bulk transfer length.
1043 c->ue_buf[0] = (u_int8_t)m->m_pkthdr.len;
1044 c->ue_buf[1] = (u_int8_t)(m->m_pkthdr.len >> 8);
1046 usbd_setup_xfer(c->ue_xfer, sc->aue_ep[AUE_ENDPT_TX],
1047 c, c->ue_buf, total_len, USBD_FORCE_SHORT_XFER,
1051 err = usbd_transfer(c->ue_xfer);
1052 if (err != USBD_IN_PROGRESS) {
1057 sc->aue_cdata.ue_tx_cnt++;
1064 aue_start(struct ifnet *ifp)
1066 struct aue_softc *sc = ifp->if_softc;
1067 aue_task_sched(sc, AUE_TASK_START);
1071 aue_start_thread(struct aue_softc *sc)
1073 struct ifnet *ifp = sc->aue_ifp;
1074 struct mbuf *m_head = NULL;
1076 AUE_SXASSERTLOCKED(sc);
1078 if (!sc->aue_link) {
1082 if (ifp->if_drv_flags & IFF_DRV_OACTIVE) {
1086 IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
1087 if (m_head == NULL) {
1091 if (aue_encap(sc, m_head, 0)) {
1092 IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
1093 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
1098 * If there's a BPF listener, bounce a copy of this frame
1101 BPF_MTAP(ifp, m_head);
1103 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
1106 * Set a timeout in case the chip goes out to lunch.
1116 struct aue_softc *sc = xsc;
1124 aue_init_body(struct aue_softc *sc)
1126 struct ifnet *ifp = sc->aue_ifp;
1127 struct mii_data *mii = GET_MII(sc);
1132 AUE_SXASSERTLOCKED(sc);
1134 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
1139 * Cancel pending I/O and free all RX/TX buffers.
1143 /* Set MAC address */
1144 for (i = 0; i < ETHER_ADDR_LEN; i++)
1145 aue_csr_write_1(sc, AUE_PAR0 + i, IF_LLADDR(sc->aue_ifp)[i]);
1147 /* If we want promiscuous mode, set the allframes bit. */
1148 if (ifp->if_flags & IFF_PROMISC)
1149 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1151 AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1154 if (usb_ether_tx_list_init(sc, &sc->aue_cdata,
1155 sc->aue_udev) == ENOBUFS) {
1156 device_printf(sc->aue_dev, "tx list init failed\n");
1161 if (usb_ether_rx_list_init(sc, &sc->aue_cdata,
1162 sc->aue_udev) == ENOBUFS) {
1163 device_printf(sc->aue_dev, "rx list init failed\n");
1168 /* Load the multicast filter. */
1171 /* Enable RX and TX */
1172 aue_csr_write_1(sc, AUE_CTL0, AUE_CTL0_RXSTAT_APPEND | AUE_CTL0_RX_ENB);
1173 AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_TX_ENB);
1174 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR);
1178 /* Open RX and TX pipes. */
1179 err = usbd_open_pipe(sc->aue_iface, sc->aue_ed[AUE_ENDPT_RX],
1180 USBD_EXCLUSIVE_USE, &sc->aue_ep[AUE_ENDPT_RX]);
1182 device_printf(sc->aue_dev, "open rx pipe failed: %s\n",
1186 err = usbd_open_pipe(sc->aue_iface, sc->aue_ed[AUE_ENDPT_TX],
1187 USBD_EXCLUSIVE_USE, &sc->aue_ep[AUE_ENDPT_TX]);
1189 device_printf(sc->aue_dev, "open tx pipe failed: %s\n",
1195 /* Start up the receive pipe. */
1196 for (i = 0; i < UE_RX_LIST_CNT; i++) {
1197 c = &sc->aue_cdata.ue_rx_chain[i];
1198 usbd_setup_xfer(c->ue_xfer, sc->aue_ep[AUE_ENDPT_RX],
1199 c, mtod(c->ue_mbuf, char *), UE_BUFSZ,
1200 USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, aue_rxeof);
1201 usbd_transfer(c->ue_xfer);
1204 ifp->if_drv_flags |= IFF_DRV_RUNNING;
1205 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1207 callout_init(&sc->aue_tick_callout, CALLOUT_MPSAFE);
1208 (void) callout_reset(&sc->aue_tick_callout, hz, aue_tick, sc);
1213 * Set media options.
1216 aue_ifmedia_upd(struct ifnet *ifp)
1218 struct aue_softc *sc = ifp->if_softc;
1219 struct mii_data *mii = GET_MII(sc);
1222 if (mii->mii_instance) {
1223 struct mii_softc *miisc;
1224 LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
1225 mii_phy_reset(miisc);
1234 * Report current media status.
1237 aue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
1239 struct aue_softc *sc = ifp->if_softc;
1240 struct mii_data *mii = GET_MII(sc);
1243 ifmr->ifm_active = mii->mii_media_active;
1244 ifmr->ifm_status = mii->mii_media_status;
1250 aue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
1252 struct aue_softc *sc = ifp->if_softc;
1253 struct ifreq *ifr = (struct ifreq *)data;
1254 struct mii_data *mii;
1258 * This prevents recursion in the interface while it's
1269 if (ifp->if_flags & IFF_UP) {
1270 if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1271 ifp->if_flags & IFF_PROMISC &&
1272 !(sc->aue_if_flags & IFF_PROMISC)) {
1273 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1274 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1275 !(ifp->if_flags & IFF_PROMISC) &&
1276 sc->aue_if_flags & IFF_PROMISC) {
1277 AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1278 } else if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
1283 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
1286 sc->aue_if_flags = ifp->if_flags;
1299 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
1303 error = ether_ioctl(ifp, command, data);
1313 aue_watchdog(struct aue_softc *sc)
1315 struct ifnet *ifp = sc->aue_ifp;
1319 AUE_SXASSERTLOCKED(sc);
1321 device_printf(sc->aue_dev, "watchdog timeout\n");
1323 c = &sc->aue_cdata.ue_tx_chain[0];
1324 usbd_get_xfer_status(c->ue_xfer, NULL, NULL, NULL, &stat);
1325 c->ue_status = stat;
1326 aue_txeof_thread(sc);
1328 if (!IFQ_IS_EMPTY(&ifp->if_snd))
1329 aue_start_thread(sc);
1334 * Stop the adapter and free any mbufs allocated to the
1338 aue_stop(struct aue_softc *sc)
1343 AUE_SXASSERTLOCKED(sc);
1347 aue_csr_write_1(sc, AUE_CTL0, 0);
1348 aue_csr_write_1(sc, AUE_CTL1, 0);
1352 /* Stop transfers. */
1353 if (sc->aue_ep[AUE_ENDPT_RX] != NULL) {
1354 err = usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_RX]);
1356 device_printf(sc->aue_dev,
1357 "abort rx pipe failed: %s\n", usbd_errstr(err));
1359 err = usbd_close_pipe(sc->aue_ep[AUE_ENDPT_RX]);
1361 device_printf(sc->aue_dev,
1362 "close rx pipe failed: %s\n", usbd_errstr(err));
1364 sc->aue_ep[AUE_ENDPT_RX] = NULL;
1367 if (sc->aue_ep[AUE_ENDPT_TX] != NULL) {
1368 err = usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]);
1370 device_printf(sc->aue_dev,
1371 "abort tx pipe failed: %s\n", usbd_errstr(err));
1373 err = usbd_close_pipe(sc->aue_ep[AUE_ENDPT_TX]);
1375 device_printf(sc->aue_dev,
1376 "close tx pipe failed: %s\n", usbd_errstr(err));
1378 sc->aue_ep[AUE_ENDPT_TX] = NULL;
1381 #ifdef AUE_INTR_PIPE
1382 if (sc->aue_ep[AUE_ENDPT_INTR] != NULL) {
1383 err = usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_INTR]);
1385 device_printf(sc->aue_dev,
1386 "abort intr pipe failed: %s\n", usbd_errstr(err));
1388 err = usbd_close_pipe(sc->aue_ep[AUE_ENDPT_INTR]);
1390 device_printf(sc->aue_dev,
1391 "close intr pipe failed: %s\n", usbd_errstr(err));
1393 sc->aue_ep[AUE_ENDPT_INTR] = NULL;
1397 /* Free RX resources. */
1398 usb_ether_rx_list_free(&sc->aue_cdata);
1399 /* Free TX resources. */
1400 usb_ether_tx_list_free(&sc->aue_cdata);
1402 #ifdef AUE_INTR_PIPE
1403 free(sc->aue_cdata.ue_ibuf, M_USBDEV);
1404 sc->aue_cdata.ue_ibuf = NULL;
1409 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
1415 * Stop all chip I/O so that the kernel's probe routines don't
1416 * get confused by errant DMAs when rebooting.
1419 aue_shutdown(device_t dev)
1421 struct aue_softc *sc;
1423 sc = device_get_softc(dev);
1434 aue_task_sched(struct aue_softc *sc, int task)
1438 sc->aue_deferedtasks |= task;
1439 usb_ether_task_enqueue(&sc->aue_taskqueue, &sc->aue_task);
1444 * We defer all interrupt operations to this function.
1446 * This allows us to do more complex operations, such as synchronous
1447 * usb io that normally would not be allowed from interrupt context.
1450 aue_task(void *arg, int pending)
1452 struct aue_softc *sc = arg;
1457 tasks = sc->aue_deferedtasks;
1458 sc->aue_deferedtasks = 0;
1464 AUE_GIANTLOCK(); // XXX: usb not giant safe
1466 if (sc->aue_dying) {
1470 if ((tasks & AUE_TASK_TICK) != 0) {
1471 aue_tick_thread(sc);
1473 if ((tasks & AUE_TASK_START) != 0) {
1474 aue_start_thread(sc);
1476 if ((tasks & AUE_TASK_RXSTART) != 0) {
1477 aue_rxstart_thread(sc);
1479 if ((tasks & AUE_TASK_RXEOF) != 0) {
1480 aue_rxeof_thread(sc);
1482 if ((tasks & AUE_TASK_TXEOF) != 0) {
1483 aue_txeof_thread(sc);
1486 AUE_GIANTUNLOCK(); // XXX: usb not giant safe