2 * Copyright (c) 1997, 1998, 1999, 2000
3 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
36 * ADMtek AN986 Pegasus and AN8511 Pegasus II USB to ethernet driver.
37 * Datasheet is available from http://www.admtek.com.tw.
39 * Written by Bill Paul <wpaul@ee.columbia.edu>
40 * Electrical Engineering Department
41 * Columbia University, New York City
45 * The Pegasus chip uses four USB "endpoints" to provide 10/100 ethernet
46 * support: the control endpoint for reading/writing registers, burst
47 * read endpoint for packet reception, burst write for packet transmission
48 * and one for "interrupts." The chip uses the same RX filter scheme
49 * as the other ADMtek ethernet parts: one perfect filter entry for the
50 * the station address and a 64-bit multicast hash table. The chip supports
51 * both MII and HomePNA attachments.
53 * Since the maximum data transfer speed of USB is supposed to be 12Mbps,
54 * you're never really going to get 100Mbps speeds from this device. I
55 * think the idea is to allow the device to connect to 10 or 100Mbps
56 * networks, not necessarily to provide 100Mbps performance. Also, since
57 * the controller uses an external PHY chip, it's possible that board
58 * designers might simply choose a 10Mbps PHY.
60 * Registers are accessed using usbd_do_request(). Packet transfers are
61 * done using usbd_transfer() and friends.
64 #include <sys/param.h>
65 #include <sys/systm.h>
66 #include <sys/sockio.h>
68 #include <sys/malloc.h>
69 #include <sys/kernel.h>
70 #include <sys/socket.h>
73 #include <net/if_arp.h>
74 #include <net/ethernet.h>
75 #include <net/if_dl.h>
76 #include <net/if_media.h>
82 #include <dev/usb/usb.h>
83 #include <dev/usb/usbdi.h>
84 #include <dev/usb/usbdi_util.h>
85 #include <dev/usb/usbdivar.h>
86 #include <dev/usb/usbdevs.h>
87 #include <dev/usb/usb_ethersubr.h>
89 #include <dev/mii/mii.h>
90 #include <dev/mii/miivar.h>
92 #include <dev/usb/if_auereg.h>
94 MODULE_DEPEND(if_aue, miibus, 1, 1, 1);
95 MODULE_DEPEND(if_aue, usb, 1, 1, 1);
97 /* "controller miibus0" required. See GENERIC if you get errors here. */
98 #include "miibus_if.h"
101 static const char rcsid[] =
106 * Various supported device vendors/products.
109 struct usb_devno aue_dev;
111 #define LSYS 0x0001 /* use Linksys reset */
112 #define PNA 0x0002 /* has Home PNA */
113 #define PII 0x0004 /* Pegasus II chip */
116 Static const struct aue_type aue_devs[] = {
117 {{ USB_VENDOR_3COM, USB_PRODUCT_3COM_3C460B}, PII },
118 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1}, PNA|PII },
119 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX2}, PII },
120 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_UFE1000}, LSYS },
121 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX4}, PNA },
122 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX5}, PNA },
123 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX6}, PII },
124 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX7}, PII },
125 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX8}, PII },
126 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX9}, PNA },
127 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX10}, 0 },
128 {{ USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_DSB650TX_PNA}, 0 },
129 {{ USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_USB320_EC}, 0 },
130 {{ USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_SS1001}, PII },
131 {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS}, PNA },
132 {{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII}, PII },
133 {{ USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_USB2LAN}, PII },
134 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100}, 0 },
135 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBLP100}, PNA },
136 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBEL100}, 0 },
137 {{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBE100}, PII },
138 {{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX}, 0 },
139 {{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXS},PII },
140 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX4}, LSYS|PII },
141 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX1}, LSYS },
142 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX}, LSYS },
143 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA}, PNA },
144 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX3}, LSYS|PII },
145 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX2}, LSYS|PII },
146 {{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650}, LSYS },
147 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX0}, 0 },
148 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX1}, 0 },
149 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX2}, 0 },
150 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX3}, PII },
151 {{ USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBLTX}, PII },
152 {{ USB_VENDOR_ELSA, USB_PRODUCT_ELSA_USB2ETHERNET}, 0 },
153 {{ USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX}, 0 },
154 {{ USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTXS}, PII },
155 {{ USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX}, 0 },
156 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX1}, LSYS|PII },
157 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10T}, LSYS },
158 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX}, LSYS },
159 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1}, LSYS|PNA },
160 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA}, LSYS },
161 {{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX2}, LSYS|PII },
162 {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1}, 0 },
163 {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5}, 0 },
164 {{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUA2TX5}, PII },
165 {{ USB_VENDOR_SIEMENS, USB_PRODUCT_SIEMENS_SPEEDSTREAM}, PII },
166 {{ USB_VENDOR_SMARTBRIDGES, USB_PRODUCT_SMARTBRIDGES_SMARTNIC},PII },
167 {{ USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB}, 0 },
168 {{ USB_VENDOR_SMC, USB_PRODUCT_SMC_2206USB}, PII },
169 {{ USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB100}, 0 },
171 #define aue_lookup(v, p) ((const struct aue_type *)usb_lookup(aue_devs, v, p))
173 Static struct usb_qdat aue_qdat;
175 Static int aue_match(device_ptr_t);
176 Static int aue_attach(device_ptr_t);
177 Static int aue_detach(device_ptr_t);
179 Static void aue_reset_pegasus_II(struct aue_softc *sc);
180 Static int aue_tx_list_init(struct aue_softc *);
181 Static int aue_rx_list_init(struct aue_softc *);
182 Static int aue_newbuf(struct aue_softc *, struct aue_chain *, struct mbuf *);
183 Static int aue_encap(struct aue_softc *, struct mbuf *, int);
185 Static void aue_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
187 Static void aue_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
188 Static void aue_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
189 Static void aue_tick(void *);
190 Static void aue_rxstart(struct ifnet *);
191 Static void aue_start(struct ifnet *);
192 Static int aue_ioctl(struct ifnet *, u_long, caddr_t);
193 Static void aue_init(void *);
194 Static void aue_stop(struct aue_softc *);
195 Static void aue_watchdog(struct ifnet *);
196 Static void aue_shutdown(device_ptr_t);
197 Static int aue_ifmedia_upd(struct ifnet *);
198 Static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
200 Static void aue_eeprom_getword(struct aue_softc *, int, u_int16_t *);
201 Static void aue_read_eeprom(struct aue_softc *, caddr_t, int, int, int);
202 Static int aue_miibus_readreg(device_ptr_t, int, int);
203 Static int aue_miibus_writereg(device_ptr_t, int, int, int);
204 Static void aue_miibus_statchg(device_ptr_t);
206 Static void aue_setmulti(struct aue_softc *);
207 Static u_int32_t aue_crc(caddr_t);
208 Static void aue_reset(struct aue_softc *);
210 Static int aue_csr_read_1(struct aue_softc *, int);
211 Static int aue_csr_write_1(struct aue_softc *, int, int);
212 Static int aue_csr_read_2(struct aue_softc *, int);
213 Static int aue_csr_write_2(struct aue_softc *, int, int);
215 Static device_method_t aue_methods[] = {
216 /* Device interface */
217 DEVMETHOD(device_probe, aue_match),
218 DEVMETHOD(device_attach, aue_attach),
219 DEVMETHOD(device_detach, aue_detach),
220 DEVMETHOD(device_shutdown, aue_shutdown),
223 DEVMETHOD(bus_print_child, bus_generic_print_child),
224 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
227 DEVMETHOD(miibus_readreg, aue_miibus_readreg),
228 DEVMETHOD(miibus_writereg, aue_miibus_writereg),
229 DEVMETHOD(miibus_statchg, aue_miibus_statchg),
234 Static driver_t aue_driver = {
237 sizeof(struct aue_softc)
240 Static devclass_t aue_devclass;
242 DRIVER_MODULE(if_aue, uhub, aue_driver, aue_devclass, usbd_driver_load, 0);
243 DRIVER_MODULE(miibus, aue, miibus_driver, miibus_devclass, 0, 0);
245 #define AUE_SETBIT(sc, reg, x) \
246 aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x))
248 #define AUE_CLRBIT(sc, reg, x) \
249 aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x))
252 aue_csr_read_1(struct aue_softc *sc, int reg)
254 usb_device_request_t req;
263 req.bmRequestType = UT_READ_VENDOR_DEVICE;
264 req.bRequest = AUE_UR_READREG;
265 USETW(req.wValue, 0);
266 USETW(req.wIndex, reg);
267 USETW(req.wLength, 1);
269 err = usbd_do_request(sc->aue_udev, &req, &val);
281 aue_csr_read_2(struct aue_softc *sc, int reg)
283 usb_device_request_t req;
292 req.bmRequestType = UT_READ_VENDOR_DEVICE;
293 req.bRequest = AUE_UR_READREG;
294 USETW(req.wValue, 0);
295 USETW(req.wIndex, reg);
296 USETW(req.wLength, 2);
298 err = usbd_do_request(sc->aue_udev, &req, &val);
310 aue_csr_write_1(struct aue_softc *sc, int reg, int val)
312 usb_device_request_t req;
320 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
321 req.bRequest = AUE_UR_WRITEREG;
322 USETW(req.wValue, val);
323 USETW(req.wIndex, reg);
324 USETW(req.wLength, 1);
326 err = usbd_do_request(sc->aue_udev, &req, &val);
338 aue_csr_write_2(struct aue_softc *sc, int reg, int val)
340 usb_device_request_t req;
348 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
349 req.bRequest = AUE_UR_WRITEREG;
350 USETW(req.wValue, val);
351 USETW(req.wIndex, reg);
352 USETW(req.wLength, 2);
354 err = usbd_do_request(sc->aue_udev, &req, &val);
366 * Read a word of data stored in the EEPROM at address 'addr.'
369 aue_eeprom_getword(struct aue_softc *sc, int addr, u_int16_t *dest)
374 aue_csr_write_1(sc, AUE_EE_REG, addr);
375 aue_csr_write_1(sc, AUE_EE_CTL, AUE_EECTL_READ);
377 for (i = 0; i < AUE_TIMEOUT; i++) {
378 if (aue_csr_read_1(sc, AUE_EE_CTL) & AUE_EECTL_DONE)
382 if (i == AUE_TIMEOUT) {
383 printf("aue%d: EEPROM read timed out\n",
387 word = aue_csr_read_2(sc, AUE_EE_DATA);
394 * Read a sequence of words from the EEPROM.
397 aue_read_eeprom(struct aue_softc *sc, caddr_t dest, int off, int cnt, int swap)
400 u_int16_t word = 0, *ptr;
402 for (i = 0; i < cnt; i++) {
403 aue_eeprom_getword(sc, off + i, &word);
404 ptr = (u_int16_t *)(dest + (i * 2));
415 aue_miibus_readreg(device_ptr_t dev, int phy, int reg)
417 struct aue_softc *sc = USBGETSOFTC(dev);
422 * The Am79C901 HomePNA PHY actually contains
423 * two transceivers: a 1Mbps HomePNA PHY and a
424 * 10Mbps full/half duplex ethernet PHY with
425 * NWAY autoneg. However in the ADMtek adapter,
426 * only the 1Mbps PHY is actually connected to
427 * anything, so we ignore the 10Mbps one. It
428 * happens to be configured for MII address 3,
429 * so we filter that out.
431 if (sc->aue_vendor == USB_VENDOR_ADMTEK &&
432 sc->aue_product == USB_PRODUCT_ADMTEK_PEGASUS) {
441 aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
442 aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_READ);
444 for (i = 0; i < AUE_TIMEOUT; i++) {
445 if (aue_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE)
449 if (i == AUE_TIMEOUT) {
450 printf("aue%d: MII read timed out\n", sc->aue_unit);
453 val = aue_csr_read_2(sc, AUE_PHY_DATA);
459 aue_miibus_writereg(device_ptr_t dev, int phy, int reg, int data)
461 struct aue_softc *sc = USBGETSOFTC(dev);
467 aue_csr_write_2(sc, AUE_PHY_DATA, data);
468 aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
469 aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_WRITE);
471 for (i = 0; i < AUE_TIMEOUT; i++) {
472 if (aue_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE)
476 if (i == AUE_TIMEOUT) {
477 printf("aue%d: MII read timed out\n",
485 aue_miibus_statchg(device_ptr_t dev)
487 struct aue_softc *sc = USBGETSOFTC(dev);
488 struct mii_data *mii = GET_MII(sc);
490 AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB);
491 if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) {
492 AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL);
494 AUE_CLRBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL);
497 if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
498 AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX);
500 AUE_CLRBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX);
502 AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB);
505 * Set the LED modes on the LinkSys adapter.
506 * This turns on the 'dual link LED' bin in the auxmode
507 * register of the Broadcom PHY.
509 if (sc->aue_flags & LSYS) {
511 auxmode = aue_miibus_readreg(dev, 0, 0x1b);
512 aue_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04);
518 #define AUE_POLY 0xEDB88320
522 aue_crc(caddr_t addr)
524 u_int32_t idx, bit, data, crc;
526 /* Compute CRC for the address value. */
527 crc = 0xFFFFFFFF; /* initial value */
529 for (idx = 0; idx < 6; idx++) {
530 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1)
531 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? AUE_POLY : 0);
534 return (crc & ((1 << AUE_BITS) - 1));
538 aue_setmulti(struct aue_softc *sc)
541 struct ifmultiaddr *ifma;
544 ifp = &sc->arpcom.ac_if;
546 if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
547 AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
551 AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
553 /* first, zot all the existing hash bits */
554 for (i = 0; i < 8; i++)
555 aue_csr_write_1(sc, AUE_MAR0 + i, 0);
557 /* now program new ones */
558 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
559 if (ifma->ifma_addr->sa_family != AF_LINK)
561 h = aue_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
562 AUE_SETBIT(sc, AUE_MAR + (h >> 3), 1 << (h & 0x7));
569 aue_reset_pegasus_II(struct aue_softc *sc)
571 /* Magic constants taken from Linux driver. */
572 aue_csr_write_1(sc, AUE_REG_1D, 0);
573 aue_csr_write_1(sc, AUE_REG_7B, 2);
575 if ((sc->aue_flags & HAS_HOME_PNA) && mii_mode)
576 aue_csr_write_1(sc, AUE_REG_81, 6);
579 aue_csr_write_1(sc, AUE_REG_81, 2);
583 aue_reset(struct aue_softc *sc)
587 AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_RESETMAC);
589 for (i = 0; i < AUE_TIMEOUT; i++) {
590 if (!(aue_csr_read_1(sc, AUE_CTL1) & AUE_CTL1_RESETMAC))
594 if (i == AUE_TIMEOUT)
595 printf("aue%d: reset failed\n", sc->aue_unit);
598 * The PHY(s) attached to the Pegasus chip may be held
599 * in reset until we flip on the GPIO outputs. Make sure
600 * to set the GPIO pins high so that the PHY(s) will
603 * Note: We force all of the GPIO pins low first, *then*
604 * enable the ones we want.
606 aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0);
607 aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0|AUE_GPIO_SEL1);
609 if (sc->aue_flags & LSYS) {
610 /* Grrr. LinkSys has to be different from everyone else. */
611 aue_csr_write_1(sc, AUE_GPIO0,
612 AUE_GPIO_SEL0 | AUE_GPIO_SEL1);
613 aue_csr_write_1(sc, AUE_GPIO0,
614 AUE_GPIO_SEL0 | AUE_GPIO_SEL1 | AUE_GPIO_OUT0);
617 if (sc->aue_flags & PII)
618 aue_reset_pegasus_II(sc);
620 /* Wait a little while for the chip to get its brains in order. */
627 * Probe for a Pegasus chip.
631 USB_MATCH_START(aue, uaa);
633 if (uaa->iface != NULL)
634 return (UMATCH_NONE);
636 return (aue_lookup(uaa->vendor, uaa->product) != NULL ?
637 UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
641 * Attach the interface. Allocate softc structures, do ifmedia
642 * setup and ethernet/BPF attach.
646 USB_ATTACH_START(aue, sc, uaa);
648 u_char eaddr[ETHER_ADDR_LEN];
650 usbd_interface_handle iface;
652 usb_interface_descriptor_t *id;
653 usb_endpoint_descriptor_t *ed;
656 bzero(sc, sizeof(struct aue_softc));
658 usbd_devinfo(uaa->device, 0, devinfo);
660 sc->aue_udev = uaa->device;
661 sc->aue_unit = device_get_unit(self);
663 if (usbd_set_config_no(sc->aue_udev, AUE_CONFIG_NO, 0)) {
664 printf("aue%d: getting interface handle failed\n",
666 USB_ATTACH_ERROR_RETURN;
669 err = usbd_device2interface_handle(uaa->device, AUE_IFACE_IDX, &iface);
671 printf("aue%d: getting interface handle failed\n",
673 USB_ATTACH_ERROR_RETURN;
676 sc->aue_iface = iface;
677 sc->aue_flags = aue_lookup(uaa->vendor, uaa->product)->aue_flags;
679 sc->aue_product = uaa->product;
680 sc->aue_vendor = uaa->vendor;
682 id = usbd_get_interface_descriptor(sc->aue_iface);
684 usbd_devinfo(uaa->device, 0, devinfo);
685 device_set_desc_copy(self, devinfo);
686 printf("%s: %s\n", USBDEVNAME(self), devinfo);
688 /* Find endpoints. */
689 for (i = 0; i < id->bNumEndpoints; i++) {
690 ed = usbd_interface2endpoint_descriptor(iface, i);
692 printf("aue%d: couldn't get ep %d\n",
694 USB_ATTACH_ERROR_RETURN;
696 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
697 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
698 sc->aue_ed[AUE_ENDPT_RX] = ed->bEndpointAddress;
699 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
700 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
701 sc->aue_ed[AUE_ENDPT_TX] = ed->bEndpointAddress;
702 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
703 UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
704 sc->aue_ed[AUE_ENDPT_INTR] = ed->bEndpointAddress;
708 mtx_init(&sc->aue_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK,
709 MTX_DEF | MTX_RECURSE);
712 /* Reset the adapter. */
716 * Get station address from the EEPROM.
718 aue_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 0);
721 * A Pegasus chip was detected. Inform the world.
723 printf("aue%d: Ethernet address: %6D\n", sc->aue_unit, eaddr, ":");
725 bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
727 ifp = &sc->arpcom.ac_if;
729 ifp->if_unit = sc->aue_unit;
730 ifp->if_name = "aue";
731 ifp->if_mtu = ETHERMTU;
732 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
733 ifp->if_ioctl = aue_ioctl;
734 ifp->if_output = ether_output;
735 ifp->if_start = aue_start;
736 ifp->if_watchdog = aue_watchdog;
737 ifp->if_init = aue_init;
738 ifp->if_baudrate = 10000000;
739 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
743 * NOTE: Doing this causes child devices to be attached to us,
744 * which we would normally disconnect at in the detach routine
745 * using device_delete_child(). However the USB code is set up
746 * such that when this driver is removed, all children devices
747 * are removed as well. In effect, the USB code ends up detaching
748 * all of our children for us, so we don't have to do is ourselves
749 * in aue_detach(). It's important to point this out since if
750 * we *do* try to detach the child devices ourselves, we will
751 * end up getting the children deleted twice, which will crash
754 if (mii_phy_probe(self, &sc->aue_miibus,
755 aue_ifmedia_upd, aue_ifmedia_sts)) {
756 printf("aue%d: MII without any PHY!\n", sc->aue_unit);
758 mtx_destroy(&sc->aue_mtx);
759 USB_ATTACH_ERROR_RETURN;
763 aue_qdat.if_rxstart = aue_rxstart;
766 * Call MI attach routine.
768 ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
769 callout_handle_init(&sc->aue_stat_ch);
770 usb_register_netisr();
774 USB_ATTACH_SUCCESS_RETURN;
778 aue_detach(device_ptr_t dev)
780 struct aue_softc *sc;
783 sc = device_get_softc(dev);
785 ifp = &sc->arpcom.ac_if;
788 untimeout(aue_tick, sc, sc->aue_stat_ch);
789 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
791 if (sc->aue_ep[AUE_ENDPT_TX] != NULL)
792 usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]);
793 if (sc->aue_ep[AUE_ENDPT_RX] != NULL)
794 usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_RX]);
796 if (sc->aue_ep[AUE_ENDPT_INTR] != NULL)
797 usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_INTR]);
801 mtx_destroy(&sc->aue_mtx);
807 * Initialize an RX descriptor and attach an MBUF cluster.
810 aue_newbuf(struct aue_softc *sc, struct aue_chain *c, struct mbuf *m)
812 struct mbuf *m_new = NULL;
815 MGETHDR(m_new, M_DONTWAIT, MT_DATA);
817 printf("aue%d: no memory for rx list "
818 "-- packet dropped!\n", sc->aue_unit);
822 MCLGET(m_new, M_DONTWAIT);
823 if (!(m_new->m_flags & M_EXT)) {
824 printf("aue%d: no memory for rx list "
825 "-- packet dropped!\n", sc->aue_unit);
829 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
832 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
833 m_new->m_data = m_new->m_ext.ext_buf;
836 m_adj(m_new, ETHER_ALIGN);
843 aue_rx_list_init(struct aue_softc *sc)
845 struct aue_cdata *cd;
850 for (i = 0; i < AUE_RX_LIST_CNT; i++) {
851 c = &cd->aue_rx_chain[i];
854 if (aue_newbuf(sc, c, NULL) == ENOBUFS)
856 if (c->aue_xfer == NULL) {
857 c->aue_xfer = usbd_alloc_xfer(sc->aue_udev);
858 if (c->aue_xfer == NULL)
867 aue_tx_list_init(struct aue_softc *sc)
869 struct aue_cdata *cd;
874 for (i = 0; i < AUE_TX_LIST_CNT; i++) {
875 c = &cd->aue_tx_chain[i];
879 if (c->aue_xfer == NULL) {
880 c->aue_xfer = usbd_alloc_xfer(sc->aue_udev);
881 if (c->aue_xfer == NULL)
884 c->aue_buf = malloc(AUE_BUFSZ, M_USBDEV, M_NOWAIT);
885 if (c->aue_buf == NULL)
894 aue_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
896 struct aue_softc *sc = priv;
898 struct aue_intrpkt *p;
901 ifp = &sc->arpcom.ac_if;
903 if (!(ifp->if_flags & IFF_RUNNING)) {
908 if (status != USBD_NORMAL_COMPLETION) {
909 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
913 printf("aue%d: usb error on intr: %s\n", sc->aue_unit,
914 usbd_errstr(status));
915 if (status == USBD_STALLED)
916 usbd_clear_endpoint_stall(sc->aue_ep[AUE_ENDPT_RX]);
921 usbd_get_xfer_status(xfer, NULL, (void **)&p, NULL, NULL);
926 if (p->aue_txstat0 & (AUE_TXSTAT0_LATECOLL & AUE_TXSTAT0_EXCESSCOLL))
927 ifp->if_collisions++;
935 aue_rxstart(struct ifnet *ifp)
937 struct aue_softc *sc;
942 c = &sc->aue_cdata.aue_rx_chain[sc->aue_cdata.aue_rx_prod];
944 if (aue_newbuf(sc, c, NULL) == ENOBUFS) {
950 /* Setup new transfer. */
951 usbd_setup_xfer(c->aue_xfer, sc->aue_ep[AUE_ENDPT_RX],
952 c, mtod(c->aue_mbuf, char *), AUE_BUFSZ, USBD_SHORT_XFER_OK,
953 USBD_NO_TIMEOUT, aue_rxeof);
954 usbd_transfer(c->aue_xfer);
961 * A frame has been uploaded: pass the resulting mbuf chain up to
962 * the higher level protocols.
965 aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
967 struct aue_chain *c = priv;
968 struct aue_softc *sc = c->aue_sc;
977 ifp = &sc->arpcom.ac_if;
979 if (!(ifp->if_flags & IFF_RUNNING)) {
984 if (status != USBD_NORMAL_COMPLETION) {
985 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
989 if (usbd_ratecheck(&sc->aue_rx_notice))
990 printf("aue%d: usb error on rx: %s\n", sc->aue_unit,
991 usbd_errstr(status));
992 if (status == USBD_STALLED)
993 usbd_clear_endpoint_stall(sc->aue_ep[AUE_ENDPT_RX]);
997 usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
999 if (total_len <= 4 + ETHER_CRC_LEN) {
1005 bcopy(mtod(m, char *) + total_len - 4, (char *)&r, sizeof(r));
1007 /* Turn off all the non-error bits in the rx status word. */
1008 r.aue_rxstat &= AUE_RXSTAT_MASK;
1015 /* No errors; receive the packet. */
1016 total_len -= (4 + ETHER_CRC_LEN);
1019 m->m_pkthdr.rcvif = (struct ifnet *)&aue_qdat;
1020 m->m_pkthdr.len = m->m_len = total_len;
1022 /* Put the packet on the special USB input queue. */
1028 /* Setup new transfer. */
1029 usbd_setup_xfer(xfer, sc->aue_ep[AUE_ENDPT_RX],
1030 c, mtod(c->aue_mbuf, char *), AUE_BUFSZ, USBD_SHORT_XFER_OK,
1031 USBD_NO_TIMEOUT, aue_rxeof);
1032 usbd_transfer(xfer);
1039 * A frame was downloaded to the chip. It's safe for us to clean up
1044 aue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
1046 struct aue_chain *c = priv;
1047 struct aue_softc *sc = c->aue_sc;
1052 ifp = &sc->arpcom.ac_if;
1054 if (status != USBD_NORMAL_COMPLETION) {
1055 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
1059 printf("aue%d: usb error on tx: %s\n", sc->aue_unit,
1060 usbd_errstr(status));
1061 if (status == USBD_STALLED)
1062 usbd_clear_endpoint_stall(sc->aue_ep[AUE_ENDPT_TX]);
1068 ifp->if_flags &= ~IFF_OACTIVE;
1069 usbd_get_xfer_status(c->aue_xfer, NULL, NULL, NULL, &err);
1071 if (c->aue_mbuf != NULL) {
1072 c->aue_mbuf->m_pkthdr.rcvif = ifp;
1073 usb_tx_done(c->aue_mbuf);
1090 struct aue_softc *sc = xsc;
1092 struct mii_data *mii;
1099 ifp = &sc->arpcom.ac_if;
1107 if (!sc->aue_link && mii->mii_media_status & IFM_ACTIVE &&
1108 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
1110 if (ifp->if_snd.ifq_head != NULL)
1114 sc->aue_stat_ch = timeout(aue_tick, sc, hz);
1122 aue_encap(struct aue_softc *sc, struct mbuf *m, int idx)
1125 struct aue_chain *c;
1128 c = &sc->aue_cdata.aue_tx_chain[idx];
1131 * Copy the mbuf data into a contiguous buffer, leaving two
1132 * bytes at the beginning to hold the frame length.
1134 m_copydata(m, 0, m->m_pkthdr.len, c->aue_buf + 2);
1137 total_len = m->m_pkthdr.len + 2;
1140 * The ADMtek documentation says that the packet length is
1141 * supposed to be specified in the first two bytes of the
1142 * transfer, however it actually seems to ignore this info
1143 * and base the frame size on the bulk transfer length.
1145 c->aue_buf[0] = (u_int8_t)m->m_pkthdr.len;
1146 c->aue_buf[1] = (u_int8_t)(m->m_pkthdr.len >> 8);
1148 usbd_setup_xfer(c->aue_xfer, sc->aue_ep[AUE_ENDPT_TX],
1149 c, c->aue_buf, total_len, USBD_FORCE_SHORT_XFER,
1153 err = usbd_transfer(c->aue_xfer);
1154 if (err != USBD_IN_PROGRESS) {
1159 sc->aue_cdata.aue_tx_cnt++;
1165 aue_start(struct ifnet *ifp)
1167 struct aue_softc *sc = ifp->if_softc;
1168 struct mbuf *m_head = NULL;
1172 if (!sc->aue_link) {
1177 if (ifp->if_flags & IFF_OACTIVE) {
1182 IF_DEQUEUE(&ifp->if_snd, m_head);
1183 if (m_head == NULL) {
1188 if (aue_encap(sc, m_head, 0)) {
1189 IF_PREPEND(&ifp->if_snd, m_head);
1190 ifp->if_flags |= IFF_OACTIVE;
1196 * If there's a BPF listener, bounce a copy of this frame
1200 bpf_mtap(ifp, m_head);
1202 ifp->if_flags |= IFF_OACTIVE;
1205 * Set a timeout in case the chip goes out to lunch.
1216 struct aue_softc *sc = xsc;
1217 struct ifnet *ifp = &sc->arpcom.ac_if;
1218 struct mii_data *mii = GET_MII(sc);
1219 struct aue_chain *c;
1225 if (ifp->if_flags & IFF_RUNNING) {
1231 * Cancel pending I/O and free all RX/TX buffers.
1235 /* Set MAC address */
1236 for (i = 0; i < ETHER_ADDR_LEN; i++)
1237 aue_csr_write_1(sc, AUE_PAR0 + i, sc->arpcom.ac_enaddr[i]);
1239 /* If we want promiscuous mode, set the allframes bit. */
1240 if (ifp->if_flags & IFF_PROMISC)
1241 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1243 AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1246 if (aue_tx_list_init(sc) == ENOBUFS) {
1247 printf("aue%d: tx list init failed\n", sc->aue_unit);
1253 if (aue_rx_list_init(sc) == ENOBUFS) {
1254 printf("aue%d: rx list init failed\n", sc->aue_unit);
1259 #ifdef AUE_INTR_PIPE
1260 sc->aue_cdata.aue_ibuf = malloc(AUE_INTR_PKTLEN, M_USBDEV, M_NOWAIT);
1263 /* Load the multicast filter. */
1266 /* Enable RX and TX */
1267 aue_csr_write_1(sc, AUE_CTL0, AUE_CTL0_RXSTAT_APPEND | AUE_CTL0_RX_ENB);
1268 AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_TX_ENB);
1269 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR);
1273 /* Open RX and TX pipes. */
1274 err = usbd_open_pipe(sc->aue_iface, sc->aue_ed[AUE_ENDPT_RX],
1275 USBD_EXCLUSIVE_USE, &sc->aue_ep[AUE_ENDPT_RX]);
1277 printf("aue%d: open rx pipe failed: %s\n",
1278 sc->aue_unit, usbd_errstr(err));
1282 err = usbd_open_pipe(sc->aue_iface, sc->aue_ed[AUE_ENDPT_TX],
1283 USBD_EXCLUSIVE_USE, &sc->aue_ep[AUE_ENDPT_TX]);
1285 printf("aue%d: open tx pipe failed: %s\n",
1286 sc->aue_unit, usbd_errstr(err));
1291 #ifdef AUE_INTR_PIPE
1292 err = usbd_open_pipe_intr(sc->aue_iface, sc->aue_ed[AUE_ENDPT_INTR],
1293 USBD_SHORT_XFER_OK, &sc->aue_ep[AUE_ENDPT_INTR], sc,
1294 sc->aue_cdata.aue_ibuf, AUE_INTR_PKTLEN, aue_intr,
1297 printf("aue%d: open intr pipe failed: %s\n",
1298 sc->aue_unit, usbd_errstr(err));
1304 /* Start up the receive pipe. */
1305 for (i = 0; i < AUE_RX_LIST_CNT; i++) {
1306 c = &sc->aue_cdata.aue_rx_chain[i];
1307 usbd_setup_xfer(c->aue_xfer, sc->aue_ep[AUE_ENDPT_RX],
1308 c, mtod(c->aue_mbuf, char *), AUE_BUFSZ,
1309 USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, aue_rxeof);
1310 usbd_transfer(c->aue_xfer);
1313 ifp->if_flags |= IFF_RUNNING;
1314 ifp->if_flags &= ~IFF_OACTIVE;
1316 sc->aue_stat_ch = timeout(aue_tick, sc, hz);
1324 * Set media options.
1327 aue_ifmedia_upd(struct ifnet *ifp)
1329 struct aue_softc *sc = ifp->if_softc;
1330 struct mii_data *mii = GET_MII(sc);
1333 if (mii->mii_instance) {
1334 struct mii_softc *miisc;
1335 LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
1336 mii_phy_reset(miisc);
1344 * Report current media status.
1347 aue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
1349 struct aue_softc *sc = ifp->if_softc;
1350 struct mii_data *mii = GET_MII(sc);
1353 ifmr->ifm_active = mii->mii_media_active;
1354 ifmr->ifm_status = mii->mii_media_status;
1360 aue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
1362 struct aue_softc *sc = ifp->if_softc;
1363 struct ifreq *ifr = (struct ifreq *)data;
1364 struct mii_data *mii;
1373 error = ether_ioctl(ifp, command, data);
1376 if (ifp->if_flags & IFF_UP) {
1377 if (ifp->if_flags & IFF_RUNNING &&
1378 ifp->if_flags & IFF_PROMISC &&
1379 !(sc->aue_if_flags & IFF_PROMISC)) {
1380 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1381 } else if (ifp->if_flags & IFF_RUNNING &&
1382 !(ifp->if_flags & IFF_PROMISC) &&
1383 sc->aue_if_flags & IFF_PROMISC) {
1384 AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
1385 } else if (!(ifp->if_flags & IFF_RUNNING))
1388 if (ifp->if_flags & IFF_RUNNING)
1391 sc->aue_if_flags = ifp->if_flags;
1402 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
1415 aue_watchdog(struct ifnet *ifp)
1417 struct aue_softc *sc = ifp->if_softc;
1418 struct aue_chain *c;
1424 printf("aue%d: watchdog timeout\n", sc->aue_unit);
1426 c = &sc->aue_cdata.aue_tx_chain[0];
1427 usbd_get_xfer_status(c->aue_xfer, NULL, NULL, NULL, &stat);
1428 aue_txeof(c->aue_xfer, c, stat);
1430 if (ifp->if_snd.ifq_head != NULL)
1437 * Stop the adapter and free any mbufs allocated to the
1441 aue_stop(struct aue_softc *sc)
1448 ifp = &sc->arpcom.ac_if;
1451 aue_csr_write_1(sc, AUE_CTL0, 0);
1452 aue_csr_write_1(sc, AUE_CTL1, 0);
1454 untimeout(aue_tick, sc, sc->aue_stat_ch);
1456 /* Stop transfers. */
1457 if (sc->aue_ep[AUE_ENDPT_RX] != NULL) {
1458 err = usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_RX]);
1460 printf("aue%d: abort rx pipe failed: %s\n",
1461 sc->aue_unit, usbd_errstr(err));
1463 err = usbd_close_pipe(sc->aue_ep[AUE_ENDPT_RX]);
1465 printf("aue%d: close rx pipe failed: %s\n",
1466 sc->aue_unit, usbd_errstr(err));
1468 sc->aue_ep[AUE_ENDPT_RX] = NULL;
1471 if (sc->aue_ep[AUE_ENDPT_TX] != NULL) {
1472 err = usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]);
1474 printf("aue%d: abort tx pipe failed: %s\n",
1475 sc->aue_unit, usbd_errstr(err));
1477 err = usbd_close_pipe(sc->aue_ep[AUE_ENDPT_TX]);
1479 printf("aue%d: close tx pipe failed: %s\n",
1480 sc->aue_unit, usbd_errstr(err));
1482 sc->aue_ep[AUE_ENDPT_TX] = NULL;
1485 #ifdef AUE_INTR_PIPE
1486 if (sc->aue_ep[AUE_ENDPT_INTR] != NULL) {
1487 err = usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_INTR]);
1489 printf("aue%d: abort intr pipe failed: %s\n",
1490 sc->aue_unit, usbd_errstr(err));
1492 err = usbd_close_pipe(sc->aue_ep[AUE_ENDPT_INTR]);
1494 printf("aue%d: close intr pipe failed: %s\n",
1495 sc->aue_unit, usbd_errstr(err));
1497 sc->aue_ep[AUE_ENDPT_INTR] = NULL;
1501 /* Free RX resources. */
1502 for (i = 0; i < AUE_RX_LIST_CNT; i++) {
1503 if (sc->aue_cdata.aue_rx_chain[i].aue_buf != NULL) {
1504 free(sc->aue_cdata.aue_rx_chain[i].aue_buf, M_USBDEV);
1505 sc->aue_cdata.aue_rx_chain[i].aue_buf = NULL;
1507 if (sc->aue_cdata.aue_rx_chain[i].aue_mbuf != NULL) {
1508 m_freem(sc->aue_cdata.aue_rx_chain[i].aue_mbuf);
1509 sc->aue_cdata.aue_rx_chain[i].aue_mbuf = NULL;
1511 if (sc->aue_cdata.aue_rx_chain[i].aue_xfer != NULL) {
1512 usbd_free_xfer(sc->aue_cdata.aue_rx_chain[i].aue_xfer);
1513 sc->aue_cdata.aue_rx_chain[i].aue_xfer = NULL;
1517 /* Free TX resources. */
1518 for (i = 0; i < AUE_TX_LIST_CNT; i++) {
1519 if (sc->aue_cdata.aue_tx_chain[i].aue_buf != NULL) {
1520 free(sc->aue_cdata.aue_tx_chain[i].aue_buf, M_USBDEV);
1521 sc->aue_cdata.aue_tx_chain[i].aue_buf = NULL;
1523 if (sc->aue_cdata.aue_tx_chain[i].aue_mbuf != NULL) {
1524 m_freem(sc->aue_cdata.aue_tx_chain[i].aue_mbuf);
1525 sc->aue_cdata.aue_tx_chain[i].aue_mbuf = NULL;
1527 if (sc->aue_cdata.aue_tx_chain[i].aue_xfer != NULL) {
1528 usbd_free_xfer(sc->aue_cdata.aue_tx_chain[i].aue_xfer);
1529 sc->aue_cdata.aue_tx_chain[i].aue_xfer = NULL;
1533 #ifdef AUE_INTR_PIPE
1534 free(sc->aue_cdata.aue_ibuf, M_USBDEV);
1535 sc->aue_cdata.aue_ibuf = NULL;
1540 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
1547 * Stop all chip I/O so that the kernel's probe routines don't
1548 * get confused by errant DMAs when rebooting.
1551 aue_shutdown(device_ptr_t dev)
1553 struct aue_softc *sc;
1555 sc = device_get_softc(dev);