Date: Mon, 9 Feb 2009 22:02:38 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r188412 - in head/sys/dev/usb2: ethernet include template Message-ID: <200902092202.n19M2c5p072509@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Mon Feb 9 22:02:38 2009 New Revision: 188412 URL: http://svn.freebsd.org/changeset/base/188412 Log: MFp4 //depot/projects/usb; 157100 1. Move most of the ifnet logic into the usb2_ethernet module, this includes, - make all usb ethernet interfaces named ue%d - handle all threading in usb2_ethernet - provide default ioctl handler - handle mbuf rx - provide locked callbacks for init,start,stop,etc 2. Cleanup CDC-Ethernet driver. Submitted by: Hans Petter Selasky Obtained from: svn.freebsd.org/base/user/thompsa/usb [1] Modified: head/sys/dev/usb2/ethernet/if_aue2.c head/sys/dev/usb2/ethernet/if_auereg.h head/sys/dev/usb2/ethernet/if_axe2.c head/sys/dev/usb2/ethernet/if_axereg.h head/sys/dev/usb2/ethernet/if_cdce2.c head/sys/dev/usb2/ethernet/if_cdcereg.h head/sys/dev/usb2/ethernet/if_cue2.c head/sys/dev/usb2/ethernet/if_cuereg.h head/sys/dev/usb2/ethernet/if_kue2.c head/sys/dev/usb2/ethernet/if_kuereg.h head/sys/dev/usb2/ethernet/if_rue2.c head/sys/dev/usb2/ethernet/if_ruereg.h head/sys/dev/usb2/ethernet/if_udav2.c head/sys/dev/usb2/ethernet/if_udavreg.h head/sys/dev/usb2/ethernet/usb2_ethernet.c head/sys/dev/usb2/ethernet/usb2_ethernet.h head/sys/dev/usb2/include/usb2_cdc.h head/sys/dev/usb2/template/usb2_template_cdce.c Modified: head/sys/dev/usb2/ethernet/if_aue2.c ============================================================================== --- head/sys/dev/usb2/ethernet/if_aue2.c Mon Feb 9 21:56:33 2009 (r188411) +++ head/sys/dev/usb2/ethernet/if_aue2.c Mon Feb 9 22:02:38 2009 (r188412) @@ -2,6 +2,9 @@ * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. * + * Copyright (c) 2006 + * Alfred Perlstein <alfred@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: @@ -40,6 +43,9 @@ __FBSDID("$FreeBSD$"); * Written by Bill Paul <wpaul@ee.columbia.edu> * Electrical Engineering Department * Columbia University, New York City + * + * SMP locking by Alfred Perlstein <alfred@freebsd.org>. + * RED Inc. */ /* @@ -58,13 +64,8 @@ __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 usb2_do_request(). Packet transfers are - * done using usb2_transfer() and friends. - */ - -/* - * NOTE: all function names beginning like "aue_cfg_" can only - * be called from within the config thread function ! + * Registers are accessed using usb2_ether_do_request(). Packet + * transfers are done using usb2_transfer() and friends. */ #include <dev/usb2/include/usb2_devid.h> @@ -72,15 +73,11 @@ __FBSDID("$FreeBSD$"); #include <dev/usb2/include/usb2_mfunc.h> #include <dev/usb2/include/usb2_error.h> -#define usb2_config_td_cc usb2_ether_cc -#define usb2_config_td_softc aue_softc - #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_config_td.h> #include <dev/usb2/core/usb2_debug.h> #include <dev/usb2/core/usb2_request.h> #include <dev/usb2/core/usb2_busdma.h> @@ -89,11 +86,6 @@ __FBSDID("$FreeBSD$"); #include <dev/usb2/ethernet/usb2_ethernet.h> #include <dev/usb2/ethernet/if_auereg.h> -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); - #if USB_DEBUG static int aue_debug = 0; @@ -106,74 +98,74 @@ SYSCTL_INT(_hw_usb2_aue, OID_AUTO, debug * Various supported device vendors/products. */ 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)}, + {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)}, }; /* prototypes */ @@ -182,48 +174,34 @@ static device_probe_t aue_probe; static device_attach_t aue_attach; static device_detach_t aue_detach; static device_shutdown_t aue_shutdown; +static miibus_readreg_t aue_miibus_readreg; +static miibus_writereg_t aue_miibus_writereg; +static miibus_statchg_t aue_miibus_statchg; -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 void aue_cfg_do_request(struct aue_softc *, - struct usb2_device_request *, void *); -static uint8_t aue_cfg_csr_read_1(struct aue_softc *, uint16_t); -static uint16_t aue_cfg_csr_read_2(struct aue_softc *, uint16_t); -static void aue_cfg_csr_write_1(struct aue_softc *, uint16_t, uint8_t); -static void aue_cfg_csr_write_2(struct aue_softc *, uint16_t, uint16_t); -static void aue_cfg_eeprom_getword(struct aue_softc *, uint8_t, uint8_t *); -static void aue_cfg_read_eeprom(struct aue_softc *, uint8_t *, uint16_t, +static usb2_ether_fn_t aue_attach_post; +static usb2_ether_fn_t aue_init; +static usb2_ether_fn_t aue_stop; +static usb2_ether_fn_t aue_start; +static usb2_ether_fn_t aue_tick; +static usb2_ether_fn_t aue_setmulti; +static usb2_ether_fn_t aue_setpromisc; + +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 void aue_csr_write_1(struct aue_softc *, uint16_t, uint8_t); +static void 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_reset(struct aue_softc *); +static void aue_reset_pegasus_II(struct aue_softc *); -static miibus_readreg_t aue_cfg_miibus_readreg; -static miibus_writereg_t aue_cfg_miibus_writereg; -static miibus_statchg_t aue_cfg_miibus_statchg; - -static usb2_config_td_command_t aue_cfg_setmulti; -static usb2_config_td_command_t aue_cfg_first_time_setup; -static usb2_config_td_command_t aue_config_copy; -static usb2_config_td_command_t aue_cfg_tick; -static usb2_config_td_command_t aue_cfg_pre_init; -static usb2_config_td_command_t aue_cfg_init; -static usb2_config_td_command_t aue_cfg_promisc_upd; -static usb2_config_td_command_t aue_cfg_ifmedia_upd; -static usb2_config_td_command_t aue_cfg_pre_stop; -static usb2_config_td_command_t aue_cfg_stop; - -static void aue_cfg_reset_pegasus_II(struct aue_softc *); -static void aue_cfg_reset(struct aue_softc *); -static void aue_start_cb(struct ifnet *); -static void aue_init_cb(void *); -static void aue_start_transfers(struct aue_softc *); -static int aue_ifmedia_upd_cb(struct ifnet *); -static void aue_ifmedia_sts_cb(struct ifnet *, struct ifmediareq *); -static int aue_ioctl_cb(struct ifnet *, u_long, caddr_t); -static void aue_watchdog(void *); +static int aue_ifmedia_upd(struct ifnet *); +static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *); static const struct usb2_config aue_config[AUE_N_TRANSFER] = { @@ -233,7 +211,7 @@ static const struct usb2_config aue_conf .direction = UE_DIR_OUT, .mh.bufsize = (MCLBYTES + 2), .mh.flags = {.pipe_bof = 1,.force_short_xfer = 1,}, - .mh.callback = &aue_bulk_write_callback, + .mh.callback = aue_bulk_write_callback, .mh.timeout = 10000, /* 10 seconds */ }, @@ -243,29 +221,7 @@ static const struct usb2_config aue_conf .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 */ + .mh.callback = aue_bulk_read_callback, }, [AUE_INTR_DT_RD] = { @@ -274,18 +230,7 @@ static const struct usb2_config aue_conf .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 */ + .mh.callback = aue_intr_callback, }, }; @@ -301,9 +246,9 @@ static device_method_t aue_methods[] = { DEVMETHOD(bus_driver_added, bus_generic_driver_added), /* MII interface */ - DEVMETHOD(miibus_readreg, aue_cfg_miibus_readreg), - DEVMETHOD(miibus_writereg, aue_cfg_miibus_writereg), - DEVMETHOD(miibus_statchg, aue_cfg_miibus_statchg), + DEVMETHOD(miibus_readreg, aue_miibus_readreg), + DEVMETHOD(miibus_writereg, aue_miibus_writereg), + DEVMETHOD(miibus_statchg, aue_miibus_statchg), {0, 0} }; @@ -318,44 +263,34 @@ static devclass_t aue_devclass; 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 void -aue_cfg_do_request(struct aue_softc *sc, struct usb2_device_request *req, - void *data) -{ - uint16_t length; - usb2_error_t err; - - if (usb2_config_td_is_gone(&sc->sc_config_td)) { - goto error; - } - err = usb2_do_request_flags - (sc->sc_udev, &sc->sc_mtx, req, data, 0, NULL, 1000); - - if (err) { - - DPRINTF("device request failed, err=%s " - "(ignored)\n", usb2_errstr(err)); - -error: - length = UGETW(req->wLength); - - if ((req->bmRequestType & UT_READ) && length) { - bzero(data, length); - } - } -} +static const struct usb2_ether_methods aue_ue_methods = { + .ue_attach_post = aue_attach_post, + .ue_start = aue_start, + .ue_init = aue_init, + .ue_stop = aue_stop, + .ue_tick = aue_tick, + .ue_setmulti = aue_setmulti, + .ue_setpromisc = aue_setpromisc, + .ue_mii_upd = aue_ifmedia_upd, + .ue_mii_sts = aue_ifmedia_sts, +}; -#define AUE_CFG_SETBIT(sc, reg, x) \ - aue_cfg_csr_write_1(sc, reg, aue_cfg_csr_read_1(sc, reg) | (x)) +#define AUE_SETBIT(sc, reg, x) \ + aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) | (x)) -#define AUE_CFG_CLRBIT(sc, reg, x) \ - aue_cfg_csr_write_1(sc, reg, aue_cfg_csr_read_1(sc, reg) & ~(x)) +#define AUE_CLRBIT(sc, reg, x) \ + aue_csr_write_1(sc, reg, aue_csr_read_1(sc, reg) & ~(x)) static uint8_t -aue_cfg_csr_read_1(struct aue_softc *sc, uint16_t reg) +aue_csr_read_1(struct aue_softc *sc, uint16_t reg) { struct usb2_device_request req; + usb2_error_t err; uint8_t val; req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -364,14 +299,17 @@ aue_cfg_csr_read_1(struct aue_softc *sc, USETW(req.wIndex, reg); USETW(req.wLength, 1); - aue_cfg_do_request(sc, &req, &val); + err = usb2_ether_do_request(&sc->sc_ue, &req, &val, 1000); + if (err) + return (0); return (val); } static uint16_t -aue_cfg_csr_read_2(struct aue_softc *sc, uint16_t reg) +aue_csr_read_2(struct aue_softc *sc, uint16_t reg) { struct usb2_device_request req; + usb2_error_t err; uint16_t val; req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -380,12 +318,14 @@ aue_cfg_csr_read_2(struct aue_softc *sc, USETW(req.wIndex, reg); USETW(req.wLength, 2); - aue_cfg_do_request(sc, &req, &val); + err = usb2_ether_do_request(&sc->sc_ue, &req, &val, 1000); + if (err) + return (0); return (le16toh(val)); } static void -aue_cfg_csr_write_1(struct aue_softc *sc, uint16_t reg, uint8_t val) +aue_csr_write_1(struct aue_softc *sc, uint16_t reg, uint8_t val) { struct usb2_device_request req; @@ -396,11 +336,13 @@ aue_cfg_csr_write_1(struct aue_softc *sc USETW(req.wIndex, reg); USETW(req.wLength, 1); - aue_cfg_do_request(sc, &req, &val); + if (usb2_ether_do_request(&sc->sc_ue, &req, &val, 1000)) { + /* error ignored */ + } } static void -aue_cfg_csr_write_2(struct aue_softc *sc, uint16_t reg, uint16_t val) +aue_csr_write_2(struct aue_softc *sc, uint16_t reg, uint16_t val) { struct usb2_device_request req; @@ -412,196 +354,154 @@ aue_cfg_csr_write_2(struct aue_softc *sc val = htole16(val); - aue_cfg_do_request(sc, &req, &val); + if (usb2_ether_do_request(&sc->sc_ue, &req, &val, 1000)) { + /* error ignored */ + } } /* * Read a word of data stored in the EEPROM at address 'addr.' */ static void -aue_cfg_eeprom_getword(struct aue_softc *sc, uint8_t addr, - uint8_t *dest) +aue_eeprom_getword(struct aue_softc *sc, int addr, uint16_t *dest) { - uint16_t i; - - aue_cfg_csr_write_1(sc, AUE_EE_REG, addr); - aue_cfg_csr_write_1(sc, AUE_EE_CTL, AUE_EECTL_READ); - - for (i = 0;; i++) { + int i; + uint16_t word = 0; - if (i < AUE_TIMEOUT) { + aue_csr_write_1(sc, AUE_EE_REG, addr); + aue_csr_write_1(sc, AUE_EE_CTL, AUE_EECTL_READ); - if (aue_cfg_csr_read_1(sc, AUE_EE_CTL) & AUE_EECTL_DONE) { - break; - } - if (usb2_config_td_sleep(&sc->sc_config_td, hz / 100)) { - break; - } - } else { - DPRINTF("EEPROM read timed out!\n"); + for (i = 0; i != AUE_TIMEOUT; i++) { + if (aue_csr_read_1(sc, AUE_EE_CTL) & AUE_EECTL_DONE) + break; + if (usb2_ether_pause(&sc->sc_ue, hz / 100)) break; - } } - i = aue_cfg_csr_read_2(sc, AUE_EE_DATA); + if (i == AUE_TIMEOUT) + device_printf(sc->sc_ue.ue_dev, "EEPROM read timed out\n"); - dest[0] = (i & 0xFF); - dest[1] = (i >> 8); + word = aue_csr_read_2(sc, AUE_EE_DATA); + *dest = word; } /* * Read a sequence of words from the EEPROM. */ static void -aue_cfg_read_eeprom(struct aue_softc *sc, uint8_t *dest, +aue_read_eeprom(struct aue_softc *sc, uint8_t *dest, uint16_t off, uint16_t len) { - uint16_t i; + uint16_t *ptr = (uint16_t *)dest; + int i; - for (i = 0; i < len; i++) { - aue_cfg_eeprom_getword(sc, off + i, dest + (i * 2)); - } + for (i = 0; i != len; i++, ptr++) + aue_eeprom_getword(sc, off + i, ptr); } static int -aue_cfg_miibus_readreg(device_t dev, int phy, int reg) +aue_miibus_readreg(device_t dev, int phy, int reg) { struct aue_softc *sc = device_get_softc(dev); - uint16_t i; - uint8_t do_unlock; + int i, locked; + uint16_t val = 0; - /* avoid recursive locking */ - if (mtx_owned(&sc->sc_mtx)) { - do_unlock = 0; - } else { - mtx_lock(&sc->sc_mtx); - do_unlock = 1; - } + locked = mtx_owned(&sc->sc_mtx); + if (!locked) + AUE_LOCK(sc); /* - * 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->sc_flags & AUE_FLAG_DUAL_PHY) { - - if (phy == 3) { - i = 0; + if (phy == 3) goto done; - } #if 0 - if (phy != 1) { - i = 0; + if (phy != 1) goto done; - } #endif } - aue_cfg_csr_write_1(sc, AUE_PHY_ADDR, phy); - aue_cfg_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_READ); - - for (i = 0;; i++) { + aue_csr_write_1(sc, AUE_PHY_ADDR, phy); + aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_READ); - if (i < AUE_TIMEOUT) { - - if (aue_cfg_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE) { - break; - } - if (usb2_config_td_sleep(&sc->sc_config_td, hz / 100)) { - break; - } - } else { - DPRINTF("MII read timed out\n"); + for (i = 0; i != AUE_TIMEOUT; i++) { + if (aue_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE) + break; + if (usb2_ether_pause(&sc->sc_ue, hz / 100)) break; - } } - i = aue_cfg_csr_read_2(sc, AUE_PHY_DATA); + if (i == AUE_TIMEOUT) + device_printf(sc->sc_ue.ue_dev, "MII read timed out\n"); + + val = aue_csr_read_2(sc, AUE_PHY_DATA); done: - if (do_unlock) { - mtx_unlock(&sc->sc_mtx); - } - return (i); + if (!locked) + AUE_UNLOCK(sc); + return (val); } static int -aue_cfg_miibus_writereg(device_t dev, int phy, int reg, int data) +aue_miibus_writereg(device_t dev, int phy, int reg, int data) { struct aue_softc *sc = device_get_softc(dev); - uint16_t i; - uint8_t do_unlock; + int i; + int locked; - if (phy == 3) { + if (phy == 3) return (0); - } - /* avoid recursive locking */ - if (mtx_owned(&sc->sc_mtx)) { - do_unlock = 0; - } else { - mtx_lock(&sc->sc_mtx); - do_unlock = 1; - } - aue_cfg_csr_write_2(sc, AUE_PHY_DATA, data); - aue_cfg_csr_write_1(sc, AUE_PHY_ADDR, phy); - aue_cfg_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_WRITE); - - for (i = 0;; i++) { - - if (i < AUE_TIMEOUT) { - if (aue_cfg_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE) { - break; - } - if (usb2_config_td_sleep(&sc->sc_config_td, hz / 100)) { - break; - } - } else { - DPRINTF("MII write timed out\n"); + locked = mtx_owned(&sc->sc_mtx); + if (!locked) + AUE_LOCK(sc); + + 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); + + for (i = 0; i != AUE_TIMEOUT; i++) { + if (aue_csr_read_1(sc, AUE_PHY_CTL) & AUE_PHYCTL_DONE) + break; + if (usb2_ether_pause(&sc->sc_ue, hz / 100)) break; - } } - if (do_unlock) { - mtx_unlock(&sc->sc_mtx); - } + if (i == AUE_TIMEOUT) + device_printf(sc->sc_ue.ue_dev, "MII read timed out\n"); + + if (!locked) + AUE_UNLOCK(sc); return (0); } static void -aue_cfg_miibus_statchg(device_t dev) +aue_miibus_statchg(device_t dev) { 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 { - mtx_lock(&sc->sc_mtx); - do_unlock = 1; - } - - AUE_CFG_CLRBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB); + int locked; - if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) { - AUE_CFG_SETBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL); - } else { - AUE_CFG_CLRBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL); - } + locked = mtx_owned(&sc->sc_mtx); + if (!locked) + AUE_LOCK(sc); + + AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB); + if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) + AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL); + else + AUE_CLRBIT(sc, AUE_CTL1, AUE_CTL1_SPEEDSEL); - if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) { - AUE_CFG_SETBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX); - } else { - AUE_CFG_CLRBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX); - } + if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) + AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX); + else + AUE_CLRBIT(sc, AUE_CTL1, AUE_CTL1_DUPLEX); - AUE_CFG_SETBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB); + AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB); /* * Set the LED modes on the LinkSys adapter. @@ -611,75 +511,80 @@ aue_cfg_miibus_statchg(device_t dev) if (sc->sc_flags & AUE_FLAG_LSYS) { uint16_t auxmode; - auxmode = aue_cfg_miibus_readreg(dev, 0, 0x1b); - aue_cfg_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04); - } - if (do_unlock) { - mtx_unlock(&sc->sc_mtx); + auxmode = aue_miibus_readreg(dev, 0, 0x1b); + aue_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04); } + if (!locked) + AUE_UNLOCK(sc); } +#define AUE_BITS 6 static void -aue_cfg_setmulti(struct aue_softc *sc, - struct usb2_config_td_cc *cc, uint16_t refcount) +aue_setmulti(struct usb2_ether *ue) { - uint16_t i; + struct aue_softc *sc = usb2_ether_getsc(ue); + struct ifnet *ifp = usb2_ether_getifp(ue); + struct ifmultiaddr *ifma; + uint32_t h = 0; + uint32_t i; + uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + AUE_LOCK_ASSERT(sc, MA_OWNED); - if ((cc->if_flags & IFF_ALLMULTI) || - (cc->if_flags & IFF_PROMISC)) { - AUE_CFG_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI); + if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { + AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI); return; } - AUE_CFG_CLRBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI); - /* clear existing ones */ - for (i = 0; i < 8; i++) { - aue_cfg_csr_write_1(sc, AUE_MAR0 + i, 0); - } + AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI); /* now program new ones */ - for (i = 0; i < 8; i++) { - aue_cfg_csr_write_1(sc, AUE_MAR0 + i, cc->if_hash[i]); + IF_ADDR_LOCK(ifp); + 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 *) + ifma->ifma_addr), ETHER_ADDR_LEN) & ((1 << AUE_BITS) - 1); + hashtbl[(h >> 3)] |= 1 << (h & 0x7); } + IF_ADDR_UNLOCK(ifp); + + /* write the hashtable */ + for (i = 0; i != 8; i++) + aue_csr_write_1(sc, AUE_MAR0 + i, hashtbl[i]); } static void -aue_cfg_reset_pegasus_II(struct aue_softc *sc) +aue_reset_pegasus_II(struct aue_softc *sc) { /* Magic constants taken from Linux driver. */ - aue_cfg_csr_write_1(sc, AUE_REG_1D, 0); - aue_cfg_csr_write_1(sc, AUE_REG_7B, 2); + aue_csr_write_1(sc, AUE_REG_1D, 0); + aue_csr_write_1(sc, AUE_REG_7B, 2); #if 0 if ((sc->sc_flags & HAS_HOME_PNA) && mii_mode) - aue_cfg_csr_write_1(sc, AUE_REG_81, 6); + aue_csr_write_1(sc, AUE_REG_81, 6); else #endif - aue_cfg_csr_write_1(sc, AUE_REG_81, 2); + aue_csr_write_1(sc, AUE_REG_81, 2); } static void -aue_cfg_reset(struct aue_softc *sc) +aue_reset(struct aue_softc *sc) { - uint16_t i; + int i; - AUE_CFG_SETBIT(sc, AUE_CTL1, AUE_CTL1_RESETMAC); + AUE_SETBIT(sc, AUE_CTL1, AUE_CTL1_RESETMAC); - for (i = 0;; i++) { - - if (i < AUE_TIMEOUT) { - - if (!(aue_cfg_csr_read_1(sc, AUE_CTL1) & AUE_CTL1_RESETMAC)) { - break; - } - if (usb2_config_td_sleep(&sc->sc_config_td, hz / 100)) { - break; - } - } else { - DPRINTF("reset timed out\n"); + for (i = 0; i != AUE_TIMEOUT; i++) { + if (!(aue_csr_read_1(sc, AUE_CTL1) & AUE_CTL1_RESETMAC)) + break; + if (usb2_ether_pause(&sc->sc_ue, hz / 100)) break; - } } + if (i == AUE_TIMEOUT) + device_printf(sc->sc_ue.ue_dev, "reset failed\n"); + /* * The PHY(s) attached to the Pegasus chip may be held * in reset until we flip on the GPIO outputs. Make sure @@ -689,24 +594,32 @@ aue_cfg_reset(struct aue_softc *sc) * Note: We force all of the GPIO pins low first, *then* * enable the ones we want. */ - aue_cfg_csr_write_1(sc, AUE_GPIO0, (AUE_GPIO_OUT0 | AUE_GPIO_SEL0)); - aue_cfg_csr_write_1(sc, AUE_GPIO0, (AUE_GPIO_OUT0 | AUE_GPIO_SEL0 | - AUE_GPIO_SEL1)); + 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->sc_flags & AUE_FLAG_LSYS) { /* Grrr. LinkSys has to be different from everyone else. */ - aue_cfg_csr_write_1(sc, AUE_GPIO0, - (AUE_GPIO_SEL0 | AUE_GPIO_SEL1)); - aue_cfg_csr_write_1(sc, AUE_GPIO0, - (AUE_GPIO_SEL0 | - AUE_GPIO_SEL1 | - AUE_GPIO_OUT0)); - } - if (sc->sc_flags & AUE_FLAG_PII) { - aue_cfg_reset_pegasus_II(sc); + 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); } - /* wait a little while for the chip to get its brains in order: */ - usb2_config_td_sleep(&sc->sc_config_td, hz / 100); + if (sc->sc_flags & AUE_FLAG_PII) + aue_reset_pegasus_II(sc); + + /* Wait a little while for the chip to get its brains in order: */ + usb2_ether_pause(&sc->sc_ue, hz / 100); +} + +static void +aue_attach_post(struct usb2_ether *ue) +{ + struct aue_softc *sc = usb2_ether_getsc(ue); + + /* reset the adapter */ + aue_reset(sc); + + /* get station address from the EEPROM */ + aue_read_eeprom(sc, ue->ue_eaddr, 0, 3); } /* @@ -717,26 +630,22 @@ aue_probe(device_t dev) { struct usb2_attach_arg *uaa = device_get_ivars(dev); - if (uaa->usb2_mode != USB_MODE_HOST) { + if (uaa->usb2_mode != USB_MODE_HOST) return (ENXIO); - } - if (uaa->info.bConfigIndex != AUE_CONFIG_INDEX) { + if (uaa->info.bConfigIndex != AUE_CONFIG_INDEX) return (ENXIO); - } - if (uaa->info.bIfaceIndex != AUE_IFACE_IDX) { + 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. + * 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->info.idVendor == USB_VENDOR_BELKIN) && - (uaa->info.idProduct == USB_PRODUCT_BELKIN_F8T012) && - (uaa->info.bcdDevice == 0x0413)) { + if (uaa->info.idVendor == USB_VENDOR_BELKIN && + uaa->info.idProduct == USB_PRODUCT_BELKIN_F8T012 && + uaa->info.bcdDevice == 0x0413) return (ENXIO); - } + return (usb2_lookup_id_by_uaa(aue_devs, sizeof(aue_devs), uaa)); } @@ -749,53 +658,40 @@ aue_attach(device_t dev) { struct usb2_attach_arg *uaa = device_get_ivars(dev); struct aue_softc *sc = device_get_softc(dev); - int32_t error; + struct usb2_ether *ue = &sc->sc_ue; uint8_t iface_index; + int error; - sc->sc_udev = uaa->device; - sc->sc_dev = dev; - sc->sc_unit = device_get_unit(dev); sc->sc_flags = USB_GET_DRIVER_INFO(uaa); if (uaa->info.bcdDevice >= 0x0201) { - sc->sc_flags |= AUE_FLAG_VER_2; /* XXX currently undocumented */ + /* XXX currently undocumented */ + sc->sc_flags |= AUE_FLAG_VER_2; } - device_set_usb2_desc(dev); - - snprintf(sc->sc_name, sizeof(sc->sc_name), "%s", - device_get_nameunit(dev)); - - mtx_init(&sc->sc_mtx, "aue lock", NULL, MTX_DEF | MTX_RECURSE); - usb2_callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0); + device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); iface_index = AUE_IFACE_IDX; error = usb2_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, aue_config, AUE_N_TRANSFER, sc, &sc->sc_mtx); if (error) { - device_printf(dev, "allocating USB " - "transfers failed!\n"); + device_printf(dev, "allocating USB transfers failed!\n"); goto detach; } - error = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_mtx, - NULL, sizeof(struct usb2_config_td_cc), 16); + + ue->ue_sc = sc; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902092202.n19M2c5p072509>