Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Feb 2009 22:12:47 +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: r188417 - head/sys/dev/usb2/wlan
Message-ID:  <200902092212.n19MClrY072910@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Mon Feb  9 22:12:47 2009
New Revision: 188417
URL: http://svn.freebsd.org/changeset/base/188417

Log:
  MFp4 //depot/projects/usb; 157412
  
  Sync from svn.freebsd.org/base/user/thompsa/usb which is a minimal changeset
  from oldUSB (no config_td).
  
  This excludes the taskqueue changes (for the moment) as requested.

Modified:
  head/sys/dev/usb2/wlan/if_rum2.c
  head/sys/dev/usb2/wlan/if_rumreg.h
  head/sys/dev/usb2/wlan/if_rumvar.h
  head/sys/dev/usb2/wlan/if_ural2.c
  head/sys/dev/usb2/wlan/if_uralreg.h
  head/sys/dev/usb2/wlan/if_uralvar.h
  head/sys/dev/usb2/wlan/if_zyd2.c
  head/sys/dev/usb2/wlan/if_zydfw.h
  head/sys/dev/usb2/wlan/if_zydreg.h

Modified: head/sys/dev/usb2/wlan/if_rum2.c
==============================================================================
--- head/sys/dev/usb2/wlan/if_rum2.c	Mon Feb  9 22:11:02 2009	(r188416)
+++ head/sys/dev/usb2/wlan/if_rum2.c	Mon Feb  9 22:12:47 2009	(r188417)
@@ -1,3 +1,5 @@
+/*	$FreeBSD$	*/
+
 /*-
  * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr>
  * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
@@ -16,11 +18,6 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/*
- * NOTE: all function names beginning like "rum_cfg_" can only
- * be called from within the config thread function !
- */
-
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
@@ -34,15 +31,11 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb2/include/usb2_mfunc.h>
 #include <dev/usb2/include/usb2_error.h>
 
-#define	usb2_config_td_cc rum_config_copy
-#define	usb2_config_td_softc rum_softc
-
 #define	USB_DEBUG_VAR rum_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>
@@ -61,928 +54,817 @@ SYSCTL_INT(_hw_usb2_rum, OID_AUTO, debug
     "Debug level");
 #endif
 
-/* prototypes */
+#define	rum_do_request(sc,req,data) \
+  usb2_do_request_proc((sc)->sc_udev, &(sc)->sc_tq, req, data, 0, NULL, 5000)
+
+static const struct usb2_device_id rum_devs[] = {
+    { USB_VP(USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_HWU54DM) },
+    { USB_VP(USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_RT2573_2) },
+    { USB_VP(USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_RT2573_3) },
+    { USB_VP(USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_RT2573_4) },
+    { USB_VP(USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_WUG2700) },
+    { USB_VP(USB_VENDOR_AMIT,		USB_PRODUCT_AMIT_CGWLUSB2GO) },
+    { USB_VP(USB_VENDOR_ASUS,		USB_PRODUCT_ASUS_RT2573_1) },
+    { USB_VP(USB_VENDOR_ASUS,		USB_PRODUCT_ASUS_RT2573_2) },
+    { USB_VP(USB_VENDOR_BELKIN,		USB_PRODUCT_BELKIN_F5D7050A) },
+    { USB_VP(USB_VENDOR_BELKIN,		USB_PRODUCT_BELKIN_F5D9050V3) },
+    { USB_VP(USB_VENDOR_CISCOLINKSYS,	USB_PRODUCT_CISCOLINKSYS_WUSB54GC) },
+    { USB_VP(USB_VENDOR_CISCOLINKSYS,	USB_PRODUCT_CISCOLINKSYS_WUSB54GR) },
+    { USB_VP(USB_VENDOR_CONCEPTRONIC2,	USB_PRODUCT_CONCEPTRONIC2_C54RU2) },
+    { USB_VP(USB_VENDOR_COREGA,		USB_PRODUCT_COREGA_CGWLUSB2GL) },
+    { USB_VP(USB_VENDOR_COREGA,		USB_PRODUCT_COREGA_CGWLUSB2GPX) },
+    { USB_VP(USB_VENDOR_DICKSMITH,	USB_PRODUCT_DICKSMITH_CWD854F) },
+    { USB_VP(USB_VENDOR_DICKSMITH,	USB_PRODUCT_DICKSMITH_RT2573) },
+    { USB_VP(USB_VENDOR_DLINK2,		USB_PRODUCT_DLINK2_DWLG122C1) },
+    { USB_VP(USB_VENDOR_DLINK2,		USB_PRODUCT_DLINK2_WUA1340) },
+    { USB_VP(USB_VENDOR_DLINK2,		USB_PRODUCT_DLINK2_DWA111) },
+    { USB_VP(USB_VENDOR_DLINK2,		USB_PRODUCT_DLINK2_DWA110) },
+    { USB_VP(USB_VENDOR_GIGABYTE,	USB_PRODUCT_GIGABYTE_GNWB01GS) },
+    { USB_VP(USB_VENDOR_GIGABYTE,	USB_PRODUCT_GIGABYTE_GNWI05GS) },
+    { USB_VP(USB_VENDOR_GIGASET,	USB_PRODUCT_GIGASET_RT2573) },
+    { USB_VP(USB_VENDOR_GOODWAY,	USB_PRODUCT_GOODWAY_RT2573) },
+    { USB_VP(USB_VENDOR_GUILLEMOT,	USB_PRODUCT_GUILLEMOT_HWGUSB254LB) },
+    { USB_VP(USB_VENDOR_GUILLEMOT,	USB_PRODUCT_GUILLEMOT_HWGUSB254V2AP) },
+    { USB_VP(USB_VENDOR_HUAWEI3COM,	USB_PRODUCT_HUAWEI3COM_WUB320G) },
+    { USB_VP(USB_VENDOR_MELCO,		USB_PRODUCT_MELCO_G54HP) },
+    { USB_VP(USB_VENDOR_MELCO,		USB_PRODUCT_MELCO_SG54HP) },
+    { USB_VP(USB_VENDOR_MSI,		USB_PRODUCT_MSI_RT2573_1) },
+    { USB_VP(USB_VENDOR_MSI,		USB_PRODUCT_MSI_RT2573_2) },
+    { USB_VP(USB_VENDOR_MSI,		USB_PRODUCT_MSI_RT2573_3) },
+    { USB_VP(USB_VENDOR_MSI,		USB_PRODUCT_MSI_RT2573_4) },
+    { USB_VP(USB_VENDOR_NOVATECH,	USB_PRODUCT_NOVATECH_RT2573) },
+    { USB_VP(USB_VENDOR_PLANEX2,	USB_PRODUCT_PLANEX2_GWUS54HP) },
+    { USB_VP(USB_VENDOR_PLANEX2,	USB_PRODUCT_PLANEX2_GWUS54MINI2) },
+    { USB_VP(USB_VENDOR_PLANEX2,	USB_PRODUCT_PLANEX2_GWUSMM) },
+    { USB_VP(USB_VENDOR_QCOM,		USB_PRODUCT_QCOM_RT2573) },
+    { USB_VP(USB_VENDOR_QCOM,		USB_PRODUCT_QCOM_RT2573_2) },
+    { USB_VP(USB_VENDOR_RALINK,		USB_PRODUCT_RALINK_RT2573) },
+    { USB_VP(USB_VENDOR_RALINK,		USB_PRODUCT_RALINK_RT2573_2) },
+    { USB_VP(USB_VENDOR_RALINK,		USB_PRODUCT_RALINK_RT2671) },
+    { USB_VP(USB_VENDOR_SITECOMEU,	USB_PRODUCT_SITECOMEU_WL113R2) },
+    { USB_VP(USB_VENDOR_SITECOMEU,	USB_PRODUCT_SITECOMEU_WL172) },
+    { USB_VP(USB_VENDOR_SPARKLAN,	USB_PRODUCT_SPARKLAN_RT2573) },
+    { USB_VP(USB_VENDOR_SURECOM,	USB_PRODUCT_SURECOM_RT2573) },
+};
+
+MODULE_DEPEND(rum, wlan, 1, 1, 1);
+MODULE_DEPEND(rum, wlan_amrr, 1, 1, 1);
+MODULE_DEPEND(rum, usb2_wlan, 1, 1, 1);
+MODULE_DEPEND(rum, usb2_core, 1, 1, 1);
 
-static device_probe_t rum_probe;
+static device_probe_t rum_match;
 static device_attach_t rum_attach;
 static device_detach_t rum_detach;
 
 static usb2_callback_t rum_bulk_read_callback;
-static usb2_callback_t rum_bulk_read_clear_stall_callback;
 static usb2_callback_t rum_bulk_write_callback;
-static usb2_callback_t rum_bulk_write_clear_stall_callback;
 
-static usb2_config_td_command_t rum_cfg_first_time_setup;
-static usb2_config_td_command_t rum_config_copy;
-static usb2_config_td_command_t rum_cfg_scan_start;
-static usb2_config_td_command_t rum_cfg_scan_end;
-static usb2_config_td_command_t rum_cfg_select_band;
-static usb2_config_td_command_t rum_cfg_set_chan;
-static usb2_config_td_command_t rum_cfg_enable_tsf_sync;
-static usb2_config_td_command_t rum_cfg_enable_mrr;
-static usb2_config_td_command_t rum_cfg_update_slot;
-static usb2_config_td_command_t rum_cfg_select_antenna;
-static usb2_config_td_command_t rum_cfg_set_txpreamble;
-static usb2_config_td_command_t rum_cfg_update_promisc;
-static usb2_config_td_command_t rum_cfg_pre_init;
-static usb2_config_td_command_t rum_cfg_init;
-static usb2_config_td_command_t rum_cfg_pre_stop;
-static usb2_config_td_command_t rum_cfg_stop;
-static usb2_config_td_command_t rum_cfg_amrr_timeout;
-static usb2_config_td_command_t rum_cfg_prepare_beacon;
-static usb2_config_td_command_t rum_cfg_newstate;
-
-static const char *rum_get_rf(uint32_t);
-static int	rum_ioctl_cb(struct ifnet *, u_long, caddr_t);
-static void	rum_std_command(struct ieee80211com *, usb2_config_td_command_t *);
-static void	rum_scan_start_cb(struct ieee80211com *);
-static void	rum_scan_end_cb(struct ieee80211com *);
-static void	rum_set_channel_cb(struct ieee80211com *);
-static uint16_t	rum_cfg_eeprom_read_2(struct rum_softc *, uint16_t);
-static uint32_t	rum_cfg_bbp_disbusy(struct rum_softc *);
-static uint32_t	rum_cfg_read(struct rum_softc *, uint16_t);
-static uint8_t	rum_cfg_bbp_init(struct rum_softc *);
-static uint8_t	rum_cfg_bbp_read(struct rum_softc *, uint8_t);
-static void	rum_cfg_amrr_start(struct rum_softc *);
-static void	rum_cfg_bbp_write(struct rum_softc *, uint8_t, uint8_t);
-static void	rum_cfg_do_request(struct rum_softc *,
-		    struct usb2_device_request *, void *);
-static void	rum_cfg_eeprom_read(struct rum_softc *, uint16_t, void *,
-		    uint16_t);
-static void	rum_cfg_load_microcode(struct rum_softc *, const uint8_t *,
-		    uint16_t);
-static void	rum_cfg_read_eeprom(struct rum_softc *);
-static void	rum_cfg_read_multi(struct rum_softc *, uint16_t, void *,
-		    uint16_t);
-static void	rum_cfg_rf_write(struct rum_softc *, uint8_t, uint32_t);
-static void	rum_cfg_set_bssid(struct rum_softc *, uint8_t *);
-static void	rum_cfg_set_macaddr(struct rum_softc *, uint8_t *);
-static void	rum_cfg_write(struct rum_softc *, uint16_t, uint32_t);
-static void	rum_cfg_write_multi(struct rum_softc *, uint16_t, void *,
-		    uint16_t);
-static void	rum_end_of_commands(struct rum_softc *);
-static void	rum_init_cb(void *);
-static void	rum_start_cb(struct ifnet *);
-static void	rum_watchdog(void *);
-static uint8_t	rum_get_rssi(struct rum_softc *, uint8_t);
+static usb2_proc_callback_t rum_attach_post;
+static usb2_proc_callback_t rum_task;
+static usb2_proc_callback_t rum_scantask;
+static usb2_proc_callback_t rum_promisctask;
+static usb2_proc_callback_t rum_amrr_task;
+static usb2_proc_callback_t rum_init_task;
+static usb2_proc_callback_t rum_stop_task;
+
 static struct ieee80211vap *rum_vap_create(struct ieee80211com *,
-		    const char[], int, int, int, const uint8_t[],
-		    const uint8_t[]);
-static void	rum_vap_delete(struct ieee80211vap *);
+			    const char name[IFNAMSIZ], int unit, int opmode,
+			    int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],
+			    const uint8_t mac[IEEE80211_ADDR_LEN]);
+static void		rum_vap_delete(struct ieee80211vap *);
+static void		rum_tx_free(struct rum_tx_data *, int);
+static void		rum_setup_tx_list(struct rum_softc *);
+static void		rum_unsetup_tx_list(struct rum_softc *);
+static int		rum_newstate(struct ieee80211vap *,
+			    enum ieee80211_state, int);
+static void		rum_setup_tx_desc(struct rum_softc *,
+			    struct rum_tx_desc *, uint32_t, uint16_t, int,
+			    int);
+static int		rum_tx_mgt(struct rum_softc *, struct mbuf *,
+			    struct ieee80211_node *);
+static int		rum_tx_raw(struct rum_softc *, struct mbuf *,
+			    struct ieee80211_node *, 
+			    const struct ieee80211_bpf_params *);
+static int		rum_tx_data(struct rum_softc *, struct mbuf *,
+			    struct ieee80211_node *);
+static void		rum_start(struct ifnet *);
+static int		rum_ioctl(struct ifnet *, u_long, caddr_t);
+static void		rum_eeprom_read(struct rum_softc *, uint16_t, void *,
+			    int);
+static uint32_t		rum_read(struct rum_softc *, uint16_t);
+static void		rum_read_multi(struct rum_softc *, uint16_t, void *,
+			    int);
+static void		rum_write(struct rum_softc *, uint16_t, uint32_t);
+static void		rum_write_multi(struct rum_softc *, uint16_t, void *,
+			    size_t);
+static void		rum_bbp_write(struct rum_softc *, uint8_t, uint8_t);
+static uint8_t		rum_bbp_read(struct rum_softc *, uint8_t);
+static void		rum_rf_write(struct rum_softc *, uint8_t, uint32_t);
+static void		rum_select_antenna(struct rum_softc *);
+static void		rum_enable_mrr(struct rum_softc *);
+static void		rum_set_txpreamble(struct rum_softc *);
+static void		rum_set_basicrates(struct rum_softc *);
+static void		rum_select_band(struct rum_softc *,
+			    struct ieee80211_channel *);
+static void		rum_set_chan(struct rum_softc *,
+			    struct ieee80211_channel *);
+static void		rum_enable_tsf_sync(struct rum_softc *);
+static void		rum_update_slot(struct ifnet *);
+static void		rum_set_bssid(struct rum_softc *, const uint8_t *);
+static void		rum_set_macaddr(struct rum_softc *, const uint8_t *);
+static const char	*rum_get_rf(int);
+static void		rum_read_eeprom(struct rum_softc *);
+static int		rum_bbp_init(struct rum_softc *);
+static void		rum_init(void *);
+static int		rum_load_microcode(struct rum_softc *, const u_char *,
+			    size_t);
+static int		rum_prepare_beacon(struct rum_softc *,
+			    struct ieee80211vap *);
+static int		rum_raw_xmit(struct ieee80211_node *, struct mbuf *,
+			    const struct ieee80211_bpf_params *);
 static struct ieee80211_node *rum_node_alloc(struct ieee80211vap *,
-		    const uint8_t[]);
-static void	rum_newassoc(struct ieee80211_node *, int);
-static void	rum_cfg_disable_tsf_sync(struct rum_softc *);
-static void	rum_cfg_set_run(struct rum_softc *, struct rum_config_copy *);
-static void	rum_fill_write_queue(struct rum_softc *);
-static void	rum_tx_clean_queue(struct rum_softc *);
-static void	rum_tx_freem(struct mbuf *);
-static void	rum_tx_mgt(struct rum_softc *, struct mbuf *,
-		    struct ieee80211_node *);
-static struct ieee80211vap *rum_get_vap(struct rum_softc *);
-static void	rum_tx_data(struct rum_softc *, struct mbuf *,
-		    struct ieee80211_node *);
-static void	rum_tx_prot(struct rum_softc *, const struct mbuf *,
-		    struct ieee80211_node *, uint8_t, uint16_t);
-static void	rum_tx_raw(struct rum_softc *, struct mbuf *,
-		    struct ieee80211_node *,
-		    const struct ieee80211_bpf_params *);
-static int	rum_raw_xmit_cb(struct ieee80211_node *, struct mbuf *,
-		    const struct ieee80211_bpf_params *);
-static void	rum_setup_desc_and_tx(struct rum_softc *, struct mbuf *,
-		    uint32_t, uint16_t, uint16_t);
-static int	rum_newstate_cb(struct ieee80211vap *,
-		    enum ieee80211_state nstate, int arg);
-static void	rum_update_mcast_cb(struct ifnet *);
-static void	rum_update_promisc_cb(struct ifnet *);
-
-/* various supported device vendors/products */
-static const struct usb2_device_id rum_devs[] = {
-	{USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_HWU54DM, 0)},
-	{USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_RT2573_2, 0)},
-	{USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_RT2573_3, 0)},
-	{USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_RT2573_4, 0)},
-	{USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_WUG2700, 0)},
-	{USB_VPI(USB_VENDOR_AMIT, USB_PRODUCT_AMIT_CGWLUSB2GO, 0)},
-	{USB_VPI(USB_VENDOR_ASUS, USB_PRODUCT_ASUS_RT2573_1, 0)},
-	{USB_VPI(USB_VENDOR_ASUS, USB_PRODUCT_ASUS_RT2573_2, 0)},
-	{USB_VPI(USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5D7050A, 0)},
-	{USB_VPI(USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5D9050V3, 0)},
-	{USB_VPI(USB_VENDOR_CISCOLINKSYS, USB_PRODUCT_CISCOLINKSYS_WUSB54GC, 0)},
-	{USB_VPI(USB_VENDOR_CISCOLINKSYS, USB_PRODUCT_CISCOLINKSYS_WUSB54GR, 0)},
-	{USB_VPI(USB_VENDOR_CONCEPTRONIC2, USB_PRODUCT_CONCEPTRONIC2_C54RU2, 0)},
-	{USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_CGWLUSB2GL, 0)},
-	{USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_CGWLUSB2GPX, 0)},
-	{USB_VPI(USB_VENDOR_DICKSMITH, USB_PRODUCT_DICKSMITH_CWD854F, 0)},
-	{USB_VPI(USB_VENDOR_DICKSMITH, USB_PRODUCT_DICKSMITH_RT2573, 0)},
-	{USB_VPI(USB_VENDOR_DLINK2, USB_PRODUCT_DLINK2_DWLG122C1, 0)},
-	{USB_VPI(USB_VENDOR_DLINK2, USB_PRODUCT_DLINK2_WUA1340, 0)},
-	{USB_VPI(USB_VENDOR_DLINK2, USB_PRODUCT_DLINK2_DWA111, 0)},
-	{USB_VPI(USB_VENDOR_DLINK2, USB_PRODUCT_DLINK2_DWA110, 0)},
-	{USB_VPI(USB_VENDOR_GIGABYTE, USB_PRODUCT_GIGABYTE_GNWB01GS, 0)},
-	{USB_VPI(USB_VENDOR_GIGABYTE, USB_PRODUCT_GIGABYTE_GNWI05GS, 0)},
-	{USB_VPI(USB_VENDOR_GIGASET, USB_PRODUCT_GIGASET_RT2573, 0)},
-	{USB_VPI(USB_VENDOR_GOODWAY, USB_PRODUCT_GOODWAY_RT2573, 0)},
-	{USB_VPI(USB_VENDOR_GUILLEMOT, USB_PRODUCT_GUILLEMOT_HWGUSB254LB, 0)},
-	{USB_VPI(USB_VENDOR_GUILLEMOT, USB_PRODUCT_GUILLEMOT_HWGUSB254V2AP, 0)},
-	{USB_VPI(USB_VENDOR_HUAWEI3COM, USB_PRODUCT_HUAWEI3COM_WUB320G, 0)},
-	{USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_G54HP, 0)},
-	{USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_SG54HP, 0)},
-	{USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_SG54HG, 0)},
-	{USB_VPI(USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_1, 0)},
-	{USB_VPI(USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_2, 0)},
-	{USB_VPI(USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_3, 0)},
-	{USB_VPI(USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_4, 0)},
-	{USB_VPI(USB_VENDOR_NOVATECH, USB_PRODUCT_NOVATECH_RT2573, 0)},
-	{USB_VPI(USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUS54HP, 0)},
-	{USB_VPI(USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUS54MINI2, 0)},
-	{USB_VPI(USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUSMM, 0)},
-	{USB_VPI(USB_VENDOR_QCOM, USB_PRODUCT_QCOM_RT2573, 0)},
-	{USB_VPI(USB_VENDOR_QCOM, USB_PRODUCT_QCOM_RT2573_2, 0)},
-	{USB_VPI(USB_VENDOR_RALINK, USB_PRODUCT_RALINK_RT2573, 0)},
-	{USB_VPI(USB_VENDOR_RALINK, USB_PRODUCT_RALINK_RT2573_2, 0)},
-	{USB_VPI(USB_VENDOR_RALINK, USB_PRODUCT_RALINK_RT2671, 0)},
-	{USB_VPI(USB_VENDOR_SITECOMEU, USB_PRODUCT_SITECOMEU_WL113R2, 0)},
-	{USB_VPI(USB_VENDOR_SITECOMEU, USB_PRODUCT_SITECOMEU_WL172, 0)},
-	{USB_VPI(USB_VENDOR_SPARKLAN, USB_PRODUCT_SPARKLAN_RT2573, 0)},
-	{USB_VPI(USB_VENDOR_SURECOM, USB_PRODUCT_SURECOM_RT2573, 0)},
+			    const uint8_t mac[IEEE80211_ADDR_LEN]);
+static void		rum_newassoc(struct ieee80211_node *, int);
+static void		rum_scan_start(struct ieee80211com *);
+static void		rum_scan_end(struct ieee80211com *);
+static void		rum_set_channel(struct ieee80211com *);
+static int		rum_get_rssi(struct rum_softc *, uint8_t);
+static void		rum_amrr_start(struct rum_softc *,
+			    struct ieee80211_node *);
+static void		rum_amrr_timeout(void *);
+static void		rum_queue_command(struct rum_softc *,
+			    usb2_proc_callback_t *, struct usb2_proc_msg *,
+			    struct usb2_proc_msg *);
+
+static const struct {
+	uint32_t	reg;
+	uint32_t	val;
+} rum_def_mac[] = {
+	{ RT2573_TXRX_CSR0,  0x025fb032 },
+	{ RT2573_TXRX_CSR1,  0x9eaa9eaf },
+	{ RT2573_TXRX_CSR2,  0x8a8b8c8d }, 
+	{ RT2573_TXRX_CSR3,  0x00858687 },
+	{ RT2573_TXRX_CSR7,  0x2e31353b },
+	{ RT2573_TXRX_CSR8,  0x2a2a2a2c },
+	{ RT2573_TXRX_CSR15, 0x0000000f },
+	{ RT2573_MAC_CSR6,   0x00000fff },
+	{ RT2573_MAC_CSR8,   0x016c030a },
+	{ RT2573_MAC_CSR10,  0x00000718 },
+	{ RT2573_MAC_CSR12,  0x00000004 },
+	{ RT2573_MAC_CSR13,  0x00007f00 },
+	{ RT2573_SEC_CSR0,   0x00000000 },
+	{ RT2573_SEC_CSR1,   0x00000000 },
+	{ RT2573_SEC_CSR5,   0x00000000 },
+	{ RT2573_PHY_CSR1,   0x000023b0 },
+	{ RT2573_PHY_CSR5,   0x00040a06 },
+	{ RT2573_PHY_CSR6,   0x00080606 },
+	{ RT2573_PHY_CSR7,   0x00000408 },
+	{ RT2573_AIFSN_CSR,  0x00002273 },
+	{ RT2573_CWMIN_CSR,  0x00002344 },
+	{ RT2573_CWMAX_CSR,  0x000034aa }
 };
 
-struct rum_def_mac {
-	uint32_t reg;
-	uint32_t val;
-};
-
-static const struct rum_def_mac rum_def_mac[] = {
-	{RT2573_TXRX_CSR0, 0x025fb032},
-	{RT2573_TXRX_CSR1, 0x9eaa9eaf},
-	{RT2573_TXRX_CSR2, 0x8a8b8c8d},
-	{RT2573_TXRX_CSR3, 0x00858687},
-	{RT2573_TXRX_CSR7, 0x2e31353b},
-	{RT2573_TXRX_CSR8, 0x2a2a2a2c},
-	{RT2573_TXRX_CSR15, 0x0000000f},
-	{RT2573_MAC_CSR6, 0x00000fff},
-	{RT2573_MAC_CSR8, 0x016c030a},
-	{RT2573_MAC_CSR10, 0x00000718},
-	{RT2573_MAC_CSR12, 0x00000004},
-	{RT2573_MAC_CSR13, 0x00007f00},
-	{RT2573_SEC_CSR0, 0x00000000},
-	{RT2573_SEC_CSR1, 0x00000000},
-	{RT2573_SEC_CSR5, 0x00000000},
-	{RT2573_PHY_CSR1, 0x000023b0},
-	{RT2573_PHY_CSR5, 0x00040a06},
-	{RT2573_PHY_CSR6, 0x00080606},
-	{RT2573_PHY_CSR7, 0x00000408},
-	{RT2573_AIFSN_CSR, 0x00002273},
-	{RT2573_CWMIN_CSR, 0x00002344},
-	{RT2573_CWMAX_CSR, 0x000034aa}
-};
-
-struct rum_def_bbp {
+static const struct {
 	uint8_t	reg;
 	uint8_t	val;
+} rum_def_bbp[] = {
+	{   3, 0x80 },
+	{  15, 0x30 },
+	{  17, 0x20 },
+	{  21, 0xc8 },
+	{  22, 0x38 },
+	{  23, 0x06 },
+	{  24, 0xfe },
+	{  25, 0x0a },
+	{  26, 0x0d },
+	{  32, 0x0b },
+	{  34, 0x12 },
+	{  37, 0x07 },
+	{  39, 0xf8 },
+	{  41, 0x60 },
+	{  53, 0x10 },
+	{  54, 0x18 },
+	{  60, 0x10 },
+	{  61, 0x04 },
+	{  62, 0x04 },
+	{  75, 0xfe },
+	{  86, 0xfe },
+	{  88, 0xfe },
+	{  90, 0x0f },
+	{  99, 0x00 },
+	{ 102, 0x16 },
+	{ 107, 0x04 }
 };
 
-static const struct rum_def_bbp rum_def_bbp[] = {
-	{3, 0x80},
-	{15, 0x30},
-	{17, 0x20},
-	{21, 0xc8},
-	{22, 0x38},
-	{23, 0x06},
-	{24, 0xfe},
-	{25, 0x0a},
-	{26, 0x0d},
-	{32, 0x0b},
-	{34, 0x12},
-	{37, 0x07},
-	{39, 0xf8},
-	{41, 0x60},
-	{53, 0x10},
-	{54, 0x18},
-	{60, 0x10},
-	{61, 0x04},
-	{62, 0x04},
-	{75, 0xfe},
-	{86, 0xfe},
-	{88, 0xfe},
-	{90, 0x0f},
-	{99, 0x00},
-	{102, 0x16},
-	{107, 0x04}
-};
-
-struct rfprog {
-	uint8_t	chan;
-	uint32_t r1, r2, r3, r4;
-};
-
-static const struct rfprog rum_rf5226[] = {
-	{1, 0x00b03, 0x001e1, 0x1a014, 0x30282},
-	{2, 0x00b03, 0x001e1, 0x1a014, 0x30287},
-	{3, 0x00b03, 0x001e2, 0x1a014, 0x30282},
-	{4, 0x00b03, 0x001e2, 0x1a014, 0x30287},
-	{5, 0x00b03, 0x001e3, 0x1a014, 0x30282},
-	{6, 0x00b03, 0x001e3, 0x1a014, 0x30287},
-	{7, 0x00b03, 0x001e4, 0x1a014, 0x30282},
-	{8, 0x00b03, 0x001e4, 0x1a014, 0x30287},
-	{9, 0x00b03, 0x001e5, 0x1a014, 0x30282},
-	{10, 0x00b03, 0x001e5, 0x1a014, 0x30287},
-	{11, 0x00b03, 0x001e6, 0x1a014, 0x30282},
-	{12, 0x00b03, 0x001e6, 0x1a014, 0x30287},
-	{13, 0x00b03, 0x001e7, 0x1a014, 0x30282},
-	{14, 0x00b03, 0x001e8, 0x1a014, 0x30284},
-
-	{34, 0x00b03, 0x20266, 0x36014, 0x30282},
-	{38, 0x00b03, 0x20267, 0x36014, 0x30284},
-	{42, 0x00b03, 0x20268, 0x36014, 0x30286},
-	{46, 0x00b03, 0x20269, 0x36014, 0x30288},
-
-	{36, 0x00b03, 0x00266, 0x26014, 0x30288},
-	{40, 0x00b03, 0x00268, 0x26014, 0x30280},
-	{44, 0x00b03, 0x00269, 0x26014, 0x30282},
-	{48, 0x00b03, 0x0026a, 0x26014, 0x30284},
-	{52, 0x00b03, 0x0026b, 0x26014, 0x30286},
-	{56, 0x00b03, 0x0026c, 0x26014, 0x30288},
-	{60, 0x00b03, 0x0026e, 0x26014, 0x30280},
-	{64, 0x00b03, 0x0026f, 0x26014, 0x30282},
-
-	{100, 0x00b03, 0x0028a, 0x2e014, 0x30280},
-	{104, 0x00b03, 0x0028b, 0x2e014, 0x30282},
-	{108, 0x00b03, 0x0028c, 0x2e014, 0x30284},
-	{112, 0x00b03, 0x0028d, 0x2e014, 0x30286},
-	{116, 0x00b03, 0x0028e, 0x2e014, 0x30288},
-	{120, 0x00b03, 0x002a0, 0x2e014, 0x30280},
-	{124, 0x00b03, 0x002a1, 0x2e014, 0x30282},
-	{128, 0x00b03, 0x002a2, 0x2e014, 0x30284},
-	{132, 0x00b03, 0x002a3, 0x2e014, 0x30286},
-	{136, 0x00b03, 0x002a4, 0x2e014, 0x30288},
-	{140, 0x00b03, 0x002a6, 0x2e014, 0x30280},
-
-	{149, 0x00b03, 0x002a8, 0x2e014, 0x30287},
-	{153, 0x00b03, 0x002a9, 0x2e014, 0x30289},
-	{157, 0x00b03, 0x002ab, 0x2e014, 0x30281},
-	{161, 0x00b03, 0x002ac, 0x2e014, 0x30283},
-	{165, 0x00b03, 0x002ad, 0x2e014, 0x30285}
-};
-
-static const struct rfprog rum_rf5225[] = {
-	{1, 0x00b33, 0x011e1, 0x1a014, 0x30282},
-	{2, 0x00b33, 0x011e1, 0x1a014, 0x30287},
-	{3, 0x00b33, 0x011e2, 0x1a014, 0x30282},
-	{4, 0x00b33, 0x011e2, 0x1a014, 0x30287},
-	{5, 0x00b33, 0x011e3, 0x1a014, 0x30282},
-	{6, 0x00b33, 0x011e3, 0x1a014, 0x30287},
-	{7, 0x00b33, 0x011e4, 0x1a014, 0x30282},
-	{8, 0x00b33, 0x011e4, 0x1a014, 0x30287},
-	{9, 0x00b33, 0x011e5, 0x1a014, 0x30282},
-	{10, 0x00b33, 0x011e5, 0x1a014, 0x30287},
-	{11, 0x00b33, 0x011e6, 0x1a014, 0x30282},
-	{12, 0x00b33, 0x011e6, 0x1a014, 0x30287},
-	{13, 0x00b33, 0x011e7, 0x1a014, 0x30282},
-	{14, 0x00b33, 0x011e8, 0x1a014, 0x30284},
-
-	{34, 0x00b33, 0x01266, 0x26014, 0x30282},
-	{38, 0x00b33, 0x01267, 0x26014, 0x30284},
-	{42, 0x00b33, 0x01268, 0x26014, 0x30286},
-	{46, 0x00b33, 0x01269, 0x26014, 0x30288},
-
-	{36, 0x00b33, 0x01266, 0x26014, 0x30288},
-	{40, 0x00b33, 0x01268, 0x26014, 0x30280},
-	{44, 0x00b33, 0x01269, 0x26014, 0x30282},
-	{48, 0x00b33, 0x0126a, 0x26014, 0x30284},
-	{52, 0x00b33, 0x0126b, 0x26014, 0x30286},
-	{56, 0x00b33, 0x0126c, 0x26014, 0x30288},
-	{60, 0x00b33, 0x0126e, 0x26014, 0x30280},
-	{64, 0x00b33, 0x0126f, 0x26014, 0x30282},
-
-	{100, 0x00b33, 0x0128a, 0x2e014, 0x30280},
-	{104, 0x00b33, 0x0128b, 0x2e014, 0x30282},
-	{108, 0x00b33, 0x0128c, 0x2e014, 0x30284},
-	{112, 0x00b33, 0x0128d, 0x2e014, 0x30286},
-	{116, 0x00b33, 0x0128e, 0x2e014, 0x30288},
-	{120, 0x00b33, 0x012a0, 0x2e014, 0x30280},
-	{124, 0x00b33, 0x012a1, 0x2e014, 0x30282},
-	{128, 0x00b33, 0x012a2, 0x2e014, 0x30284},
-	{132, 0x00b33, 0x012a3, 0x2e014, 0x30286},
-	{136, 0x00b33, 0x012a4, 0x2e014, 0x30288},
-	{140, 0x00b33, 0x012a6, 0x2e014, 0x30280},
-
-	{149, 0x00b33, 0x012a8, 0x2e014, 0x30287},
-	{153, 0x00b33, 0x012a9, 0x2e014, 0x30289},
-	{157, 0x00b33, 0x012ab, 0x2e014, 0x30281},
-	{161, 0x00b33, 0x012ac, 0x2e014, 0x30283},
-	{165, 0x00b33, 0x012ad, 0x2e014, 0x30285}
+static const struct rfprog {
+	uint8_t		chan;
+	uint32_t	r1, r2, r3, r4;
+}  rum_rf5226[] = {
+	{   1, 0x00b03, 0x001e1, 0x1a014, 0x30282 },
+	{   2, 0x00b03, 0x001e1, 0x1a014, 0x30287 },
+	{   3, 0x00b03, 0x001e2, 0x1a014, 0x30282 },
+	{   4, 0x00b03, 0x001e2, 0x1a014, 0x30287 },
+	{   5, 0x00b03, 0x001e3, 0x1a014, 0x30282 },
+	{   6, 0x00b03, 0x001e3, 0x1a014, 0x30287 },
+	{   7, 0x00b03, 0x001e4, 0x1a014, 0x30282 },
+	{   8, 0x00b03, 0x001e4, 0x1a014, 0x30287 },
+	{   9, 0x00b03, 0x001e5, 0x1a014, 0x30282 },
+	{  10, 0x00b03, 0x001e5, 0x1a014, 0x30287 },
+	{  11, 0x00b03, 0x001e6, 0x1a014, 0x30282 },
+	{  12, 0x00b03, 0x001e6, 0x1a014, 0x30287 },
+	{  13, 0x00b03, 0x001e7, 0x1a014, 0x30282 },
+	{  14, 0x00b03, 0x001e8, 0x1a014, 0x30284 },
+
+	{  34, 0x00b03, 0x20266, 0x36014, 0x30282 },
+	{  38, 0x00b03, 0x20267, 0x36014, 0x30284 },
+	{  42, 0x00b03, 0x20268, 0x36014, 0x30286 },
+	{  46, 0x00b03, 0x20269, 0x36014, 0x30288 },
+
+	{  36, 0x00b03, 0x00266, 0x26014, 0x30288 },
+	{  40, 0x00b03, 0x00268, 0x26014, 0x30280 },
+	{  44, 0x00b03, 0x00269, 0x26014, 0x30282 },
+	{  48, 0x00b03, 0x0026a, 0x26014, 0x30284 },
+	{  52, 0x00b03, 0x0026b, 0x26014, 0x30286 },
+	{  56, 0x00b03, 0x0026c, 0x26014, 0x30288 },
+	{  60, 0x00b03, 0x0026e, 0x26014, 0x30280 },
+	{  64, 0x00b03, 0x0026f, 0x26014, 0x30282 },
+
+	{ 100, 0x00b03, 0x0028a, 0x2e014, 0x30280 },
+	{ 104, 0x00b03, 0x0028b, 0x2e014, 0x30282 },
+	{ 108, 0x00b03, 0x0028c, 0x2e014, 0x30284 },
+	{ 112, 0x00b03, 0x0028d, 0x2e014, 0x30286 },
+	{ 116, 0x00b03, 0x0028e, 0x2e014, 0x30288 },
+	{ 120, 0x00b03, 0x002a0, 0x2e014, 0x30280 },
+	{ 124, 0x00b03, 0x002a1, 0x2e014, 0x30282 },
+	{ 128, 0x00b03, 0x002a2, 0x2e014, 0x30284 },
+	{ 132, 0x00b03, 0x002a3, 0x2e014, 0x30286 },
+	{ 136, 0x00b03, 0x002a4, 0x2e014, 0x30288 },
+	{ 140, 0x00b03, 0x002a6, 0x2e014, 0x30280 },
+
+	{ 149, 0x00b03, 0x002a8, 0x2e014, 0x30287 },
+	{ 153, 0x00b03, 0x002a9, 0x2e014, 0x30289 },
+	{ 157, 0x00b03, 0x002ab, 0x2e014, 0x30281 },
+	{ 161, 0x00b03, 0x002ac, 0x2e014, 0x30283 },
+	{ 165, 0x00b03, 0x002ad, 0x2e014, 0x30285 }
+}, rum_rf5225[] = {
+	{   1, 0x00b33, 0x011e1, 0x1a014, 0x30282 },
+	{   2, 0x00b33, 0x011e1, 0x1a014, 0x30287 },
+	{   3, 0x00b33, 0x011e2, 0x1a014, 0x30282 },
+	{   4, 0x00b33, 0x011e2, 0x1a014, 0x30287 },
+	{   5, 0x00b33, 0x011e3, 0x1a014, 0x30282 },
+	{   6, 0x00b33, 0x011e3, 0x1a014, 0x30287 },
+	{   7, 0x00b33, 0x011e4, 0x1a014, 0x30282 },
+	{   8, 0x00b33, 0x011e4, 0x1a014, 0x30287 },
+	{   9, 0x00b33, 0x011e5, 0x1a014, 0x30282 },
+	{  10, 0x00b33, 0x011e5, 0x1a014, 0x30287 },
+	{  11, 0x00b33, 0x011e6, 0x1a014, 0x30282 },
+	{  12, 0x00b33, 0x011e6, 0x1a014, 0x30287 },
+	{  13, 0x00b33, 0x011e7, 0x1a014, 0x30282 },
+	{  14, 0x00b33, 0x011e8, 0x1a014, 0x30284 },
+
+	{  34, 0x00b33, 0x01266, 0x26014, 0x30282 },
+	{  38, 0x00b33, 0x01267, 0x26014, 0x30284 },
+	{  42, 0x00b33, 0x01268, 0x26014, 0x30286 },
+	{  46, 0x00b33, 0x01269, 0x26014, 0x30288 },
+
+	{  36, 0x00b33, 0x01266, 0x26014, 0x30288 },
+	{  40, 0x00b33, 0x01268, 0x26014, 0x30280 },
+	{  44, 0x00b33, 0x01269, 0x26014, 0x30282 },
+	{  48, 0x00b33, 0x0126a, 0x26014, 0x30284 },
+	{  52, 0x00b33, 0x0126b, 0x26014, 0x30286 },
+	{  56, 0x00b33, 0x0126c, 0x26014, 0x30288 },
+	{  60, 0x00b33, 0x0126e, 0x26014, 0x30280 },
+	{  64, 0x00b33, 0x0126f, 0x26014, 0x30282 },
+
+	{ 100, 0x00b33, 0x0128a, 0x2e014, 0x30280 },
+	{ 104, 0x00b33, 0x0128b, 0x2e014, 0x30282 },
+	{ 108, 0x00b33, 0x0128c, 0x2e014, 0x30284 },
+	{ 112, 0x00b33, 0x0128d, 0x2e014, 0x30286 },
+	{ 116, 0x00b33, 0x0128e, 0x2e014, 0x30288 },
+	{ 120, 0x00b33, 0x012a0, 0x2e014, 0x30280 },
+	{ 124, 0x00b33, 0x012a1, 0x2e014, 0x30282 },
+	{ 128, 0x00b33, 0x012a2, 0x2e014, 0x30284 },
+	{ 132, 0x00b33, 0x012a3, 0x2e014, 0x30286 },
+	{ 136, 0x00b33, 0x012a4, 0x2e014, 0x30288 },
+	{ 140, 0x00b33, 0x012a6, 0x2e014, 0x30280 },
+
+	{ 149, 0x00b33, 0x012a8, 0x2e014, 0x30287 },
+	{ 153, 0x00b33, 0x012a9, 0x2e014, 0x30289 },
+	{ 157, 0x00b33, 0x012ab, 0x2e014, 0x30281 },
+	{ 161, 0x00b33, 0x012ac, 0x2e014, 0x30283 },
+	{ 165, 0x00b33, 0x012ad, 0x2e014, 0x30285 }
 };
 
 static const struct usb2_config rum_config[RUM_N_TRANSFER] = {
-	[RUM_BULK_DT_WR] = {
+	[RUM_BULK_WR] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
 		.mh.bufsize = (MCLBYTES + RT2573_TX_DESC_SIZE + 8),
 		.mh.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
-		.mh.callback = &rum_bulk_write_callback,
+		.mh.callback = rum_bulk_write_callback,
 		.mh.timeout = 5000,	/* ms */
 	},
-
-	[RUM_BULK_DT_RD] = {
+	[RUM_BULK_RD] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
 		.mh.bufsize = (MCLBYTES + RT2573_RX_DESC_SIZE),
 		.mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
-		.mh.callback = &rum_bulk_read_callback,
-	},
-
-	[RUM_BULK_CS_WR] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.callback = &rum_bulk_write_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
-	},
-
-	[RUM_BULK_CS_RD] = {
-		.type = UE_CONTROL,
-		.endpoint = 0x00,	/* Control pipe */
-		.direction = UE_DIR_ANY,
-		.mh.bufsize = sizeof(struct usb2_device_request),
-		.mh.callback = &rum_bulk_read_clear_stall_callback,
-		.mh.timeout = 1000,	/* 1 second */
-		.mh.interval = 50,	/* 50ms */
+		.mh.callback = rum_bulk_read_callback,
 	},
 };
 
-static devclass_t rum_devclass;
-
-static device_method_t rum_methods[] = {
-	DEVMETHOD(device_probe, rum_probe),
-	DEVMETHOD(device_attach, rum_attach),
-	DEVMETHOD(device_detach, rum_detach),
-	{0, 0}
-};
-
-static driver_t rum_driver = {
-	.name = "rum",
-	.methods = rum_methods,
-	.size = sizeof(struct rum_softc),
-};
-
-DRIVER_MODULE(rum, ushub, rum_driver, rum_devclass, NULL, 0);
-MODULE_DEPEND(rum, usb2_wlan, 1, 1, 1);
-MODULE_DEPEND(rum, usb2_core, 1, 1, 1);
-MODULE_DEPEND(rum, wlan, 1, 1, 1);
-MODULE_DEPEND(rum, wlan_amrr, 1, 1, 1);
-
 static int
-rum_probe(device_t dev)
+rum_match(device_t self)
 {
-	struct usb2_attach_arg *uaa = device_get_ivars(dev);
+	struct usb2_attach_arg *uaa = device_get_ivars(self);
 
-	if (uaa->usb2_mode != USB_MODE_HOST) {
+	if (uaa->usb2_mode != USB_MODE_HOST)
 		return (ENXIO);
-	}
-	if (uaa->info.bConfigIndex != 0) {
+	if (uaa->info.bConfigIndex != 0)
 		return (ENXIO);
-	}
-	if (uaa->info.bIfaceIndex != RT2573_IFACE_INDEX) {
+	if (uaa->info.bIfaceIndex != RT2573_IFACE_INDEX)
 		return (ENXIO);
-	}
+
 	return (usb2_lookup_id_by_uaa(rum_devs, sizeof(rum_devs), uaa));
 }
 
 static int
-rum_attach(device_t dev)
+rum_attach(device_t self)
 {
-	struct usb2_attach_arg *uaa = device_get_ivars(dev);
-	struct rum_softc *sc = device_get_softc(dev);
-	int error;
+	struct usb2_attach_arg *uaa = device_get_ivars(self);
+	struct rum_softc *sc = device_get_softc(self);
 	uint8_t iface_index;
+	int error;
 
-	device_set_usb2_desc(dev);
-
-	mtx_init(&sc->sc_mtx, "rum lock", MTX_NETWORK_LOCK,
-	    MTX_DEF | MTX_RECURSE);
-
-	snprintf(sc->sc_name, sizeof(sc->sc_name), "%s",
-	    device_get_nameunit(dev));
-
+	device_set_usb2_desc(self);
 	sc->sc_udev = uaa->device;
-	sc->sc_unit = device_get_unit(dev);
+	sc->sc_dev = self;
 
-	usb2_callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0);
+	mtx_init(&sc->sc_mtx, device_get_nameunit(self),
+	    MTX_NETWORK_LOCK, MTX_DEF);
 
 	iface_index = RT2573_IFACE_INDEX;
 	error = usb2_transfer_setup(uaa->device, &iface_index,
 	    sc->sc_xfer, rum_config, RUM_N_TRANSFER, sc, &sc->sc_mtx);
 	if (error) {
-		device_printf(dev, "could not allocate USB transfers, "
+		device_printf(self, "could not allocate USB transfers, "
 		    "err=%s\n", usb2_errstr(error));
 		goto detach;
 	}
-	error = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_mtx,
-	    &rum_end_of_commands,
-	    sizeof(struct usb2_config_td_cc), 24);
+	error = usb2_proc_create(&sc->sc_tq, &sc->sc_mtx,
+	    device_get_nameunit(self), USB_PRI_MED);
 	if (error) {
-		device_printf(dev, "could not setup config "
-		    "thread!\n");
+		device_printf(self, "could not setup config thread!\n");
 		goto detach;
 	}
-	mtx_lock(&sc->sc_mtx);
-
-	/* start setup */
-
-	usb2_config_td_queue_command
-	    (&sc->sc_config_td, NULL, &rum_cfg_first_time_setup, 0, 0);
 
-	rum_watchdog(sc);
-	mtx_unlock(&sc->sc_mtx);
-	return (0);			/* success */
+	/* fork rest of the attach code */
+	RUM_LOCK(sc);
+	rum_queue_command(sc, rum_attach_post,
+	    &sc->sc_synctask[0].hdr,
+	    &sc->sc_synctask[1].hdr);
+	RUM_UNLOCK(sc);
+	return (0);
 
 detach:
-	rum_detach(dev);
+	rum_detach(self);
 	return (ENXIO);			/* failure */
 }
 
-static int
-rum_detach(device_t dev)
+static void
+rum_attach_post(struct usb2_proc_msg *pm)
 {
-	struct rum_softc *sc = device_get_softc(dev);
-	struct ieee80211com *ic;
+	struct rum_task *task = (struct rum_task *)pm;
+	struct rum_softc *sc = task->sc;
 	struct ifnet *ifp;
+	struct ieee80211com *ic;
+	unsigned int ntries;
+	int error;
+	uint32_t tmp;
+	uint8_t bands;
 
-	usb2_config_td_drain(&sc->sc_config_td);
+	/* retrieve RT2573 rev. no */
+	for (ntries = 0; ntries != 1000; ntries++) {
+		if ((tmp = rum_read(sc, RT2573_MAC_CSR0)) != 0)
+			break;
+		usb2_pause_mtx(&sc->sc_mtx, hz / 1000);
+	}
+	if (ntries == 1000) {
+		device_printf(sc->sc_dev, "timeout waiting for chip to settle\n");
+		return;
+	}
 
-	mtx_lock(&sc->sc_mtx);
+	/* retrieve MAC address and various other things from EEPROM */
+	rum_read_eeprom(sc);
 
-	usb2_callout_stop(&sc->sc_watchdog);
+	device_printf(sc->sc_dev, "MAC/BBP RT2573 (rev 0x%05x), RF %s\n",
+	    tmp, rum_get_rf(sc->rf_rev));
 
-	rum_cfg_pre_stop(sc, NULL, 0);
+	error = rum_load_microcode(sc, rt2573_ucode, sizeof(rt2573_ucode));
+	if (error != 0) {
+		RUM_UNLOCK(sc);
+		device_printf(sc->sc_dev, "could not load 8051 microcode\n");
+		return;
+	}
+	RUM_UNLOCK(sc);
 
-	ifp = sc->sc_ifp;
+	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
+	if (ifp == NULL) {
+		device_printf(sc->sc_dev, "can not if_alloc()\n");
+		RUM_LOCK(sc);
+		return;
+	}
 	ic = ifp->if_l2com;
 
-	mtx_unlock(&sc->sc_mtx);
-
-	/* stop all USB transfers first */
-	usb2_transfer_unsetup(sc->sc_xfer, RUM_N_TRANSFER);
-
-	/* get rid of any late children */
-	bus_generic_detach(dev);
-
-	if (ifp) {
-		bpfdetach(ifp);
-		ieee80211_ifdetach(ic);
-		if_free(ifp);
-	}
-	usb2_config_td_unsetup(&sc->sc_config_td);
+	ifp->if_softc = sc;
+	if_initname(ifp, "rum", device_get_unit(sc->sc_dev));
+	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+	ifp->if_init = rum_init;
+	ifp->if_ioctl = rum_ioctl;
+	ifp->if_start = rum_start;
+	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
+	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
+	IFQ_SET_READY(&ifp->if_snd);
 
-	usb2_callout_drain(&sc->sc_watchdog);
+	ic->ic_ifp = ifp;
+	ic->ic_phytype = IEEE80211_T_OFDM;	/* not only, but not used */
+	IEEE80211_ADDR_COPY(ic->ic_myaddr, sc->sc_bssid);
 
-	mtx_destroy(&sc->sc_mtx);
+	/* set device capabilities */
+	ic->ic_caps =
+	      IEEE80211_C_STA		/* station mode supported */
+	    | IEEE80211_C_IBSS		/* IBSS mode supported */
+	    | IEEE80211_C_MONITOR	/* monitor mode supported */
+	    | IEEE80211_C_HOSTAP	/* HostAp mode supported */
+	    | IEEE80211_C_TXPMGT	/* tx power management */
+	    | IEEE80211_C_SHPREAMBLE	/* short preamble supported */
+	    | IEEE80211_C_SHSLOT	/* short slot time supported */
+	    | IEEE80211_C_BGSCAN	/* bg scanning supported */
+	    | IEEE80211_C_WPA		/* 802.11i */
+	    ;
 
-	return (0);
-}
+	bands = 0;
+	setbit(&bands, IEEE80211_MODE_11B);
+	setbit(&bands, IEEE80211_MODE_11G);
+	if (sc->rf_rev == RT2573_RF_5225 || sc->rf_rev == RT2573_RF_5226)
+		setbit(&bands, IEEE80211_MODE_11A);
+	ieee80211_init_channels(ic, NULL, &bands);
 
-static void
-rum_cfg_do_request(struct rum_softc *sc, struct usb2_device_request *req,
-    void *data)
-{
-	uint16_t length;
-	usb2_error_t err;
+	ieee80211_ifattach(ic);
+	ic->ic_newassoc = rum_newassoc;
+	ic->ic_raw_xmit = rum_raw_xmit;
+	ic->ic_node_alloc = rum_node_alloc;
+	ic->ic_scan_start = rum_scan_start;
+	ic->ic_scan_end = rum_scan_end;
+	ic->ic_set_channel = rum_set_channel;
 
-repeat:
+	ic->ic_vap_create = rum_vap_create;
+	ic->ic_vap_delete = rum_vap_delete;
 
-	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);
+	sc->sc_rates = ieee80211_get_ratetable(ic->ic_curchan);
 
-	if (err) {
+	bpfattach(ifp, DLT_IEEE802_11_RADIO,
+	    sizeof (struct ieee80211_frame) + sizeof(sc->sc_txtap));
 
-		DPRINTF("device request failed, err=%s "
-		    "(ignored)\n", usb2_errstr(err));
+	sc->sc_rxtap_len = sizeof sc->sc_rxtap;
+	sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
+	sc->sc_rxtap.wr_ihdr.it_present = htole32(RT2573_RX_RADIOTAP_PRESENT);
 
-		/* wait a little before next try */
-		if (usb2_config_td_sleep(&sc->sc_config_td, hz / 4)) {
-			goto error;
-		}
-		/* try until we are detached */
-		goto repeat;
+	sc->sc_txtap_len = sizeof sc->sc_txtap;
+	sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
+	sc->sc_txtap.wt_ihdr.it_present = htole32(RT2573_TX_RADIOTAP_PRESENT);
 
-error:
-		/* the device has been detached */
-		length = UGETW(req->wLength);
+	if (bootverbose)
+		ieee80211_announce(ic);
 
-		if ((req->bmRequestType & UT_READ) && length) {
-			bzero(data, length);
-		}
-	}
+	RUM_LOCK(sc);
 }
 
-static void
-rum_cfg_eeprom_read(struct rum_softc *sc, uint16_t addr, void *buf, uint16_t len)
+static int
+rum_detach(device_t self)
 {
-	struct usb2_device_request req;
+	struct rum_softc *sc = device_get_softc(self);
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
 
-	req.bmRequestType = UT_READ_VENDOR_DEVICE;
-	req.bRequest = RT2573_READ_EEPROM;
-	USETW(req.wValue, 0);
-	USETW(req.wIndex, addr);
-	USETW(req.wLength, len);
+	/* wait for any post attach or other command to complete */
+	usb2_proc_drain(&sc->sc_tq);
 
-	rum_cfg_do_request(sc, &req, buf);
-}
+	/* stop all USB transfers */
+	usb2_transfer_unsetup(sc->sc_xfer, RUM_N_TRANSFER);
+	usb2_proc_free(&sc->sc_tq);
 
-static uint16_t
-rum_cfg_eeprom_read_2(struct rum_softc *sc, uint16_t addr)
-{
-	uint16_t tmp;
+	/* free TX list, if any */
+	RUM_LOCK(sc);
+	rum_unsetup_tx_list(sc);
+	RUM_UNLOCK(sc);
 
-	rum_cfg_eeprom_read(sc, addr, &tmp, sizeof(tmp));
-	return (le16toh(tmp));
-}

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902092212.n19MClrY072910>