svn commit: r187754 - user/thompsa/usb/sys/dev/usb2/ethernet

Andrew Thompson thompsa at FreeBSD.org
Mon Jan 26 17:31:25 PST 2009


Author: thompsa
Date: Tue Jan 27 01:31:24 2009
New Revision: 187754
URL: http://svn.freebsd.org/changeset/base/187754

Log:
  Convert over to the USB2 API.

Modified:
  user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_auereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_axereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_cdce2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_cdcereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_cuereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_kuereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_rue2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_ruereg.h
  user/thompsa/usb/sys/dev/usb2/ethernet/if_udav2.c
  user/thompsa/usb/sys/dev/usb2/ethernet/if_udavreg.h

Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c	Tue Jan 27 01:29:22 2009	(r187753)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c	Tue Jan 27 01:31:24 2009	(r187754)
@@ -2,9 +2,6 @@
  * Copyright (c) 1997, 1998, 1999, 2000
  *	Bill Paul <wpaul at ee.columbia.edu>.  All rights reserved.
  *
- * Copyright (c) 2006
- *      Alfred Perlstein <alfred at freebsd.org>. All rights reserved.
- *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -43,9 +40,6 @@ __FBSDID("$FreeBSD$");
  * Written by Bill Paul <wpaul at ee.columbia.edu>
  * Electrical Engineering Department
  * Columbia University, New York City
- *
- * SMP locking by Alfred Perlstein <alfred at freebsd.org>.
- * RED Inc.
  */
 
 /*
@@ -64,138 +58,113 @@ __FBSDID("$FreeBSD$");
  * the controller uses an external PHY chip, it's possible that board
  * designers might simply choose a 10Mbps PHY.
  *
- * Registers are accessed using usbd_do_request(). Packet transfers are
- * done using usbd_transfer() and friends.
+ * Registers are accessed using usb2_do_request(). Packet transfers are
+ * done using usb2_transfer() and friends.
  */
 
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/kdb.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/socket.h>
-#include <sys/sx.h>
-#include <sys/taskqueue.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-
-#include <net/bpf.h>
-
-#include <sys/bus.h>
-#include <machine/bus.h>
-
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
-#include <dev/usb/usbdivar.h>
-#include "usbdevs.h"
-#include <dev/usb/usb_ethersubr.h>
-
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
-
-#include <dev/usb/if_auereg.h>
-
-MODULE_DEPEND(aue, usb, 1, 1, 1);
-MODULE_DEPEND(aue, ether, 1, 1, 1);
-MODULE_DEPEND(aue, miibus, 1, 1, 1);
-
-/* "device miibus" required.  See GENERIC if you get errors here. */
-#include "miibus_if.h"
+#include <dev/usb2/include/usb2_devid.h>
+#include <dev/usb2/include/usb2_standard.h>
+#include <dev/usb2/include/usb2_mfunc.h>
+#include <dev/usb2/include/usb2_error.h>
+
+#define	USB_DEBUG_VAR aue_debug
+
+#include <dev/usb2/core/usb2_core.h>
+#include <dev/usb2/core/usb2_lookup.h>
+#include <dev/usb2/core/usb2_process.h>
+#include <dev/usb2/core/usb2_debug.h>
+#include <dev/usb2/core/usb2_request.h>
+#include <dev/usb2/core/usb2_busdma.h>
+#include <dev/usb2/core/usb2_util.h>
+
+#include <dev/usb2/ethernet/usb2_ethernet.h>
+#include <dev/usb2/ethernet/if_auereg.h>
+
+#if USB_DEBUG
+static int aue_debug = 0;
+
+SYSCTL_NODE(_hw_usb2, OID_AUTO, aue, CTLFLAG_RW, 0, "USB aue");
+SYSCTL_INT(_hw_usb2_aue, OID_AUTO, debug, CTLFLAG_RW, &aue_debug, 0,
+    "Debug level");
+#endif
 
 /*
  * Various supported device vendors/products.
  */
-struct aue_type {
-	struct usb_devno	aue_dev;
-	u_int16_t		aue_flags;
-#define LSYS	0x0001		/* use Linksys reset */
-#define PNA	0x0002		/* has Home PNA */
-#define PII	0x0004		/* Pegasus II chip */
+static const struct usb2_device_id aue_devs[] = {
+    {USB_VPI(USB_VENDOR_3COM, USB_PRODUCT_3COM_3C460B, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_DSB650TX_PNA, 0)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_UFE1000, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX10, 0)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1, AUE_FLAG_PNA | AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX2, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX4, AUE_FLAG_PNA)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX5, AUE_FLAG_PNA)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX6, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX7, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX8, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX9, AUE_FLAG_PNA)},
+    {USB_VPI(USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_SS1001, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_USB320_EC, 0)},
+    {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_2, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_3, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_4, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS, AUE_FLAG_PNA | AUE_FLAG_DUAL_PHY)},
+    {USB_VPI(USB_VENDOR_AEI, USB_PRODUCT_AEI_FASTETHERNET, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ALLIEDTELESYN, USB_PRODUCT_ALLIEDTELESYN_ATUSB100, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC110T, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_USB2LAN, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100, 0)},
+    {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBE100, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBEL100, 0)},
+    {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBLP100, AUE_FLAG_PNA)},
+    {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXS, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX, 0)},
+    {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX1, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX2, AUE_FLAG_LSYS | AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX3, AUE_FLAG_LSYS | AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX4, AUE_FLAG_LSYS | AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA, AUE_FLAG_PNA)},
+    {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_ELCON, USB_PRODUCT_ELCON_PLAN, AUE_FLAG_PNA | AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSB20, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBLTX, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX0, 0)},
+    {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX1, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX2, 0)},
+    {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX3, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_ELSA, USB_PRODUCT_ELSA_USB2ETHERNET, 0)},
+    {USB_VPI(USB_VENDOR_GIGABYTE, USB_PRODUCT_GIGABYTE_GNBR402W, 0)},
+    {USB_VPI(USB_VENDOR_HAWKING, USB_PRODUCT_HAWKING_UF100, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_HP, USB_PRODUCT_HP_HN210E, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTXS, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX, 0)},
+    {USB_VPI(USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX, 0)},
+    {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1, AUE_FLAG_LSYS | AUE_FLAG_PNA)},
+    {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX1, AUE_FLAG_LSYS | AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX2, AUE_FLAG_LSYS | AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10T, AUE_FLAG_LSYS)},
+    {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUA2TX5, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1, 0)},
+    {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5, 0)},
+    {USB_VPI(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_MN110, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_NETGEAR, USB_PRODUCT_NETGEAR_FA101, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_SIEMENS, USB_PRODUCT_SIEMENS_SPEEDSTREAM, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_SIIG2, USB_PRODUCT_SIIG2_USBTOETHER, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_SMARTBRIDGES, USB_PRODUCT_SMARTBRIDGES_SMARTNIC, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB, 0)},
+    {USB_VPI(USB_VENDOR_SMC, USB_PRODUCT_SMC_2206USB, AUE_FLAG_PII)},
+    {USB_VPI(USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB100, 0)},
+    {USB_VPI(USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB110, AUE_FLAG_PII)},
 };
 
-static const struct aue_type aue_devs[] = {
- {{ USB_VENDOR_3COM,		USB_PRODUCT_3COM_3C460B},         PII },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX1},	  PNA|PII },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX2},	  PII },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_UFE1000},	  LSYS },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX4},	  PNA },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX5},	  PNA },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX6},	  PII },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX7},	  PII },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX8},	  PII },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX9},	  PNA },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX10},	  0 },
- {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_DSB650TX_PNA}, 0 },
- {{ USB_VENDOR_ACCTON,		USB_PRODUCT_ACCTON_USB320_EC},	  0 },
- {{ USB_VENDOR_ACCTON,		USB_PRODUCT_ACCTON_SS1001},	  PII },
- {{ USB_VENDOR_ADMTEK,		USB_PRODUCT_ADMTEK_PEGASUS},	  PNA },
- {{ USB_VENDOR_ADMTEK,		USB_PRODUCT_ADMTEK_PEGASUSII},	  PII },
- {{ USB_VENDOR_ADMTEK,		USB_PRODUCT_ADMTEK_PEGASUSII_2},  PII },
- {{ USB_VENDOR_ADMTEK,		USB_PRODUCT_ADMTEK_PEGASUSII_3},  PII },
- {{ USB_VENDOR_ADMTEK,		USB_PRODUCT_ADMTEK_PEGASUSII_4},  PII },
- {{ USB_VENDOR_AEI,		USB_PRODUCT_AEI_FASTETHERNET},    PII },
- {{ USB_VENDOR_ALLIEDTELESYN,	USB_PRODUCT_ALLIEDTELESYN_ATUSB100}, PII },
- {{ USB_VENDOR_ATEN,		USB_PRODUCT_ATEN_UC110T},         PII },
- {{ USB_VENDOR_BELKIN,		USB_PRODUCT_BELKIN_USB2LAN},	  PII },
- {{ USB_VENDOR_BILLIONTON,	USB_PRODUCT_BILLIONTON_USB100},	  0 },
- {{ USB_VENDOR_BILLIONTON,	USB_PRODUCT_BILLIONTON_USBLP100}, PNA },
- {{ USB_VENDOR_BILLIONTON,	USB_PRODUCT_BILLIONTON_USBEL100}, 0 },
- {{ USB_VENDOR_BILLIONTON,	USB_PRODUCT_BILLIONTON_USBE100},  PII },
- {{ USB_VENDOR_COREGA,		USB_PRODUCT_COREGA_FETHER_USB_TX}, 0 },
- {{ USB_VENDOR_COREGA,		USB_PRODUCT_COREGA_FETHER_USB_TXS},PII },
- {{ USB_VENDOR_DLINK,		USB_PRODUCT_DLINK_DSB650TX4},	  LSYS|PII },
- {{ USB_VENDOR_DLINK,		USB_PRODUCT_DLINK_DSB650TX1},	  LSYS },
- {{ USB_VENDOR_DLINK,		USB_PRODUCT_DLINK_DSB650TX},	  LSYS },
- {{ USB_VENDOR_DLINK,		USB_PRODUCT_DLINK_DSB650TX_PNA},  PNA },
- {{ USB_VENDOR_DLINK,		USB_PRODUCT_DLINK_DSB650TX3},	  LSYS|PII },
- {{ USB_VENDOR_DLINK,		USB_PRODUCT_DLINK_DSB650TX2},	  LSYS|PII },
- {{ USB_VENDOR_DLINK,		USB_PRODUCT_DLINK_DSB650},	  LSYS },
- {{ USB_VENDOR_ELCON,		USB_PRODUCT_ELCON_PLAN},	  PNA|PII },
- {{ USB_VENDOR_ELECOM,		USB_PRODUCT_ELECOM_LDUSB20},	  PII },
- {{ USB_VENDOR_ELECOM,		USB_PRODUCT_ELECOM_LDUSBTX0},	  0 },
- {{ USB_VENDOR_ELECOM,		USB_PRODUCT_ELECOM_LDUSBTX1},	  LSYS },
- {{ USB_VENDOR_ELECOM,		USB_PRODUCT_ELECOM_LDUSBTX2},	  0 },
- {{ USB_VENDOR_ELECOM,		USB_PRODUCT_ELECOM_LDUSBTX3},	  LSYS },
- {{ USB_VENDOR_ELECOM,		USB_PRODUCT_ELECOM_LDUSBLTX},	  PII },
- {{ USB_VENDOR_ELSA,		USB_PRODUCT_ELSA_USB2ETHERNET},	  0 },
- {{ USB_VENDOR_GIGABYTE,	USB_PRODUCT_GIGABYTE_GNBR402W},	  0 },
- {{ USB_VENDOR_HAWKING,		USB_PRODUCT_HAWKING_UF100},       PII },
- {{ USB_VENDOR_HP,		USB_PRODUCT_HP_HN210E},           PII },
- {{ USB_VENDOR_IODATA,		USB_PRODUCT_IODATA_USBETTX},	  0 },
- {{ USB_VENDOR_IODATA,		USB_PRODUCT_IODATA_USBETTXS},	  PII },
- {{ USB_VENDOR_KINGSTON,	USB_PRODUCT_KINGSTON_KNU101TX},   0 },
- {{ USB_VENDOR_LINKSYS,		USB_PRODUCT_LINKSYS_USB10TX1},	  LSYS|PII },
- {{ USB_VENDOR_LINKSYS,		USB_PRODUCT_LINKSYS_USB10T},	  LSYS },
- {{ USB_VENDOR_LINKSYS,		USB_PRODUCT_LINKSYS_USB100TX},	  LSYS },
- {{ USB_VENDOR_LINKSYS,		USB_PRODUCT_LINKSYS_USB100H1},	  LSYS|PNA },
- {{ USB_VENDOR_LINKSYS,		USB_PRODUCT_LINKSYS_USB10TA},	  LSYS },
- {{ USB_VENDOR_LINKSYS,		USB_PRODUCT_LINKSYS_USB10TX2},	  LSYS|PII },
- {{ USB_VENDOR_MELCO,		USB_PRODUCT_MELCO_LUATX1},	  0 },
- {{ USB_VENDOR_MELCO,		USB_PRODUCT_MELCO_LUATX5},	  0 },
- {{ USB_VENDOR_MELCO,		USB_PRODUCT_MELCO_LUA2TX5},	  PII },
- {{ USB_VENDOR_MICROSOFT,	USB_PRODUCT_MICROSOFT_MN110},	  PII },
- {{ USB_VENDOR_NETGEAR,		USB_PRODUCT_NETGEAR_FA101},	  PII },
- {{ USB_VENDOR_SIEMENS,		USB_PRODUCT_SIEMENS_SPEEDSTREAM}, PII },
- {{ USB_VENDOR_SIIG2,		USB_PRODUCT_SIIG2_USBTOETHER},    PII },
- {{ USB_VENDOR_SMARTBRIDGES,	USB_PRODUCT_SMARTBRIDGES_SMARTNIC},PII },
- {{ USB_VENDOR_SMC,		USB_PRODUCT_SMC_2202USB},	  0 },
- {{ USB_VENDOR_SMC,		USB_PRODUCT_SMC_2206USB},	  PII },
- {{ USB_VENDOR_SOHOWARE,	USB_PRODUCT_SOHOWARE_NUB100},	  0 },
- {{ USB_VENDOR_SOHOWARE,	USB_PRODUCT_SOHOWARE_NUB110},	  PII },
-};
-#define aue_lookup(v, p) ((const struct aue_type *)usb_lookup(aue_devs, v, p))
+/* prototypes */
 
-static device_probe_t aue_match;
+static device_probe_t aue_probe;
 static device_attach_t aue_attach;
 static device_detach_t aue_detach;
 static device_shutdown_t aue_shutdown;
@@ -203,85 +172,163 @@ static miibus_readreg_t aue_miibus_readr
 static miibus_writereg_t aue_miibus_writereg;
 static miibus_statchg_t aue_miibus_statchg;
 
-static void aue_reset_pegasus_II(struct aue_softc *sc);
-static int aue_encap(struct aue_softc *, struct mbuf *, int);
-#ifdef AUE_INTR_PIPE
-static void aue_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
-#endif
-static void aue_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
-static void aue_rxeof_thread(struct aue_softc *sc);
-static void aue_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
-static void aue_txeof_thread(struct aue_softc *);
-static void aue_task_sched(struct aue_softc *, int);
-static void aue_task(void *xsc, int pending);
-static void aue_tick(void *);
-static void aue_rxstart(struct ifnet *);
-static void aue_rxstart_thread(struct aue_softc *);
-static void aue_start(struct ifnet *);
-static void aue_start_thread(struct aue_softc *);
-static int aue_ioctl(struct ifnet *, u_long, caddr_t);
-static void aue_init(void *);
-static void aue_init_body(struct aue_softc *);
-static void aue_stop(struct aue_softc *);
-static void aue_watchdog(struct aue_softc *);
-static int aue_ifmedia_upd(struct ifnet *);
-static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
-
-static void aue_eeprom_getword(struct aue_softc *, int, u_int16_t *);
-static void aue_read_eeprom(struct aue_softc *, caddr_t, int, int, int);
-
-static void aue_setmulti(struct aue_softc *);
-static void aue_reset(struct aue_softc *);
-
-static int aue_csr_read_1(struct aue_softc *, int);
-static int aue_csr_write_1(struct aue_softc *, int, int);
-static int aue_csr_read_2(struct aue_softc *, int);
-static int aue_csr_write_2(struct aue_softc *, int, int);
+static usb2_callback_t aue_intr_clear_stall_callback;
+static usb2_callback_t aue_intr_callback;
+static usb2_callback_t aue_bulk_read_clear_stall_callback;
+static usb2_callback_t aue_bulk_read_callback;
+static usb2_callback_t aue_bulk_write_clear_stall_callback;
+static usb2_callback_t aue_bulk_write_callback;
+
+static usb2_task_fn_t aue_promisc_task;
+static usb2_task_fn_t aue_ifmedia_task;
+static usb2_task_fn_t aue_setmulti_task;
+static usb2_task_fn_t aue_tick_task;
+
+static int	aue_do_request(struct aue_softc *,
+		    struct usb2_device_request *, void *);
+static uint8_t	aue_csr_read_1(struct aue_softc *, uint16_t);
+static uint16_t	aue_csr_read_2(struct aue_softc *, uint16_t);
+static int	aue_csr_write_1(struct aue_softc *, uint16_t, uint8_t);
+static int	aue_csr_write_2(struct aue_softc *, uint16_t, uint16_t);
+static void	aue_eeprom_getword(struct aue_softc *, int, uint16_t *);
+static void	aue_read_eeprom(struct aue_softc *, uint8_t *, uint16_t,
+		    uint16_t);
+static void	aue_setmulti(struct aue_softc *);
+static void	aue_setpromisc(struct aue_softc *);
+static void	aue_reset(struct aue_softc *);
+static void	aue_reset_pegasus_II(struct aue_softc *);
+static void	aue_start(struct ifnet *);
+static void	aue_init(void *);
+static void	aue_init_locked(struct aue_softc *);
+static void	aue_stop(struct aue_softc *);
+static void	aue_start_transfers(struct aue_softc *);
+static int	aue_ifmedia_upd(struct ifnet *);
+static void	aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int	aue_ioctl(struct ifnet *, u_long, caddr_t);
+static void	aue_watchdog(void *);
+
+static const struct usb2_config aue_config[AUE_N_TRANSFER] = {
+
+	[AUE_BULK_DT_WR] = {
+		.type = UE_BULK,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_OUT,
+		.mh.bufsize = (MCLBYTES + 2),
+		.mh.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
+		.mh.callback = aue_bulk_write_callback,
+		.mh.timeout = 10000,	/* 10 seconds */
+	},
+
+	[AUE_BULK_DT_RD] = {
+		.type = UE_BULK,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_IN,
+		.mh.bufsize = (MCLBYTES + 4 + ETHER_CRC_LEN),
+		.mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
+		.mh.callback = aue_bulk_read_callback,
+	},
+
+	[AUE_BULK_CS_WR] = {
+		.type = UE_CONTROL,
+		.endpoint = 0x00,	/* Control pipe */
+		.direction = UE_DIR_ANY,
+		.mh.bufsize = sizeof(struct usb2_device_request),
+		.mh.flags = {},
+		.mh.callback = aue_bulk_write_clear_stall_callback,
+		.mh.timeout = 1000,	/* 1 second */
+		.mh.interval = 50,	/* 50ms */
+	},
+
+	[AUE_BULK_CS_RD] = {
+		.type = UE_CONTROL,
+		.endpoint = 0x00,	/* Control pipe */
+		.direction = UE_DIR_ANY,
+		.mh.bufsize = sizeof(struct usb2_device_request),
+		.mh.flags = {},
+		.mh.callback = aue_bulk_read_clear_stall_callback,
+		.mh.timeout = 1000,	/* 1 second */
+		.mh.interval = 50,	/* 50ms */
+	},
+
+	[AUE_INTR_DT_RD] = {
+		.type = UE_INTERRUPT,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_IN,
+		.mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
+		.mh.bufsize = 0,	/* use wMaxPacketSize */
+		.mh.callback = aue_intr_callback,
+	},
+
+	[AUE_INTR_CS_RD] = {
+		.type = UE_CONTROL,
+		.endpoint = 0x00,	/* Control pipe */
+		.direction = UE_DIR_ANY,
+		.mh.bufsize = sizeof(struct usb2_device_request),
+		.mh.flags = {},
+		.mh.callback = aue_intr_clear_stall_callback,
+		.mh.timeout = 1000,	/* 1 second */
+		.mh.interval = 50,	/* 50ms */
+	},
+};
 
 static device_method_t aue_methods[] = {
 	/* Device interface */
-	DEVMETHOD(device_probe,		aue_match),
-	DEVMETHOD(device_attach,	aue_attach),
-	DEVMETHOD(device_detach,	aue_detach),
-	DEVMETHOD(device_shutdown,	aue_shutdown),
+	DEVMETHOD(device_probe, aue_probe),
+	DEVMETHOD(device_attach, aue_attach),
+	DEVMETHOD(device_detach, aue_detach),
+	DEVMETHOD(device_shutdown, aue_shutdown),
 
 	/* bus interface */
-	DEVMETHOD(bus_print_child,	bus_generic_print_child),
-	DEVMETHOD(bus_driver_added,	bus_generic_driver_added),
+	DEVMETHOD(bus_print_child, bus_generic_print_child),
+	DEVMETHOD(bus_driver_added, bus_generic_driver_added),
 
 	/* MII interface */
-	DEVMETHOD(miibus_readreg,	aue_miibus_readreg),
-	DEVMETHOD(miibus_writereg,	aue_miibus_writereg),
-	DEVMETHOD(miibus_statchg,	aue_miibus_statchg),
+	DEVMETHOD(miibus_readreg, aue_miibus_readreg),
+	DEVMETHOD(miibus_writereg, aue_miibus_writereg),
+	DEVMETHOD(miibus_statchg, aue_miibus_statchg),
 
-	{ 0, 0 }
+	{0, 0}
 };
 
 static driver_t aue_driver = {
-	"aue",
-	aue_methods,
-	sizeof(struct aue_softc)
+	.name = "aue",
+	.methods = aue_methods,
+	.size = sizeof(struct aue_softc)
 };
 
 static devclass_t aue_devclass;
 
-DRIVER_MODULE(aue, uhub, aue_driver, aue_devclass, usbd_driver_load, 0);
+DRIVER_MODULE(aue, ushub, aue_driver, aue_devclass, NULL, 0);
 DRIVER_MODULE(miibus, aue, miibus_driver, miibus_devclass, 0, 0);
+MODULE_DEPEND(aue, usb2_ethernet, 1, 1, 1);
+MODULE_DEPEND(aue, usb2_core, 1, 1, 1);
+MODULE_DEPEND(aue, ether, 1, 1, 1);
+MODULE_DEPEND(aue, miibus, 1, 1, 1);
+
+static int
+aue_do_request(struct aue_softc *sc, struct usb2_device_request *req,
+    void *data)
+{
+	usb2_error_t err;
+
+	err = usb2_do_request_flags(sc->sc_udev, &sc->sc_mtx, req, data, 0,
+	    NULL, 1000);
 
-#define AUE_SETBIT(sc, reg, x)				\
+	return (err);
+}
+
+#define	AUE_SETBIT(sc, reg, x) \
 	aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x))
 
-#define AUE_CLRBIT(sc, reg, x)				\
+#define	AUE_CLRBIT(sc, reg, x) \
 	aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x))
 
-static int
-aue_csr_read_1(struct aue_softc *sc, int reg)
+static uint8_t
+aue_csr_read_1(struct aue_softc *sc, uint16_t reg)
 {
-	usb_device_request_t	req;
-	usbd_status		err;
-	u_int8_t		val = 0;
-
-	AUE_SXASSERTLOCKED(sc);
+	struct usb2_device_request req;
+	usb2_error_t err;
+	uint8_t val;
 
 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = AUE_UR_READREG;
@@ -289,23 +336,18 @@ aue_csr_read_1(struct aue_softc *sc, int
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, 1);
 
-	err = usbd_do_request(sc->aue_udev, &req, &val);
-
-	if (err) {
+	err = aue_do_request(sc, &req, &val);
+	if (err)
 		return (0);
-	}
-
 	return (val);
 }
 
-static int
-aue_csr_read_2(struct aue_softc *sc, int reg)
+static uint16_t
+aue_csr_read_2(struct aue_softc *sc, uint16_t reg)
 {
-	usb_device_request_t	req;
-	usbd_status		err;
-	u_int16_t		val = 0;
-
-	AUE_SXASSERTLOCKED(sc);
+	struct usb2_device_request req;
+	usb2_error_t err;
+	uint16_t val;
 
 	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = AUE_UR_READREG;
@@ -313,45 +355,31 @@ aue_csr_read_2(struct aue_softc *sc, int
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, 2);
 
-	err = usbd_do_request(sc->aue_udev, &req, &val);
-
-	if (err) {
+	err = aue_do_request(sc, &req, &val);
+	if (err)
 		return (0);
-	}
-
-	return (val);
+	return (le16toh(val));
 }
 
 static int
-aue_csr_write_1(struct aue_softc *sc, int reg, int val)
+aue_csr_write_1(struct aue_softc *sc, uint16_t reg, uint8_t val)
 {
-	usb_device_request_t	req;
-	usbd_status		err;
-
-	AUE_SXASSERTLOCKED(sc);
+	struct usb2_device_request req;
 
 	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
 	req.bRequest = AUE_UR_WRITEREG;
-	USETW(req.wValue, val);
+	req.wValue[0] = val;
+	req.wValue[1] = 0;
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, 1);
 
-	err = usbd_do_request(sc->aue_udev, &req, &val);
-
-	if (err) {
-		return (-1);
-	}
-
-	return (0);
+	return (aue_do_request(sc, &req, &val));
 }
 
 static int
-aue_csr_write_2(struct aue_softc *sc, int reg, int val)
+aue_csr_write_2(struct aue_softc *sc, uint16_t reg, uint16_t val)
 {
-	usb_device_request_t	req;
-	usbd_status		err;
-
-	AUE_SXASSERTLOCKED(sc);
+	struct usb2_device_request req;
 
 	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
 	req.bRequest = AUE_UR_WRITEREG;
@@ -359,23 +387,19 @@ aue_csr_write_2(struct aue_softc *sc, in
 	USETW(req.wIndex, reg);
 	USETW(req.wLength, 2);
 
-	err = usbd_do_request(sc->aue_udev, &req, &val);
-
-	if (err) {
-		return (-1);
-	}
+	val = htole16(val);
 
-	return (0);
+	return (aue_do_request(sc, &req, &val));
 }
 
 /*
  * Read a word of data stored in the EEPROM at address 'addr.'
  */
 static void
-aue_eeprom_getword(struct aue_softc *sc, int addr, u_int16_t *dest)
+aue_eeprom_getword(struct aue_softc *sc, int addr, uint16_t *dest)
 {
-	int		i;
-	u_int16_t	word = 0;
+	int i;
+	uint16_t word = 0;
 
 	aue_csr_write_1(sc, AUE_EE_REG, addr);
 	aue_csr_write_1(sc, AUE_EE_CTL, AUE_EECTL_READ);
@@ -385,65 +409,57 @@ aue_eeprom_getword(struct aue_softc *sc,
 			break;
 	}
 
-	if (i == AUE_TIMEOUT) {
-		printf("aue%d: EEPROM read timed out\n",
-		    sc->aue_unit);
-	}
+	if (i == AUE_TIMEOUT)
+		device_printf(sc->sc_dev, "EEPROM read timed out\n");
 
 	word = aue_csr_read_2(sc, AUE_EE_DATA);
 	*dest = word;
-
-	return;
 }
 
 /*
  * Read a sequence of words from the EEPROM.
  */
 static void
-aue_read_eeprom(struct aue_softc *sc, caddr_t dest, int off, int cnt, int swap)
+aue_read_eeprom(struct aue_softc *sc, uint8_t *dest,
+    uint16_t off, uint16_t len)
 {
-	int			i;
-	u_int16_t		word = 0, *ptr;
-
-	for (i = 0; i < cnt; i++) {
-		aue_eeprom_getword(sc, off + i, &word);
-		ptr = (u_int16_t *)(dest + (i * 2));
-		if (swap)
-			*ptr = ntohs(word);
-		else
-			*ptr = word;
-	}
+	uint16_t *ptr = (uint16_t *)dest;
+	int i;
 
-	return;
+	for (i = 0; i < len; i++, ptr++)
+		aue_eeprom_getword(sc, off + i, ptr);
 }
 
 static int
 aue_miibus_readreg(device_t dev, int phy, int reg)
 {
-	struct aue_softc	*sc = device_get_softc(dev);
-	int			i;
-	u_int16_t		val = 0;
+	struct aue_softc *sc = device_get_softc(dev);
+	int i, do_unlock;
+	uint16_t val = 0;
+
+	/* avoid recursive locking */
+	if (mtx_owned(&sc->sc_mtx)) {
+		do_unlock = 0;
+	} else {
+		AUE_LOCK(sc);
+		do_unlock = 1;
+	}
 
 	/*
-	 * The Am79C901 HomePNA PHY actually contains
-	 * two transceivers: a 1Mbps HomePNA PHY and a
-	 * 10Mbps full/half duplex ethernet PHY with
-	 * NWAY autoneg. However in the ADMtek adapter,
-	 * only the 1Mbps PHY is actually connected to
-	 * anything, so we ignore the 10Mbps one. It
-	 * happens to be configured for MII address 3,
-	 * so we filter that out.
+	 * The Am79C901 HomePNA PHY actually contains two transceivers: a 1Mbps
+	 * HomePNA PHY and a 10Mbps full/half duplex ethernet PHY with NWAY
+	 * autoneg. However in the ADMtek adapter, only the 1Mbps PHY is
+	 * actually connected to anything, so we ignore the 10Mbps one. It
+	 * happens to be configured for MII address 3, so we filter that out.
 	 */
-	if (sc->aue_vendor == USB_VENDOR_ADMTEK &&
-	    sc->aue_product == USB_PRODUCT_ADMTEK_PEGASUS) {
+	if (sc->sc_flags & AUE_FLAG_DUAL_PHY) {
 		if (phy == 3)
-			return (0);
-#ifdef notdef
+			goto done;
+#if 0
 		if (phy != 1)
-			return (0);
+			goto done;
 #endif
 	}
-
 	aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
 	aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_READ);
 
@@ -452,24 +468,34 @@ aue_miibus_readreg(device_t dev, int phy
 			break;
 	}
 
-	if (i == AUE_TIMEOUT) {
-		printf("aue%d: MII read timed out\n", sc->aue_unit);
-	}
+	if (i == AUE_TIMEOUT)
+		device_printf(sc->sc_dev, "MII read timed out\n");
 
 	val = aue_csr_read_2(sc, AUE_PHY_DATA);
 
+done:
+	if (do_unlock)
+		AUE_UNLOCK(sc);
 	return (val);
 }
 
 static int
 aue_miibus_writereg(device_t dev, int phy, int reg, int data)
 {
-	struct aue_softc	*sc = device_get_softc(dev);
-	int			i;
+	struct aue_softc *sc = device_get_softc(dev);
+	int i, do_unlock;
 
 	if (phy == 3)
 		return (0);
 
+	/* avoid recursive locking */
+	if (mtx_owned(&sc->sc_mtx)) {
+		do_unlock = 0;
+	} else {
+		AUE_LOCK(sc);
+		do_unlock = 1;
+	}
+
 	aue_csr_write_2(sc, AUE_PHY_DATA, data);
 	aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
 	aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_WRITE);
@@ -479,26 +505,34 @@ aue_miibus_writereg(device_t dev, int ph
 			break;
 	}
 
-	if (i == AUE_TIMEOUT) {
-		printf("aue%d: MII read timed out\n",
-		    sc->aue_unit);
-	}
+	if (i == AUE_TIMEOUT)
+		device_printf(sc->sc_dev, "MII read timed out\n");
 
-	return(0);
+	if (do_unlock)
+		AUE_UNLOCK(sc);
+	return (0);
 }
 
 static void
 aue_miibus_statchg(device_t dev)
 {
-	struct aue_softc	*sc = device_get_softc(dev);
-	struct mii_data		*mii = GET_MII(sc);
+	struct aue_softc *sc = device_get_softc(dev);
+	struct mii_data *mii = GET_MII(sc);
+	uint8_t do_unlock;
+
+	/* avoid recursive locking */
+	if (mtx_owned(&sc->sc_mtx)) {
+		do_unlock = 0;
+	} else {
+		AUE_LOCK(sc);
+		do_unlock = 1;
+	}
 
 	AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB);
-	if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) {
+	if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX)
 		AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL);
-	} else {
+	else
 		AUE_CLRBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL);
-	}
 
 	if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
 		AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX);
@@ -512,27 +546,32 @@ aue_miibus_statchg(device_t dev)
 	 * This turns on the 'dual link LED' bin in the auxmode
 	 * register of the Broadcom PHY.
 	 */
-	if (sc->aue_flags & LSYS) {
-		u_int16_t auxmode;
+	if (sc->sc_flags & AUE_FLAG_LSYS) {
+		uint16_t auxmode;
+
 		auxmode = aue_miibus_readreg(dev, 0, 0x1b);
 		aue_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04);
 	}
-
-	return;
+	if (do_unlock)
+		AUE_UNLOCK(sc);
 }
 
-#define AUE_BITS	6
+static void
+aue_setmulti_task(void *context, struct usb2_task *task)
+{
+	struct aue_softc *sc = context;
+
+	aue_setmulti(sc);
+}
 
+#define	AUE_BITS	6
 static void
 aue_setmulti(struct aue_softc *sc)
 {
-	struct ifnet		*ifp;
-	struct ifmultiaddr	*ifma;
-	u_int32_t		h = 0, i;
-	u_int8_t		hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
-
-	AUE_SXASSERTLOCKED(sc);
-	ifp = sc->aue_ifp;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ifmultiaddr *ifma;
+	uint32_t h = 0, i;
+	uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 
 	if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
 		AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
@@ -543,8 +582,7 @@ aue_setmulti(struct aue_softc *sc)
 
 	/* now program new ones */
 	IF_ADDR_LOCK(ifp);
-	TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link)
-	{
+	TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
 		if (ifma->ifma_addr->sa_family != AF_LINK)
 			continue;
 		h = ether_crc32_le(LLADDR((struct sockaddr_dl *)
@@ -556,8 +594,6 @@ aue_setmulti(struct aue_softc *sc)
 	/* write the hashtable */
 	for (i = 0; i < 8; i++)
 		aue_csr_write_1(sc, AUE_MAR0 + i, hashtbl[i]);
-
-	return;
 }
 
 static void
@@ -567,7 +603,7 @@ aue_reset_pegasus_II(struct aue_softc *s
 	aue_csr_write_1(sc, AUE_REG_1D, 0);
 	aue_csr_write_1(sc, AUE_REG_7B, 2);
 #if 0
-	if ((sc->aue_flags & HAS_HOME_PNA) && mii_mode)
+	if ((sc->sc_flags & HAS_HOME_PNA) && mii_mode)
 		aue_csr_write_1(sc, AUE_REG_81, 6);
 	else
 #endif
@@ -577,9 +613,8 @@ aue_reset_pegasus_II(struct aue_softc *s
 static void
 aue_reset(struct aue_softc *sc)
 {
-	int		i;
+	int i;
 
-	AUE_SXASSERTLOCKED(sc);
 	AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_RESETMAC);
 
 	for (i = 0; i < AUE_TIMEOUT; i++) {
@@ -588,7 +623,7 @@ aue_reset(struct aue_softc *sc)
 	}
 
 	if (i == AUE_TIMEOUT)
-		printf("aue%d: reset failed\n", sc->aue_unit);
+		device_printf(sc->sc_dev, "reset failed\n");
 
 	/*
 	 * The PHY(s) attached to the Pegasus chip may be held
@@ -602,45 +637,44 @@ aue_reset(struct aue_softc *sc)
 	aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0);
 	aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_OUT0|AUE_GPIO_SEL0|AUE_GPIO_SEL1);
 
-	if (sc->aue_flags & LSYS) {
+	if (sc->sc_flags & AUE_FLAG_LSYS) {
 		/* Grrr. LinkSys has to be different from everyone else. */
+		aue_csr_write_1(sc, AUE_GPIO0, AUE_GPIO_SEL0|AUE_GPIO_SEL1);
 		aue_csr_write_1(sc, AUE_GPIO0,
-		    AUE_GPIO_SEL0 | AUE_GPIO_SEL1);
-		aue_csr_write_1(sc, AUE_GPIO0,
-		    AUE_GPIO_SEL0 | AUE_GPIO_SEL1 | AUE_GPIO_OUT0);
+		    AUE_GPIO_SEL0|AUE_GPIO_SEL1|AUE_GPIO_OUT0);
 	}
+	if (sc->sc_flags & AUE_FLAG_PII)
+		aue_reset_pegasus_II(sc);
 
-	if (sc->aue_flags & PII)
-                aue_reset_pegasus_II(sc);
-
-	/* Wait a little while for the chip to get its brains in order. */
-	DELAY(10000);
-
-	return;
+	/* Wait a little while for the chip to get its brains in order: */
+	usb2_pause_mtx(&sc->sc_mtx, hz / 100);
 }
 
 /*
  * Probe for a Pegasus chip.
  */
 static int
-aue_match(device_t self)
+aue_probe(device_t dev)
 {
-	struct usb_attach_arg *uaa = device_get_ivars(self);
-
-	if (uaa->iface != NULL)
-		return (UMATCH_NONE);
+	struct usb2_attach_arg *uaa = device_get_ivars(dev);
 
+	if (uaa->usb2_mode != USB_MODE_HOST)
+		return (ENXIO);
+	if (uaa->info.bConfigIndex != AUE_CONFIG_INDEX)
+		return (ENXIO);
+	if (uaa->info.bIfaceIndex != AUE_IFACE_IDX)
+		return (ENXIO);
 	/*
 	 * Belkin USB Bluetooth dongles of the F8T012xx1 model series conflict
 	 * with older Belkin USB2LAN adapters.  Skip if_aue if we detect one of
 	 * the devices that look like Bluetooth adapters.
 	 */
-	if (uaa->vendor == USB_VENDOR_BELKIN &&
-	    uaa->product == USB_PRODUCT_BELKIN_F8T012 && uaa->release == 0x0413)
-		return (UMATCH_NONE);
+	if (uaa->info.idVendor == USB_VENDOR_BELKIN &&
+	    uaa->info.idProduct == USB_PRODUCT_BELKIN_F8T012 &&
+	    uaa->info.bcdDevice == 0x0413)
+		return (ENXIO);
 
-	return (aue_lookup(uaa->vendor, uaa->product) != NULL ?
-		UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
+	return (usb2_lookup_id_by_uaa(aue_devs, sizeof(aue_devs), uaa));
 }
 
 /*
@@ -648,86 +682,65 @@ aue_match(device_t self)
  * setup and ethernet/BPF attach.
  */
 static int
-aue_attach(device_t self)
+aue_attach(device_t dev)
 {
-	struct aue_softc *sc = device_get_softc(self);
-	struct usb_attach_arg *uaa = device_get_ivars(self);
-	u_char			eaddr[ETHER_ADDR_LEN];
-	struct ifnet		*ifp;
-	usbd_interface_handle	iface;
-	usbd_status		err;
-	usb_interface_descriptor_t	*id;
-	usb_endpoint_descriptor_t	*ed;
-	int			i;
-
-	sc->aue_dev = self;
-	sc->aue_udev = uaa->device;
-	sc->aue_unit = device_get_unit(self);
-
-	if (usbd_set_config_no(sc->aue_udev, AUE_CONFIG_NO, 0)) {
-		device_printf(self, "getting interface handle failed\n");
-		return ENXIO;
-	}
-
-	err = usbd_device2interface_handle(uaa->device, AUE_IFACE_IDX, &iface);
-	if (err) {
-		device_printf(self, "getting interface handle failed\n");
-		return ENXIO;
-	}
-
-	sc->aue_iface = iface;
-	sc->aue_flags = aue_lookup(uaa->vendor, uaa->product)->aue_flags;
-
-	sc->aue_product = uaa->product;
-	sc->aue_vendor = uaa->vendor;
-
-	id = usbd_get_interface_descriptor(sc->aue_iface);
-
-	/* Find endpoints. */
-	for (i = 0; i < id->bNumEndpoints; i++) {
-		ed = usbd_interface2endpoint_descriptor(iface, i);
-		if (ed == NULL) {
-			device_printf(self, "couldn't get ep %d\n", i);
-			return ENXIO;
-		}
-		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
-		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
-			sc->aue_ed[AUE_ENDPT_RX] = ed->bEndpointAddress;
-		} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
-			   UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
-			sc->aue_ed[AUE_ENDPT_TX] = ed->bEndpointAddress;
-		} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
-			   UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
-			sc->aue_ed[AUE_ENDPT_INTR] = ed->bEndpointAddress;
-		}
+	struct usb2_attach_arg *uaa = device_get_ivars(dev);
+	struct aue_softc *sc = device_get_softc(dev);
+	struct ifnet *ifp;
+	uint8_t eaddr[ETHER_ADDR_LEN];
+	uint8_t iface_index;
+	int error;
+
+	if (sc == NULL)
+		return (ENOMEM);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-user mailing list