kernel: Remove (unhooked) acx(4), bwi(4), iwl(4) and rtw(4).
authorSascha Wildner <saw@online.de>
Mon, 9 Mar 2015 02:06:04 +0000 (03:06 +0100)
committerSascha Wildner <saw@online.de>
Mon, 9 Mar 2015 02:08:04 +0000 (03:08 +0100)
The first three were written by sephe and rtw(4) was ported from NetBSD
by him. They were all never ported to the newer wlan(4) upgrades we got,
starting with Rui Paulo's back in 2010.

Approved-by: sephe
55 files changed:
Makefile_upgrade.inc
share/man/man4/Makefile
share/man/man4/acx.4 [deleted file]
share/man/man4/bwi.4 [deleted file]
share/man/man4/bwn.4
share/man/man4/iwl.4 [deleted file]
share/man/man4/rtw.4 [deleted file]
share/man/man4/wlan.4
share/man/man4/wlan_amrr.4
sys/boot/dloader/loader-bootp.conf
sys/boot/dloader/loader.conf
sys/conf/files
sys/config/LINT
sys/config/LINT64
sys/dev/netif/Makefile
sys/dev/netif/acx/Makefile [deleted file]
sys/dev/netif/acx/_acxcmd.h [deleted file]
sys/dev/netif/acx/acx100.c [deleted file]
sys/dev/netif/acx/acx111.c [deleted file]
sys/dev/netif/acx/acxcmd.c [deleted file]
sys/dev/netif/acx/acxcmd.h [deleted file]
sys/dev/netif/acx/if_acx.c [deleted file]
sys/dev/netif/acx/if_acxreg.h [deleted file]
sys/dev/netif/acx/if_acxvar.h [deleted file]
sys/dev/netif/bwi/Makefile [deleted file]
sys/dev/netif/bwi/bwimac.c [deleted file]
sys/dev/netif/bwi/bwimac.h [deleted file]
sys/dev/netif/bwi/bwiphy.c [deleted file]
sys/dev/netif/bwi/bwiphy.h [deleted file]
sys/dev/netif/bwi/bwirf.c [deleted file]
sys/dev/netif/bwi/bwirf.h [deleted file]
sys/dev/netif/bwi/if_bwi.c [deleted file]
sys/dev/netif/bwi/if_bwireg.h [deleted file]
sys/dev/netif/bwi/if_bwivar.h [deleted file]
sys/dev/netif/iwl/Makefile [deleted file]
sys/dev/netif/iwl/if_iwl.c [deleted file]
sys/dev/netif/iwl/if_iwlreg.h [deleted file]
sys/dev/netif/iwl/if_iwlvar.h [deleted file]
sys/dev/netif/iwl/iwl2100.c [deleted file]
sys/dev/netif/iwl/iwl2100reg.h [deleted file]
sys/dev/netif/iwl/iwl2100var.h [deleted file]
sys/dev/netif/rtw/Makefile [deleted file]
sys/dev/netif/rtw/if_rtw_pci.c [deleted file]
sys/dev/netif/rtw/max2820reg.h [deleted file]
sys/dev/netif/rtw/rtw.c [deleted file]
sys/dev/netif/rtw/rtwphy.c [deleted file]
sys/dev/netif/rtw/rtwphy.h [deleted file]
sys/dev/netif/rtw/rtwphyio.c [deleted file]
sys/dev/netif/rtw/rtwphyio.h [deleted file]
sys/dev/netif/rtw/rtwreg.h [deleted file]
sys/dev/netif/rtw/rtwvar.h [deleted file]
sys/dev/netif/rtw/sa2400reg.h [deleted file]
sys/dev/netif/rtw/si4136reg.h [deleted file]
sys/dev/netif/rtw/smc93cx6.c [deleted file]
sys/dev/netif/rtw/smc93cx6var.h [deleted file]

index 492af71..7ab2f31 100644 (file)
@@ -2854,6 +2854,18 @@ TO_REMOVE+=/usr/share/man/man8/smrsh.8.gz
 TO_REMOVE+=/usr/share/sendmail
 TO_REMOVE+=/usr/share/libg++
 TO_REMOVE+=/etc/mail/helpfile
+TO_REMOVE+=/boot/kernel/if_acx.ko
+TO_REMOVE+=/usr/share/man/cat4/acx.4.gz
+TO_REMOVE+=/usr/share/man/man4/acx.4.gz
+TO_REMOVE+=/boot/kernel/if_bwi.ko
+TO_REMOVE+=/usr/share/man/cat4/bwi.4.gz
+TO_REMOVE+=/usr/share/man/man4/bwi.4.gz
+TO_REMOVE+=/boot/kernel/if_iwl.ko
+TO_REMOVE+=/usr/share/man/cat4/iwl.4.gz
+TO_REMOVE+=/usr/share/man/man4/iwl.4.gz
+TO_REMOVE+=/boot/kernel/if_rtw.ko
+TO_REMOVE+=/usr/share/man/cat4/rtw.4.gz
+TO_REMOVE+=/usr/share/man/man4/rtw.4.gz
 
 .if ${MACHINE_ARCH} == "x86_64"
 TO_REMOVE+=/usr/sbin/stlstats
@@ -2880,17 +2892,3 @@ TO_REMOVE+=/boot/kernel/ng_sync_sr.ko
 # XXX Remove when pfsync(4) has been fixed
 TO_REMOVE+=/usr/share/man/cat4/pfsync.4.gz
 TO_REMOVE+=/usr/share/man/man4/pfsync.4.gz
-
-# XXX Remove when adjusted to the new 802.11 framework
-TO_REMOVE+=/boot/kernel/if_acx.ko
-TO_REMOVE+=/usr/share/man/cat4/acx.4.gz
-TO_REMOVE+=/usr/share/man/man4/acx.4.gz
-TO_REMOVE+=/boot/kernel/if_bwi.ko
-TO_REMOVE+=/usr/share/man/cat4/bwi.4.gz
-TO_REMOVE+=/usr/share/man/man4/bwi.4.gz
-TO_REMOVE+=/boot/kernel/if_iwl.ko
-TO_REMOVE+=/usr/share/man/cat4/iwl.4.gz
-TO_REMOVE+=/usr/share/man/man4/iwl.4.gz
-TO_REMOVE+=/boot/kernel/if_rtw.ko
-TO_REMOVE+=/usr/share/man/cat4/rtw.4.gz
-TO_REMOVE+=/usr/share/man/man4/rtw.4.gz
index 6c7fd4e..e977e74 100644 (file)
@@ -403,14 +403,7 @@ MAN=       aac.4 \
 # XXX re-add when pfsync(4) has been fixed
 #      pfsync.4 \
 
-# XXX re-add when adjusted to the new 802.11 framework
-#      acx.4 \
-#      bwi.4 \
-#      iwl.4 \
-#      rtw.4 \
-
 MLINKS=        acpi_thermal.4 acpi_tz.4
-#MLINKS+=acx.4 if_acx.4
 MLINKS+=ae.4 if_ae.4
 MLINKS+=age.4 if_age.4
 MLINKS+=agp.4 agpgart.4
@@ -427,7 +420,6 @@ MLINKS+=bge.4 if_bge.4
 MLINKS+=bktr.4 brooktree.4
 MLINKS+=bnx.4 if_bnx.4
 MLINKS+=bridge.4 if_bridge.4
-#MLINKS+=bwi.4 if_bwi.4
 MLINKS+=bwn.4 if_bwn.4
 MLINKS+=crypto.4 cryptodev.4
 MLINKS+=cue.4 if_cue.4
@@ -459,7 +451,6 @@ MLINKS+=ipfirewall.4 ipaccounting.4 \
        ipfirewall.4 ipfw.4
 MLINKS+=ipheth.4 if_ipheth.4
 MLINKS+=iwi.4 if_iwi.4
-#MLINKS+=iwl.4 if_iwl.4
 MLINKS+=iwn.4 if_iwn.4
 MLINKS+=ix.4 if_ix.4 \
        ix.4 ixgbe.4 \
@@ -492,7 +483,6 @@ MLINKS+=ral.4 if_ral.4
 MLINKS+=random.4 urandom.4
 MLINKS+=re.4 if_re.4
 MLINKS+=rl.4 if_rl.4
-#MLINKS+=rtw.4 if_rtw.4
 #MLINKS+=rue.4 if_rue.4
 MLINKS+=rum.4 if_rum.4
 MLINKS+=run.4 if_run.4
diff --git a/share/man/man4/acx.4 b/share/man/man4/acx.4
deleted file mode 100644 (file)
index 2437a8e..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-.\"
-.\" Copyright (c) 2006 The DragonFly Project.  All rights reserved.
-.\" 
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in
-.\"    the documentation and/or other materials provided with the
-.\"    distribution.
-.\" 3. Neither the name of The DragonFly Project nor the names of its
-.\"    contributors may be used to endorse or promote products derived
-.\"    from this software without specific, prior written permission.
-.\" 
-.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
-.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
-.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.Dd November 28, 2014
-.Dt ACX 4
-.Os
-.Sh NAME
-.Nm acx
-.Nd Texas Instruments ACX100/ACX111 IEEE 802.11a/b/g wireless network driver
-.Sh SYNOPSIS
-To compile this driver into the kernel, place the following lines in
-your kernel configuration file:
-.Bd -ragged -offset indent
-.Cd "device acx"
-.Cd "device wlan"
-.Cd "device wlan_ratectl_onoe"
-.Cd "device wlan_ratectl_amrr"
-.Ed
-.Pp
-Alternatively, to load the driver as a module at boot time, place the
-following line in
-.Pa /boot/loader.conf :
-.Bd -literal -offset indent
-if_acx_load="YES"
-.Ed
-.Sh DESCRIPTION
-The
-.Nm
-driver provides support for Texas Instruments TNETW1100/TNETW1100B (ACX100)
-and TNETW1130 (ACX111) based PCI/CardBus network adapters.
-.Pp
-The ACX100A and ACX100B are first generation 802.11b devices
-from TI.
-The ACX111 is a second generation device which supports 802.11b/g
-and in some cases 802.11a.
-.Pp
-By default, the
-.Nm
-driver configures the adapter for BSS operation (infrastructure mode).
-This mode requires the use of an access point.
-In addition, IBSS operation (adhoc mode) is also supported.
-For more information on configuring this device, see
-.Xr ifconfig 8 .
-.Ss MIB Variables
-The following per-interface variables are implemented in the
-.Va dev.acx. Ns Em X
-branch of the
-.Xr sysctl 3
-MIB.
-.Bl -tag -width ".Va combined_radio_fw"
-.It Va msdu_lifetime
-MSDU life time.
-.It Va long_retry_limit
-Long retry limit.
-.It Va scan_dwell
-Channel dwell time during scanning (unit: milliseconds)
-.It Va combined_radio_fw
-The base and radio firmwares are combined in one image file.
-By default,
-it is set to 1 for ACX111 parts and 0 for ACX100A and ACX100B parts.
-.It Va free_fw
-Set to non-zero value to free the loaded firmwares.
-This does not affect a running device.
-Firmwares will be reloaded from
-.Pa /etc/firmware/acx
-when device is brought up next time.
-.El
-.Sh HARDWARE
-The following cards are among those supported by the
-.Nm
-driver:
-.Pp
-.Bl -column -compact "WESTELL A90-200WG-01" "ACX111" "CardBus" "a/b/g" -offset 6n
-.It Em Card Ta Em Chip Ta Em Bus Ta Em Standard
-.It "D-Link DWL-520+" Ta ACX100 Ta PCI Ta b
-.It "D-Link DWL-650+" Ta ACX100 Ta CardBus Ta b
-.It "D-Link DWL-G520+" Ta ACX111 Ta PCI Ta b/g
-.It "D-Link DWL-G630+" Ta ACX111 Ta CardBus Ta b/g
-.It "D-Link DWL-G650+" Ta ACX111 Ta CardBus Ta b/g
-.It "Ergenic ERG WL-003" Ta ACX100 Ta CardBus Ta b
-.It "Hamlet HNWP254" Ta ACX111 Ta CardBus Ta b/g
-.It "Hawking HWP54G" Ta ACX111 Ta PCI Ta b/g
-.It "Linksys WPC54Gv2" Ta ACX111 Ta CardBus Ta b/g
-.It "Microcom Travelcard" Ta ACX111 Ta CardBus Ta b/g
-.It "Netgear WG311v2" Ta ACX111 Ta PCI Ta b/g
-.It "Sceptre SC254W+" Ta ACX111 Ta CardBus Ta b/g
-.It "Tornado/ADT 211g" Ta ACX111 Ta PCI Ta b/g
-.It "USR USR5410" Ta ACX111 Ta CardBus Ta b/g
-.It "USR USR5416" Ta ACX111 Ta PCI Ta b/g
-.It "WESTELL A90-200WG-01" Ta ACX111 Ta CardBus Ta b/g
-.It "ZyXEL G-160" Ta ACX111 Ta CardBus Ta b/g
-.It "ZyXEL G-360 EE" Ta ACX111 Ta PCI Ta b/g
-.El
-.Sh FILES
-The firmware for the adapter is not shipped with
-.Dx
-and must be obtained separately.
-An archive with firmware files that are known to work can be found at:
-.Bd -literal -offset indent
-http://leaf.dragonflybsd.org/~sephe/acx/acx_fw.tbz
-.Ed
-.Pp
-The firmware files have to reside in
-.Pa /etc/firmware/acx
-and will be loaded when the interface is brought up.
-.Sh EXAMPLES
-Refer to the
-.Sx EXAMPLES
-section of
-.Xr wlan 4 .
-.Sh SEE ALSO
-.Xr arp 4 ,
-.Xr cardbus 4 ,
-.Xr ifmedia 4 ,
-.Xr pci 4 ,
-.Xr wlan 4 ,
-.Xr wlan_ratectl 4 ,
-.Xr hostapd 8 ,
-.Xr ifconfig 8 ,
-.Xr sysctl 8 ,
-.Xr wpa_supplicant 8
-.Sh HISTORY
-The
-.Nm
-driver first appeared in
-.Dx 1.5 .
-.Sh AUTHORS
-.An -nosplit
-The
-.Nm
-driver was written by
-.An Sepherosa Ziehau .
-The manual page was written by
-.An Sascha Wildner .
-Both are based on the
-.Pa http://wlan.kewl.org
-project team's original code.
-.Pp
-The hardware specification was reverse engineered by the good folks at
-.Pa http://acx100.sourceforge.net .
-Without them this driver would not have been possible.
diff --git a/share/man/man4/bwi.4 b/share/man/man4/bwi.4
deleted file mode 100644 (file)
index 221e0b6..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-.\"
-.\" Copyright (c) 2007 The DragonFly Project.  All rights reserved.
-.\" 
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in
-.\"    the documentation and/or other materials provided with the
-.\"    distribution.
-.\" 3. Neither the name of The DragonFly Project nor the names of its
-.\"    contributors may be used to endorse or promote products derived
-.\"    from this software without specific, prior written permission.
-.\" 
-.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
-.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
-.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.Dd November 28, 2014
-.Dt BWI 4
-.Os
-.Sh NAME
-.Nm bwi
-.Nd Broadcom BCM430x/4318 IEEE 802.11b/g wireless network driver
-.Sh SYNOPSIS
-To load the driver as a module at boot time, place the
-following line in
-.Pa /boot/loader.conf :
-.Bd -literal -offset indent
-if_bwi_load="YES"
-.Ed
-.Sh DESCRIPTION
-The
-.Nm
-driver provides support for Broadcom BCM430x/4318 wireless network adapters.
-For more information on configuring this device, see
-.Xr ifconfig 8 .
-.Ss MIB Variables
-The following per-interface variables are implemented in the
-.Va dev.bwi. Ns Em X
-branch of the
-.Xr sysctl 3
-MIB.
-.Bl -tag -width ".Va txpwr_calib"
-.It Va debug
-Debug flags.
-.It Va dwell_time
-Channel dwell time during scan (msec).
-.It Va fw_version
-Firmware version.
-.It Va led_idle
-Number of ticks before LED enters idle state.
-.It Va led_blink
-Allow LED to blink.
-.It Va txpwr_calib
-Enable software TX power calibration.
-.El
-.Sh HARDWARE
-The following cards are among those supported by the
-.Nm
-driver:
-.Pp
-.Bl -column -compact "Buffalo WLI-PCI-G54S" "BCM4318" "CardBus" "b/g" -offset 6n
-.It Em Card Ta Em Chip Ta Em Bus Ta Em Standard
-.It "Linksys WPC54Gv3" Ta BCM4318 Ta CardBus Ta b/g
-.It "Linksys WPC54GSv2" Ta BCM4318 Ta CardBus Ta b/g
-.It "Buffalo WLI-CB-G54S" Ta BCM4318 Ta CardBus Ta b/g
-.It "Buffalo WLI-PCI-G54S" Ta BCM4306 Ta PCI Ta b/g
-.It "Dell Wireless 1470" Ta BCM4318 Ta Mini PCI Ta b/g
-.It "Dell Truemobile 1400" Ta BCM4309 Ta Mini PCI Ta b/g
-.El
-.Sh FILES
-The firmware for the adapter is not shipped with
-.Dx
-and must be obtained separately.
-An archive with firmware files that are known to work can be found at:
-.Bd -literal -offset indent
-http://leaf.dragonflybsd.org/~sephe/bwi/v3.tbz
-.Ed
-.Pp
-The firmware files have to reside in
-.Pa /etc/firmware/bwi
-and will be loaded when the interface is brought up.
-.Sh EXAMPLES
-Refer to the
-.Sx EXAMPLES
-section of
-.Xr wlan 4 .
-.Sh SEE ALSO
-.Xr arp 4 ,
-.Xr cardbus 4 ,
-.Xr ifmedia 4 ,
-.Xr pci 4 ,
-.Xr wlan 4 ,
-.Xr wlan_ratectl 4 ,
-.Xr ifconfig 8 ,
-.Xr wpa_supplicant 8
-.Sh HISTORY
-The
-.Nm
-driver first appeared in
-.Dx 1.11 .
-.Sh AUTHORS
-.An -nosplit
-The
-.Nm
-driver was written by
-.An Sepherosa Ziehau .
-.Pp
-The hardware specification was reverse engineered by the people at
-.Pa http://bcm-specs.sipsolutions.net .
-Thanks go also to johill and mb on the #bcm-specs channel.
-.Sh BUGS
-BCM4306 and BCM4309 chips do not work properly on channel 1, 2 and 3.
index 4c37b52..770b41d 100644 (file)
@@ -88,12 +88,6 @@ driver supports Broadcom BCM43xx based wireless devices, including:
 .It "Linksys WPC54GS Ver 2     BCM4318 CardBus b/g"
 .It "US Robotics 5411  BCM4318 CardBus b/g"
 .El
-.\".Pp
-.\"Users of older Broadcom chipsets (BCM4301, BCM4303 and BCM4306 rev 2)
-.\"must use
-.\".Xr bwi 4
-.\"because the v4 version of the firmware does not support these chips.
-.\"The newer firmware is too big to fit into these old chips.
 .Sh EXAMPLES
 Join an existing BSS network (i.e., connect to an access point):
 .Bd -literal -offset indent
@@ -127,7 +121,6 @@ The default value is 1.
 .El
 .Sh SEE ALSO
 .Xr arp 4 ,
-.\".Xr bwi 4 ,
 .Xr cardbus 4 ,
 .Xr ifmedia 4 ,
 .Xr intro 4 ,
diff --git a/share/man/man4/iwl.4 b/share/man/man4/iwl.4
deleted file mode 100644 (file)
index d472410..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-.\"
-.\" Copyright (c) 2008
-.\"    The DragonFly Project.  All rights reserved.
-.\" 
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in
-.\"    the documentation and/or other materials provided with the
-.\"    distribution.
-.\" 3. Neither the name of The DragonFly Project nor the names of its
-.\"    contributors may be used to endorse or promote products derived
-.\"    from this software without specific, prior written permission.
-.\" 
-.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
-.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
-.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $DragonFly: src/share/man/man4/iwl.4,v 1.3 2008/07/26 16:25:40 swildner Exp $
-.\"
-.Dd July 26, 2008
-.Os
-.Dt IWL 4
-.Sh NAME
-.Nm iwl
-.Nd Intel(R) PRO/Wireless 2100 IEEE 802.11 driver
-.Sh SYNOPSIS
-To compile this driver into the kernel,
-place the following lines in your
-kernel configuration file:
-.Bd -ragged -offset indent
-.Cd "device iwl"
-.Ed
-.Pp
-Alternatively, to load the driver as a
-module at boot time, place the following line in
-.Xr loader.conf 5 :
-.Bd -literal -offset indent
-if_iwl_load="YES"
-.Ed
-.Sh DESCRIPTION
-The
-.Nm
-driver provides support for the Intel(R) PRO/Wireless 2100 MiniPCI network
-adapter.
-.Pp
-By default, the
-.Nm
-driver configures the adapter for BSS operation (aka infrastructure mode).
-This mode requires the use of an access point.
-.Pp
-For more information on configuring this device, see
-.Xr ifconfig 8 .
-.Sh FILES
-The firmware for the adapter is not shipped with
-.Dx
-and must be obtained separately.
-An archive with firmware files that are known to work can be found at:
-.Bd -literal -offset indent
-http://ipw2100.sourceforge.net/firmware.php?fid=4
-.Ed
-.Pp
-The firmware files have to reside in
-.Pa /etc/firmware/iwl/2100/1.3
-and will be loaded when the interface is brought up.
-.Sh EXAMPLES
-Refer to the
-.Sx EXAMPLES
-section of
-.Xr wlan 4 .
-.\".Sh DIAGNOSTICS
-.\".Bl -diag
-.\".It "iwl%d: device timeout"
-.\"The driver will reset the hardware. This should not happen.
-.\".El
-.Sh SEE ALSO
-.Xr arp 4 ,
-.Xr ifmedia 4 ,
-.Xr pci 4 ,
-.Xr wlan 4 ,
-.Xr ifconfig 8 ,
-.Xr wpa_supplicant 8
-.Sh HISTORY
-The
-.Nm
-first appeared in
-.Dx 1.13 .
-.Sh AUTHORS
-The
-.Nm
-driver was written by
-.An Sepherosa Ziehau .
diff --git a/share/man/man4/rtw.4 b/share/man/man4/rtw.4
deleted file mode 100644 (file)
index 4a3eb23..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-.\"    $NetBSD: rtw.4,v 1.3 2005/09/09 14:11:39 drochner Exp $
-.\"    $OpenBSD: rtw.4,v 1.18 2005/06/09 09:03:38 jmc Exp $
-.\"
-.\" Copyright (c) 2004 Jonathan Gray <jsg@openbsd.org>
-.\"
-.\" Permission to use, copy, modify, and distribute this software for any
-.\" purpose with or without fee is hereby granted, provided that the above
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\"
-.Dd July 26, 2008
-.Dt RTW 4
-.Os
-.Sh NAME
-.Nm rtw
-.Nd Realtek RTL8180L IEEE 802.11b wireless network driver
-.Sh SYNOPSIS
-To compile this driver into the kernel,
-place the following lines in your
-kernel configuration file:
-.Bd -ragged -offset indent
-.Cd "device rtw"
-.Cd "device wlan"
-.Cd "device wlan_wep"
-.Cd "device wlan_ratectl_onoe"
-.Ed
-.Pp
-Alternatively, to load the driver as a
-module at boot time, place the following line in
-.Xr loader.conf 5 :
-.Bd -literal -offset indent
-if_rtw_load="YES"
-.Ed
-.Sh DESCRIPTION
-The
-.Nm
-driver supports PCI/CardBus 802.11b wireless adapters based on the
-Realtek RTL8180L.
-.Pp
-A variety of radio transceivers can be found in these devices, including
-the Philips SA2400A, Maxim MAX2820, and GCT GRF5101, though not all of them
-are currently supported.
-.Pp
-These are the modes the
-.Nm
-driver can operate in:
-.Bl -tag -width "monitor mode"
-.It BSS mode
-Also known as
-.Em infrastructure
-mode, this is used when associating with an access point, through
-which all traffic passes.
-This mode is the default.
-.It IBSS mode
-Also known as
-.Em IEEE ad-hoc
-mode or
-.Em peer-to-peer
-mode.
-This is the standardized method of operating without an access point.
-Stations associate with a service set.
-However, actual connections between stations are peer-to-peer.
-.It Host AP
-In this mode the driver acts as an access point (base station)
-for other cards.
-.It monitor mode
-In this mode the driver is able to receive packets without
-associating with an access point.
-This disables the internal receive filter and enables the card to
-capture packets from networks which it wouldn't normally have access to,
-or to scan for access points.
-.El
-.Pp
-.Nm
-supports software WEP.
-Wired Equivalent Privacy (WEP) is the de facto encryption standard
-for wireless networks.
-It can be typically configured in one of three modes:
-no encryption; 40-bit encryption; or 104-bit encryption.
-Unfortunately, due to serious weaknesses in WEP protocol
-it is strongly recommended that it not be used as the
-sole mechanism to secure wireless communication.
-WEP is not enabled by default.
-.Sh CONFIGURATION
-The
-.Nm
-driver can be configured at runtime with
-.Xr ifconfig 8
-using the following parameters:
-.Bl -tag -width ".Fl mediaopt Ar opts"
-.It Cm bssid Ar bssid
-Set the desired BSSID.
-.It Fl bssid
-Unset the desired BSSID.
-The interface will automatically select a BSSID in this mode, which is
-the default.
-.It Cm chan Ar n
-Set the channel (radio frequency) to be used by the driver based on
-the given channel ID
-.Ar n .
-.It Fl chan
-Unset the desired channel to be used by the driver.
-The driver will automatically select a channel in this mode, which is
-the default.
-.It Cm media Ar media
-The
-.Nm
-driver supports the following
-.Ar media
-types:
-.Pp
-.Bl -tag -width ".Cm autoselect" -compact
-.It Cm autoselect
-Enable autoselection of the media type and options.
-.It Cm DS1
-Set 802.11b DS 1Mbps operation.
-.It Cm DS2
-Set 802.11b DS 2Mbps operation.
-.It Cm DS5
-Set 802.11b DS 5.5Mbps operation.
-.It Cm DS11
-Set 802.11b DS 11Mbps operation.
-.El
-.It Cm mediaopt Ar opts
-The
-.Nm
-driver supports the following media options:
-.Pp
-.Bl -tag -width ".Cm monitor" -compact
-.It Cm hostap
-Select Host AP operation.
-.It Cm ibss
-Select IBSS operation.
-.It Cm monitor
-Select monitor mode.
-.El
-.It Fl mediaopt Ar opts
-Disable the specified media options on the driver and return it to the
-default mode of operation (BSS).
-.It Cm ssid Ar id
-Set the network ID.
-The
-.Ar id
-can either be any text string up to 32 characters in length,
-or a series of hexadecimal digits up to 64 digits.
-An empty
-.Ar id
-string allows the interface to connect to any available access points.
-By default the
-.Nm
-driver uses an empty string.
-Note that network ID is synonymous with Extended Service Set ID (ESSID).
-.It Cm nwkey Ar key
-Enable WEP encryption using the specified
-.Ar key .
-The
-.Ar key
-can either be a string, a series of hexadecimal digits (preceded by
-.Sq 0x ) ,
-or a set of keys of the form
-.Dq n:k1,k2,k3,k4 ,
-where
-.Sq n
-specifies which of the keys will be used for transmitted packets,
-and the four keys,
-.Dq k1
-through
-.Dq k4 ,
-are configured as WEP keys.
-If a set of keys is specified, a comma
-.Pq Sq \&,
-within the key must be escaped with a backslash.
-Note that if multiple keys are used, their order must be the same within
-the network.
-.Nm
-is capable of using both 40-bit (5 characters or 10 hexadecimal digits)
-or 104-bit (13 characters or 26 hexadecimal digits) keys.
-.It Fl nwkey
-Disable WEP encryption.
-This is the default mode of operation.
-.It Cm nwkey persist
-Enable WEP encryption with the persistent key stored in the network card.
-.El
-.Sh HARDWARE
-The following adapters should work:
-.Pp
-.Bl -column -compact ".Li Ovislink AirLive WL-1120PCM" "CardBus"
-.It Em Card Ta Em Bus
-.\".It Li "Acer Aspire 1357 LMi" Ta Mini PCI
-.\".It Li "Belkin F5D6001 V3" Ta PCI
-.It Li "Belkin F5D6020 V3" Ta CardBus
-.It Li "Buffalo WLI-CB-B11" Ta CardBus
-.It Li "Corega CG-WLCB11V3" Ta CardBus
-.\".It Li "D-Link DWL-510" Ta PCI
-.\".It Li "D-Link DWL-520 rev D" Ta PCI
-.It Li "D-Link DWL-610" Ta CardBus
-.\".It Li "Encore ENLWI-PCI1-NT" Ta PCI
-.\".It Li "Gigabyte GN-WLMR101" Ta PCI
-.It Li "Level-One WPC-0101" Ta CardBus
-.It Li "Linksys WPC11 v4" Ta CardBus
-.It Li "Netgear MA521" Ta CardBus
-.It Li "Ovislink AirLive WL-1120PCM" Ta CardBus
-.It Li "Planet WL-3553" Ta CardBus
-.It Li "TrendNET TEW-266PC" Ta CardBus
-.\".It Li "TrendNET TEW-288PI" Ta PCI
-.It Li "VCTnet PC-11B1" Ta CardBus
-.El
-.Sh EXAMPLES
-Refer to the
-.Sx EXAMPLES
-section of
-.Xr wlan 4 .
-.Sh SEE ALSO
-.Xr arp 4 ,
-.Xr cardbus 4 ,
-.Xr ifmedia 4 ,
-.Xr intro 4 ,
-.Xr netintro 4 ,
-.Xr pci 4 ,
-.Xr wlan 4 ,
-.Xr wlan_ratectl 4 ,
-.Xr hostapd 8 ,
-.Xr ifconfig 8
-.Rs
-.%T Realtek
-.%O http://www.realtek.com.tw
-.Re
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Nx 3.0
-and then in
-.Ox 3.7 .
-It was imported into
-.Dx 1.7 .
-.Sh AUTHORS
-.An -nosplit
-The
-.Nm
-driver was written by
-.An David Young Aq Mt dyoung@NetBSD.org
-and ported to
-.Ox
-by
-.An Jonathan Gray Aq Mt jsg@openbsd.org ,
-who wrote this man page.
-The
-.Dx
-port was done by
-.An Sepherosa Ziehau Aq Mt sepherosa@gmail.com .
-.Sh BUGS
-Only the Philips SA2400A and Maxim MAX2820 RF transceivers are known to work.
-Devices incorporating a GCT RF transceiver are not supported due to a lack of
-documentation from GCT.
-.Pp
-While PCI devices will attach most of them are not able to transmit.
index 2276b24..102c51f 100644 (file)
@@ -228,19 +228,15 @@ Beware that this specification is incompatible with earlier drafts;
 and stations implementing earlier drafts (e.g. Linux)
 may not interoperate.
 .Sh SEE ALSO
-.\".Xr acx 4 ,
 .Xr an 4 ,
 .Xr ath 4 ,
-.\".Xr bwi 4 ,
 .Xr bwn 4 ,
 .\".Xr ipw 4 ,
 .Xr iwi 4 ,
-.\".Xr iwl 4 ,
 .Xr iwn 4 ,
 .\".Xr malo 4 ,
 .Xr netintro 4 ,
 .Xr ral 4 ,
-.\".Xr rtw 4 ,
 .Xr rum 4 ,
 .Xr run 4 ,
 .\".Xr uath 4 ,
index 723e59c..707f6f7 100644 (file)
@@ -39,7 +39,6 @@ The
 module implements the Adaptive Multi-Rate Retry tx rate control
 algorithm for use by 802.11 device drivers.
 .Sh SEE ALSO
-.\".Xr bwi 4 ,
 .Xr bwn 4 ,
 .Xr iwn 4 ,
 .Xr ral 4 ,
index 69c9c41..74b3230 100644 (file)
@@ -171,14 +171,12 @@ pf_load="NO"                      # OpenBSD's packet filter
 # be able to mount the root filesystem via NFS.
 
 miibus_load="NO"               # miibus support, needed for some drivers
-if_acx_load="NO"               # TI ACX100/ACX111 802.11 wireless NICs
 if_an_load="NO"                        # Aironet 4500/4800 802.11 wireless NICs
 if_ar_load="NO"                        # Digi SYNC/570i
 if_ath_load="NO"               # Atheros 802.11 wireless NICs
 if_bce_load="NO"               # Broadcom BCM5706/BCM5708 gigabit ethernet
 if_bfe_load="NO"               # Broadcom BCM4401 PCI ethernet
 if_bge_load="NO"               # Broadcom BCM570x PCI gigabit ethernet
-if_bwi_load="NO"               # Broadcom BCM430x/4318 IEEE 802.11b/g wireless
 if_dc_load="NO"                        # DEC/Intel 21143 and various workalikes
 if_ed_load="NO"                        # National Semiconductor DS8390/WD83C690 ethernet
 if_em_load="NO"                        # Intel(R) PRO/1000 gigabit ethernet
@@ -187,7 +185,6 @@ if_et_load="NO"                     # Agere ET1310 10/100/Gigabit ethernet
 if_fwe_load="NO"               # Ethernet emulation driver for FireWire
 if_fxp_load="NO"               # Intel EtherExpress PRO/100B (82557, 82558)
 if_iwi_load="NO"               # Intel(R) PRO/Wireless 2200BG/2915ABG MiniPCI
-if_iwl_load="NO"               # Intel(R) PRO/Wireless 2100 MiniPCI
 if_lge_load="NO"               # Level 1 LXT1001 NetCellerator PCI gigabit ethernet
 if_lnc_load="NO"               # AMD Lance/PCnet Ethernet
 if_msk_load="NO"               # Marvell/SysKonnect Yukon II Gigabit Ethernet
@@ -199,7 +196,6 @@ if_pcn_load="NO"            # AMD PCnet PCI
 if_ral_load="NO"               # Ralink Technology 802.11 wireless NICs
 if_re_load="NO"                        # RealTek 8139C+/8169/816xS/811xS/8101E
 if_rl_load="NO"                        # RealTek 8129/8139
-if_rtw_load="NO"               # Realtek RTL8180L IEEE 802.11b wireless NICs
 if_sbni_load="NO"              # Granch SBNI12 leased line adapters
 if_sbsh_load="NO"              # Granch SBNI16 SHDSL modem
 if_sf_load="NO"                        # Adaptec Duralink PCI (AIC-6915 "starfire")
index bae1eb5..8dd8512 100644 (file)
@@ -175,14 +175,12 @@ pf_load="NO"                      # OpenBSD's packet filter
 ##############################################################
 
 miibus_load="NO"               # miibus support, needed for some drivers
-if_acx_load="NO"               # TI ACX100/ACX111 802.11 wireless NICs
 if_an_load="NO"                        # Aironet 4500/4800 802.11 wireless NICs
 if_ar_load="NO"                        # Digi SYNC/570i
 if_ath_load="NO"               # Atheros 802.11 wireless NICs
 if_bce_load="NO"               # Broadcom BCM5706/BCM5708 gigabit ethernet
 if_bfe_load="NO"               # Broadcom BCM4401 PCI ethernet
 if_bge_load="NO"               # Broadcom BCM570x PCI gigabit ethernet
-if_bwi_load="NO"               # Broadcom BCM430x/4318 IEEE 802.11b/g wireless
 if_dc_load="NO"                        # DEC/Intel 21143 and various workalikes
 if_ed_load="NO"                        # National Semiconductor DS8390/WD83C690 ethernet
 if_em_load="NO"                        # Intel(R) PRO/1000 gigabit ethernet
@@ -191,7 +189,6 @@ if_et_load="NO"                     # Agere ET1310 10/100/Gigabit ethernet
 if_fwe_load="NO"               # Ethernet emulation driver for FireWire
 if_fxp_load="NO"               # Intel EtherExpress PRO/100B (82557, 82558)
 if_iwi_load="NO"               # Intel(R) PRO/Wireless 2200BG/2915ABG MiniPCI
-if_iwl_load="NO"               # Intel(R) PRO/Wireless 2100 MiniPCI
 if_lge_load="NO"               # Level 1 LXT1001 NetCellerator PCI gigabit ethernet
 if_lnc_load="NO"               # AMD Lance/PCnet Ethernet
 if_msk_load="NO"               # Marvell/SysKonnect Yukon II Gigabit Ethernet
@@ -203,7 +200,6 @@ if_pcn_load="NO"            # AMD PCnet PCI
 if_ral_load="NO"               # Ralink Technology 802.11 wireless NICs
 if_re_load="NO"                        # RealTek 8139C+/8169/816xS/811xS/8101E
 if_rl_load="NO"                        # RealTek 8129/8139
-if_rtw_load="NO"               # Realtek RTL8180L IEEE 802.11b wireless NICs
 if_sbni_load="NO"              # Granch SBNI12 leased line adapters
 if_sbsh_load="NO"              # Granch SBNI16 SHDSL modem
 if_sf_load="NO"                        # Adaptec Duralink PCI (AIC-6915 "starfire")
index 7ae0174..d2b8b18 100644 (file)
@@ -679,13 +679,7 @@ iwn6050.fw                 optional iwnfw                          \
        compile-with    "${NORMAL_FW}"                                  \
        no-obj no-implicit-rule                                         \
        clean           "iwn6050.fw"
-dev/netif/iwl/if_iwl.c optional iwl
-dev/netif/iwl/iwl2100.c        optional iwl
 dev/netif/jme/if_jme.c optional jme
-dev/netif/acx/if_acx.c optional acx
-dev/netif/acx/acxcmd.c optional acx
-dev/netif/acx/acx100.c optional acx
-dev/netif/acx/acx111.c optional acx
 dev/netif/ral/if_ral_pci.c     optional ral
 dev/netif/ral/rt2560.c         optional ral
 dev/netif/ral/rt2661.c         optional ral
@@ -959,11 +953,6 @@ wpi.fw                     optional wpifw                                  \
        compile-with    "${NORMAL_FW}"                                  \
        no-obj no-implicit-rule                                         \
        clean           "wpi.fw"
-dev/netif/rtw/rtw.c                    optional rtw
-dev/netif/rtw/rtwphy.c                 optional rtw
-dev/netif/rtw/rtwphyio.c               optional rtw
-dev/netif/rtw/smc93cx6.c               optional rtw
-dev/netif/rtw/if_rtw_pci.c             optional rtw pci
 dev/netif/xe/if_xe.c                   optional xe
 dev/netif/xe/if_xe_pccard.c            optional xe pccard
 gnu/vfs/ext2fs/ext2_alloc.c            optional ext2fs
index 535032c..1f6b691 100644 (file)
@@ -1307,13 +1307,10 @@ device          bwn             # Broadcom BCM43xx NICs using v4 firmware
 options                BWN_DEBUG       # turn on debugging output
 options                BWN_RXRING_SLOTS=128    # number of RX slots to allocate
 options                BWN_TXRING_SLOTS=128    # number of TX slots to allocate
-#device                iwl             # Intel PRO/Wireless 2100
 device         iwi             # Intel PRO/Wireless 2200BG/2915ABG
 device         iwn             # Intel WiFi Link 4965/1000/5000/5150/5300/6000/6050
 options                IWN_DEBUG       # turn on debugging output
 device         wi              # WaveLAN/IEEE, PRISM-II, Spectrum24 802.11DS
-#device                rtw             # RealTek 8180
-#device                acx             # TI ACX100/ACX111.
 device         xe              # Xircom PCMCIA
 device         ral             # Ralink Technology 802.11 wireless NIC
 device         wpi
index 57a4f6f..d610647 100644 (file)
@@ -1177,13 +1177,10 @@ device          bwn             # Broadcom BCM43xx NICs using v4 firmware
 options                BWN_DEBUG       # turn on debugging output
 options                BWN_RXRING_SLOTS=128    # number of RX slots to allocate
 options                BWN_TXRING_SLOTS=128    # number of TX slots to allocate
-#device                iwl             # Intel PRO/Wireless 2100
 device         iwi             # Intel PRO/Wireless 2200BG/2915ABG
 device         iwn             # Intel WiFi Link 4965/1000/5000/5150/5300/6000/6050
 options                IWN_DEBUG       # turn on debugging output
 device         wi              # WaveLAN/IEEE, PRISM-II, Spectrum24 802.11DS
-#device                rtw             # RealTek 8180
-#device                acx             # TI ACX100/ACX111.
 device         xe              # Xircom PCMCIA
 device         ral             # Ralink Technology 802.11 wireless NIC
 device         wpi
index d3ca2a7..7b94033 100644 (file)
@@ -9,8 +9,4 @@ SUBDIR= an age alc ale ath bce bfe bge bwn \
 SUBDIR+=ar ed sbni sr
 .endif
 
-# XXX need to be updated to the new net80211 stack
-# SUBDIR+= acx bwi iwl rtw
-# .endif
-
 .include <bsd.subdir.mk>
diff --git a/sys/dev/netif/acx/Makefile b/sys/dev/netif/acx/Makefile
deleted file mode 100644 (file)
index dfdedc8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-KMOD   = if_acx
-
-SRCS   = if_acx.c acxcmd.c acx100.c acx111.c
-SRCS   += device_if.h bus_if.h pci_if.h pcidevs.h
-
-.include <bsd.kmod.mk>
diff --git a/sys/dev/netif/acx/_acxcmd.h b/sys/dev/netif/acx/_acxcmd.h
deleted file mode 100644 (file)
index ed457e7..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * 
- * $DragonFly: src/sys/dev/netif/acx/_acxcmd.h,v 1.2 2008/06/06 10:47:14 sephe Exp $
- */
-
-#ifndef _X_ACXCMD_H
-#define _X_ACXCMD_H
-
-#define ACXCMD_GET_CONF                0x01
-#define ACXCMD_SET_CONF                0x02
-#define ACXCMD_ENABLE_RXCHAN   0x03
-#define ACXCMD_ENABLE_TXCHAN   0x04
-#define ACXCMD_TMPLT_TIM       0x0a
-#define ACXCMD_JOIN_BSS                0x0b
-#define ACXCMD_WEP_MGMT                0x0c    /* acx111 */
-#define ACXCMD_SLEEP           0x0f
-#define ACXCMD_WAKEUP          0x10
-#define ACXCMD_INIT_MEM                0x12    /* acx100 */
-#define ACXCMD_TMPLT_BEACON    0x13
-#define ACXCMD_TMPLT_PROBE_RESP        0x14
-#define ACXCMD_TMPLT_NULL_DATA 0x15
-#define ACXCMD_TMPLT_PROBE_REQ 0x16
-#define ACXCMD_INIT_RADIO      0x18
-#define ACXCMD_CALIBRATE       0x19    /* acx111 */
-
-#if 0
-/*
- * acx111 does not agree with acx100 about
- * the meaning of following values.  So they
- * are put into chip specific files.
- */
-#define ACX_CONF_FW_RING       0x0003
-#define ACX_CONF_MEMOPT                0x0005
-#endif
-#define ACX_CONF_MEMBLK_SIZE   0x0004  /* acx100 */
-#define ACX_CONF_RATE_FALLBACK 0x0006
-#define ACX_CONF_WEPOPT                0x0007  /* acx100 */
-#define ACX_CONF_MMAP          0x0008
-#define ACX_CONF_FWREV         0x000d
-#define ACX_CONF_RXOPT         0x0010
-#define ACX_CONF_OPTION                0x0015  /* acx111 */
-#define ACX_CONF_EADDR         0x1001
-#define ACX_CONF_NRETRY_SHORT  0x1005
-#define ACX_CONF_NRETRY_LONG   0x1006
-#define ACX_CONF_WEPKEY                0x1007  /* acx100 */
-#define ACX_CONF_MSDU_LIFETIME 0x1008
-#define ACX_CONF_REGDOM                0x100a
-#define ACX_CONF_ANTENNA       0x100b
-#define ACX_CONF_TXPOWER       0x100d  /* acx111 */
-#define ACX_CONF_CCA_MODE      0x100e
-#define ACX_CONF_ED_THRESH     0x100f
-#define ACX_CONF_WEP_TXKEY     0x1010
-
-#endif /* !_X_ACXCMD_H */
diff --git a/sys/dev/netif/acx/acx100.c b/sys/dev/netif/acx/acx100.c
deleted file mode 100644 (file)
index 464fbf4..0000000
+++ /dev/null
@@ -1,859 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/endian.h>
-#include <sys/rman.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-
-#include <netproto/802_11/ieee80211_var.h>
-#include <netproto/802_11/ieee80211_radiotap.h>
-#include <netproto/802_11/wlan_ratectl/amrr/ieee80211_amrr_param.h>
-#include <netproto/802_11/wlan_ratectl/onoe/ieee80211_onoe_param.h>
-
-#include <bus/pci/pcireg.h>
-
-#define ACX_DEBUG
-
-#include <dev/netif/acx/if_acxreg.h>
-#include <dev/netif/acx/if_acxvar.h>
-#include <dev/netif/acx/acxcmd.h>
-
-#define ACX100_CONF_FW_RING    0x0003
-#define ACX100_CONF_MEMOPT     0x0005
-
-#define ACX100_INTR_ENABLE     (ACXRV_INTR_TX_FINI | ACXRV_INTR_RX_FINI)
-/*
- * XXX do we really care about following interrupts?
- *
- * ACXRV_INTR_INFO | ACXRV_INTR_SCAN_FINI
- */
-
-#define ACX100_INTR_DISABLE    (uint16_t)~(ACXRV_INTR_UNKN)
-
-#define ACX100_RATE(rate)      ((rate) * 5)
-
-#define ACX100_RSSI_CORR       8
-#define ACX100_TXPOWER         18
-#define ACX100_GPIO_POWER_LED  0x0800
-#define ACX100_EE_EADDR_OFS    0x1a
-
-#define ACX100_FW_TXRING_SIZE  (ACX_TX_DESC_CNT * sizeof(struct acx_fw_txdesc))
-#define ACX100_FW_RXRING_SIZE  (ACX_RX_DESC_CNT * sizeof(struct acx_fw_rxdesc))
-
-/*
- * NOTE:
- * Following structs' fields are little endian
- */
-
-struct acx100_bss_join {
-       uint8_t dtim_intvl;
-       uint8_t basic_rates;
-       uint8_t op_rates;
-} __packed;
-
-struct acx100_conf_fw_ring {
-       struct acx_conf confcom;
-       uint32_t        fw_ring_size;   /* total size of fw (tx + rx) ring */
-       uint32_t        fw_rxring_addr; /* start phyaddr of fw rx desc */
-       uint8_t         opt;            /* see ACX100_RINGOPT_ */
-       uint8_t         fw_txring_num;  /* num of TX ring */
-       uint8_t         fw_rxdesc_num;  /* num of fw rx desc */
-       uint8_t         reserved0;
-       uint32_t        fw_ring_end[2]; /* see ACX100_SET_RING_END() */
-       uint32_t        fw_txring_addr; /* start phyaddr of fw tx desc */
-       uint8_t         fw_txring_prio; /* see ACX100_TXRING_PRIO_ */
-       uint8_t         fw_txdesc_num;  /* num of fw tx desc */
-       uint16_t        reserved1;
-} __packed;
-
-#define ACX100_RINGOPT_AUTO_RESET      0x1
-#define ACX100_TXRING_PRIO_DEFAULT     0
-#define ACX100_SET_RING_END(conf, end)                 \
-do {                                                   \
-       (conf)->fw_ring_end[0] = htole32(end);          \
-       (conf)->fw_ring_end[1] = htole32(end + 8);      \
-} while (0)
-
-struct acx100_conf_memblk_size {
-       struct acx_conf confcom;
-       uint16_t        memblk_size;    /* size of each mem block */
-} __packed;
-
-struct acx100_conf_mem {
-       struct acx_conf confcom;
-       uint32_t        opt;            /* see ACX100_MEMOPT_ */
-       uint32_t        h_rxring_paddr; /* host rx desc start phyaddr */
-
-       /*
-        * Memory blocks are controled by hardware
-        * once after they are initialized
-        */
-       uint32_t        rx_memblk_addr; /* start addr of rx mem blocks */
-       uint32_t        tx_memblk_addr; /* start addr of tx mem blocks */
-       uint16_t        rx_memblk_num;  /* num of RX mem block */
-       uint16_t        tx_memblk_num;  /* num of TX mem block */
-} __packed;
-
-#define ACX100_MEMOPT_MEM_INSTR                0x00000000 /* memory access instruct */
-#define ACX100_MEMOPT_HOSTDESC         0x00010000 /* host indirect desc */
-#define ACX100_MEMOPT_MEMBLOCK         0x00020000 /* local mem block list */
-#define ACX100_MEMOPT_IO_INSTR         0x00040000 /* IO instruct */
-#define ACX100_MEMOPT_PCICONF          0x00080000 /* PCI conf space */
-
-#define ACX100_MEMBLK_ALIGN            0x20
-
-struct acx100_conf_cca_mode {
-       struct acx_conf confcom;
-       uint8_t         cca_mode;
-       uint8_t         unknown;
-} __packed;
-
-struct acx100_conf_ed_thresh {
-       struct acx_conf confcom;
-       uint8_t         ed_thresh;
-       uint8_t         unknown[3];
-} __packed;
-
-struct acx100_conf_wepkey {
-       struct acx_conf confcom;
-       uint8_t         action; /* see ACX100_WEPKEY_ACT_ */
-       uint8_t         key_len;
-       uint8_t         key_idx;
-#define ACX100_WEPKEY_LEN      29
-       uint8_t         key[ACX100_WEPKEY_LEN];
-} __packed;
-
-#define ACX100_WEPKEY_ACT_ADD  1
-
-#define ACX100_CONF_FUNC(sg, name)     _ACX_CONF_FUNC(sg, name, 100)
-#define ACX_CONF_fw_ring               ACX100_CONF_FW_RING
-#define ACX_CONF_memblk_size           ACX_CONF_MEMBLK_SIZE
-#define ACX_CONF_mem                   ACX100_CONF_MEMOPT
-#define ACX_CONF_cca_mode              ACX_CONF_CCA_MODE
-#define ACX_CONF_ed_thresh             ACX_CONF_ED_THRESH
-#define ACX_CONF_wepkey                        ACX_CONF_WEPKEY
-ACX100_CONF_FUNC(set, fw_ring);
-ACX100_CONF_FUNC(set, memblk_size);
-ACX100_CONF_FUNC(set, mem);
-ACX100_CONF_FUNC(get, cca_mode);
-ACX100_CONF_FUNC(set, cca_mode);
-ACX100_CONF_FUNC(get, ed_thresh);
-ACX100_CONF_FUNC(set, ed_thresh);
-ACX100_CONF_FUNC(set, wepkey);
-
-#define ACXCMD_init_mem                        ACXCMD_INIT_MEM
-ACX_NOARG_FUNC(init_mem);
-
-static const uint16_t  acx100_reg[ACXREG_MAX] = {
-       ACXREG(SOFT_RESET,              0x0000),
-
-       ACXREG(FWMEM_ADDR,              0x0014),
-       ACXREG(FWMEM_DATA,              0x0018),
-       ACXREG(FWMEM_CTRL,              0x001c),
-       ACXREG(FWMEM_START,             0x0020),
-
-       ACXREG(EVENT_MASK,              0x0034),
-
-       ACXREG(INTR_TRIG,               0x007c),
-       ACXREG(INTR_MASK,               0x0098),
-       ACXREG(INTR_STATUS,             0x00a4),
-       ACXREG(INTR_STATUS_CLR,         0x00a8),
-       ACXREG(INTR_ACK,                0x00ac),
-
-       ACXREG(HINTR_TRIG,              0x00b0),
-       ACXREG(RADIO_ENABLE,            0x0104),
-
-       ACXREG(EEPROM_INIT,             0x02d0),
-       ACXREG(EEPROM_CTRL,             0x0250),
-       ACXREG(EEPROM_ADDR,             0x0254),
-       ACXREG(EEPROM_DATA,             0x0258),
-       ACXREG(EEPROM_CONF,             0x025c),
-       ACXREG(EEPROM_INFO,             0x02ac),
-
-       ACXREG(PHY_ADDR,                0x0268),
-       ACXREG(PHY_DATA,                0x026c),
-       ACXREG(PHY_CTRL,                0x0270),
-
-       ACXREG(GPIO_OUT_ENABLE,         0x0290),
-       ACXREG(GPIO_OUT,                0x0298),
-
-       ACXREG(CMD_REG_OFFSET,          0x02a4),
-       ACXREG(INFO_REG_OFFSET,         0x02a8),
-
-       ACXREG(RESET_SENSE,             0x02d4),
-       ACXREG(ECPU_CTRL,               0x02d8) 
-};
-
-static const uint8_t   acx100_txpower_maxim[21] = {
-       63, 63, 63, 62,
-       61, 61, 60, 60,
-       59, 58, 57, 55,
-       53, 50, 47, 43,
-       38, 31, 23, 13,
-       0
-};
-
-static const uint8_t   acx100_txpower_rfmd[21] = {
-        0,  0,  0,  1,
-        2,  2,  3,  3,
-        4,  5,  6,  8,
-       10, 13, 16, 20,
-       25, 32, 41, 50,
-       63
-};
-
-static const uint8_t   acx100_rate_map[45] = {
-       [2]     = 0x01,
-       [4]     = 0x02,
-       [11]    = 0x04,
-       [22]    = 0x08,
-       [44]    = 0x10
-};
-
-static int     acx100_init(struct acx_softc *);
-static int     acx100_init_wep(struct acx_softc *);
-static int     acx100_init_tmplt(struct acx_softc *);
-static int     acx100_init_fw_ring(struct acx_softc *);
-static int     acx100_init_memory(struct acx_softc *);
-
-static void    acx100_init_fw_txring(struct acx_softc *, uint32_t);
-static void    acx100_init_fw_rxring(struct acx_softc *, uint32_t);
-
-static int     acx100_read_config(struct acx_softc *, struct acx_config *);
-static int     acx100_write_config(struct acx_softc *, struct acx_config *);
-
-static void    *acx100_ratectl_attach(struct ieee80211com *, u_int);
-
-static int     acx100_set_txpower(struct acx_softc *);
-
-static uint8_t acx100_set_fw_txdesc_rate(struct acx_softc *,
-                                         struct acx_txbuf *,
-                                         struct ieee80211_node *, int);
-static void    acx100_tx_complete(struct acx_softc *, struct acx_txbuf *,
-                                  int, int);
-static void    acx100_set_bss_join_param(struct acx_softc *, void *, int);
-
-static int     acx100_set_wepkey(struct acx_softc *, struct ieee80211_key *,
-                                 int);
-
-static void    acx100_proc_wep_rxbuf(struct acx_softc *, struct mbuf *, int *);
-
-#define ACX100_CHK_RATE(ifp, rate, rate_idx)   \
-       acx100_check_rate(ifp, rate, rate_idx, __func__)
-
-static __inline int
-acx100_check_rate(struct ifnet *ifp, u_int rate, int rate_idx,
-                 const char *fname)
-{
-       if (rate >= NELEM(acx100_rate_map)) {
-               if_printf(ifp, "%s rate out of range %u (idx %d)\n",
-                         fname, rate, rate_idx);
-               return -1;
-       }
-
-       if (acx100_rate_map[rate] == 0) {
-               if_printf(ifp, "%s invalid rate %u (idx %d)\n",
-                         fname, rate, rate_idx);
-               return -1;
-       }
-       return 0;
-}
-
-void
-acx100_set_param(device_t dev)
-{
-       struct acx_softc *sc = device_get_softc(dev);
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct acx_firmware *fw = &sc->sc_firmware;
-
-       sc->chip_mem1_rid = PCIR_BAR(1);
-       sc->chip_mem2_rid = PCIR_BAR(2);
-       sc->chip_ioreg = acx100_reg;
-       sc->chip_hw_crypt = 1;
-       sc->chip_intr_enable = ACX100_INTR_ENABLE;
-       sc->chip_intr_disable = ACX100_INTR_DISABLE;
-       sc->chip_gpio_pled = ACX100_GPIO_POWER_LED;
-       sc->chip_ee_eaddr_ofs = ACX100_EE_EADDR_OFS;
-       sc->chip_txdesc1_len = ACX_FRAME_HDRLEN;
-       sc->chip_fw_txdesc_ctrl = DESC_CTRL_AUTODMA |
-                                 DESC_CTRL_RECLAIM |
-                                 DESC_CTRL_FIRST_FRAG;
-       sc->chip_short_retry_limit = 7;
-       sc->chip_rssi_corr = ACX100_RSSI_CORR;
-
-       sc->chip_phymode = IEEE80211_MODE_11B;
-       sc->chip_chan_flags = IEEE80211_CHAN_B;
-
-       ic->ic_phytype = IEEE80211_T_DS;
-       if (acx_enable_pbcc)
-               ic->ic_sup_rates[IEEE80211_MODE_11B] = acx_rates_11b_pbcc;
-       else
-               ic->ic_sup_rates[IEEE80211_MODE_11B] = acx_rates_11b;
-
-       IEEE80211_ONOE_PARAM_SETUP(&sc->sc_onoe_param);
-
-       ic->ic_ratectl.rc_st_ratectl_cap = IEEE80211_RATECTL_CAP_ONOE;
-       ic->ic_ratectl.rc_st_ratectl = IEEE80211_RATECTL_ONOE;
-       ic->ic_ratectl.rc_st_attach = acx100_ratectl_attach;
-
-       sc->chip_init = acx100_init;
-       sc->chip_set_wepkey = acx100_set_wepkey;
-       sc->chip_read_config = acx100_read_config;
-       sc->chip_write_config = acx100_write_config;
-       sc->chip_set_fw_txdesc_rate = acx100_set_fw_txdesc_rate;
-       sc->chip_tx_complete = acx100_tx_complete;
-       sc->chip_set_bss_join_param = acx100_set_bss_join_param;
-       sc->chip_proc_wep_rxbuf = acx100_proc_wep_rxbuf;
-
-       fw->combined_radio_fw = 0;
-       fw->fwdir = "100";
-}
-
-static int
-acx100_init(struct acx_softc *sc)
-{
-       /*
-        * NOTE:
-        * Order of initialization:
-        * 1) WEP
-        * 2) Templates
-        * 3) Firmware TX/RX ring
-        * 4) Hardware memory
-        * Above order is critical to get a correct memory map
-        */
-
-       if (acx100_init_wep(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't initialize wep\n",
-                         __func__);
-               return ENXIO;
-       }
-
-       if (acx100_init_tmplt(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't initialize templates\n",
-                         __func__);
-               return ENXIO;
-       }
-
-       if (acx100_init_fw_ring(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't initialize fw ring\n",
-                         __func__);
-               return ENXIO;
-       }
-
-       if (acx100_init_memory(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't initialize hw memory\n",
-                         __func__);
-               return ENXIO;
-       }
-       return 0;
-}
-
-static int
-acx100_init_wep(struct acx_softc *sc)
-{
-       struct acx_conf_wepopt wep_opt;
-       struct acx_conf_mmap mem_map;
-
-       /* Set WEP cache start/end address */
-       if (acx_get_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get mmap\n");
-               return 1;
-       }
-
-       mem_map.wep_cache_start = htole32(le32toh(mem_map.code_end) + 4);
-       mem_map.wep_cache_end = htole32(le32toh(mem_map.code_end) + 4);
-       if (acx_set_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set mmap\n");
-               return 1;
-       }
-
-       /* Set WEP options */
-       wep_opt.nkey = htole16(IEEE80211_WEP_NKID + 10);
-       wep_opt.opt = WEPOPT_HDWEP;
-       if (acx_set_wepopt_conf(sc, &wep_opt) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set wep opt\n");
-               return 1;
-       }
-       return 0;
-}
-
-static int
-acx100_init_tmplt(struct acx_softc *sc)
-{
-       struct acx_conf_mmap mem_map;
-
-       /* Set templates start address */
-       if (acx_get_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get mmap\n");
-               return 1;
-       }
-
-       mem_map.pkt_tmplt_start = mem_map.wep_cache_end;
-       if (acx_set_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set mmap\n");
-               return 1;
-       }
-
-       /* Initialize various packet templates */
-       if (acx_init_tmplt_ordered(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't init tmplt\n");
-               return 1;
-       }
-       return 0;
-}
-
-static int
-acx100_init_fw_ring(struct acx_softc *sc)
-{
-       struct acx100_conf_fw_ring ring;
-       struct acx_conf_mmap mem_map;
-       uint32_t txring_start, rxring_start, ring_end;
-
-       /* Set firmware descriptor ring start address */
-       if (acx_get_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get mmap\n");
-               return 1;
-       }
-
-       txring_start = le32toh(mem_map.pkt_tmplt_end) + 4;
-       rxring_start = txring_start + ACX100_FW_TXRING_SIZE;
-       ring_end = rxring_start + ACX100_FW_RXRING_SIZE;
-
-       mem_map.fw_desc_start = htole32(txring_start);
-       if (acx_set_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set mmap\n");
-               return 1;
-       }
-
-       /* Set firmware descriptor ring configure */
-       bzero(&ring, sizeof(ring));
-       ring.fw_ring_size = htole32(ACX100_FW_TXRING_SIZE +
-                                   ACX100_FW_RXRING_SIZE + 8);
-
-       ring.fw_txring_num = 1;
-       ring.fw_txring_addr = htole32(txring_start);
-       ring.fw_txring_prio = ACX100_TXRING_PRIO_DEFAULT;
-       ring.fw_txdesc_num = 0; /* XXX ignored?? */
-
-       ring.fw_rxring_addr = htole32(rxring_start);
-       ring.fw_rxdesc_num = 0; /* XXX ignored?? */
-
-       ring.opt = ACX100_RINGOPT_AUTO_RESET;
-       ACX100_SET_RING_END(&ring, ring_end);
-       if (acx100_set_fw_ring_conf(sc, &ring) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set fw ring configure\n");
-               return 1;
-       }
-
-       /* Setup firmware TX/RX descriptor ring */
-       acx100_init_fw_txring(sc, txring_start);
-       acx100_init_fw_rxring(sc, rxring_start);
-
-       return 0;
-}
-
-#define MEMBLK_ALIGN(addr)     \
-       (((addr) + (ACX100_MEMBLK_ALIGN - 1)) & ~(ACX100_MEMBLK_ALIGN - 1))
-
-static int
-acx100_init_memory(struct acx_softc *sc)
-{
-       struct acx100_conf_memblk_size memblk_sz;
-       struct acx100_conf_mem mem;
-       struct acx_conf_mmap mem_map;
-       uint32_t memblk_start, memblk_end;
-       int total_memblk, txblk_num, rxblk_num;
-
-       /* Set memory block start address */
-       if (acx_get_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get mmap\n");
-               return 1;
-       }
-
-       mem_map.memblk_start =
-               htole32(MEMBLK_ALIGN(le32toh(mem_map.fw_desc_end) + 4));
-
-       if (acx_set_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set mmap\n");
-               return 1;
-       }
-
-       /* Set memory block size */
-       memblk_sz.memblk_size = htole16(ACX_MEMBLOCK_SIZE);
-       if (acx100_set_memblk_size_conf(sc, &memblk_sz) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set mem block size\n");
-               return 1;
-       }
-
-       /* Get memory map after setting it */
-       if (acx_get_mmap_conf(sc, &mem_map) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get mmap again\n");
-               return 1;
-       }
-       memblk_start = le32toh(mem_map.memblk_start);
-       memblk_end = le32toh(mem_map.memblk_end);
-
-       /* Set memory options */
-       mem.opt = htole32(ACX100_MEMOPT_MEMBLOCK | ACX100_MEMOPT_HOSTDESC);
-       mem.h_rxring_paddr = htole32(sc->sc_ring_data.rx_ring_paddr);
-
-       total_memblk = (memblk_end - memblk_start) / ACX_MEMBLOCK_SIZE;
-
-       rxblk_num = total_memblk / 2;           /* 50% */
-       txblk_num = total_memblk - rxblk_num;   /* 50% */
-
-       DPRINTF((&sc->sc_ic.ic_if, "\ttotal memory blocks\t%d\n"
-                                  "\trx memory blocks\t%d\n"
-                                  "\ttx memory blocks\t%d\n",
-                                  total_memblk, rxblk_num, txblk_num));
-
-       mem.rx_memblk_num = htole16(rxblk_num);
-       mem.tx_memblk_num = htole16(txblk_num);
-
-       mem.rx_memblk_addr = htole32(MEMBLK_ALIGN(memblk_start));
-       mem.tx_memblk_addr =
-               htole32(MEMBLK_ALIGN(memblk_start +
-                                    (ACX_MEMBLOCK_SIZE * rxblk_num)));
-
-       if (acx100_set_mem_conf(sc, &mem) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set mem options\n");
-               return 1;
-       }
-
-       /* Initialize memory */
-       if (acx_init_mem(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't init mem\n");
-               return 1;
-       }
-       return 0;
-}
-
-#undef MEMBLK_ALIGN
-
-static void
-acx100_init_fw_txring(struct acx_softc *sc, uint32_t fw_txdesc_start)
-{
-       struct acx_fw_txdesc fw_desc;
-       struct acx_txbuf *tx_buf;
-       uint32_t desc_paddr, fw_desc_offset;
-       int i;
-
-       bzero(&fw_desc, sizeof(fw_desc));
-       fw_desc.f_tx_ctrl = DESC_CTRL_HOSTOWN |
-                           DESC_CTRL_RECLAIM |
-                           DESC_CTRL_AUTODMA |
-                           DESC_CTRL_FIRST_FRAG;
-
-       tx_buf = sc->sc_buf_data.tx_buf;
-       fw_desc_offset = fw_txdesc_start;
-       desc_paddr = sc->sc_ring_data.tx_ring_paddr;
-
-       for (i = 0; i < ACX_TX_DESC_CNT; ++i) {
-               fw_desc.f_tx_host_desc = htole32(desc_paddr);
-
-               if (i == ACX_TX_DESC_CNT - 1) {
-                       fw_desc.f_tx_next_desc = htole32(fw_txdesc_start);
-               } else {
-                       fw_desc.f_tx_next_desc =
-                               htole32(fw_desc_offset +
-                                       sizeof(struct acx_fw_txdesc));
-               }
-
-               tx_buf[i].tb_fwdesc_ofs = fw_desc_offset;
-               DESC_WRITE_REGION_1(sc, fw_desc_offset, &fw_desc,
-                                   sizeof(fw_desc));
-
-               desc_paddr += (2 * sizeof(struct acx_host_desc));
-               fw_desc_offset += sizeof(fw_desc);
-       }
-}
-
-static void
-acx100_init_fw_rxring(struct acx_softc *sc, uint32_t fw_rxdesc_start)
-{
-       struct acx_fw_rxdesc fw_desc;
-       uint32_t fw_desc_offset;
-       int i;
-
-       bzero(&fw_desc, sizeof(fw_desc));
-       fw_desc.f_rx_ctrl = DESC_CTRL_RECLAIM | DESC_CTRL_AUTODMA;
-
-       fw_desc_offset = fw_rxdesc_start;
-
-       for (i = 0; i < ACX_RX_DESC_CNT; ++i) {
-               if (i == ACX_RX_DESC_CNT - 1) {
-                       fw_desc.f_rx_next_desc = htole32(fw_rxdesc_start);
-               } else {
-                       fw_desc.f_rx_next_desc =
-                               htole32(fw_desc_offset +
-                                       sizeof(struct acx_fw_rxdesc));
-               }
-
-               DESC_WRITE_REGION_1(sc, fw_desc_offset, &fw_desc,
-                                   sizeof(fw_desc));
-
-               fw_desc_offset += sizeof(fw_desc);
-       }
-}
-
-static int
-acx100_read_config(struct acx_softc *sc, struct acx_config *conf)
-{
-       struct acx100_conf_cca_mode cca;
-       struct acx100_conf_ed_thresh ed;
-
-       /*
-        * NOTE:
-        * CCA mode and ED threshold MUST be read during initialization
-        * or the acx100 card won't work as expected
-        */
-
-       /* Get CCA mode */
-       if (acx100_get_cca_mode_conf(sc, &cca) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't get cca mode\n",
-                         __func__);
-               return ENXIO;
-       }
-       conf->cca_mode = cca.cca_mode;
-       DPRINTF((&sc->sc_ic.ic_if, "cca mode %02x\n", cca.cca_mode));
-
-       /* Get ED threshold */
-       if (acx100_get_ed_thresh_conf(sc, &ed) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't get ed threshold\n",
-                         __func__);
-               return ENXIO;
-       }
-       conf->ed_thresh = ed.ed_thresh;
-       DPRINTF((&sc->sc_ic.ic_if, "ed threshold %02x\n", ed.ed_thresh));
-
-       return 0;
-}
-
-static int
-acx100_write_config(struct acx_softc *sc, struct acx_config *conf)
-{
-       struct acx100_conf_cca_mode cca;
-       struct acx100_conf_ed_thresh ed;
-
-       /* Set CCA mode */
-       cca.cca_mode = conf->cca_mode;
-       if (acx100_set_cca_mode_conf(sc, &cca) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't set cca mode\n",
-                         __func__);
-               return ENXIO;
-       }
-
-       /* Set ED threshold */
-       ed.ed_thresh = conf->ed_thresh;
-       if (acx100_set_ed_thresh_conf(sc, &ed) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't set ed threshold\n",
-                         __func__);
-               return ENXIO;
-       }
-
-       /* Set TX power */
-       acx100_set_txpower(sc); /* ignore return value */
-
-       return 0;
-}
-
-static int
-acx100_set_txpower(struct acx_softc *sc)
-{
-       const uint8_t *map;
-
-       switch (sc->sc_radio_type) {
-       case ACX_RADIO_TYPE_MAXIM:
-               map = acx100_txpower_maxim;
-               break;
-       case ACX_RADIO_TYPE_RFMD:
-       case ACX_RADIO_TYPE_RALINK:
-               map = acx100_txpower_rfmd;
-               break;
-       default:
-               if_printf(&sc->sc_ic.ic_if, "TX power for radio type 0x%02x "
-                         "can't be set yet\n", sc->sc_radio_type);
-               return 1;
-       }
-
-       acx_write_phyreg(sc, ACXRV_PHYREG_TXPOWER, map[ACX100_TXPOWER]);
-       return 0;
-}
-
-static uint8_t
-acx100_set_fw_txdesc_rate(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                         struct ieee80211_node *ni, int data_len)
-{
-       int rate;
-
-       tx_buf->tb_rateidx_len = 1;
-       if (ni == NULL) {
-               rate = 2;       /* 1Mbit/s */
-               tx_buf->tb_rateidx[0] = 0;
-       } else {
-               ieee80211_ratectl_findrate(ni, data_len,
-                                          tx_buf->tb_rateidx, 1);
-               rate = IEEE80211_RS_RATE(&ni->ni_rates,
-                                        tx_buf->tb_rateidx[0]);
-               if (ACX100_CHK_RATE(&sc->sc_ic.ic_if, rate,
-                                   tx_buf->tb_rateidx[0]) < 0)
-                       rate = 2;
-       }
-       FW_TXDESC_SETFIELD_1(sc, tx_buf, f_tx_rate100, ACX100_RATE(rate));
-
-       return rate;
-}
-
-static void
-acx100_set_bss_join_param(struct acx_softc *sc, void *param, int dtim_intvl)
-{
-       struct acx100_bss_join *bj = param;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       const struct ieee80211_rateset *rs = &sc->sc_ic.ic_bss->ni_rates;
-       int i;
-
-       bj->basic_rates = 0;
-       bj->op_rates = 0;
-       for (i = 0; i < rs->rs_nrates; ++i) {
-               u_int map_idx = IEEE80211_RS_RATE(rs, i);
-               uint8_t rate;
-
-               if (ACX100_CHK_RATE(ifp, map_idx, i) < 0)
-                       continue;
-
-               rate = acx100_rate_map[map_idx];
-               if (rs->rs_rates[i] & IEEE80211_RATE_BASIC)
-                       bj->basic_rates |= rate;
-               bj->op_rates |= rate;
-       }
-       DPRINTF((ifp, "basic rates:0x%02x, op rates:0x%02x\n",
-                bj->basic_rates, bj->op_rates));
-
-       bj->dtim_intvl = dtim_intvl;
-}
-
-static int
-acx100_set_wepkey(struct acx_softc *sc, struct ieee80211_key *wk, int wk_idx)
-{
-       struct acx100_conf_wepkey conf_wk;
-
-       if (wk->wk_keylen > ACX100_WEPKEY_LEN) {
-               if_printf(&sc->sc_ic.ic_if, "%dth WEP key size beyond %d\n",
-                         wk_idx, ACX100_WEPKEY_LEN);
-               return EINVAL;
-       }
-
-       conf_wk.action = ACX100_WEPKEY_ACT_ADD;
-       conf_wk.key_len = wk->wk_keylen;
-       conf_wk.key_idx = wk_idx;
-       bcopy(wk->wk_key, conf_wk.key, wk->wk_keylen);
-       if (acx100_set_wepkey_conf(sc, &conf_wk) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s set %dth WEP key failed\n",
-                         __func__, wk_idx);
-               return ENXIO;
-       }
-       return 0;
-}
-
-static void
-acx100_proc_wep_rxbuf(struct acx_softc *sc, struct mbuf *m, int *len)
-{
-       int mac_hdrlen;
-       struct ieee80211_frame *f;
-
-       /*
-        * Strip leading IV and KID, and trailing CRC
-        */
-
-       f = mtod(m, struct ieee80211_frame *);
-
-       if ((f->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS)
-               mac_hdrlen = sizeof(struct ieee80211_frame_addr4);
-       else
-               mac_hdrlen = sizeof(struct ieee80211_frame);
-
-#define IEEEWEP_IVLEN  (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN)
-#define IEEEWEP_EXLEN  (IEEEWEP_IVLEN + IEEE80211_WEP_CRCLEN)
-
-       *len = *len - IEEEWEP_EXLEN;
-
-       /* Move MAC header toward frame body */
-       ovbcopy(f, (uint8_t *)f + IEEEWEP_IVLEN, mac_hdrlen);
-       m_adj(m, IEEEWEP_IVLEN);
-
-#undef IEEEWEP_EXLEN
-#undef IEEEWEP_IVLEN
-}
-
-static void
-acx100_tx_complete(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                  int frame_len, int is_fail)
-{
-       int rts_retries, data_retries;
-       struct ieee80211_ratectl_res rc_res;
-
-       rts_retries = FW_TXDESC_GETFIELD_1(sc, tx_buf, f_tx_rts_nretry);
-       data_retries = FW_TXDESC_GETFIELD_1(sc, tx_buf, f_tx_data_nretry);
-
-       rc_res.rc_res_rateidx = tx_buf->tb_rateidx[0];
-       rc_res.rc_res_tries = data_retries + 1;
-
-       ieee80211_ratectl_tx_complete(tx_buf->tb_node, frame_len,
-                                     &rc_res, 1, data_retries, rts_retries,
-                                     is_fail);
-}
-
-static void *
-acx100_ratectl_attach(struct ieee80211com *ic, u_int rc)
-{
-       struct acx_softc *sc = ic->ic_if.if_softc;
-
-       switch (rc) {
-       case IEEE80211_RATECTL_ONOE:
-               return &sc->sc_onoe_param;
-       case IEEE80211_RATECTL_NONE:
-               /* This could only happen during detaching */
-               return NULL;
-       default:
-               panic("unknown rate control algo %u", rc);
-               return NULL;
-       }
-}
diff --git a/sys/dev/netif/acx/acx111.c b/sys/dev/netif/acx/acx111.c
deleted file mode 100644 (file)
index 27eb594..0000000
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/endian.h>
-#include <sys/rman.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-
-#include <netproto/802_11/ieee80211_var.h>
-#include <netproto/802_11/ieee80211_radiotap.h>
-#include <netproto/802_11/wlan_ratectl/amrr/ieee80211_amrr_param.h>
-#include <netproto/802_11/wlan_ratectl/onoe/ieee80211_onoe_param.h>
-
-#include <bus/pci/pcireg.h>
-
-#define ACX_DEBUG
-
-#include <dev/netif/acx/if_acxreg.h>
-#include <dev/netif/acx/if_acxvar.h>
-#include <dev/netif/acx/acxcmd.h>
-
-#define ACX111_CONF_MEM                0x0003
-#define ACX111_CONF_MEMINFO    0x0005
-#define ACX111_CONF_RT0_NRETRY 0x0006
-
-#define ACX111_INTR_ENABLE     (ACXRV_INTR_TX_FINI | ACXRV_INTR_RX_FINI)
-/*
- * XXX do we really care about fowlling interrupts?
- *
- * ACXRV_INTR_IV_ICV_FAILURE | ACXRV_INTR_INFO |
- * ACXRV_INTR_SCAN_FINI | ACXRV_INTR_FCS_THRESHOLD
- */
-
-#define ACX111_INTR_DISABLE    (uint16_t)~(ACXRV_INTR_CMD_FINI)
-
-#define ACX111_RATE_2          0x0001
-#define ACX111_RATE_4          0x0002
-#define ACX111_RATE_11         0x0004
-#define ACX111_RATE_12         0x0008
-#define ACX111_RATE_18         0x0010
-#define ACX111_RATE_22         0x0020
-#define ACX111_RATE_24         0x0040
-#define ACX111_RATE_36         0x0080
-#define ACX111_RATE_44         0x0100
-#define ACX111_RATE_48         0x0200
-#define ACX111_RATE_72         0x0400
-#define ACX111_RATE_96         0x0800
-#define ACX111_RATE_108                0x1000
-#define ACX111_RATE(rate)      [rate] = ACX111_RATE_##rate
-
-#define ACX111_RSSI_CORR       5
-#define ACX111_TXPOWER         15
-#define ACX111_GPIO_POWER_LED  0x0040
-#define ACX111_EE_EADDR_OFS    0x21
-
-#define ACX111_FW_TXDESC_SIZE  (sizeof(struct acx_fw_txdesc) + 4)
-
-#if ACX111_TXPOWER <= 12
-#define ACX111_TXPOWER_VAL     1
-#else
-#define ACX111_TXPOWER_VAL     2
-#endif
-
-#define ACX111_ONOE_RATEIDX_MAX                4
-#define ACX111_AMRR_RATEIDX_MAX                4
-
-/*
- * NOTE:
- * Following structs' fields are little endian
- */
-
-struct acx111_bss_join {
-       uint16_t        basic_rates;
-       uint8_t         dtim_intvl;
-} __packed;
-
-struct acx111_calib {
-       uint32_t        calib;          /* ACX111_CALIB_ */
-       uint32_t        interval;       /* TU */
-} __packed;
-
-#define ACX111_CALIB_AUTO              0x80000000
-#define ACX111_CALIB_DC                        0x00000001
-#define ACX111_CALIB_AFE_DC            0x00000002
-#define ACX111_CALIB_TX_MISMATCH       0x00000004
-#define ACX111_CALIB_TX_EQUAL          0x00000008
-
-#define ACX111_FW_CALIB_INTVL          IEEE80211_MS_TO_TU(60000) /* 60sec */
-
-struct acx111_conf_mem {
-       struct acx_conf confcom;
-
-       uint16_t        sta_max;        /* max num of sta, ACX111_STA_MAX */
-       uint16_t        memblk_size;    /* mem block size */
-       uint8_t         rx_memblk_perc; /* percent of RX mem block, unit: 5% */
-       uint8_t         fw_rxring_num;  /* num of RX ring */
-       uint8_t         fw_txring_num;  /* num of TX ring */
-       uint8_t         opt;            /* see ACX111_MEMOPT_ */
-       uint8_t         xfer_perc;      /* frag/xfer proportion, unit: 5% */
-       uint16_t        reserved0;
-       uint8_t         reserved1;
-
-       uint8_t         fw_rxdesc_num;  /* num of fw rx desc */
-       uint8_t         fw_rxring_reserved1;
-       uint8_t         fw_rxring_type; /* see ACX111_RXRING_TYPE_ */
-       uint8_t         fw_rxring_prio; /* see ACX111_RXRING_PRIO_ */
-
-       uint32_t        h_rxring_paddr; /* host rx desc start phyaddr */
-
-       uint8_t         fw_txdesc_num;  /* num of fw tx desc */
-       uint8_t         fw_txring_reserved1;
-       uint8_t         fw_txring_reserved2;
-       uint8_t         fw_txring_attr; /* see ACX111_TXRING_ATTR_ */
-} __packed;
-
-/*
- * ACX111 does support limited multi-rate retry, following rules apply to
- * at least firmware rev1.2.x.x:
- * 1) Rate field in firmware descriptor is a bitmask, which indicates
- *    set of rates to be used to send the packet.
- * 2) "acx111_conf_rt0_nretry" configures the number of retries for
- *    1st rate.
- * 3) Except for the last rate and 1st rate, rest of the rates in the
- *    rate set are tried only once.
- * 4) Last rate will be tried until "short retry limit" + "long retry limit"
- *    reaches.
- *
- * e.g.
- * a) 54Mbit/s, 48Mbit/s and 1Mbit/s are in the rate set.
- * b) Number of retries for the 1st rate (i.e. 54Mbit/s) is set to 3.
- * c) Short retry limit is set to 7
- *
- * For the above configuration:
- * A) 4 tries will be spent at 54Mbit/s.
- * B) 1 try will be spent at 48Mbit/s, if A) fails.
- * C) 3 tries will be spent at 1Mbit/s, if A) and B) fail.
- */
-struct acx111_conf_rt0_nretry {
-       struct acx_conf confcom;
-       uint8_t         rt0_nretry;     /* number of retry for 1st rate */
-} __packed;
-
-#define ACX111_STA_MAX                 32
-#define ACX111_RX_MEMBLK_PERCENT       10      /* 50% */
-#define ACX111_XFER_PERCENT            15      /* 75% */
-#define ACX111_RXRING_TYPE_DEFAULT     7
-#define ACX111_RXRING_PRIO_DEFAULT     0
-#define ACX111_TXRING_ATTR_DEFAULT     0
-#define ACX111_MEMOPT_DEFAULT          0
-
-struct acx111_conf_meminfo {
-       struct acx_conf confcom;
-       uint32_t        tx_memblk_addr; /* start addr of tx mem blocks */
-       uint32_t        rx_memblk_addr; /* start addr of rx mem blocks */
-       uint32_t        fw_rxring_start; /* start phyaddr of fw rx ring */
-       uint32_t        reserved0;
-       uint32_t        fw_txring_start; /* start phyaddr of fw tx ring */
-       uint8_t         fw_txring_attr; /* XXX see ACX111_TXRING_ATTR_ */
-       uint16_t        reserved1;
-       uint8_t         reserved2;
-} __packed;
-
-struct acx111_conf_txpower {
-       struct acx_conf confcom;
-       uint8_t         txpower;
-} __packed;
-
-struct acx111_conf_option {
-       struct acx_conf confcom;
-       uint32_t        feature;
-       uint32_t        dataflow;       /* see ACX111_DF_ */
-} __packed;
-
-#define ACX111_DF_NO_RXDECRYPT 0x00000080
-#define ACX111_DF_NO_TXENCRYPT 0x00000001
-
-struct acx111_wepkey {
-       uint8_t         mac_addr[IEEE80211_ADDR_LEN];
-       uint16_t        action;         /* see ACX111_WEPKEY_ACT_ */
-       uint16_t        reserved;
-       uint8_t         key_len;
-       uint8_t         key_type;       /* see ACX111_WEPKEY_TYPE_ */
-       uint8_t         index;          /* XXX ?? */
-       uint8_t         key_idx;
-       uint8_t         counter[6];
-#define ACX111_WEPKEY_LEN      32
-       uint8_t         key[ACX111_WEPKEY_LEN];
-} __packed;
-
-#define ACX111_WEPKEY_ACT_ADD          1
-#define ACX111_WEPKEY_TYPE_DEFAULT     0
-
-#define ACX111_CONF_FUNC(sg, name)     _ACX_CONF_FUNC(sg, name, 111)
-#define ACX_CONF_mem                   ACX111_CONF_MEM
-#define ACX_CONF_meminfo               ACX111_CONF_MEMINFO
-#define ACX_CONF_rt0_nretry            ACX111_CONF_RT0_NRETRY
-#define ACX_CONF_txpower               ACX_CONF_TXPOWER
-#define ACX_CONF_option                        ACX_CONF_OPTION
-ACX111_CONF_FUNC(set, mem);
-ACX111_CONF_FUNC(get, meminfo);
-ACX111_CONF_FUNC(set, txpower);
-ACX111_CONF_FUNC(get, option);
-ACX111_CONF_FUNC(set, option);
-ACX111_CONF_FUNC(set, rt0_nretry);
-
-static const uint16_t acx111_reg[ACXREG_MAX] = {
-       ACXREG(SOFT_RESET,              0x0000),
-
-       ACXREG(FWMEM_ADDR,              0x0014),
-       ACXREG(FWMEM_DATA,              0x0018),
-       ACXREG(FWMEM_CTRL,              0x001c),
-       ACXREG(FWMEM_START,             0x0020),
-
-       ACXREG(EVENT_MASK,              0x0034),
-
-       ACXREG(INTR_TRIG,               0x00b4),
-       ACXREG(INTR_MASK,               0x00d4),
-       ACXREG(INTR_STATUS,             0x00f0),
-       ACXREG(INTR_STATUS_CLR,         0x00e4),
-       ACXREG(INTR_ACK,                0x00e8),
-
-       ACXREG(HINTR_TRIG,              0x00ec),
-       ACXREG(RADIO_ENABLE,            0x01d0),
-
-       ACXREG(EEPROM_INIT,             0x0100),
-       ACXREG(EEPROM_CTRL,             0x0338),
-       ACXREG(EEPROM_ADDR,             0x033c),
-       ACXREG(EEPROM_DATA,             0x0340),
-       ACXREG(EEPROM_CONF,             0x0344),
-       ACXREG(EEPROM_INFO,             0x0390),
-
-       ACXREG(PHY_ADDR,                0x0350),
-       ACXREG(PHY_DATA,                0x0354),
-       ACXREG(PHY_CTRL,                0x0358),
-
-       ACXREG(GPIO_OUT_ENABLE,         0x0374),
-       ACXREG(GPIO_OUT,                0x037c),
-
-       ACXREG(CMD_REG_OFFSET,          0x0388),
-       ACXREG(INFO_REG_OFFSET,         0x038c),
-
-       ACXREG(RESET_SENSE,             0x0104),
-       ACXREG(ECPU_CTRL,               0x0108) 
-};
-
-static const uint16_t  acx111_rate_map[109] = {
-       ACX111_RATE(2),
-       ACX111_RATE(4),
-       ACX111_RATE(11),
-       ACX111_RATE(22),
-       ACX111_RATE(12),
-       ACX111_RATE(18),
-       ACX111_RATE(24),
-       ACX111_RATE(36),
-       ACX111_RATE(44),
-       ACX111_RATE(48),
-       ACX111_RATE(72),
-       ACX111_RATE(96),
-       ACX111_RATE(108)
-};
-
-static const int
-acx111_onoe_tries[IEEE80211_RATEIDX_MAX] = { 4, 1, 1, 3, 0 };
-
-static const int
-acx111_amrr_tries[IEEE80211_RATEIDX_MAX] = { 4, 1, 1, 3, 0 };
-
-static int     acx111_init(struct acx_softc *);
-static int     acx111_init_memory(struct acx_softc *);
-static void    acx111_init_fw_txring(struct acx_softc *, uint32_t);
-
-static int     acx111_write_config(struct acx_softc *, struct acx_config *);
-
-static void    acx111_set_bss_join_param(struct acx_softc *, void *, int);
-static int     acx111_calibrate(struct acx_softc *);
-
-static void    *acx111_ratectl_attach(struct ieee80211com *, u_int);
-
-static uint8_t _acx111_set_fw_txdesc_rate(struct acx_softc *,
-                                          struct acx_txbuf *,
-                                          struct ieee80211_node *, int, int);
-static uint8_t acx111_set_fw_txdesc_rate_onoe(struct acx_softc *,
-                                              struct acx_txbuf *,
-                                              struct ieee80211_node *, int);
-static uint8_t acx111_set_fw_txdesc_rate_amrr(struct acx_softc *,
-                                              struct acx_txbuf *,
-                                              struct ieee80211_node *, int);
-
-static void    _acx111_tx_complete(struct acx_softc *, struct acx_txbuf *,
-                                   int, int, const int[]);
-static void    acx111_tx_complete_onoe(struct acx_softc *, struct acx_txbuf *,
-                                       int, int);
-static void    acx111_tx_complete_amrr(struct acx_softc *, struct acx_txbuf *,
-                                       int, int);
-
-#define ACX111_CHK_RATE(ifp, rate, rate_idx)   \
-       acx111_check_rate(ifp, rate, rate_idx, __func__)
-
-static __inline int
-acx111_check_rate(struct ifnet *ifp, u_int rate, int rate_idx,
-                 const char *fname)
-{
-       if (rate >= NELEM(acx111_rate_map)) {
-               if_printf(ifp, "%s rate out of range %u (idx %d)\n",
-                         fname, rate, rate_idx);
-               return -1;
-       }
-
-       if (acx111_rate_map[rate] == 0) {
-               if_printf(ifp, "%s invalid rate %u (idx %d)\n",
-                         fname, rate, rate_idx);
-               return -1;
-       }
-       return 0;
-}
-
-void
-acx111_set_param(device_t dev)
-{
-       struct acx_softc *sc = device_get_softc(dev);
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct acx_firmware *fw = &sc->sc_firmware;
-
-       sc->chip_mem1_rid = PCIR_BAR(0);
-       sc->chip_mem2_rid = PCIR_BAR(1);
-       sc->chip_ioreg = acx111_reg;
-       sc->chip_intr_enable = ACX111_INTR_ENABLE;
-       sc->chip_intr_disable = ACX111_INTR_DISABLE;
-       sc->chip_gpio_pled = ACX111_GPIO_POWER_LED;
-       sc->chip_ee_eaddr_ofs = ACX111_EE_EADDR_OFS;
-       sc->chip_rssi_corr = ACX111_RSSI_CORR;
-       sc->chip_calibrate = acx111_calibrate;
-
-       sc->chip_phymode = IEEE80211_MODE_11G;
-       sc->chip_chan_flags = IEEE80211_CHAN_CCK |
-                             IEEE80211_CHAN_OFDM |
-                             IEEE80211_CHAN_DYN |
-                             IEEE80211_CHAN_2GHZ;
-
-       ic->ic_caps = IEEE80211_C_WPA | IEEE80211_C_SHSLOT;
-       ic->ic_phytype = IEEE80211_T_OFDM;
-       if (acx_enable_pbcc) {
-               ic->ic_sup_rates[IEEE80211_MODE_11B] = acx_rates_11b_pbcc;
-               ic->ic_sup_rates[IEEE80211_MODE_11G] = acx_rates_11g_pbcc;
-       } else {
-               ic->ic_sup_rates[IEEE80211_MODE_11B] = acx_rates_11b;
-               ic->ic_sup_rates[IEEE80211_MODE_11G] = acx_rates_11g;
-       }
-
-       IEEE80211_ONOE_PARAM_SETUP(&sc->sc_onoe_param);
-       IEEE80211_AMRR_PARAM_SETUP(&sc->sc_amrr_param);
-
-       ic->ic_ratectl.rc_st_ratectl_cap = IEEE80211_RATECTL_CAP_ONOE |
-                                          IEEE80211_RATECTL_CAP_AMRR;
-       ic->ic_ratectl.rc_st_ratectl = IEEE80211_RATECTL_AMRR;
-       ic->ic_ratectl.rc_st_attach = acx111_ratectl_attach;
-
-       sc->chip_init = acx111_init;
-       sc->chip_write_config = acx111_write_config;
-       sc->chip_set_bss_join_param = acx111_set_bss_join_param;
-
-       fw->combined_radio_fw = 1;
-       fw->fwdir = "111";
-}
-
-static int
-acx111_init(struct acx_softc *sc)
-{
-       /*
-        * NOTE:
-        * Order of initialization:
-        * 1) Templates
-        * 2) Hardware memory
-        * Above order is critical to get a correct memory map
-        */
-
-       if (acx_init_tmplt_ordered(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't initialize templates\n",
-                         __func__);
-               return ENXIO;
-       }
-
-       if (acx111_init_memory(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't initialize hw memory\n",
-                         __func__);
-               return ENXIO;
-       }
-       return 0;
-}
-
-static int
-acx111_init_memory(struct acx_softc *sc)
-{
-       struct acx111_conf_mem mem;
-       struct acx111_conf_meminfo mem_info;
-
-       /* Set memory configuration */
-       bzero(&mem, sizeof(mem));
-
-       mem.sta_max = htole16(ACX111_STA_MAX);
-       mem.memblk_size = htole16(ACX_MEMBLOCK_SIZE);
-       mem.rx_memblk_perc = ACX111_RX_MEMBLK_PERCENT;
-       mem.opt = ACX111_MEMOPT_DEFAULT;
-       mem.xfer_perc = ACX111_XFER_PERCENT;
-
-       mem.fw_rxring_num = 1;
-       mem.fw_rxring_type = ACX111_RXRING_TYPE_DEFAULT;
-       mem.fw_rxring_prio = ACX111_RXRING_PRIO_DEFAULT;
-       mem.fw_rxdesc_num = ACX_RX_DESC_CNT;
-       mem.h_rxring_paddr = htole32(sc->sc_ring_data.rx_ring_paddr);
-
-       mem.fw_txring_num = 1;
-       mem.fw_txring_attr = ACX111_TXRING_ATTR_DEFAULT;
-       mem.fw_txdesc_num = ACX_TX_DESC_CNT;
-
-       if (acx111_set_mem_conf(sc, &mem) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set mem\n");
-               return 1;
-       }
-
-       /* Get memory configuration */
-       if (acx111_get_meminfo_conf(sc, &mem_info) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get meminfo\n");
-               return 1;
-       }
-
-       /* Setup firmware TX descriptor ring */
-       acx111_init_fw_txring(sc, le32toh(mem_info.fw_txring_start));
-
-       /*
-        * There is no need to setup firmware RX descriptor ring,
-        * it is automaticly setup by hardware.
-        */
-
-       return 0;
-}
-
-static void
-acx111_init_fw_txring(struct acx_softc *sc, uint32_t fw_txdesc_start)
-{
-       struct acx_txbuf *tx_buf;
-       uint32_t desc_paddr;
-       int i;
-
-       tx_buf = sc->sc_buf_data.tx_buf;
-       desc_paddr = sc->sc_ring_data.tx_ring_paddr;
-
-       for (i = 0; i < ACX_TX_DESC_CNT; ++i) {
-               tx_buf[i].tb_fwdesc_ofs = fw_txdesc_start +
-                                         (i * ACX111_FW_TXDESC_SIZE);
-
-               /*
-                * Except for the following fields, rest of the fields
-                * are setup by hardware.
-                */
-               FW_TXDESC_SETFIELD_4(sc, &tx_buf[i], f_tx_host_desc,
-                                    desc_paddr);
-               FW_TXDESC_SETFIELD_1(sc, &tx_buf[i], f_tx_ctrl,
-                                    DESC_CTRL_HOSTOWN);
-
-               desc_paddr += (2 * sizeof(struct acx_host_desc));
-       }
-}
-
-static int
-acx111_write_config(struct acx_softc *sc, struct acx_config *conf)
-{
-       struct acx111_conf_txpower tx_power;
-       struct acx111_conf_option opt;
-       struct acx111_conf_rt0_nretry rt0_nretry;
-       uint32_t dataflow;
-
-       /* Set TX power */
-       tx_power.txpower = ACX111_TXPOWER_VAL;
-       if (acx111_set_txpower_conf(sc, &tx_power) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't set TX power\n",
-                         __func__);
-               return ENXIO;
-       }
-
-       /*
-        * Turn off hardware WEP
-        */
-       if (acx111_get_option_conf(sc, &opt) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't get option\n", __func__);
-               return ENXIO;
-       }
-
-       dataflow = le32toh(opt.dataflow) |
-                  ACX111_DF_NO_TXENCRYPT |
-                  ACX111_DF_NO_RXDECRYPT;
-       opt.dataflow = htole32(dataflow);
-
-       if (acx111_set_option_conf(sc, &opt) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't set option\n", __func__);
-               return ENXIO;
-       }
-
-       /*
-        * Set number of retries for 0th rate
-        */
-       rt0_nretry.rt0_nretry = sc->chip_rate_fallback;
-       if (acx111_set_rt0_nretry_conf(sc, &rt0_nretry) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "%s can't set rate0 nretry\n",
-                         __func__);
-               return ENXIO;
-       }
-       return 0;
-}
-
-static uint8_t
-_acx111_set_fw_txdesc_rate(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                          struct ieee80211_node *ni, int data_len,
-                          int rateidx_max)
-{
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       uint16_t rate;
-       uint8_t ret = 0;
-
-       KKASSERT(rateidx_max <= IEEE80211_RATEIDX_MAX);
-
-       if (ni == NULL) {
-               rate = ACX111_RATE_2;   /* 1Mbit/s */
-               ret = 2;
-               tx_buf->tb_rateidx_len = 1;
-               tx_buf->tb_rateidx[0] = 0;
-       } else {
-               struct ieee80211_rateset *rs = &ni->ni_rates;
-               int *rateidx = tx_buf->tb_rateidx;
-               int i, n;
-
-               n = ieee80211_ratectl_findrate(ni, data_len, rateidx,
-                                              rateidx_max);
-
-               rate = 0;
-               for (i = 0; i < n; ++i) {
-                       u_int map_idx = IEEE80211_RS_RATE(rs, rateidx[i]);
-
-                       if (ACX111_CHK_RATE(ifp, map_idx, rateidx[i]) < 0)
-                               continue;
-
-                       if (ret == 0)
-                               ret = map_idx;
-
-                       rate |= acx111_rate_map[map_idx];
-               }
-               if (rate == 0) {
-                       if_printf(ifp, "WARNING no rate, set to 1Mbit/s\n");
-                       rate = ACX111_RATE_2;
-                       ret = 2;
-                       tx_buf->tb_rateidx_len = 1;
-                       tx_buf->tb_rateidx[0] = 0;
-               } else {
-                       tx_buf->tb_rateidx_len = n;
-               }
-       }
-       FW_TXDESC_SETFIELD_2(sc, tx_buf, u.r2.rate111, rate);
-
-       return ret;
-}
-
-static uint8_t
-acx111_set_fw_txdesc_rate_onoe(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                              struct ieee80211_node *ni, int data_len)
-{
-       return _acx111_set_fw_txdesc_rate(sc, tx_buf, ni, data_len,
-                                         ACX111_ONOE_RATEIDX_MAX);
-}
-
-static uint8_t
-acx111_set_fw_txdesc_rate_amrr(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                              struct ieee80211_node *ni, int data_len)
-{
-       return _acx111_set_fw_txdesc_rate(sc, tx_buf, ni, data_len,
-                                         ACX111_AMRR_RATEIDX_MAX);
-}
-
-static void
-acx111_set_bss_join_param(struct acx_softc *sc, void *param, int dtim_intvl)
-{
-       struct acx111_bss_join *bj = param;
-       const struct ieee80211_rateset *rs = &sc->sc_ic.ic_bss->ni_rates;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       uint16_t basic_rates = 0;
-       int i;
-
-       for (i = 0; i < rs->rs_nrates; ++i) {
-               if (rs->rs_rates[i] & IEEE80211_RATE_BASIC) {
-                       u_int map_idx = IEEE80211_RS_RATE(rs, i);
-
-                       if (ACX111_CHK_RATE(ifp, map_idx, i) < 0)
-                               continue;
-
-                       basic_rates |= acx111_rate_map[map_idx];
-               }
-       }
-       DPRINTF((ifp, "basic rates: 0x%04x\n", basic_rates));
-
-       bj->basic_rates = htole16(basic_rates);
-       bj->dtim_intvl = dtim_intvl;
-}
-
-static void *
-acx111_ratectl_attach(struct ieee80211com *ic, u_int rc)
-{
-       struct ifnet *ifp = &ic->ic_if;
-       struct acx_softc *sc = ifp->if_softc;
-       const int *tries;
-       void *ret;
-       int i;
-
-       switch (rc) {
-       case IEEE80211_RATECTL_ONOE:
-               tries = acx111_onoe_tries;
-               sc->chip_set_fw_txdesc_rate = acx111_set_fw_txdesc_rate_onoe;
-               sc->chip_tx_complete = acx111_tx_complete_onoe;
-               ret = &sc->sc_onoe_param;
-               break;
-
-       case IEEE80211_RATECTL_AMRR:
-               tries = acx111_amrr_tries;
-               sc->chip_set_fw_txdesc_rate = acx111_set_fw_txdesc_rate_amrr;
-               sc->chip_tx_complete = acx111_tx_complete_amrr;
-               ret = &sc->sc_amrr_param;
-               break;
-
-       case IEEE80211_RATECTL_NONE:
-               /* This could only happen during detaching */
-               return NULL;
-
-       default:
-               panic("unknown rate control algo %u", rc);
-               break;
-       }
-
-       sc->chip_rate_fallback = tries[0] - 1;
-
-       sc->chip_short_retry_limit = 0;
-       for (i = 0; i < IEEE80211_RATEIDX_MAX; ++i)
-               sc->chip_short_retry_limit += tries[i];
-       sc->chip_short_retry_limit--;
-
-       if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) ==
-           (IFF_RUNNING | IFF_UP)) {
-               struct acx_conf_nretry_short sretry;
-               struct acx111_conf_rt0_nretry rt0_nretry;
-
-               /*
-                * Set number of short retries
-                */
-               sretry.nretry = sc->chip_short_retry_limit;
-               if (acx_set_nretry_short_conf(sc, &sretry) != 0) {
-                       if_printf(ifp, "%s can't set short retry limit\n",
-                                 __func__);
-               }
-               DPRINTF((ifp, "%s set sretry %d\n", __func__,
-                        sc->chip_short_retry_limit));
-
-               /*
-                * Set number of retries for 0th rate
-                */
-               rt0_nretry.rt0_nretry = sc->chip_rate_fallback;
-               if (acx111_set_rt0_nretry_conf(sc, &rt0_nretry) != 0) {
-                       if_printf(ifp, "%s can't set rate0 nretry\n",
-                                 __func__);
-               }
-               DPRINTF((ifp, "%s set rate 0 nretry %d\n", __func__,
-                        sc->chip_rate_fallback));
-       }
-       return ret;
-}
-
-static void
-_acx111_tx_complete(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                   int frame_len, int is_fail, const int tries_arr[])
-{
-       struct ieee80211_ratectl_res rc_res[IEEE80211_RATEIDX_MAX];
-       int rts_retries, data_retries, n, tries, prev_tries;
-
-       KKASSERT(tx_buf->tb_rateidx_len <= IEEE80211_RATEIDX_MAX);
-
-       rts_retries = FW_TXDESC_GETFIELD_1(sc, tx_buf, f_tx_rts_nretry);
-       data_retries = FW_TXDESC_GETFIELD_1(sc, tx_buf, f_tx_data_nretry);
-
-#if 0
-       DPRINTF((&sc->sc_ic.ic_if, "d%d r%d rateidx_len %d\n",
-                data_retries, rts_retries, tx_buf->tb_rateidx_len));
-#endif
-
-       prev_tries = tries = 0;
-       for (n = 0; n < tx_buf->tb_rateidx_len; ++n) {
-               rc_res[n].rc_res_tries = tries_arr[n];
-               rc_res[n].rc_res_rateidx = tx_buf->tb_rateidx[n];
-               if (!is_fail) {
-                       if (data_retries + 1 <= tries)
-                               break;
-                       prev_tries = tries;
-                       tries += tries_arr[n];
-               }
-       }
-       KKASSERT(n != 0);
-
-       if (!is_fail && data_retries + 1 <= tries) {
-               rc_res[n - 1].rc_res_tries = data_retries + 1 - prev_tries;
-#if 0
-               DPRINTF((&sc->sc_ic.ic_if, "n %d, last tries%d\n",
-                        n, rc_res[n - 1].rc_res_tries));
-#endif
-       }
-       ieee80211_ratectl_tx_complete(tx_buf->tb_node, frame_len, rc_res, n,
-                                     data_retries, rts_retries, is_fail);
-}
-
-static void
-acx111_tx_complete_onoe(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                       int frame_len, int is_fail)
-{
-       _acx111_tx_complete(sc, tx_buf, frame_len, is_fail,
-                           acx111_onoe_tries);
-}
-
-static void
-acx111_tx_complete_amrr(struct acx_softc *sc, struct acx_txbuf *tx_buf,
-                       int frame_len, int is_fail)
-{
-       _acx111_tx_complete(sc, tx_buf, frame_len, is_fail,
-                           acx111_amrr_tries);
-}
-
-static int
-acx111_calibrate(struct acx_softc *sc)
-{
-       struct acx111_calib calib;
-
-       calib.calib = htole32(ACX111_CALIB_AUTO |
-                             ACX111_CALIB_DC |
-                             ACX111_CALIB_AFE_DC |
-                             ACX111_CALIB_TX_MISMATCH |
-                             ACX111_CALIB_TX_EQUAL);
-       calib.interval = htole32(ACX111_FW_CALIB_INTVL);
-
-       return acx_exec_command(sc, ACXCMD_CALIBRATE, &calib, sizeof(calib),
-                               NULL, 0);
-}
diff --git a/sys/dev/netif/acx/acxcmd.c b/sys/dev/netif/acx/acxcmd.c
deleted file mode 100644 (file)
index dc94801..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * 
- * $DragonFly: src/sys/dev/netif/acx/acxcmd.c,v 1.11 2008/06/01 03:58:38 sephe Exp $
- */
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/endian.h>
-#include <sys/kernel.h>
-#include <sys/rman.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-
-#include <netproto/802_11/ieee80211_var.h>
-#include <netproto/802_11/ieee80211_radiotap.h>
-#include <netproto/802_11/wlan_ratectl/amrr/ieee80211_amrr_param.h>
-#include <netproto/802_11/wlan_ratectl/onoe/ieee80211_onoe_param.h>
-
-#define ACX_DEBUG
-
-#include <dev/netif/acx/if_acxreg.h>
-#include <dev/netif/acx/if_acxvar.h>
-#include <dev/netif/acx/acxcmd.h>
-
-#define CMDPRM_WRITE_REGION_1(sc, r, rlen)             \
-       bus_space_write_region_1((sc)->sc_mem2_bt,      \
-                                (sc)->sc_mem2_bh,      \
-                                (sc)->sc_cmd_param,    \
-                                (const uint8_t *)(r), (rlen))
-
-#define CMDPRM_READ_REGION_1(sc, r, rlen)                              \
-       bus_space_read_region_1((sc)->sc_mem2_bt, (sc)->sc_mem2_bh,     \
-                               (sc)->sc_cmd_param, (uint8_t *)(r), (rlen))
-
-/*
- * This will clear previous command's
- * execution status too
- */
-#define CMD_WRITE_4(sc, val)                                   \
-       bus_space_write_4((sc)->sc_mem2_bt, (sc)->sc_mem2_bh,   \
-                         (sc)->sc_cmd, (val))
-#define CMD_READ_4(sc)         \
-       bus_space_read_4((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (sc)->sc_cmd)
-
-/*
- * acx command register layerout:
- * upper 16bits are command execution status
- * lower 16bits are command to be executed
- */
-#define ACX_CMD_STATUS_SHIFT   16
-#define ACX_CMD_STATUS_OK      1
-
-struct radio_init {
-       uint32_t        radio_ofs;      /* radio firmware offset */
-       uint32_t        radio_len;      /* radio firmware length */
-} __packed;
-
-struct bss_join_hdr {
-       uint8_t         bssid[IEEE80211_ADDR_LEN];
-       uint16_t        beacon_intvl;
-       uint8_t         chip_spec[3];
-       uint8_t         ndata_txrate;   /* see ACX_NDATA_TXRATE_ */
-       uint8_t         ndata_txopt;    /* see ACX_NDATA_TXOPT_ */
-       uint8_t         mode;           /* see ACX_MODE_ */
-       uint8_t         channel;
-       uint8_t         esslen;
-       char            essid[1];
-} __packed;
-
-/*
- * non-data frame tx rate
- */
-#define ACX_NDATA_TXRATE_1             10      /* 1Mbits/s */
-#define ACX_NDATA_TXRATE_2             20      /* 2Mbits/s */
-
-/*
- * non-data frame tx options
- */
-#define ACX_NDATA_TXOPT_PBCC           0x40
-#define ACX_NDATA_TXOPT_OFDM           0x20
-#define ACX_NDATA_TXOPT_SHORT_PREAMBLE 0x10
-
-#define BSS_JOIN_BUFLEN                \
-       (sizeof(struct bss_join_hdr) + IEEE80211_NWID_LEN)
-#define BSS_JOIN_PARAM_SIZE(bj)        \
-       (sizeof(struct bss_join_hdr) + (bj)->esslen)
-
-void
-acx_init_cmd_reg(struct acx_softc *sc)
-{
-       sc->sc_cmd = CSR_READ_4(sc, ACXREG_CMD_REG_OFFSET);
-       sc->sc_cmd_param = sc->sc_cmd + ACX_CMD_REG_SIZE;
-
-       /* Clear command & status */
-       CMD_WRITE_4(sc, 0);
-}
-
-int
-acx_join_bss(struct acx_softc *sc, uint8_t mode, struct ieee80211_node *ni,
-            struct ieee80211_channel *c)
-{
-       uint8_t bj_buf[BSS_JOIN_BUFLEN];
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct bss_join_hdr *bj;
-       int i;
-
-       bzero(bj_buf, sizeof(bj_buf));
-       bj = (struct bss_join_hdr *)bj_buf;
-
-       for (i = 0; i < IEEE80211_ADDR_LEN; ++i)
-               bj->bssid[i] = ni->ni_bssid[IEEE80211_ADDR_LEN - i - 1];
-
-       bj->beacon_intvl = htole16(ni->ni_intval);
-
-       sc->chip_set_bss_join_param(sc, bj->chip_spec, ic->ic_dtim_period);
-
-       bj->ndata_txrate = ACX_NDATA_TXRATE_1;
-       bj->ndata_txopt = 0;
-       bj->mode = mode;
-       bj->channel = ieee80211_chan2ieee(ic, c);
-       bj->esslen = ni->ni_esslen;
-       bcopy(ni->ni_essid, bj->essid, ni->ni_esslen);
-
-       DPRINTF((&ic->ic_if, "join BSS/IBSS on channel %d\n", bj->channel));
-       return acx_exec_command(sc, ACXCMD_JOIN_BSS,
-                               bj, BSS_JOIN_PARAM_SIZE(bj), NULL, 0);
-}
-
-int
-acx_enable_txchan(struct acx_softc *sc, uint8_t chan)
-{
-       return acx_exec_command(sc, ACXCMD_ENABLE_TXCHAN, &chan, sizeof(chan),
-                               NULL, 0);
-}
-
-int
-acx_enable_rxchan(struct acx_softc *sc, uint8_t chan)
-{
-       return acx_exec_command(sc, ACXCMD_ENABLE_RXCHAN, &chan, sizeof(chan),
-                               NULL, 0);
-}
-
-int
-acx_get_conf(struct acx_softc *sc, uint16_t conf_id, void *conf,
-            uint16_t conf_len)
-{
-       struct acx_conf *confcom;
-
-       if (conf_len < sizeof(*confcom)) {
-               if_printf(&sc->sc_ic.ic_if, "%s configure data is too short\n",
-                         __func__);
-               return 1;
-       }
-
-       confcom = conf;
-       confcom->conf_id = htole16(conf_id);
-       confcom->conf_data_len = htole16(conf_len - sizeof(*confcom));
-
-       return acx_exec_command(sc, ACXCMD_GET_CONF, confcom, sizeof(*confcom),
-                               conf, conf_len);
-}
-
-int
-acx_set_conf(struct acx_softc *sc, uint16_t conf_id, void *conf,
-            uint16_t conf_len)
-{
-       struct acx_conf *confcom;
-
-       if (conf_len < sizeof(*confcom)) {
-               if_printf(&sc->sc_ic.ic_if, "%s configure data is too short\n",
-                         __func__);
-               return 1;
-       }
-
-       confcom = conf;
-       confcom->conf_id = htole16(conf_id);
-       confcom->conf_data_len = htole16(conf_len - sizeof(*confcom));
-
-       return acx_exec_command(sc, ACXCMD_SET_CONF, conf, conf_len, NULL, 0);
-}
-
-int
-acx_set_tmplt(struct acx_softc *sc, uint16_t cmd, void *tmplt,
-             uint16_t tmplt_len)
-{
-       uint16_t *size;
-
-       if (tmplt_len < sizeof(*size)) {
-               if_printf(&sc->sc_ic.ic_if, "%s template is too short\n",
-                         __func__);
-               return 1;
-       }
-
-       size = tmplt;
-       *size = htole16(tmplt_len - sizeof(*size));
-
-       return acx_exec_command(sc, cmd, tmplt, tmplt_len, NULL, 0);
-}
-
-int
-acx_init_radio(struct acx_softc *sc, uint32_t radio_ofs, uint32_t radio_len)
-{
-       struct radio_init r;
-
-       r.radio_ofs = htole32(radio_ofs);
-       r.radio_len = htole32(radio_len);
-       return acx_exec_command(sc, ACXCMD_INIT_RADIO, &r, sizeof(r), NULL, 0);
-}
-
-int
-acx_exec_command(struct acx_softc *sc, uint16_t cmd, void *param,
-                uint16_t param_len, void *result, uint16_t result_len)
-{
-       uint16_t status;
-       int i, ret;
-
-       ASSERT_SERIALIZED(sc->sc_ic.ic_if.if_serializer);
-
-       if ((sc->sc_flags & ACX_FLAG_FW_LOADED) == 0) {
-               if_printf(&sc->sc_ic.ic_if, "cmd 0x%04x failed (base firmware "
-                         "not loaded)", cmd);
-               return 1;
-       }
-
-       ret = 0;
-
-       if (param != NULL && param_len != 0) {
-               /* Set command param */
-               CMDPRM_WRITE_REGION_1(sc, param, param_len);
-       }
-
-       /* Set command */
-       CMD_WRITE_4(sc, cmd);
-
-       /* Exec command */
-       CSR_WRITE_2(sc, ACXREG_INTR_TRIG, ACXRV_TRIG_CMD_FINI);
-       DELAY(50);      /* XXX maybe 100 */
-
-       /* Wait for command to complete */
-       if (cmd == ACXCMD_INIT_RADIO) {
-               /* XXX radio initialization is extremely long */
-               tsleep(&cmd, 0, "rdinit", (150 * hz) / 1000);   /* 150ms */
-       }
-
-#define CMDWAIT_RETRY_MAX      1000
-       for (i = 0; i < CMDWAIT_RETRY_MAX; ++i) {
-               uint16_t reg;
-
-               reg = CSR_READ_2(sc, ACXREG_INTR_STATUS);
-               if (reg & ACXRV_INTR_CMD_FINI) {
-                       CSR_WRITE_2(sc, ACXREG_INTR_ACK, ACXRV_INTR_CMD_FINI);
-                       break;
-               }
-               DELAY(50);
-       }
-       if (i == CMDWAIT_RETRY_MAX) {
-               if_printf(&sc->sc_ic.ic_if, "cmd %04x failed (timeout)\n", cmd);
-               ret = 1;
-               goto back;
-       }
-#undef CMDWAIT_RETRY_MAX
-
-       /* Get command exec status */
-       status = (CMD_READ_4(sc) >> ACX_CMD_STATUS_SHIFT);
-       if (status != ACX_CMD_STATUS_OK) {
-               if_printf(&sc->sc_ic.ic_if, "cmd %04x failed\n", cmd);
-               ret = 1;
-               goto back;
-       }
-
-       if (result != NULL && result_len != 0) {
-               /* Get command result */
-               CMDPRM_READ_REGION_1(sc, result, result_len);
-       }
-
-back:
-       CMD_WRITE_4(sc, 0);
-       return ret;
-}
diff --git a/sys/dev/netif/acx/acxcmd.h b/sys/dev/netif/acx/acxcmd.h
deleted file mode 100644 (file)
index bfe5100..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * 
- * $DragonFly: src/sys/dev/netif/acx/acxcmd.h,v 1.6 2007/02/17 07:05:53 sephe Exp $
- */
-
-#ifndef _ACXCMD_H
-#define _ACXCMD_H
-
-#include "_acxcmd.h"
-
-void   acx_init_cmd_reg(struct acx_softc *);
-
-int    acx_enable_txchan(struct acx_softc *, uint8_t);
-int    acx_enable_rxchan(struct acx_softc *, uint8_t);
-int    acx_init_radio(struct acx_softc *, uint32_t, uint32_t);
-int    acx_join_bss(struct acx_softc *, uint8_t,
-                    struct ieee80211_node *, struct ieee80211_channel *);
-
-/*
- * Possible values for the second parameter of acx_join_bss()
- */
-#define ACX_MODE_ADHOC 0
-#define ACX_MODE_UNUSED        1
-#define ACX_MODE_STA   2
-#define ACX_MODE_AP    3
-
-/*
- * Do not use following functions directly
- */
-int    acx_get_conf(struct acx_softc *, uint16_t, void *, uint16_t);
-int    acx_set_conf(struct acx_softc *, uint16_t, void *, uint16_t);
-int    acx_set_tmplt(struct acx_softc *, uint16_t, void *, uint16_t);
-int    acx_exec_command(struct acx_softc *, uint16_t, void *, uint16_t,
-                        void *, uint16_t);
-
-
-/*
- * NOTE:
- * Following structs' fields are little endian
- */
-
-struct acx_conf {
-       uint16_t        conf_id;        /* see ACXCONF_ (_acxcmd.h) */
-       uint16_t        conf_data_len;
-} __packed;
-
-struct acx_conf_mmap {
-       struct acx_conf confcom;
-       uint32_t        code_start;
-       uint32_t        code_end;
-       uint32_t        wep_cache_start;
-       uint32_t        wep_cache_end;
-       uint32_t        pkt_tmplt_start;
-       uint32_t        pkt_tmplt_end;
-       uint32_t        fw_desc_start;
-       uint32_t        fw_desc_end;
-       uint32_t        memblk_start;
-       uint32_t        memblk_end;
-} __packed;
-
-struct acx_conf_wepopt {
-       struct acx_conf confcom;
-       uint16_t        nkey;
-       uint8_t         opt;    /* see WEPOPT_ */
-} __packed;
-
-#define WEPOPT_HDWEP   0       /* hardware WEP */
-
-struct acx_conf_eaddr {
-       struct acx_conf confcom;
-       uint8_t         eaddr[IEEE80211_ADDR_LEN];
-} __packed;
-
-struct acx_conf_regdom {
-       struct acx_conf confcom;
-       uint8_t         regdom;
-       uint8_t         unknown;
-} __packed;
-
-struct acx_conf_antenna {
-       struct acx_conf confcom;
-       uint8_t         antenna;
-} __packed;
-
-struct acx_conf_fwrev {
-       struct acx_conf confcom;
-#define ACX_FWREV_LEN  20
-       /*
-        * "Rev xx.xx.xx.xx"
-        * '\0' terminated
-        */
-       char            fw_rev[ACX_FWREV_LEN];
-       uint32_t        hw_id;
-} __packed;
-
-struct acx_conf_nretry_long {
-       struct acx_conf confcom;
-       uint8_t         nretry;
-} __packed;
-
-struct acx_conf_nretry_short {
-       struct acx_conf confcom;
-       uint8_t         nretry;
-} __packed;
-
-struct acx_conf_msdu_lifetime {
-       struct acx_conf confcom;
-       uint32_t        lifetime;
-} __packed;
-
-struct acx_conf_rate_fallback {
-       struct acx_conf confcom;
-       uint8_t         ratefb_enable;  /* 0/1 */
-} __packed;
-
-struct acx_conf_rxopt {
-       struct acx_conf confcom;
-       uint16_t        opt1;   /* see RXOPT1_ */
-       uint16_t        opt2;   /* see RXOPT2_ */
-} __packed;
-
-#define RXOPT1_INCL_RXBUF_HDR  0x2000  /* rxbuf with acx_rxbuf_hdr */
-#define RXOPT1_RECV_SSID       0x0400  /* recv frame for joined SSID */
-#define RXOPT1_FILT_BCAST      0x0200  /* filt broadcast pkt */
-#define RXOPT1_RECV_MCAST1     0x0100  /* recv pkt for multicast addr1 */
-#define RXOPT1_RECV_MCAST0     0x0080  /* recv pkt for multicast addr0 */
-#define RXOPT1_FILT_ALLMULTI   0x0040  /* filt allmulti pkt */
-#define RXOPT1_FILT_FSSID      0x0020  /* filt frame for foreign SSID */
-#define RXOPT1_FILT_FDEST      0x0010  /* filt frame for foreign dest addr */
-#define RXOPT1_PROMISC         0x0008  /* promisc mode */
-#define RXOPT1_INCL_FCS                0x0004
-#define RXOPT1_INCL_PHYHDR     0x0000  /* XXX 0x0002 */
-
-#define RXOPT2_RECV_ASSOC_REQ  0x0800
-#define RXOPT2_RECV_AUTH       0x0400
-#define RXOPT2_RECV_BEACON     0x0200
-#define RXOPT2_RECV_CF         0x0100
-#define RXOPT2_RECV_CTRL       0x0080
-#define RXOPT2_RECV_DATA       0x0040
-#define RXOPT2_RECV_BROKEN     0x0020  /* broken frame */
-#define RXOPT2_RECV_MGMT       0x0010
-#define RXOPT2_RECV_PROBE_REQ  0x0008
-#define RXOPT2_RECV_PROBE_RESP 0x0004
-#define RXOPT2_RECV_ACK                0x0002  /* RTS/CTS/ACK */
-#define RXOPT2_RECV_OTHER      0x0001
-
-struct acx_conf_wep_txkey {
-       struct acx_conf confcom;
-       uint8_t         wep_txkey;
-} __packed;
-
-
-struct acx_tmplt_null_data {
-       uint16_t        size;
-       struct ieee80211_frame data;
-} __packed;
-
-struct acx_tmplt_probe_req {
-       uint16_t        size;
-       union {
-               struct {
-                       struct ieee80211_frame f;
-                       uint8_t         var[1];
-               } __packed      u_data;
-               uint8_t         u_mem[0x44];
-       }               data;
-} __packed;
-
-#define ACX_TMPLT_PROBE_REQ_SIZ(var_len)       \
-       (sizeof(uint16_t) + sizeof(struct ieee80211_frame) + (var_len))
-
-struct acx_tmplt_probe_resp {
-       uint16_t        size;
-       union {
-               struct {
-                       struct ieee80211_frame f;
-                       uint8_t         time_stamp[8];
-                       uint16_t        beacon_intvl;
-                       uint16_t        cap;
-                       uint8_t         var[1];
-               } __packed      u_data;
-               uint8_t         u_mem[0x100];
-       }               data;
-} __packed;
-
-/* XXX same as acx_tmplt_probe_resp */
-struct acx_tmplt_beacon {
-       uint16_t        size;
-       union {
-               struct {
-                       struct ieee80211_frame f;
-                       uint8_t         time_stamp[8];
-                       uint16_t        beacon_intvl;
-                       uint16_t        cap;
-                       uint8_t         var[1];
-               } __packed      u_data;
-               uint8_t         u_mem[0x100];
-       }               data;
-} __packed;
-
-struct acx_tmplt_tim {
-       uint16_t        size;
-       union {
-               struct ieee80211_tim_ie u_tim;
-               uint8_t                 u_mem[0x100];
-       }               data;
-} __packed;
-
-#define ACX_INIT_TMPLT_FUNC(name)                      \
-static __inline int                                    \
-acx_init_##name##_tmplt(struct acx_softc *_sc)         \
-{                                                      \
-       struct acx_tmplt_##name _tmplt;                 \
-                                                       \
-       bzero(&_tmplt, sizeof(_tmplt));                 \
-       return acx_set_tmplt(_sc, ACXCMD_TMPLT_##name,  \
-                            &_tmplt, sizeof(_tmplt));  \
-}                                                      \
-struct __hack
-
-#define ACX_SET_TMPLT_FUNC(name)                       \
-static __inline int                                    \
-_acx_set_##name##_tmplt(struct acx_softc *_sc,         \
-                      struct acx_tmplt_##name *_tmplt, \
-                      uint16_t _tmplt_len)             \
-{                                                      \
-       return acx_set_tmplt(_sc, ACXCMD_TMPLT_##name,  \
-                            _tmplt, _tmplt_len);       \
-}                                                      \
-struct __hack
-
-#define _ACX_CONF_FUNC(sg, name, chip)                 \
-static __inline int                                    \
-acx##chip##_##sg##_##name##_conf(struct acx_softc *_sc,        \
-       struct acx##chip##_conf_##name *_conf)          \
-{                                                      \
-       return acx_##sg##_conf(_sc, ACX_CONF_##name,    \
-                              _conf, sizeof(*_conf));  \
-}                                                      \
-struct __hack
-
-#define ACX_NOARG_FUNC(name)                           \
-static __inline int                                    \
-acx_##name(struct acx_softc *_sc)                      \
-{                                                      \
-       return acx_exec_command(_sc, ACXCMD_##name,     \
-                               NULL, 0, NULL, 0);      \
-}                                                      \
-struct __hack
-
-
-#define ACXCMD_TMPLT_tim       ACXCMD_TMPLT_TIM
-#define ACXCMD_TMPLT_beacon    ACXCMD_TMPLT_BEACON
-#define ACXCMD_TMPLT_probe_resp        ACXCMD_TMPLT_PROBE_RESP
-#define ACXCMD_TMPLT_null_data ACXCMD_TMPLT_NULL_DATA
-#define ACXCMD_TMPLT_probe_req ACXCMD_TMPLT_PROBE_REQ
-ACX_INIT_TMPLT_FUNC(tim);
-ACX_INIT_TMPLT_FUNC(null_data);
-ACX_INIT_TMPLT_FUNC(beacon);
-ACX_INIT_TMPLT_FUNC(probe_req);
-ACX_INIT_TMPLT_FUNC(probe_resp);
-ACX_SET_TMPLT_FUNC(tim);
-ACX_SET_TMPLT_FUNC(null_data);
-ACX_SET_TMPLT_FUNC(beacon);
-ACX_SET_TMPLT_FUNC(probe_req);
-ACX_SET_TMPLT_FUNC(probe_resp);
-
-#define ACX_CONF_FUNC(sg, name)        _ACX_CONF_FUNC(sg, name,)
-#define ACX_CONF_wepopt                ACX_CONF_WEPOPT
-#define ACX_CONF_mmap          ACX_CONF_MMAP
-#define ACX_CONF_eaddr         ACX_CONF_EADDR
-#define ACX_CONF_regdom                ACX_CONF_REGDOM
-#define ACX_CONF_antenna       ACX_CONF_ANTENNA
-#define ACX_CONF_fwrev         ACX_CONF_FWREV
-#define ACX_CONF_nretry_long   ACX_CONF_NRETRY_LONG
-#define ACX_CONF_nretry_short  ACX_CONF_NRETRY_SHORT
-#define ACX_CONF_msdu_lifetime ACX_CONF_MSDU_LIFETIME
-#define ACX_CONF_rate_fallback ACX_CONF_RATE_FALLBACK
-#define ACX_CONF_rxopt         ACX_CONF_RXOPT
-#define ACX_CONF_wep_txkey     ACX_CONF_WEP_TXKEY
-ACX_CONF_FUNC(get, mmap);
-ACX_CONF_FUNC(set, mmap);
-ACX_CONF_FUNC(set, wepopt);
-ACX_CONF_FUNC(get, eaddr);
-ACX_CONF_FUNC(get, regdom);
-ACX_CONF_FUNC(set, regdom);
-ACX_CONF_FUNC(get, antenna);
-ACX_CONF_FUNC(set, antenna);
-ACX_CONF_FUNC(get, fwrev);
-ACX_CONF_FUNC(set, nretry_long);
-ACX_CONF_FUNC(set, nretry_short);
-ACX_CONF_FUNC(set, msdu_lifetime);
-ACX_CONF_FUNC(set, rate_fallback);
-ACX_CONF_FUNC(set, rxopt);
-ACX_CONF_FUNC(set, wep_txkey);
-
-#define ACXCMD_sleep           ACXCMD_SLEEP
-#define ACXCMD_wakeup          ACXCMD_WAKEUP
-ACX_NOARG_FUNC(sleep);
-ACX_NOARG_FUNC(wakeup);
-
-#endif /* !_ACXCMD_H */
diff --git a/sys/dev/netif/acx/if_acx.c b/sys/dev/netif/acx/if_acx.c
deleted file mode 100644 (file)
index dc4530e..0000000
+++ /dev/null
@@ -1,2773 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * 
- */
-
-/*
- * Copyright (c) 2003-2004 wlan.kewl.org Project
- * All rights reserved.
- * 
- * $Id: LICENSE,v 1.1.1.1 2004/07/01 12:20:39 darron Exp $
- *  
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *    
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- * 
- *    This product includes software developed by the wlan.kewl.org Project.
- * 
- * 4. Neither the name of the wlan.kewl.org Project nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
- * THE wlan.kewl.org Project BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/endian.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/firmware.h>
-#include <sys/interrupt.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/rman.h>
-#include <sys/serialize.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <net/bpf.h>
-#include <net/if_arp.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/ifq_var.h>
-
-#include <netproto/802_11/ieee80211_var.h>
-#include <netproto/802_11/ieee80211_radiotap.h>
-#include <netproto/802_11/wlan_ratectl/amrr/ieee80211_amrr_param.h>
-#include <netproto/802_11/wlan_ratectl/onoe/ieee80211_onoe_param.h>
-
-#include <bus/pci/pcireg.h>
-#include <bus/pci/pcivar.h>
-#include "pcidevs.h"
-
-#define ACX_DEBUG
-
-#include <dev/netif/acx/if_acxreg.h>
-#include <dev/netif/acx/if_acxvar.h>
-#include <dev/netif/acx/acxcmd.h>
-
-static int     acx_probe(device_t);
-static int     acx_attach(device_t);
-static int     acx_detach(device_t);
-static int     acx_shutdown(device_t);
-
-static void    acx_init(void *);
-static void    acx_start(struct ifnet *, struct ifaltq_subque *);
-static int     acx_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
-static void    acx_watchdog(struct ifnet *);
-
-static void    acx_intr(void *);
-static void    acx_txeof(struct acx_softc *);
-static void    acx_txerr(struct acx_softc *, uint8_t);
-static void    acx_rxeof(struct acx_softc *);
-static void    acx_disable_intr(struct acx_softc *);
-static void    acx_enable_intr(struct acx_softc *);
-
-static int     acx_reset(struct acx_softc *);
-static int     acx_stop(struct acx_softc *);
-static void    acx_init_info_reg(struct acx_softc *);
-static int     acx_config(struct acx_softc *);
-static int     acx_read_config(struct acx_softc *, struct acx_config *);
-static int     acx_write_config(struct acx_softc *, struct acx_config *);
-static int     acx_rx_config(struct acx_softc *, int);
-static int     acx_set_crypt_keys(struct acx_softc *);
-static void    acx_calibrate(void *);
-
-static int     acx_dma_alloc(struct acx_softc *);
-static void    acx_dma_free(struct acx_softc *);
-static int     acx_init_tx_ring(struct acx_softc *);
-static int     acx_init_rx_ring(struct acx_softc *);
-static int     acx_newbuf(struct acx_softc *, struct acx_rxbuf *, int);
-static int     acx_encap(struct acx_softc *, struct acx_txbuf *,
-                         struct mbuf *, struct ieee80211_node *);
-
-static int     acx_set_null_tmplt(struct acx_softc *);
-static int     acx_set_probe_req_tmplt(struct acx_softc *, const char *, int);
-static int     acx_set_probe_resp_tmplt(struct acx_softc *,
-                                        struct ieee80211_node *);
-static int     acx_set_beacon_tmplt(struct acx_softc *,
-                                    struct ieee80211_node *);
-
-static int     acx_read_eeprom(struct acx_softc *, uint32_t, uint8_t *);
-static int     acx_read_phyreg(struct acx_softc *, uint32_t, uint8_t *);
-
-static int     acx_alloc_firmware(struct acx_softc *);
-static void    acx_free_firmware(struct acx_softc *);
-static int     acx_setup_firmware(struct acx_softc *, struct fw_image *,
-                                  const uint8_t **, int *);
-static int     acx_load_firmware(struct acx_softc *, uint32_t,
-                                 const uint8_t *, int);
-static int     acx_load_radio_firmware(struct acx_softc *, const uint8_t *,
-                                       uint32_t);
-static int     acx_load_base_firmware(struct acx_softc *, const uint8_t *,
-                                      uint32_t);
-
-static void    acx_next_scan(void *);
-static int     acx_set_chan(struct acx_softc *, struct ieee80211_channel *);
-
-static int     acx_media_change(struct ifnet *);
-static int     acx_newstate(struct ieee80211com *, enum ieee80211_state, int);
-
-static int     acx_sysctl_msdu_lifetime(SYSCTL_HANDLER_ARGS);
-static int     acx_sysctl_free_firmware(SYSCTL_HANDLER_ARGS);
-
-const struct ieee80211_rateset acx_rates_11b =
-       { 4, { 2, 4, 11, 22 } };
-const struct ieee80211_rateset acx_rates_11g =
-       { 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 } };
-const struct ieee80211_rateset acx_rates_11b_pbcc =
-       { 5, { 2, 4, 11, 22, 44 } };
-const struct ieee80211_rateset acx_rates_11g_pbcc =
-       { 13, { 2, 4, 11, 22, 44, 12, 18, 24, 36, 48, 72, 96, 108 } };
-
-int    acx_enable_pbcc = 1;
-TUNABLE_INT("hw.acx.enable_pbcc", &acx_enable_pbcc);
-
-static const struct acx_device {
-       uint16_t        vid;
-       uint16_t        did;
-       void            (*set_param)(device_t);
-       const char      *desc;
-} acx_devices[] = {
-       { PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX100A, acx100_set_param,
-         "Texas Instruments TNETW1100A Wireless Adapter" },
-       { PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX100B, acx100_set_param,
-         "Texas Instruments TNETW1100B Wireless Adapter" },
-       { PCI_VENDOR_TI, PCI_PRODUCT_TI_ACX111, acx111_set_param,
-         "Texas Instruments TNETW1130 Wireless Adapter" },
-       { 0, 0, NULL, NULL }
-};
-
-static device_method_t acx_methods[] = {
-       DEVMETHOD(device_probe,         acx_probe),
-       DEVMETHOD(device_attach,        acx_attach),
-       DEVMETHOD(device_detach,        acx_detach),
-       DEVMETHOD(device_shutdown,      acx_shutdown),
-#if 0
-       DEVMETHOD(device_suspend,       acx_suspend),
-       DEVMETHOD(device_resume,        acx_resume),
-#endif
-       DEVMETHOD_END
-};
-
-static driver_t acx_driver = {
-       "acx",
-       acx_methods,
-       sizeof(struct acx_softc)
-};
-
-static devclass_t acx_devclass;
-
-DRIVER_MODULE(acx, pci, acx_driver, acx_devclass, NULL, NULL);
-DRIVER_MODULE(acx, cardbus, acx_driver, acx_devclass, NULL, NULL);
-
-MODULE_DEPEND(acx, wlan, 1, 1, 1);
-MODULE_DEPEND(acx, wlan_ratectl_onoe, 1, 1, 1);
-MODULE_DEPEND(acx, wlan_ratectl_amrr, 1, 1, 1);
-MODULE_DEPEND(acx, pci, 1, 1, 1);
-MODULE_DEPEND(acx, cardbus, 1, 1, 1);
-
-static __inline int
-acx_get_rssi(struct acx_softc *sc, uint8_t raw)
-{
-       int rssi;
-
-       rssi = ((sc->chip_rssi_corr / 2) + (raw * 5)) / sc->chip_rssi_corr;
-       return rssi > 100 ? 100 : rssi;
-}
-
-static int
-acx_probe(device_t dev)
-{
-       const struct acx_device *a;
-       uint16_t did, vid;
-
-       vid = pci_get_vendor(dev);
-       did = pci_get_device(dev);
-       for (a = acx_devices; a->desc != NULL; ++a) {
-               if (vid == a->vid && did == a->did) {
-                       a->set_param(dev);
-                       device_set_desc(dev, a->desc);
-                       return 0;
-               }
-       }
-       return ENXIO;
-}
-
-static int
-acx_attach(device_t dev)
-{
-       struct acx_softc *sc;
-       struct ifnet *ifp;
-       struct ieee80211com *ic;
-       struct sysctl_ctx_list *sctx;
-       struct sysctl_oid *soid;
-       int i, error;
-
-       sc = device_get_softc(dev);
-       ic = &sc->sc_ic;
-       ifp = &ic->ic_if;
-
-       if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-
-#ifndef BURN_BRIDGES
-       if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
-               uint32_t mem1, mem2, irq;
-
-               mem1 = pci_read_config(dev, sc->chip_mem1_rid, 4);
-               mem2 = pci_read_config(dev, sc->chip_mem2_rid, 4);
-               irq = pci_read_config(dev, PCIR_INTLINE, 4);
-
-               device_printf(dev, "chip is in D%d power mode "
-                   "-- setting to D0\n", pci_get_powerstate(dev));
-
-               pci_set_powerstate(dev, PCI_POWERSTATE_D0);
-
-               pci_write_config(dev, sc->chip_mem1_rid, mem1, 4);
-               pci_write_config(dev, sc->chip_mem2_rid, mem2, 4);
-               pci_write_config(dev, PCIR_INTLINE, irq, 4);
-       }
-#endif /* !BURN_BRIDGE */
-
-       /* Enable bus mastering */
-       pci_enable_busmaster(dev); 
-
-       /* Allocate IO memory 1 */
-       sc->sc_mem1_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
-                                                &sc->chip_mem1_rid,
-                                                RF_ACTIVE);
-       if (sc->sc_mem1_res == NULL) {
-               error = ENXIO;
-               device_printf(dev, "can't allocate IO mem1\n");
-               goto fail;
-       }
-       sc->sc_mem1_bt = rman_get_bustag(sc->sc_mem1_res);
-       sc->sc_mem1_bh = rman_get_bushandle(sc->sc_mem1_res);
-
-       /* Allocate IO memory 2 */
-       sc->sc_mem2_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
-                                                &sc->chip_mem2_rid,
-                                                RF_ACTIVE);
-       if (sc->sc_mem2_res == NULL) {
-               error = ENXIO;
-               device_printf(dev, "can't allocate IO mem2\n");
-               goto fail;
-       }
-       sc->sc_mem2_bt = rman_get_bustag(sc->sc_mem2_res);
-       sc->sc_mem2_bh = rman_get_bushandle(sc->sc_mem2_res);
-
-       /* Allocate irq */
-       sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
-                                               &sc->sc_irq_rid,
-                                               RF_SHAREABLE | RF_ACTIVE);
-       if (sc->sc_irq_res == NULL) {
-               error = ENXIO;
-               device_printf(dev, "can't allocate intr\n");
-               goto fail;
-       }
-
-       /* Initialize channel scanning timer */
-       callout_init(&sc->sc_scan_timer);
-
-       /* Initialize calibration timer */
-       callout_init(&sc->sc_calibrate_timer);
-
-       /* Allocate busdma stuffs */
-       error = acx_dma_alloc(sc);
-       if (error)
-               goto fail;
-
-       /* Reset Hardware */
-       error = acx_reset(sc);
-       if (error)
-               goto fail;
-
-       /* Disable interrupts before firmware is loaded */
-       acx_disable_intr(sc);
-
-       /* Get radio type and form factor */
-#define EEINFO_RETRY_MAX       50
-       for (i = 0; i < EEINFO_RETRY_MAX; ++i) {
-               uint16_t ee_info;
-
-               ee_info = CSR_READ_2(sc, ACXREG_EEPROM_INFO);
-               if (ACX_EEINFO_HAS_RADIO_TYPE(ee_info)) {
-                       sc->sc_form_factor = ACX_EEINFO_FORM_FACTOR(ee_info);
-                       sc->sc_radio_type = ACX_EEINFO_RADIO_TYPE(ee_info);
-                       break;
-               }
-               DELAY(10000);
-       }
-       if (i == EEINFO_RETRY_MAX) {
-               error = ENXIO;
-               goto fail;
-       }
-#undef EEINFO_RETRY_MAX
-
-       DPRINTF((&sc->sc_ic.ic_if, "radio type %02x\n", sc->sc_radio_type));
-
-#ifdef DUMP_EEPROM
-       for (i = 0; i < 0x40; ++i) {
-               uint8_t val;
-
-               error = acx_read_eeprom(sc, i, &val);
-               if (i % 10 == 0)
-                       kprintf("\n");
-               kprintf("%02x ", val);
-       }
-       kprintf("\n");
-#endif /* DUMP_EEPROM */
-
-       /* Get EEPROM version */
-       error = acx_read_eeprom(sc, ACX_EE_VERSION_OFS, &sc->sc_eeprom_ver);
-       if (error)
-               goto fail;
-       DPRINTF((&sc->sc_ic.ic_if, "EEPROM version %u\n", sc->sc_eeprom_ver));
-
-       /*
-        * Initialize device sysctl before ieee80211_ifattach()
-        */
-       sc->sc_long_retry_limit = 4;
-       sc->sc_msdu_lifetime = 4096;
-       sc->sc_scan_dwell = 200;        /* 200 milliseconds */
-       sc->sc_calib_intvl = 3 * 60;    /* 3 minutes */
-
-       sctx = device_get_sysctl_ctx(dev);
-       soid = device_get_sysctl_tree(dev);
-       SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                       "msdu_lifetime", CTLTYPE_INT | CTLFLAG_RW,
-                       sc, 0, acx_sysctl_msdu_lifetime, "I",
-                       "MSDU life time");
-       SYSCTL_ADD_INT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                      "long_retry_limit", CTLFLAG_RW,
-                      &sc->sc_long_retry_limit, 0, "Long retry limit");
-       SYSCTL_ADD_INT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                      "scan_dwell", CTLFLAG_RW,
-                      &sc->sc_scan_dwell, 0, "Scan channel dwell time (ms)");
-       SYSCTL_ADD_INT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                      "calib_intvl", CTLFLAG_RW,
-                      &sc->sc_calib_intvl, 0, "Calibration interval (second)");
-
-       /*
-        * Nodes for firmware operation
-        */
-       SYSCTL_ADD_INT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                      "combined_radio_fw", CTLFLAG_RW,
-                      &sc->sc_firmware.combined_radio_fw, 0,
-                      "Radio and base firmwares are combined");
-       SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "free_fw",
-                       CTLTYPE_INT | CTLFLAG_RW,
-                       sc, 0, acx_sysctl_free_firmware, "I",
-                       "Free firmware");
-
-       /*
-        * Nodes for statistics
-        */
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "frag_error", CTLFLAG_RW, &sc->sc_stats.err_oth_frag,
-                        0, "Fragment errors");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "tx_abort", CTLFLAG_RW, &sc->sc_stats.err_abort,
-                        0, "TX abortions");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "tx_invalid", CTLFLAG_RW, &sc->sc_stats.err_param,
-                        0, "Invalid TX param in TX descriptor");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "no_wepkey", CTLFLAG_RW, &sc->sc_stats.err_no_wepkey,
-                        0, "No WEP key exists");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "msdu_timeout", CTLFLAG_RW,
-                        &sc->sc_stats.err_msdu_timeout,
-                        0, "MSDU timeouts");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "ex_txretry", CTLFLAG_RW, &sc->sc_stats.err_ex_retry,
-                        0, "Excessive TX retries");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "buf_oflow", CTLFLAG_RW, &sc->sc_stats.err_buf_oflow,
-                        0, "Buffer overflows");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "dma_error", CTLFLAG_RW, &sc->sc_stats.err_dma,
-                        0, "DMA errors");
-       SYSCTL_ADD_UQUAD(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-                        "unkn_error", CTLFLAG_RW, &sc->sc_stats.err_unkn,
-                        0, "Unknown errors");
-
-       ifp->if_softc = sc;
-       ifp->if_init = acx_init;
-       ifp->if_ioctl = acx_ioctl;
-       ifp->if_start = acx_start;
-       ifp->if_watchdog = acx_watchdog;
-       ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
-       ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
-#ifdef notyet
-       ifq_set_ready(&ifp->if_snd);
-#endif
-
-       /* Set channels */
-       for (i = 1; i <= 14; ++i) {
-               ic->ic_channels[i].ic_freq =
-                       ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ);
-               ic->ic_channels[i].ic_flags = sc->chip_chan_flags;
-       }
-
-       ic->ic_opmode = IEEE80211_M_STA;
-       ic->ic_state = IEEE80211_S_INIT;
-
-       /*
-        * NOTE: Don't overwrite ic_caps set by chip specific code
-        */
-       ic->ic_caps |= IEEE80211_C_WEP |        /* WEP */
-                      IEEE80211_C_HOSTAP |     /* HostAP mode */
-                      IEEE80211_C_MONITOR |    /* Monitor mode */
-                      IEEE80211_C_IBSS |       /* IBSS modes */
-                      IEEE80211_C_SHPREAMBLE;  /* Short preamble */
-       if (acx_enable_pbcc)
-               ic->ic_caps_ext = IEEE80211_CEXT_PBCC;  /* PBCC modulation */
-
-       /* Get station id */
-       for (i = 0; i < IEEE80211_ADDR_LEN; ++i) {
-               error = acx_read_eeprom(sc, sc->chip_ee_eaddr_ofs - i,
-                                       &ic->ic_myaddr[i]);
-       }
-
-       ieee80211_ifattach(ic);
-
-       /* Enable software beacon missing */
-       ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS;
-
-       /* Override newstate */
-       sc->sc_newstate = ic->ic_newstate;
-       ic->ic_newstate = acx_newstate;
-
-       ieee80211_media_init(ic, acx_media_change, ieee80211_media_status);
-
-       /*
-        * Radio tap attaching
-        */
-       bpfattach_dlt(ifp, DLT_IEEE802_11_RADIO,
-                     sizeof(struct ieee80211_frame) + sizeof(sc->sc_tx_th),
-                     &sc->sc_drvbpf);
-
-       sc->sc_tx_th_len = roundup(sizeof(sc->sc_tx_th), sizeof(uint32_t));
-       sc->sc_tx_th.wt_ihdr.it_len = htole16(sc->sc_tx_th_len);
-       sc->sc_tx_th.wt_ihdr.it_present = htole32(ACX_TX_RADIOTAP_PRESENT);
-
-       sc->sc_rx_th_len = roundup(sizeof(sc->sc_rx_th), sizeof(uint32_t));
-       sc->sc_rx_th.wr_ihdr.it_len = htole16(sc->sc_rx_th_len);
-       sc->sc_rx_th.wr_ihdr.it_present = htole32(ACX_RX_RADIOTAP_PRESENT);
-
-       ifq_set_cpuid(&ifp->if_snd, rman_get_cpuid(sc->sc_irq_res));
-
-       error = bus_setup_intr(dev, sc->sc_irq_res, INTR_MPSAFE, acx_intr, sc,
-                              &sc->sc_irq_handle, ifp->if_serializer);
-       if (error) {
-               device_printf(dev, "can't set up interrupt\n");
-               bpfdetach(ifp);
-               ieee80211_ifdetach(ic);
-               goto fail;
-       }
-
-       if (bootverbose)
-               ieee80211_announce(ic);
-
-       return 0;
-fail:
-       acx_detach(dev);
-       return error;
-}
-
-static int
-acx_detach(device_t dev)
-{
-       struct acx_softc *sc = device_get_softc(dev);
-
-       if (device_is_attached(dev)) {
-               struct ieee80211com *ic = &sc->sc_ic;
-               struct ifnet *ifp = &ic->ic_if;
-
-               lwkt_serialize_enter(ifp->if_serializer);
-
-               acx_stop(sc);
-               acx_free_firmware(sc);
-               bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_irq_handle);
-
-               lwkt_serialize_exit(ifp->if_serializer);
-
-               bpfdetach(ifp);
-               ieee80211_ifdetach(ic);
-       }
-
-       if (sc->sc_irq_res != NULL) {
-               bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid,
-                                    sc->sc_irq_res);
-       }
-       if (sc->sc_mem1_res != NULL) {
-               bus_release_resource(dev, SYS_RES_MEMORY, sc->chip_mem1_rid,
-                                    sc->sc_mem1_res);
-       }
-       if (sc->sc_mem2_res != NULL) {
-               bus_release_resource(dev, SYS_RES_MEMORY, sc->chip_mem2_rid,
-                                    sc->sc_mem2_res);
-       }
-
-       acx_dma_free(sc);
-       return 0;
-}
-
-static int
-acx_shutdown(device_t dev)
-{
-       struct acx_softc *sc = device_get_softc(dev);
-
-       lwkt_serialize_enter(sc->sc_ic.ic_if.if_serializer);
-       acx_stop(sc);
-       lwkt_serialize_exit(sc->sc_ic.ic_if.if_serializer);
-       return 0;
-}
-
-static void
-acx_init(void *arg)
-{
-       struct acx_softc *sc = arg;
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct ifnet *ifp = &ic->ic_if;
-       struct acx_firmware *fw = &sc->sc_firmware;
-       int error;
-
-       error = acx_stop(sc);
-       if (error)
-               return;
-
-       error = acx_alloc_firmware(sc);
-       if (error)
-               return;
-
-       error = acx_init_tx_ring(sc);
-       if (error) {
-               if_printf(ifp, "can't initialize TX ring\n");
-               goto back;
-       }
-
-       error = acx_init_rx_ring(sc);
-       if (error) {
-               if_printf(ifp, "can't initialize RX ring\n");
-               goto back;
-       }
-
-       error = acx_load_base_firmware(sc, fw->base_fw, fw->base_fw_len);
-       if (error)
-               goto back;
-
-       /*
-        * Initialize command and information registers
-        * NOTE: This should be done after base firmware is loaded
-        */
-       acx_init_cmd_reg(sc);
-       acx_init_info_reg(sc);
-
-       sc->sc_flags |= ACX_FLAG_FW_LOADED;
-
-#if 0
-       if (sc->chip_post_basefw != NULL) {
-               error = sc->chip_post_basefw(sc);
-               if (error)
-                       goto back;
-       }
-#endif
-
-       if (fw->radio_fw != NULL) {
-               error = acx_load_radio_firmware(sc, fw->radio_fw,
-                                               fw->radio_fw_len);
-               if (error)
-                       goto back;
-       }
-
-       error = sc->chip_init(sc);
-       if (error)
-               goto back;
-
-       /* Get and set device various configuration */
-       error = acx_config(sc);
-       if (error)
-               goto back;
-
-       /* Setup crypto stuffs */
-       if (sc->sc_ic.ic_flags & IEEE80211_F_PRIVACY) {
-               error = acx_set_crypt_keys(sc);
-               if (error)
-                       goto back;
-               sc->sc_ic.ic_flags &= ~IEEE80211_F_DROPUNENC;
-       }
-
-       /* Turn on power led */
-       CSR_CLRB_2(sc, ACXREG_GPIO_OUT, sc->chip_gpio_pled);
-
-       acx_enable_intr(sc);
-
-       ifp->if_flags |= IFF_RUNNING;
-       ifq_clr_oactive(&ifp->if_snd);
-
-       if (ic->ic_opmode != IEEE80211_M_MONITOR) {
-               if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)
-                       ieee80211_new_state(&sc->sc_ic, IEEE80211_S_SCAN, -1);
-       } else {
-               ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
-       }
-back:
-       if (error)
-               acx_stop(sc);
-}
-
-static void
-acx_init_info_reg(struct acx_softc *sc)
-{
-       sc->sc_info = CSR_READ_4(sc, ACXREG_INFO_REG_OFFSET);
-       sc->sc_info_param = sc->sc_info + ACX_INFO_REG_SIZE;
-}
-
-static int
-acx_set_crypt_keys(struct acx_softc *sc)
-{
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct acx_conf_wep_txkey wep_txkey;
-       int i, error, got_wk = 0;
-
-       for (i = 0; i < IEEE80211_WEP_NKID; ++i) {
-               struct ieee80211_key *wk = &ic->ic_nw_keys[i];
-
-               if (wk->wk_keylen == 0)
-                       continue;
-
-               if (sc->chip_hw_crypt) {
-                       error = sc->chip_set_wepkey(sc, wk, i);
-                       if (error)
-                               return error;
-                       got_wk = 1;
-               } else if (wk->wk_flags & IEEE80211_KEY_XMIT) {
-                       wk->wk_flags |= IEEE80211_KEY_SWCRYPT;
-               }
-       }
-
-       if (!got_wk || sc->chip_hw_crypt ||
-           ic->ic_def_txkey == IEEE80211_KEYIX_NONE)
-               return 0;
-
-       /* Set current WEP key index */
-       wep_txkey.wep_txkey = ic->ic_def_txkey;
-       if (acx_set_wep_txkey_conf(sc, &wep_txkey) != 0) {
-               if_printf(&ic->ic_if, "set WEP txkey failed\n");
-               return ENXIO;
-       }
-       return 0;
-}
-
-static void
-acx_next_scan(void *arg)
-{
-       struct acx_softc *sc = arg;
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct ifnet *ifp = &ic->ic_if;
-
-       lwkt_serialize_enter(ifp->if_serializer);
-
-       if (ic->ic_state == IEEE80211_S_SCAN)
-               ieee80211_next_scan(ic);
-
-       lwkt_serialize_exit(ifp->if_serializer);
-}
-
-static int
-acx_stop(struct acx_softc *sc)
-{
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct ifnet *ifp = &ic->ic_if;
-       struct acx_buf_data *bd = &sc->sc_buf_data;
-       struct acx_ring_data *rd = &sc->sc_ring_data;
-       int i, error;
-
-       ASSERT_SERIALIZED(ifp->if_serializer);
-
-       ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1);
-
-       sc->sc_firmware_ver = 0;
-       sc->sc_hardware_id = 0;
-
-       /* Reset hardware */
-       error = acx_reset(sc);
-       if (error)
-               return error;
-
-       /* Firmware no longer functions after hardware reset */
-       sc->sc_flags &= ~ACX_FLAG_FW_LOADED;
-
-       acx_disable_intr(sc);
-
-       /* Stop backgroud scanning */
-       callout_stop(&sc->sc_scan_timer);
-
-       /* Turn off power led */
-       CSR_SETB_2(sc, ACXREG_GPIO_OUT, sc->chip_gpio_pled);
-
-       /* Free TX mbuf */
-       for (i = 0; i < ACX_TX_DESC_CNT; ++i) {
-               struct acx_txbuf *buf;
-
-               buf = &bd->tx_buf[i];
-
-               if (buf->tb_mbuf != NULL) {
-                       bus_dmamap_unload(bd->mbuf_dma_tag,
-                                         buf->tb_mbuf_dmamap);
-                       m_freem(buf->tb_mbuf);
-                       buf->tb_mbuf = NULL;
-               }
-
-               if (buf->tb_node != NULL)
-                       ieee80211_free_node(buf->tb_node);
-               buf->tb_node = NULL;
-       }
-
-       /* Clear TX host descriptors */
-       bzero(rd->tx_ring, ACX_TX_RING_SIZE);
-
-       /* Free RX mbuf */
-       for (i = 0; i < ACX_RX_DESC_CNT; ++i) {
-               if (bd->rx_buf[i].rb_mbuf != NULL) {
-                       bus_dmamap_unload(bd->mbuf_dma_tag,
-                                         bd->rx_buf[i].rb_mbuf_dmamap);
-                       m_freem(bd->rx_buf[i].rb_mbuf);
-                       bd->rx_buf[i].rb_mbuf = NULL;
-               }
-       }
-
-       /* Clear RX host descriptors */
-       bzero(rd->rx_ring, ACX_RX_RING_SIZE);
-
-       sc->sc_tx_timer = 0;
-       ifp->if_timer = 0;
-       ifp->if_flags &= ~IFF_RUNNING;
-       ifq_clr_oactive(&ifp->if_snd);
-
-       return 0;
-}
-
-static int
-acx_config(struct acx_softc *sc)
-{
-       struct acx_config conf;
-       int error;
-
-       error = acx_read_config(sc, &conf);
-       if (error)
-               return error;
-
-       error = acx_write_config(sc, &conf);
-       if (error)
-               return error;
-
-       error = acx_rx_config(sc, sc->sc_flags & ACX_FLAG_PROMISC);
-       if (error)
-               return error;
-
-       if (acx_set_probe_req_tmplt(sc, "", 0) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set probe req template "
-                         "(empty ssid)\n");
-               return ENXIO;
-       }
-
-       /* XXX for PM?? */
-       if (acx_set_null_tmplt(sc) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set null data template\n");
-               return ENXIO;
-       }
-       return 0;
-}
-
-static int
-acx_read_config(struct acx_softc *sc, struct acx_config *conf)
-{
-       struct acx_conf_eaddr addr;
-       struct acx_conf_regdom reg_dom;
-       struct acx_conf_antenna ant;
-       struct acx_conf_fwrev fw_rev;
-       char ethstr[ETHER_ADDRSTRLEN + 1];
-       uint32_t fw_rev_no;
-       uint8_t sen;
-       int i, error;
-
-       /* Get station id */
-       if (acx_get_eaddr_conf(sc, &addr) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get station id\n");
-               return ENXIO;
-       }
-
-       /*
-        * Get and print station id in case that EEPROM station id's
-        * offset is not correct
-        */
-       for (i = 0; i < IEEE80211_ADDR_LEN; ++i)
-               conf->eaddr[IEEE80211_ADDR_LEN - 1 - i] = addr.eaddr[i];
-       if_printf(&sc->sc_ic.ic_if, "MAC address (from firmware): %s\n",
-           kether_ntoa(conf->eaddr, ethstr));
-
-       /* Get region domain */
-       if (acx_get_regdom_conf(sc, &reg_dom) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get region domain\n");
-               return ENXIO;
-       }
-       conf->regdom = reg_dom.regdom;
-       DPRINTF((&sc->sc_ic.ic_if, "regdom %02x\n", reg_dom.regdom));
-
-       /* Get antenna */
-       if (acx_get_antenna_conf(sc, &ant) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get antenna\n");
-               return ENXIO;
-       }
-       conf->antenna = ant.antenna;
-       DPRINTF((&sc->sc_ic.ic_if, "antenna %02x\n", ant.antenna));
-
-       /* Get sensitivity XXX not used */
-       if (sc->sc_radio_type == ACX_RADIO_TYPE_MAXIM ||
-           sc->sc_radio_type == ACX_RADIO_TYPE_RFMD ||
-           sc->sc_radio_type == ACX_RADIO_TYPE_RALINK) {
-               error = acx_read_phyreg(sc, ACXRV_PHYREG_SENSITIVITY, &sen);
-               if (error) {
-                       if_printf(&sc->sc_ic.ic_if, "can't get sensitivity\n");
-                       return error;
-               }
-       } else {
-               sen = 0;
-       }
-       DPRINTF((&sc->sc_ic.ic_if, "sensitivity %02x\n", sen));
-
-       /* Get firmware revision */
-       if (acx_get_fwrev_conf(sc, &fw_rev) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't get firmware revision\n");
-               return ENXIO;
-       }
-
-       if (strncmp(fw_rev.fw_rev, "Rev ", 4) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "strange revision string -- %s\n",
-                         fw_rev.fw_rev);
-               fw_rev_no = 0x01090407;
-       } else {
-               char *s, *endp;
-
-               /*
-                *  01234
-                * "Rev xx.xx.xx.xx"
-                *      ^ Start from here
-                */
-               s = &fw_rev.fw_rev[4];
-               fw_rev_no = 0;
-               for (i = 0; i < 4; ++i) {
-                       uint8_t val;
-
-                       val = strtoul(s, &endp, 16);
-                       fw_rev_no |= val << ((3 - i) * 8);
-
-                       if (*endp == '\0')
-                               break;
-                       else
-                               s = ++endp;
-               }
-       }
-       sc->sc_firmware_ver = fw_rev_no;
-       sc->sc_hardware_id = le32toh(fw_rev.hw_id);
-       DPRINTF((&sc->sc_ic.ic_if, "fw rev %08x, hw id %08x\n",
-                sc->sc_firmware_ver, sc->sc_hardware_id));
-
-       if (sc->chip_read_config != NULL) {
-               error = sc->chip_read_config(sc, conf);
-               if (error)
-                       return error;
-       }
-       return 0;
-}
-
-static int
-acx_write_config(struct acx_softc *sc, struct acx_config *conf)
-{
-       struct acx_conf_nretry_short sretry;
-       struct acx_conf_nretry_long lretry;
-       struct acx_conf_msdu_lifetime msdu_lifetime;
-       struct acx_conf_rate_fallback rate_fb;
-       struct acx_conf_antenna ant;
-       struct acx_conf_regdom reg_dom;
-       int error;
-
-       /* Set number of long/short retry */
-       KKASSERT(sc->chip_short_retry_limit > 0);
-       sretry.nretry = sc->chip_short_retry_limit;
-       if (acx_set_nretry_short_conf(sc, &sretry) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set short retry limit\n");
-               return ENXIO;
-       }
-
-       lretry.nretry = sc->sc_long_retry_limit;
-       if (acx_set_nretry_long_conf(sc, &lretry) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set long retry limit\n");
-               return ENXIO;
-       }
-
-       /* Set MSDU lifetime */
-       msdu_lifetime.lifetime = htole32(sc->sc_msdu_lifetime);
-       if (acx_set_msdu_lifetime_conf(sc, &msdu_lifetime) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set MSDU lifetime\n");
-               return ENXIO;
-       }
-
-       /* Enable rate fallback */
-       rate_fb.ratefb_enable = 1;
-       if (acx_set_rate_fallback_conf(sc, &rate_fb) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't enable rate fallback\n");
-               return ENXIO;
-       }
-
-       /* Set antenna */
-       ant.antenna = conf->antenna;
-       if (acx_set_antenna_conf(sc, &ant) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set antenna\n");
-               return ENXIO;
-       }
-
-       /* Set region domain */
-       reg_dom.regdom = conf->regdom;
-       if (acx_set_regdom_conf(sc, &reg_dom) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't set region domain\n");
-               return ENXIO;
-       }
-
-       if (sc->chip_write_config != NULL) {
-               error = sc->chip_write_config(sc, conf);
-               if (error)
-                       return error;
-       }
-
-       return 0;
-}
-
-static int
-acx_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
-{
-       struct acx_softc *sc = ifp->if_softc;
-       struct ieee80211com *ic = &sc->sc_ic;
-       int error;
-
-       error = 0;
-
-       switch (cmd) {
-       case SIOCSIFFLAGS:
-               if (ifp->if_flags & IFF_UP) {
-                       if ((ifp->if_flags & IFF_RUNNING)) {
-                               int promisc = -1;
-
-                               if ((ifp->if_flags & IFF_PROMISC) &&
-                                   (sc->sc_flags & ACX_FLAG_PROMISC) == 0)
-                                       promisc = 1;
-                               else if ((ifp->if_flags & IFF_PROMISC) == 0 &&
-                                        (sc->sc_flags & ACX_FLAG_PROMISC))
-                                       promisc = 0;
-
-                               /*
-                                * Promisc mode is always enabled when
-                                * operation mode is Monitor.
-                                */
-                               if (ic->ic_opmode != IEEE80211_M_MONITOR &&
-                                   promisc >= 0)
-                                       error = acx_rx_config(sc, promisc);
-                       } else {
-                               acx_init(sc);
-                       }
-               } else {
-                       if (ifp->if_flags & IFF_RUNNING)
-                               acx_stop(sc);
-               }
-
-               if (ifp->if_flags & IFF_PROMISC)
-                       sc->sc_flags |= ACX_FLAG_PROMISC;
-               else
-                       sc->sc_flags &= ~ACX_FLAG_PROMISC;
-               break;
-       case SIOCADDMULTI:
-       case SIOCDELMULTI:
-               /* TODO */
-               break;
-       default:
-               error = ieee80211_ioctl(ic, cmd, data, cr);
-               break;
-       }
-
-       if (error == ENETRESET) {
-               if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) ==
-                   (IFF_RUNNING | IFF_UP))
-                       acx_init(sc);
-               error = 0;
-       }
-       return error;
-}
-
-static void
-acx_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
-{
-       struct acx_softc *sc = ifp->if_softc;
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct acx_buf_data *bd = &sc->sc_buf_data;
-       struct acx_txbuf *buf;
-       int trans, idx;
-
-       ASSERT_ALTQ_SQ_DEFAULT(ifp, ifsq);
-       ASSERT_SERIALIZED(ifp->if_serializer);
-
-       if ((sc->sc_flags & ACX_FLAG_FW_LOADED) == 0) {
-               ifq_purge(&ifp->if_snd);
-               ieee80211_drain_mgtq(&ic->ic_mgtq);
-               return;
-       }
-
-       if ((ifp->if_flags & IFF_RUNNING) == 0 || ifq_is_oactive(ifp->if_snd))
-               return;
-
-       /*
-        * NOTE:
-        * We can't start from a random position that TX descriptor
-        * is free, since hardware will be confused by that.
-        * We have to follow the order of the TX ring.
-        */
-       idx = bd->tx_free_start;
-       trans = 0;
-       for (buf = &bd->tx_buf[idx]; buf->tb_mbuf == NULL;
-            buf = &bd->tx_buf[idx]) {
-               struct ieee80211_frame *f;
-               struct ieee80211_node *ni = NULL;
-               struct mbuf *m;
-               int mgmt_pkt = 0;
-
-               if (!IF_QEMPTY(&ic->ic_mgtq)) {
-                       IF_DEQUEUE(&ic->ic_mgtq, m);
-
-                       ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
-                       m->m_pkthdr.rcvif = NULL;
-
-                       mgmt_pkt = 1;
-
-                       /*
-                        * Don't transmit probe response firmware will
-                        * do it for us.
-                        */
-                       f = mtod(m, struct ieee80211_frame *);
-                       if ((f->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
-                           IEEE80211_FC0_TYPE_MGT &&
-                           (f->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) ==
-                           IEEE80211_FC0_SUBTYPE_PROBE_RESP) {
-                               if (ni != NULL)
-                                       ieee80211_free_node(ni);
-                               m_freem(m);
-                               continue;
-                       }
-               } else if (!ifq_is_empty(&ifp->if_snd)) {
-                       struct ether_header *eh;
-
-                       if (ic->ic_state != IEEE80211_S_RUN) {
-                               ifq_purge(&ifp->if_snd);
-                               break;
-                       }
-
-                       m = ifq_dequeue(&ifp->if_snd);
-                       if (m == NULL)
-                               break;
-
-                       if (m->m_len < sizeof(struct ether_header)) {
-                               m = m_pullup(m, sizeof(struct ether_header));
-                               if (m == NULL) {
-                                       IFNET_STAT_INC(ifp, oerrors, 1);
-                                       continue;
-                               }
-                       }
-                       eh = mtod(m, struct ether_header *);
-
-                       ni = ieee80211_find_txnode(ic, eh->ether_dhost);
-                       if (ni == NULL) {
-                               m_freem(m);
-                               IFNET_STAT_INC(ifp, oerrors, 1);
-                               continue;
-                       }
-
-                       /* TODO power save */
-
-                       BPF_MTAP(ifp, m);
-
-                       m = ieee80211_encap(ic, m, ni);
-                       if (m == NULL) {
-                               ieee80211_free_node(ni);
-                               IFNET_STAT_INC(ifp, oerrors, 1);
-                               continue;
-                       }
-               } else {
-                       break;
-               }
-
-               if (ic->ic_rawbpf != NULL)
-                       bpf_mtap(ic->ic_rawbpf, m);
-
-               f = mtod(m, struct ieee80211_frame *);
-               if ((f->i_fc[1] & IEEE80211_FC1_PROTECTED) && !sc->chip_hw_crypt) {
-                       KASSERT(ni != NULL, ("TX node is NULL (WEP)"));
-                       if (ieee80211_crypto_encap(ic, ni, m) == NULL) {
-                               ieee80211_free_node(ni);
-                               m_freem(m);
-                               IFNET_STAT_INC(ifp, oerrors, 1);
-                               continue;
-                       }
-               }
-
-               /*
-                * Since mgmt data are transmitted at fixed rate
-                * they will not be used to do rate control.
-                */
-               if (mgmt_pkt && ni != NULL) {
-                       ieee80211_free_node(ni);
-                       ni = NULL;
-               }
-
-               if (acx_encap(sc, buf, m, ni) != 0) {
-                       /*
-                        * NOTE: `m' will be freed in acx_encap()
-                        * if we reach here.
-                        */
-                       if (ni != NULL)
-                               ieee80211_free_node(ni);
-                       IFNET_STAT_INC(ifp, oerrors, 1);
-                       continue;
-               }
-
-               /*
-                * NOTE:
-                * 1) `m' should not be touched after acx_encap()
-                * 2) `node' will be used to do TX rate control during
-                *    acx_txeof(), so it is not freed here.  acx_txeof()
-                *    will free it for us
-                */
-
-               trans = 1;
-               bd->tx_used_count++;
-               idx = (idx + 1) % ACX_TX_DESC_CNT;
-       }
-       bd->tx_free_start = idx;
-
-       if (bd->tx_used_count == ACX_TX_DESC_CNT)
-               ifq_set_oactive(&ifp->if_snd);
-
-       if (trans && sc->sc_tx_timer == 0)
-               sc->sc_tx_timer = 5;
-       ifp->if_timer = 1;
-}
-
-static void
-acx_watchdog(struct ifnet *ifp)
-{
-       struct acx_softc *sc = ifp->if_softc;
-
-       ifp->if_timer = 0;
-
-       if ((ifp->if_flags & IFF_RUNNING) == 0)
-               return;
-
-       if (sc->sc_tx_timer) {
-               if (--sc->sc_tx_timer == 0) {
-                       if_printf(ifp, "watchdog timeout\n");
-                       IFNET_STAT_INC(ifp, oerrors, 1);
-                       acx_txeof(ifp->if_softc);
-               } else {
-                       ifp->if_timer = 1;
-               }
-       }
-       ieee80211_watchdog(&sc->sc_ic);
-}
-
-static void
-acx_intr(void *arg)
-{
-       struct acx_softc *sc = arg;
-       uint16_t intr_status;
-
-       if ((sc->sc_flags & ACX_FLAG_FW_LOADED) == 0)
-               return;
-
-       intr_status = CSR_READ_2(sc, ACXREG_INTR_STATUS_CLR);
-       if (intr_status == ACXRV_INTR_ALL) {
-               /* not our interrupt */
-               return;
-       }
-
-       intr_status &= sc->chip_intr_enable;
-       if (intr_status == 0) {
-               /* not interrupts we care about */
-               return;
-       }
-
-       /* Acknowledge all interrupts */
-       CSR_WRITE_2(sc, ACXREG_INTR_ACK, ACXRV_INTR_ALL);
-
-       if (intr_status & ACXRV_INTR_TX_FINI)
-               acx_txeof(sc);
-
-       if (intr_status & ACXRV_INTR_RX_FINI)
-               acx_rxeof(sc);
-}
-
-static void
-acx_disable_intr(struct acx_softc *sc)
-{
-       CSR_WRITE_2(sc, ACXREG_INTR_MASK, sc->chip_intr_disable);
-       CSR_WRITE_2(sc, ACXREG_EVENT_MASK, 0);
-}
-
-static void
-acx_enable_intr(struct acx_softc *sc)
-{
-       /* Mask out interrupts that are not in the enable set */
-       CSR_WRITE_2(sc, ACXREG_INTR_MASK, ~sc->chip_intr_enable);
-       CSR_WRITE_2(sc, ACXREG_EVENT_MASK, ACXRV_EVENT_DISABLE);
-}
-
-static void
-acx_txeof(struct acx_softc *sc)
-{
-       struct acx_buf_data *bd;
-       struct acx_txbuf *buf;
-       struct ifnet *ifp;
-       int idx;
-
-       ifp = &sc->sc_ic.ic_if;
-       ASSERT_SERIALIZED(ifp->if_serializer);
-
-       bd = &sc->sc_buf_data;
-       idx = bd->tx_used_start;
-       for (buf = &bd->tx_buf[idx]; buf->tb_mbuf != NULL;
-            buf = &bd->tx_buf[idx]) {
-               uint8_t ctrl, error;
-               int frame_len;
-
-               ctrl = FW_TXDESC_GETFIELD_1(sc, buf, f_tx_ctrl);
-               if ((ctrl & (DESC_CTRL_HOSTOWN | DESC_CTRL_ACXDONE)) !=
-                   (DESC_CTRL_HOSTOWN | DESC_CTRL_ACXDONE))
-                       break;
-
-               bus_dmamap_unload(bd->mbuf_dma_tag, buf->tb_mbuf_dmamap);
-               frame_len = buf->tb_mbuf->m_pkthdr.len;
-               m_freem(buf->tb_mbuf);
-               buf->tb_mbuf = NULL;
-
-               error = FW_TXDESC_GETFIELD_1(sc, buf, f_tx_error);
-               if (error) {
-                       acx_txerr(sc, error);
-                       IFNET_STAT_INC(ifp, oerrors, 1);
-               } else {
-                       IFNET_STAT_INC(ifp, opackets, 1);
-               }
-
-               if (buf->tb_node != NULL) {
-                       sc->chip_tx_complete(sc, buf, frame_len, error);
-                       ieee80211_free_node(buf->tb_node);
-                       buf->tb_node = NULL;
-               }
-
-               FW_TXDESC_SETFIELD_1(sc, buf, f_tx_ctrl, DESC_CTRL_HOSTOWN);
-
-               bd->tx_used_count--;
-
-               idx = (idx + 1) % ACX_TX_DESC_CNT;
-       }
-       bd->tx_used_start = idx;
-
-       sc->sc_tx_timer = bd->tx_used_count == 0 ? 0 : 5;
-
-       if (bd->tx_used_count != ACX_TX_DESC_CNT) {
-               ifq_clr_oactive(&ifp->if_snd);
-               ifp->if_start(ifp);
-       }
-}
-
-static void
-acx_txerr(struct acx_softc *sc, uint8_t err)
-{
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       struct acx_stats *stats = &sc->sc_stats;
-
-       if (err == DESC_ERR_EXCESSIVE_RETRY) {
-               /*
-                * This a common error (see comment below),
-                * so print it using DPRINTF()
-                */
-               DPRINTF((ifp, "TX failed -- excessive retry\n"));
-       } else {
-               if_printf(ifp, "TX failed -- ");
-       }
-
-       /*
-        * Although `err' looks like bitmask, it never
-        * has multiple bits set.
-        */
-       switch (err) {
-#if 0
-       case DESC_ERR_OTHER_FRAG:
-               /* XXX what's this */
-               kprintf("error in other fragment\n");
-               stats->err_oth_frag++;
-               break;
-#endif
-       case DESC_ERR_ABORT:
-               kprintf("aborted\n");
-               stats->err_abort++;
-               break;
-       case DESC_ERR_PARAM:
-               kprintf("wrong parameters in descriptor\n");
-               stats->err_param++;
-               break;
-       case DESC_ERR_NO_WEPKEY:
-               kprintf("WEP key missing\n");
-               stats->err_no_wepkey++;
-               break;
-       case DESC_ERR_MSDU_TIMEOUT:
-               kprintf("MSDU life timeout\n");
-               stats->err_msdu_timeout++;
-               break;
-       case DESC_ERR_EXCESSIVE_RETRY:
-               /*
-                * Possible causes:
-                * 1) Distance is too long
-                * 2) Transmit failed (e.g. no MAC level ACK)
-                * 3) Chip overheated (this should be rare)
-                */
-               stats->err_ex_retry++;
-               break;
-       case DESC_ERR_BUF_OVERFLOW:
-               kprintf("buffer overflow\n");
-               stats->err_buf_oflow++;
-               break;
-       case DESC_ERR_DMA:
-               kprintf("DMA error\n");
-               stats->err_dma++;
-               break;
-       default:
-               kprintf("unknown error %d\n", err);
-               stats->err_unkn++;
-               break;
-       }
-}
-
-static void
-acx_rxeof(struct acx_softc *sc)
-{
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct acx_ring_data *rd = &sc->sc_ring_data;
-       struct acx_buf_data *bd = &sc->sc_buf_data;
-       struct ifnet *ifp = &ic->ic_if;
-       int idx, ready;
-
-       ASSERT_SERIALIZED(ic->ic_if.if_serializer);
-
-       bus_dmamap_sync(rd->rx_ring_dma_tag, rd->rx_ring_dmamap,
-                       BUS_DMASYNC_POSTREAD);
-
-       /*
-        * Locate first "ready" rx buffer,
-        * start from last stopped position
-        */
-       idx = bd->rx_scan_start;
-       ready = 0;
-       do {
-               struct acx_rxbuf *buf;
-
-               buf = &bd->rx_buf[idx];
-               if ((buf->rb_desc->h_ctrl & htole16(DESC_CTRL_HOSTOWN)) &&
-                   (buf->rb_desc->h_status & htole32(DESC_STATUS_FULL))) {
-                       ready = 1;
-                       break;
-               }
-               idx = (idx + 1) % ACX_RX_DESC_CNT;
-       } while (idx != bd->rx_scan_start);
-
-       if (!ready)
-               return;
-
-       /*
-        * NOTE: don't mess up `idx' here, it will
-        * be used in the following code
-        */
-
-       do {
-               struct acx_rxbuf_hdr *head;
-               struct acx_rxbuf *buf;
-               struct ieee80211_frame_min *wh;
-               struct mbuf *m;
-               uint32_t desc_status;
-               uint16_t desc_ctrl;
-               int len, error, rssi, is_priv;
-
-               buf = &bd->rx_buf[idx];
-
-               desc_ctrl = le16toh(buf->rb_desc->h_ctrl);
-               desc_status = le32toh(buf->rb_desc->h_status);
-               if (!(desc_ctrl & DESC_CTRL_HOSTOWN) ||
-                   !(desc_status & DESC_STATUS_FULL))
-                       break;
-
-               bus_dmamap_sync(bd->mbuf_dma_tag, buf->rb_mbuf_dmamap,
-                               BUS_DMASYNC_POSTREAD);
-
-               m = buf->rb_mbuf;
-
-               error = acx_newbuf(sc, buf, 0);
-               if (error) {
-                       IFNET_STAT_INC(ifp, ierrors, 1);
-                       goto next;
-               }
-
-               head = mtod(m, struct acx_rxbuf_hdr *);
-               len = le16toh(head->rbh_len) & ACX_RXBUF_LEN_MASK;
-               rssi = acx_get_rssi(sc, head->rbh_level);
-
-               m_adj(m, sizeof(struct acx_rxbuf_hdr) + sc->chip_rxbuf_exhdr);
-               m->m_len = m->m_pkthdr.len = len;
-               m->m_pkthdr.rcvif = &ic->ic_if;
-
-               wh = mtod(m, struct ieee80211_frame_min *);
-               is_priv = (wh->i_fc[1] & IEEE80211_FC1_PROTECTED);
-
-               if (sc->sc_drvbpf != NULL) {
-                       sc->sc_rx_th.wr_tsf = htole32(head->rbh_time);
-
-                       sc->sc_rx_th.wr_flags = 0;
-                       if (is_priv) {
-                               sc->sc_rx_th.wr_flags |=
-                                       IEEE80211_RADIOTAP_F_WEP;
-                       }
-                       if (head->rbh_bbp_stat & ACX_RXBUF_STAT_SHPRE) {
-                               sc->sc_rx_th.wr_flags |=
-                                       IEEE80211_RADIOTAP_F_SHORTPRE;
-                       }
-
-                       if (sc->chip_phymode == IEEE80211_MODE_11G) {
-                               sc->sc_rx_th.wr_rate =
-                                   ieee80211_plcp2rate(head->rbh_plcp,
-                                   head->rbh_bbp_stat & ACX_RXBUF_STAT_OFDM);
-                       } else {
-                               sc->sc_rx_th.wr_rate =
-                                   ieee80211_plcp2rate(head->rbh_plcp, 0);
-                       }
-
-                       sc->sc_rx_th.wr_antsignal = rssi;
-
-                       if (head->rbh_bbp_stat & ACX_RXBUF_STAT_ANT1)
-                               sc->sc_rx_th.wr_antenna = 1;
-                       else
-                               sc->sc_rx_th.wr_antenna = 0;
-
-                       bpf_ptap(sc->sc_drvbpf, m, &sc->sc_rx_th,
-                                sc->sc_rx_th_len);
-               }
-
-               if (len >= sizeof(struct ieee80211_frame_min) &&
-                   len < MCLBYTES) {
-                       struct ieee80211_node *ni;
-
-                       if (is_priv && sc->chip_hw_crypt) {
-                               /* Short circuit software WEP */
-                               wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
-
-                               /* Do chip specific RX buffer processing */
-                               if (sc->chip_proc_wep_rxbuf != NULL) {
-                                       sc->chip_proc_wep_rxbuf(sc, m, &len);
-                                       wh = mtod(m,
-                                            struct ieee80211_frame_min *);
-                               }
-                       }
-                       m->m_len = m->m_pkthdr.len = len;
-
-                       ni = ieee80211_find_rxnode(ic, wh);
-                       ieee80211_input(ic, m, ni, rssi,
-                                       le32toh(head->rbh_time));
-                       ieee80211_free_node(ni);
-
-                       IFNET_STAT_INC(ifp, ipackets, 1);
-               } else {
-                       if (len < sizeof(struct ieee80211_frame_min)) {
-                               if (ic->ic_rawbpf != NULL &&
-                                   len >= sizeof(struct ieee80211_frame_ack))
-                                       bpf_mtap(ic->ic_rawbpf, m);
-
-                               if (ic->ic_opmode != IEEE80211_M_MONITOR)
-                                       ic->ic_stats.is_rx_tooshort++;
-                       }
-                       m_freem(m);
-               }
-next:
-               buf->rb_desc->h_ctrl = htole16(desc_ctrl & ~DESC_CTRL_HOSTOWN);
-               buf->rb_desc->h_status = 0;
-               bus_dmamap_sync(rd->rx_ring_dma_tag, rd->rx_ring_dmamap,
-                               BUS_DMASYNC_PREWRITE);
-
-               idx = (idx + 1) % ACX_RX_DESC_CNT;
-       } while (idx != bd->rx_scan_start);
-
-       /*
-        * Record the position so that next
-        * time we can start from it
-        */
-       bd->rx_scan_start = idx;
-}
-
-static int
-acx_reset(struct acx_softc *sc)
-{
-       uint16_t reg;
-
-       /* Halt ECPU */
-       CSR_SETB_2(sc, ACXREG_ECPU_CTRL, ACXRV_ECPU_HALT);
-
-       /* Software reset */
-       reg = CSR_READ_2(sc, ACXREG_SOFT_RESET);
-       CSR_WRITE_2(sc, ACXREG_SOFT_RESET, reg | ACXRV_SOFT_RESET);
-       DELAY(100);
-       CSR_WRITE_2(sc, ACXREG_SOFT_RESET, reg);
-
-       /* Initialize EEPROM */
-       CSR_SETB_2(sc, ACXREG_EEPROM_INIT, ACXRV_EEPROM_INIT);
-       DELAY(50000);
-
-       /* Test whether ECPU is stopped */
-       reg = CSR_READ_2(sc, ACXREG_ECPU_CTRL);
-       if (!(reg & ACXRV_ECPU_HALT)) {
-               if_printf(&sc->sc_ic.ic_if, "can't halt ECPU\n");
-               return ENXIO;
-       }
-       return 0;
-}
-
-static int
-acx_read_eeprom(struct acx_softc *sc, uint32_t offset, uint8_t *val)
-{
-       int i;
-
-       CSR_WRITE_4(sc, ACXREG_EEPROM_CONF, 0);
-       CSR_WRITE_4(sc, ACXREG_EEPROM_ADDR, offset);
-       CSR_WRITE_4(sc, ACXREG_EEPROM_CTRL, ACXRV_EEPROM_READ);
-
-#define EE_READ_RETRY_MAX      100
-       for (i = 0; i < EE_READ_RETRY_MAX; ++i) {
-               if (CSR_READ_2(sc, ACXREG_EEPROM_CTRL) == 0)
-                       break;
-               DELAY(10000);
-       }
-       if (i == EE_READ_RETRY_MAX) {
-               if_printf(&sc->sc_ic.ic_if, "can't read EEPROM offset %x "
-                         "(timeout)\n", offset);
-               return ETIMEDOUT;
-       }
-#undef EE_READ_RETRY_MAX
-
-       *val = CSR_READ_1(sc, ACXREG_EEPROM_DATA);
-       return 0;
-}
-
-static int
-acx_read_phyreg(struct acx_softc *sc, uint32_t reg, uint8_t *val)
-{
-       int i;
-
-       CSR_WRITE_4(sc, ACXREG_PHY_ADDR, reg);
-       CSR_WRITE_4(sc, ACXREG_PHY_CTRL, ACXRV_PHY_READ);
-
-#define PHY_READ_RETRY_MAX     100
-       for (i = 0; i < PHY_READ_RETRY_MAX; ++i) {
-               if (CSR_READ_4(sc, ACXREG_PHY_CTRL) == 0)
-                       break;
-               DELAY(10000);
-       }
-       if (i == PHY_READ_RETRY_MAX) {
-               if_printf(&sc->sc_ic.ic_if, "can't read phy reg %x (timeout)\n",
-                         reg);
-               return ETIMEDOUT;
-       }
-#undef PHY_READ_RETRY_MAX
-
-       *val = CSR_READ_1(sc, ACXREG_PHY_DATA);
-       return 0;
-}
-
-void
-acx_write_phyreg(struct acx_softc *sc, uint32_t reg, uint8_t val)
-{
-       CSR_WRITE_4(sc, ACXREG_PHY_DATA, val);
-       CSR_WRITE_4(sc, ACXREG_PHY_ADDR, reg);
-       CSR_WRITE_4(sc, ACXREG_PHY_CTRL, ACXRV_PHY_WRITE);
-}
-
-static int
-acx_alloc_firmware(struct acx_softc *sc)
-{
-       struct acx_firmware *fw = &sc->sc_firmware;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       struct fw_image *img;
-       char filename[64];
-       int error = 0;
-
-       /*
-        * NB: serializer need to be released before loading firmware
-        *     image to avoid possible dead lock
-        */
-       ASSERT_SERIALIZED(ifp->if_serializer);
-
-       if (fw->base_fw_image == NULL) {
-               if (fw->combined_radio_fw) {
-                       ksnprintf(filename, sizeof(filename),
-                                 ACX_BASE_RADIO_FW_PATH,
-                                 fw->fwdir, sc->sc_radio_type);
-               } else {
-                       ksnprintf(filename, sizeof(filename),
-                                 ACX_BASE_FW_PATH, fw->fwdir);
-               }
-
-               lwkt_serialize_exit(ifp->if_serializer);
-               img = firmware_image_load(filename, NULL);
-               lwkt_serialize_enter(ifp->if_serializer);
-
-               fw->base_fw_image = img;
-               if (fw->base_fw_image == NULL) {
-                       if_printf(ifp, "load %s base fw failed\n", filename);
-                       error = EIO;
-                       goto back;
-               }
-
-               error = acx_setup_firmware(sc, fw->base_fw_image,
-                                          &fw->base_fw, &fw->base_fw_len);
-               if (error)
-                       goto back;
-       }
-
-       if (!fw->combined_radio_fw && fw->radio_fw_image == NULL) {
-               ksnprintf(filename, sizeof(filename), ACX_RADIO_FW_PATH,
-                         fw->fwdir, sc->sc_radio_type);
-
-               lwkt_serialize_exit(ifp->if_serializer);
-               img = firmware_image_load(filename, NULL);
-               lwkt_serialize_enter(ifp->if_serializer);
-
-               fw->radio_fw_image = img;
-               if (fw->radio_fw_image == NULL) {
-                       if_printf(ifp, "load %s radio fw failed\n", filename);
-                       error = EIO;
-                       goto back;
-               }
-
-               error = acx_setup_firmware(sc, fw->radio_fw_image,
-                                          &fw->radio_fw, &fw->radio_fw_len);
-       }
-back:
-       if (error)
-               acx_free_firmware(sc);
-       return error;
-}
-
-static int
-acx_setup_firmware(struct acx_softc *sc, struct fw_image *img,
-                  const uint8_t **ptr, int *len)
-{
-       const struct acx_firmware_hdr *hdr;
-       const uint8_t *p;
-       uint32_t cksum;
-       int i;
-
-       *ptr = NULL;
-       *len = 0;
-
-       /*
-        * Make sure that the firmware image contains more than just a header
-        */
-       if (img->fw_imglen <= sizeof(*hdr)) {
-               if_printf(&sc->sc_ic.ic_if, "%s is invalid image, "
-                         "size %zu (too small)\n",
-                         img->fw_name, img->fw_imglen);
-               return EINVAL;
-       }
-       hdr = (const struct acx_firmware_hdr *)img->fw_image;
-
-       /*
-        * Verify length
-        */
-       if (hdr->fwh_len != img->fw_imglen - sizeof(*hdr)) {
-               if_printf(&sc->sc_ic.ic_if, "%s is invalid image, "
-                         "size in hdr %u and image size %zu mismatches\n",
-                         img->fw_name, hdr->fwh_len, img->fw_imglen);
-               return EINVAL;
-       }
-
-       /*
-        * Verify cksum
-        */
-       cksum = 0;
-       for (i = 0, p = (const uint8_t *)&hdr->fwh_len;
-            i < img->fw_imglen - sizeof(hdr->fwh_cksum); ++i, ++p)
-               cksum += *p;
-       if (cksum != hdr->fwh_cksum) {
-               if_printf(&sc->sc_ic.ic_if, "%s is invalid image, "
-                         "checksum mismatch\n", img->fw_name);
-               return EINVAL;
-       }
-
-       *ptr = ((const uint8_t *)img->fw_image + sizeof(*hdr));
-       *len = img->fw_imglen - sizeof(*hdr);
-       return 0;
-}
-
-static void
-acx_free_firmware(struct acx_softc *sc)
-{
-       struct acx_firmware *fw = &sc->sc_firmware;
-
-       if (fw->base_fw_image != NULL) {
-               firmware_image_unload(fw->base_fw_image);
-               fw->base_fw_image = NULL;
-               fw->base_fw = NULL;
-               fw->base_fw_len = 0;
-       }
-       if (fw->radio_fw_image != NULL) {
-               firmware_image_unload(fw->radio_fw_image);
-               fw->radio_fw_image = NULL;
-               fw->radio_fw = NULL;
-               fw->radio_fw_len = 0;
-       }
-}
-
-static int
-acx_load_base_firmware(struct acx_softc *sc, const uint8_t *base_fw,
-                      uint32_t base_fw_len)
-{
-       int i, error;
-
-       /* Load base firmware */
-       error = acx_load_firmware(sc, 0, base_fw, base_fw_len);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't load base firmware\n");
-               return error;
-       }
-       DPRINTF((&sc->sc_ic.ic_if, "base firmware loaded\n"));
-
-       /* Start ECPU */
-       CSR_WRITE_2(sc, ACXREG_ECPU_CTRL, ACXRV_ECPU_START);
-
-       /* Wait for ECPU to be up */
-       for (i = 0; i < 500; ++i) {
-               uint16_t reg;
-
-               reg = CSR_READ_2(sc, ACXREG_INTR_STATUS);
-               if (reg & ACXRV_INTR_FCS_THRESH) {
-                       CSR_WRITE_2(sc, ACXREG_INTR_ACK, ACXRV_INTR_FCS_THRESH);
-                       return 0;
-               }
-               DELAY(10000);
-       }
-
-       if_printf(&sc->sc_ic.ic_if, "can't initialize ECPU (timeout)\n");
-       return ENXIO;
-}
-
-static int
-acx_load_radio_firmware(struct acx_softc *sc, const uint8_t *radio_fw,
-                       uint32_t radio_fw_len)
-{
-       struct acx_conf_mmap mem_map;
-       uint32_t radio_fw_ofs;
-       int error;
-
-       /*
-        * Get the position, where base firmware is loaded, so that
-        * radio firmware can be loaded after it.
-        */
-       if (acx_get_mmap_conf(sc, &mem_map) != 0)
-               return ENXIO;
-       radio_fw_ofs = le32toh(mem_map.code_end);
-
-       /* Put ECPU into sleeping state, before loading radio firmware */
-       if (acx_sleep(sc) != 0)
-               return ENXIO;
-
-       /* Load radio firmware */
-       error = acx_load_firmware(sc, radio_fw_ofs, radio_fw, radio_fw_len);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't load radio firmware\n");
-               return ENXIO;
-       }
-       DPRINTF((&sc->sc_ic.ic_if, "radio firmware loaded\n"));
-
-       /* Wake up sleeping ECPU, after radio firmware is loaded */
-       if (acx_wakeup(sc) != 0)
-               return ENXIO;
-
-       /* Initialize radio */
-       if (acx_init_radio(sc, radio_fw_ofs, radio_fw_len) != 0)
-               return ENXIO;
-
-       /* Verify radio firmware's loading position */
-       if (acx_get_mmap_conf(sc, &mem_map) != 0)
-               return ENXIO;
-       if (le32toh(mem_map.code_end) != radio_fw_ofs + radio_fw_len) {
-               if_printf(&sc->sc_ic.ic_if, "loaded radio firmware position "
-                         "mismatch\n");
-               return ENXIO;
-       }
-
-       DPRINTF((&sc->sc_ic.ic_if, "radio firmware initialized\n"));
-       return 0;
-}
-
-static int
-acx_load_firmware(struct acx_softc *sc, uint32_t offset, const uint8_t *data,
-                 int data_len)
-{
-       const uint32_t *fw;
-       int i, fw_len;
-
-       fw = (const uint32_t *)data;
-       fw_len = data_len / sizeof(uint32_t);
-
-       /*
-        * LOADFW_AUTO_INC only works with some older firmware:
-        * 1) acx100's firmware
-        * 2) acx111's firmware whose rev is 0x00010011
-        */
-
-       /* Load firmware */
-       CSR_WRITE_4(sc, ACXREG_FWMEM_START, ACXRV_FWMEM_START_OP);
-#ifndef LOADFW_AUTO_INC
-       CSR_WRITE_4(sc, ACXREG_FWMEM_CTRL, 0);
-#else
-       CSR_WRITE_4(sc, ACXREG_FWMEM_CTRL, ACXRV_FWMEM_ADDR_AUTOINC);
-       CSR_WRITE_4(sc, ACXREG_FWMEM_ADDR, offset);
-#endif
-
-       for (i = 0; i < fw_len; ++i) {
-#ifndef LOADFW_AUTO_INC
-               CSR_WRITE_4(sc, ACXREG_FWMEM_ADDR, offset + (i * 4));
-#endif
-               CSR_WRITE_4(sc, ACXREG_FWMEM_DATA, be32toh(fw[i]));
-       }
-
-       /* Verify firmware */
-       CSR_WRITE_4(sc, ACXREG_FWMEM_START, ACXRV_FWMEM_START_OP);
-#ifndef LOADFW_AUTO_INC
-       CSR_WRITE_4(sc, ACXREG_FWMEM_CTRL, 0);
-#else
-       CSR_WRITE_4(sc, ACXREG_FWMEM_CTRL, ACXRV_FWMEM_ADDR_AUTOINC);
-       CSR_WRITE_4(sc, ACXREG_FWMEM_ADDR, offset);
-#endif
-
-       for (i = 0; i < fw_len; ++i) {
-               uint32_t val;
-
-#ifndef LOADFW_AUTO_INC
-               CSR_WRITE_4(sc, ACXREG_FWMEM_ADDR, offset + (i * 4));
-#endif
-               val = CSR_READ_4(sc, ACXREG_FWMEM_DATA);
-               if (be32toh(fw[i]) != val) {
-                       if_printf(&sc->sc_ic.ic_if, "fireware mismatch "
-                                 "fw %08x  loaded %08x\n", fw[i], val);
-                       return ENXIO;
-               }
-       }
-       return 0;
-}
-
-static int
-acx_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
-{
-       struct ifnet *ifp = &ic->ic_if;
-       struct acx_softc *sc = ifp->if_softc;
-       struct ieee80211_node *ni = NULL;
-       struct ieee80211_channel *c = NULL;
-       int error = 1, mode = 0;
-
-       ASSERT_SERIALIZED(ifp->if_serializer);
-
-       ieee80211_ratectl_newstate(ic, nstate);
-       callout_stop(&sc->sc_scan_timer);
-       callout_stop(&sc->sc_calibrate_timer);
-
-       switch (nstate) {
-       case IEEE80211_S_SCAN:
-               acx_set_chan(sc, ic->ic_curchan);
-               callout_reset(&sc->sc_scan_timer,
-                             (hz * sc->sc_scan_dwell) / 1000,
-                             acx_next_scan, sc);
-               break;
-       case IEEE80211_S_AUTH:
-               if (ic->ic_opmode == IEEE80211_M_STA) {
-                       ni = ic->ic_bss;
-                       c = ni->ni_chan;
-                       mode = ACX_MODE_STA;
-               }
-               break;
-       case IEEE80211_S_RUN:
-               if (ic->ic_opmode == IEEE80211_M_IBSS ||
-                   ic->ic_opmode == IEEE80211_M_HOSTAP) {
-                       ni = ic->ic_bss;
-                       c = ni->ni_chan;
-                       if (ic->ic_opmode == IEEE80211_M_IBSS)
-                               mode = ACX_MODE_ADHOC;
-                       else
-                               mode = ACX_MODE_AP;
-
-                       if (acx_set_beacon_tmplt(sc, ni) != 0) {
-                               if_printf(ifp, "set bescon template failed\n");
-                               goto back;
-                       }
-                       if (acx_set_probe_resp_tmplt(sc, ni) != 0) {
-                               if_printf(ifp, "set probe response template"
-                                         " failed\n");
-                               goto back;
-                       }
-               } else if (ic->ic_opmode == IEEE80211_M_MONITOR) {
-                       ni = ic->ic_bss;
-                       c = ic->ic_curchan;
-                       mode = ACX_MODE_STA;
-               }
-               break;
-       default:
-               break;
-       }
-
-       if (ni != NULL) {
-               KKASSERT(c != NULL);
-
-               if (acx_set_chan(sc, c) != 0)
-                       goto back;
-
-               if (acx_join_bss(sc, mode, ni, c) != 0) {
-                       if_printf(ifp, "join BSS failed\n");
-                       goto back;
-               }
-       }
-
-       if (nstate == IEEE80211_S_RUN) {
-               int interval = sc->sc_calib_intvl;
-
-               if (sc->chip_calibrate != NULL) {
-                       error = sc->chip_calibrate(sc);
-                       if (error) {
-                               /*
-                                * Restart calibration some time later
-                                */
-                               interval = 10;
-                       }
-                       callout_reset(&sc->sc_calibrate_timer,
-                                     hz * interval, acx_calibrate, sc);
-               }
-       }
-       error = 0;
-back:
-       if (error) {
-               /* XXX */
-               nstate = IEEE80211_S_INIT;
-               arg = -1;
-       }
-       return sc->sc_newstate(ic, nstate, arg);
-}
-
-int
-acx_init_tmplt_ordered(struct acx_softc *sc)
-{
-#define INIT_TMPLT(name)                       \
-do {                                           \
-       if (acx_init_##name##_tmplt(sc) != 0)   \
-               return 1;                       \
-} while (0)
-
-       /*
-        * NOTE:
-        * Order of templates initialization:
-        * 1) Probe request
-        * 2) NULL data
-        * 3) Beacon
-        * 4) TIM
-        * 5) Probe response
-        * Above order is critical to get a correct memory map.
-        */
-       INIT_TMPLT(probe_req);
-       INIT_TMPLT(null_data);
-       INIT_TMPLT(beacon);
-       INIT_TMPLT(tim);
-       INIT_TMPLT(probe_resp);
-
-#undef INIT_TMPLT
-       return 0;
-}
-
-static void
-acx_ring_dma_addr(void *arg, bus_dma_segment_t *seg, int nseg, int error)
-{
-       *((uint32_t *)arg) = seg->ds_addr;
-}
-
-static int
-acx_dma_alloc(struct acx_softc *sc)
-{
-       struct acx_ring_data *rd = &sc->sc_ring_data;
-       struct acx_buf_data *bd = &sc->sc_buf_data;
-       int i, error;
-
-       /* Allocate DMA stuffs for RX descriptors  */
-       error = bus_dma_tag_create(NULL, PAGE_SIZE, 0,
-                                  BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
-                                  NULL, NULL,
-                                  ACX_RX_RING_SIZE, 1, ACX_RX_RING_SIZE,
-                                  0, &rd->rx_ring_dma_tag);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't create rx ring dma tag\n");
-               return error;
-       }
-
-       error = bus_dmamem_alloc(rd->rx_ring_dma_tag, (void **)&rd->rx_ring,
-                                BUS_DMA_WAITOK | BUS_DMA_ZERO,
-                                &rd->rx_ring_dmamap);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if,
-                         "can't allocate rx ring dma memory\n");
-               bus_dma_tag_destroy(rd->rx_ring_dma_tag);
-               rd->rx_ring_dma_tag = NULL;
-               return error;
-       }
-
-       error = bus_dmamap_load(rd->rx_ring_dma_tag, rd->rx_ring_dmamap,
-                               rd->rx_ring, ACX_RX_RING_SIZE,
-                               acx_ring_dma_addr, &rd->rx_ring_paddr,
-                               BUS_DMA_WAITOK);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't get rx ring dma address\n");
-               bus_dmamem_free(rd->rx_ring_dma_tag, rd->rx_ring,
-                               rd->rx_ring_dmamap);
-               bus_dma_tag_destroy(rd->rx_ring_dma_tag);
-               rd->rx_ring_dma_tag = NULL;
-               return error;
-       }
-
-       /* Allocate DMA stuffs for TX descriptors */
-       error = bus_dma_tag_create(NULL, PAGE_SIZE, 0,
-                                  BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
-                                  NULL, NULL,
-                                  ACX_TX_RING_SIZE, 1, ACX_TX_RING_SIZE,
-                                  0, &rd->tx_ring_dma_tag);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't create tx ring dma tag\n");
-               return error;
-       }
-
-       error = bus_dmamem_alloc(rd->tx_ring_dma_tag, (void **)&rd->tx_ring,
-                                BUS_DMA_WAITOK | BUS_DMA_ZERO,
-                                &rd->tx_ring_dmamap);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if,
-                         "can't allocate tx ring dma memory\n");
-               bus_dma_tag_destroy(rd->tx_ring_dma_tag);
-               rd->tx_ring_dma_tag = NULL;
-               return error;
-       }
-
-       error = bus_dmamap_load(rd->tx_ring_dma_tag, rd->tx_ring_dmamap,
-                               rd->tx_ring, ACX_TX_RING_SIZE,
-                               acx_ring_dma_addr, &rd->tx_ring_paddr,
-                               BUS_DMA_WAITOK);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't get tx ring dma address\n");
-               bus_dmamem_free(rd->tx_ring_dma_tag, rd->tx_ring,
-                               rd->tx_ring_dmamap);
-               bus_dma_tag_destroy(rd->tx_ring_dma_tag);
-               rd->tx_ring_dma_tag = NULL;
-               return error;
-       }
-
-       /* Create DMA tag for RX/TX mbuf map */
-       error = bus_dma_tag_create(NULL, 1, 0,
-                                  BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
-                                  NULL, NULL,
-                                  MCLBYTES, 1, MCLBYTES,
-                                  0, &bd->mbuf_dma_tag);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't create mbuf dma tag\n");
-               return error;
-       }
-
-       /* Create a spare RX DMA map */
-       error = bus_dmamap_create(bd->mbuf_dma_tag, 0, &bd->mbuf_tmp_dmamap);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't create tmp mbuf dma map\n");
-               bus_dma_tag_destroy(bd->mbuf_dma_tag);
-               bd->mbuf_dma_tag = NULL;
-               return error;
-       }
-
-       /* Create DMA map for RX mbufs */
-       for (i = 0; i < ACX_RX_DESC_CNT; ++i) {
-               error = bus_dmamap_create(bd->mbuf_dma_tag, 0,
-                                         &bd->rx_buf[i].rb_mbuf_dmamap);
-               if (error) {
-                       if_printf(&sc->sc_ic.ic_if, "can't create rx mbuf "
-                                 "dma map (%d)\n", i);
-                       return error;
-               }
-               bd->rx_buf[i].rb_desc = &rd->rx_ring[i];
-       }
-
-       /* Create DMA map for TX mbufs */
-       for (i = 0; i < ACX_TX_DESC_CNT; ++i) {
-               error = bus_dmamap_create(bd->mbuf_dma_tag, 0,
-                                         &bd->tx_buf[i].tb_mbuf_dmamap);
-               if (error) {
-                       if_printf(&sc->sc_ic.ic_if, "can't create tx mbuf "
-                                 "dma map (%d)\n", i);
-                       return error;
-               }
-               bd->tx_buf[i].tb_desc1 = &rd->tx_ring[i * 2];
-               bd->tx_buf[i].tb_desc2 = &rd->tx_ring[(i * 2) + 1];
-       }
-
-       return 0;
-}
-
-static void
-acx_dma_free(struct acx_softc *sc)
-{
-       struct acx_ring_data *rd = &sc->sc_ring_data;
-       struct acx_buf_data *bd = &sc->sc_buf_data;
-       int i;
-
-       if (rd->rx_ring_dma_tag != NULL) {
-               bus_dmamap_unload(rd->rx_ring_dma_tag, rd->rx_ring_dmamap);
-               bus_dmamem_free(rd->rx_ring_dma_tag, rd->rx_ring,
-                               rd->rx_ring_dmamap);
-               bus_dma_tag_destroy(rd->rx_ring_dma_tag);
-       }
-
-       if (rd->tx_ring_dma_tag != NULL) {
-               bus_dmamap_unload(rd->tx_ring_dma_tag, rd->tx_ring_dmamap);
-               bus_dmamem_free(rd->tx_ring_dma_tag, rd->tx_ring,
-                               rd->tx_ring_dmamap);
-               bus_dma_tag_destroy(rd->tx_ring_dma_tag);
-       }
-
-       for (i = 0; i < ACX_RX_DESC_CNT; ++i) {
-               if (bd->rx_buf[i].rb_desc != NULL) {
-                       if (bd->rx_buf[i].rb_mbuf != NULL) {
-                               bus_dmamap_unload(bd->mbuf_dma_tag,
-                                                 bd->rx_buf[i].rb_mbuf_dmamap);
-                               m_freem(bd->rx_buf[i].rb_mbuf);
-                       }
-                       bus_dmamap_destroy(bd->mbuf_dma_tag,
-                                          bd->rx_buf[i].rb_mbuf_dmamap);
-               }
-       }
-
-       for (i = 0; i < ACX_TX_DESC_CNT; ++i) {
-               if (bd->tx_buf[i].tb_desc1 != NULL) {
-                       if (bd->tx_buf[i].tb_mbuf != NULL) {
-                               bus_dmamap_unload(bd->mbuf_dma_tag,
-                                                 bd->tx_buf[i].tb_mbuf_dmamap);
-                               m_freem(bd->tx_buf[i].tb_mbuf);
-                       }
-                       bus_dmamap_destroy(bd->mbuf_dma_tag,
-                                          bd->tx_buf[i].tb_mbuf_dmamap);
-               }
-       }
-
-       if (bd->mbuf_dma_tag != NULL) {
-               bus_dmamap_destroy(bd->mbuf_dma_tag, bd->mbuf_tmp_dmamap);
-               bus_dma_tag_destroy(bd->mbuf_dma_tag);
-       }
-}
-
-static int
-acx_init_tx_ring(struct acx_softc *sc)
-{
-       struct acx_ring_data *rd;
-       struct acx_buf_data *bd;
-       uint32_t paddr;
-       int i;
-
-       rd = &sc->sc_ring_data;
-       paddr = rd->tx_ring_paddr;
-       for (i = 0; i < (ACX_TX_DESC_CNT * 2) - 1; ++i) {
-               paddr += sizeof(struct acx_host_desc);
-
-               rd->tx_ring[i].h_ctrl = htole16(DESC_CTRL_HOSTOWN);
-
-               if (i == (ACX_TX_DESC_CNT * 2) - 1)
-                       rd->tx_ring[i].h_next_desc = htole32(rd->tx_ring_paddr);
-               else
-                       rd->tx_ring[i].h_next_desc = htole32(paddr);
-       }
-
-       bus_dmamap_sync(rd->tx_ring_dma_tag, rd->tx_ring_dmamap,
-                       BUS_DMASYNC_PREWRITE);
-
-       bd = &sc->sc_buf_data;
-       bd->tx_free_start = 0;
-       bd->tx_used_start = 0;
-       bd->tx_used_count = 0;
-
-       return 0;
-}
-
-static int
-acx_init_rx_ring(struct acx_softc *sc)
-{
-       struct acx_ring_data *rd;
-       struct acx_buf_data *bd;
-       uint32_t paddr;
-       int i;
-
-       bd = &sc->sc_buf_data;
-       rd = &sc->sc_ring_data;
-       paddr = rd->rx_ring_paddr;
-
-       for (i = 0; i < ACX_RX_DESC_CNT; ++i) {
-               int error;
-
-               paddr += sizeof(struct acx_host_desc);
-
-               error = acx_newbuf(sc, &bd->rx_buf[i], 1);
-               if (error)
-                       return error;
-
-               if (i == ACX_RX_DESC_CNT - 1)
-                       rd->rx_ring[i].h_next_desc = htole32(rd->rx_ring_paddr);
-               else
-                       rd->rx_ring[i].h_next_desc = htole32(paddr);
-       }
-
-       bus_dmamap_sync(rd->rx_ring_dma_tag, rd->rx_ring_dmamap,
-                       BUS_DMASYNC_PREWRITE);
-
-       bd->rx_scan_start = 0;
-       return 0;
-}
-
-static void
-acx_buf_dma_addr(void *arg, bus_dma_segment_t *seg, int nseg,
-                bus_size_t mapsz, int error)
-{
-       if (error)
-               return;
-
-       /* XXX */
-       KASSERT(nseg == 1, ("too many RX dma segments"));
-       *((uint32_t *)arg) = seg->ds_addr;
-}
-
-static int
-acx_newbuf(struct acx_softc *sc, struct acx_rxbuf *rb, int wait)
-{
-       struct acx_buf_data *bd;
-       struct mbuf *m;
-       bus_dmamap_t map;
-       uint32_t paddr;
-       int error;
-
-       bd = &sc->sc_buf_data;
-
-       m = m_getcl(wait ? M_WAITOK : M_NOWAIT, MT_DATA, M_PKTHDR);
-       if (m == NULL)
-               return ENOBUFS;
-
-       m->m_len = m->m_pkthdr.len = MCLBYTES;
-
-       error = bus_dmamap_load_mbuf(bd->mbuf_dma_tag, bd->mbuf_tmp_dmamap,
-                                    m, acx_buf_dma_addr, &paddr,
-                                    wait ? BUS_DMA_WAITOK : BUS_DMA_NOWAIT);
-       if (error) {
-               m_freem(m);
-               if_printf(&sc->sc_ic.ic_if, "can't map rx mbuf %d\n", error);
-               return error;
-       }
-
-       /* Unload originally mapped mbuf */
-       bus_dmamap_unload(bd->mbuf_dma_tag, rb->rb_mbuf_dmamap);
-
-       /* Swap this dmamap with tmp dmamap */
-       map = rb->rb_mbuf_dmamap;
-       rb->rb_mbuf_dmamap = bd->mbuf_tmp_dmamap;
-       bd->mbuf_tmp_dmamap = map;
-
-       rb->rb_mbuf = m;
-       rb->rb_desc->h_data_paddr = htole32(paddr);
-       rb->rb_desc->h_data_len = htole16(m->m_len);
-
-       bus_dmamap_sync(bd->mbuf_dma_tag, rb->rb_mbuf_dmamap,
-                       BUS_DMASYNC_PREREAD);
-       return 0;
-}
-
-static int
-acx_encap(struct acx_softc *sc, struct acx_txbuf *txbuf, struct mbuf *m,
-         struct ieee80211_node *ni)
-{
-       struct acx_buf_data *bd = &sc->sc_buf_data;
-       struct acx_ring_data *rd = &sc->sc_ring_data;
-       uint32_t paddr;
-       uint8_t ctrl, rate;
-       int error;
-
-       KASSERT(txbuf->tb_mbuf == NULL, ("free TX buf has mbuf installed"));
-
-       if (m->m_pkthdr.len > MCLBYTES) {
-               if_printf(&sc->sc_ic.ic_if, "mbuf too big\n");
-               error = E2BIG;
-               goto back;
-       } else if (m->m_pkthdr.len < ACX_FRAME_HDRLEN) {
-               if_printf(&sc->sc_ic.ic_if, "mbuf too small\n");
-               error = EINVAL;
-               goto back;
-       }
-
-       error = bus_dmamap_load_mbuf(bd->mbuf_dma_tag, txbuf->tb_mbuf_dmamap,
-                                    m, acx_buf_dma_addr, &paddr,
-                                    BUS_DMA_NOWAIT);
-       if (error && error != EFBIG) {
-               if_printf(&sc->sc_ic.ic_if, "can't map tx mbuf1 %d\n", error);
-               goto back;
-       }
-
-       if (error) {    /* error == EFBIG */
-               struct mbuf *m_new;
-
-               m_new = m_defrag(m, M_NOWAIT);
-               if (m_new == NULL) {
-                       if_printf(&sc->sc_ic.ic_if, "can't defrag tx mbuf\n");
-                       error = ENOBUFS;
-                       goto back;
-               } else {
-                       m = m_new;
-               }
-
-               error = bus_dmamap_load_mbuf(bd->mbuf_dma_tag,
-                                            txbuf->tb_mbuf_dmamap, m,
-                                            acx_buf_dma_addr, &paddr,
-                                            BUS_DMA_NOWAIT);
-               if (error) {
-                       if_printf(&sc->sc_ic.ic_if, "can't map tx mbuf2 %d\n",
-                                 error);
-                       goto back;
-               }
-       }
-
-       error = 0;
-
-       bus_dmamap_sync(bd->mbuf_dma_tag, txbuf->tb_mbuf_dmamap,
-                       BUS_DMASYNC_PREWRITE);
-
-       txbuf->tb_mbuf = m;
-       txbuf->tb_node = ni;
-
-       /*
-        * TX buffers are accessed in following way:
-        * acx_fw_txdesc -> acx_host_desc -> buffer
-        *
-        * It is quite strange that acx also querys acx_host_desc next to
-        * the one we have assigned to acx_fw_txdesc even if first one's
-        * acx_host_desc.h_data_len == acx_fw_txdesc.f_tx_len
-        *
-        * So we allocate two acx_host_desc for one acx_fw_txdesc and
-        * assign the first acx_host_desc to acx_fw_txdesc
-        *
-        * For acx111
-        * host_desc1.h_data_len = buffer_len
-        * host_desc2.h_data_len = buffer_len - mac_header_len
-        *
-        * For acx100
-        * host_desc1.h_data_len = mac_header_len
-        * host_desc2.h_data_len = buffer_len - mac_header_len
-        */
-
-       txbuf->tb_desc1->h_data_paddr = htole32(paddr);
-       txbuf->tb_desc2->h_data_paddr = htole32(paddr + ACX_FRAME_HDRLEN);
-
-       txbuf->tb_desc1->h_data_len =
-               htole16(sc->chip_txdesc1_len ? sc->chip_txdesc1_len
-                                            : m->m_pkthdr.len);
-       txbuf->tb_desc2->h_data_len =
-               htole16(m->m_pkthdr.len - ACX_FRAME_HDRLEN);
-
-       /*
-        * NOTE:
-        * We can't simply assign f_tx_ctrl, we will first read it back
-        * and change it bit by bit
-        */
-       ctrl = FW_TXDESC_GETFIELD_1(sc, txbuf, f_tx_ctrl);
-       ctrl |= sc->chip_fw_txdesc_ctrl; /* extra chip specific flags */
-       ctrl &= ~(DESC_CTRL_HOSTOWN | DESC_CTRL_ACXDONE);
-
-       FW_TXDESC_SETFIELD_2(sc, txbuf, f_tx_len, m->m_pkthdr.len);
-       FW_TXDESC_SETFIELD_1(sc, txbuf, f_tx_error, 0);
-       FW_TXDESC_SETFIELD_1(sc, txbuf, f_tx_data_nretry, 0);
-       FW_TXDESC_SETFIELD_1(sc, txbuf, f_tx_rts_nretry, 0);
-       FW_TXDESC_SETFIELD_1(sc, txbuf, f_tx_rts_ok, 0);
-       rate = sc->chip_set_fw_txdesc_rate(sc, txbuf, ni, m->m_pkthdr.len);
-
-       if (sc->sc_drvbpf != NULL) {
-               struct ieee80211_frame_min *wh;
-
-               wh = mtod(m, struct ieee80211_frame_min *);
-               sc->sc_tx_th.wt_flags = 0;
-               if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
-                       sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP;
-               sc->sc_tx_th.wt_rate = rate;
-
-               bpf_ptap(sc->sc_drvbpf, m, &sc->sc_tx_th, sc->sc_tx_th_len);
-       }
-
-       txbuf->tb_desc1->h_ctrl = 0;
-       txbuf->tb_desc2->h_ctrl = 0;
-       bus_dmamap_sync(rd->tx_ring_dma_tag, rd->tx_ring_dmamap,
-                       BUS_DMASYNC_PREWRITE);
-
-       FW_TXDESC_SETFIELD_1(sc, txbuf, f_tx_ctrl2, 0);
-       FW_TXDESC_SETFIELD_1(sc, txbuf, f_tx_ctrl, ctrl);
-
-       /* Tell chip to inform us about TX completion */
-       CSR_WRITE_2(sc, ACXREG_INTR_TRIG, ACXRV_TRIG_TX_FINI);
-back:
-       if (error)
-               m_freem(m);
-       return error;
-}
-
-static int
-acx_set_null_tmplt(struct acx_softc *sc)
-{
-       struct acx_tmplt_null_data n;
-       struct ieee80211_frame *f;
-
-       bzero(&n, sizeof(n));
-
-       f = &n.data;
-       f->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_DATA |
-                    IEEE80211_FC0_SUBTYPE_NODATA;
-       IEEE80211_ADDR_COPY(f->i_addr1, etherbroadcastaddr);
-       IEEE80211_ADDR_COPY(f->i_addr2, IF_LLADDR(&sc->sc_ic.ic_if));
-       IEEE80211_ADDR_COPY(f->i_addr3, etherbroadcastaddr);
-
-       return _acx_set_null_data_tmplt(sc, &n, sizeof(n));
-}
-
-static int
-acx_set_probe_req_tmplt(struct acx_softc *sc, const char *ssid, int ssid_len)
-{
-       struct acx_tmplt_probe_req req;
-       struct ieee80211_frame *f;
-       uint8_t *v;
-       int vlen;
-
-       bzero(&req, sizeof(req));
-
-       f = &req.data.u_data.f;
-       f->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
-                    IEEE80211_FC0_SUBTYPE_PROBE_REQ;
-       IEEE80211_ADDR_COPY(f->i_addr1, etherbroadcastaddr);
-       IEEE80211_ADDR_COPY(f->i_addr2, IF_LLADDR(&sc->sc_ic.ic_if));
-       IEEE80211_ADDR_COPY(f->i_addr3, etherbroadcastaddr);
-
-       v = req.data.u_data.var;
-       v = ieee80211_add_ssid(v, ssid, ssid_len);
-       v = ieee80211_add_rates(v, &sc->sc_ic.ic_sup_rates[sc->chip_phymode]);
-       v = ieee80211_add_xrates(v, &sc->sc_ic.ic_sup_rates[sc->chip_phymode]);
-       vlen = v - req.data.u_data.var;
-
-       return _acx_set_probe_req_tmplt(sc, &req,
-                                       ACX_TMPLT_PROBE_REQ_SIZ(vlen));
-}
-
-static int
-acx_set_probe_resp_tmplt(struct acx_softc *sc, struct ieee80211_node *ni)
-{
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct acx_tmplt_probe_resp resp;
-       struct ieee80211_frame *f;
-       struct mbuf *m;
-       int len;
-
-       m = ieee80211_probe_resp_alloc(ic, ni);
-       if (m == NULL)
-               return 1;
-       DPRINTF((&ic->ic_if, "%s alloc probe resp size %d\n", __func__,
-                m->m_pkthdr.len));
-
-       f = mtod(m, struct ieee80211_frame *);
-       IEEE80211_ADDR_COPY(f->i_addr1, etherbroadcastaddr);
-
-       bzero(&resp, sizeof(resp));
-       m_copydata(m, 0, m->m_pkthdr.len, (caddr_t)&resp.data);
-       len = m->m_pkthdr.len + sizeof(resp.size);
-       m_freem(m);
-
-       return _acx_set_probe_resp_tmplt(sc, &resp, len);
-}
-
-static int
-acx_set_beacon_tmplt(struct acx_softc *sc, struct ieee80211_node *ni)
-{
-       struct ieee80211com *ic = &sc->sc_ic;
-       struct acx_tmplt_beacon beacon;
-       struct acx_tmplt_tim tim;
-       struct ieee80211_beacon_offsets bo;
-       struct mbuf *m;
-       int beacon_tmplt_len = 0, tim_tmplt_len = 0;
-
-       bzero(&bo, sizeof(bo));
-       m = ieee80211_beacon_alloc(ic, ni, &bo);
-       if (m == NULL)
-               return 1;
-       DPRINTF((&ic->ic_if, "%s alloc beacon size %d\n", __func__,
-                m->m_pkthdr.len));
-
-       if (bo.bo_tim_len == 0) {
-               beacon_tmplt_len = m->m_pkthdr.len;
-       } else {
-               beacon_tmplt_len = bo.bo_tim - mtod(m, uint8_t *);
-               tim_tmplt_len = m->m_pkthdr.len - beacon_tmplt_len;
-       }
-
-       bzero(&beacon, sizeof(beacon));
-       bzero(&tim, sizeof(tim));
-
-       m_copydata(m, 0, beacon_tmplt_len, (caddr_t)&beacon.data);
-       if (tim_tmplt_len != 0) {
-               m_copydata(m, beacon_tmplt_len, tim_tmplt_len,
-                          (caddr_t)&tim.data);
-       }
-       m_freem(m);
-
-       beacon_tmplt_len += sizeof(beacon.size);
-       if (_acx_set_beacon_tmplt(sc, &beacon, beacon_tmplt_len) != 0)
-               return 1;
-
-       if (tim_tmplt_len != 0) {
-               tim_tmplt_len += sizeof(tim.size);
-               if (_acx_set_tim_tmplt(sc, &tim, tim_tmplt_len) != 0)
-                       return 1;
-       }
-       return 0;
-}
-
-static int
-acx_sysctl_msdu_lifetime(SYSCTL_HANDLER_ARGS)
-{
-       struct acx_softc *sc = arg1;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       int error = 0, v;
-
-       lwkt_serialize_enter(ifp->if_serializer);
-
-       v = sc->sc_msdu_lifetime;
-       error = sysctl_handle_int(oidp, &v, 0, req);
-       if (error || req->newptr == NULL)
-               goto back;
-       if (v <= 0) {
-               error = EINVAL;
-               goto back;
-       }
-
-       if (sc->sc_flags & ACX_FLAG_FW_LOADED) {
-               struct acx_conf_msdu_lifetime msdu_lifetime;
-
-               msdu_lifetime.lifetime = htole32(v);
-               if (acx_set_msdu_lifetime_conf(sc, &msdu_lifetime) != 0) {
-                       if_printf(&sc->sc_ic.ic_if,
-                                 "can't set MSDU lifetime\n");
-                       error = ENXIO;
-                       goto back;
-               }
-       }
-       sc->sc_msdu_lifetime = v;
-back:
-       lwkt_serialize_exit(ifp->if_serializer);
-       return error;
-}
-
-static int
-acx_sysctl_free_firmware(SYSCTL_HANDLER_ARGS)
-{
-       struct acx_softc *sc = arg1;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       int error = 0, v;
-
-       lwkt_serialize_enter(ifp->if_serializer);
-
-       v = 0;
-       error = sysctl_handle_int(oidp, &v, 0, req);
-       if (error || req->newptr == NULL)
-               goto back;
-       if (v == 0)     /* Do nothing */
-               goto back;
-
-       acx_free_firmware(sc);
-back:
-       lwkt_serialize_exit(ifp->if_serializer);
-       return error;
-}
-
-static int
-acx_media_change(struct ifnet *ifp)
-{
-       int error;
-
-       error = ieee80211_media_change(ifp);
-       if (error != ENETRESET)
-               return error;
-
-       if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING))
-               acx_init(ifp->if_softc);
-       return 0;
-}
-
-static int
-acx_rx_config(struct acx_softc *sc, int promisc)
-{
-       struct acx_conf_rxopt rx_opt;
-       struct ieee80211com *ic = &sc->sc_ic;
-
-       /*
-        * What we want to receive and how to receive
-        */
-
-       /* Common for all operational modes */
-       rx_opt.opt1 = RXOPT1_INCL_RXBUF_HDR;
-       rx_opt.opt2 = RXOPT2_RECV_ASSOC_REQ |
-                     RXOPT2_RECV_AUTH |
-                     RXOPT2_RECV_BEACON |
-                     RXOPT2_RECV_CF |
-                     RXOPT2_RECV_CTRL |
-                     RXOPT2_RECV_DATA |
-                     RXOPT2_RECV_MGMT |
-                     RXOPT2_RECV_PROBE_REQ |
-                     RXOPT2_RECV_PROBE_RESP |
-                     RXOPT2_RECV_OTHER;
-
-       if (ic->ic_opmode == IEEE80211_M_MONITOR) {
-               rx_opt.opt1 |= RXOPT1_PROMISC;
-               rx_opt.opt2 |= RXOPT2_RECV_BROKEN | RXOPT2_RECV_ACK;
-       } else {
-               rx_opt.opt1 |= promisc ? RXOPT1_PROMISC : RXOPT1_FILT_FDEST;
-       }
-
-       if (acx_set_rxopt_conf(sc, &rx_opt) != 0) {
-               if_printf(&sc->sc_ic.ic_if, "can't config RX\n");
-               return ENXIO;
-       }
-       return 0;
-}
-
-static int
-acx_set_chan(struct acx_softc *sc, struct ieee80211_channel *c)
-{
-       struct ieee80211com *ic = &sc->sc_ic;
-       uint16_t flags;
-       uint8_t chan;
-
-       chan = ieee80211_chan2ieee(ic, c);
-       if (acx_enable_txchan(sc, chan) != 0) {
-               if_printf(&ic->ic_if, "enable TX on channel %d failed\n", chan);
-               return EIO;
-       }
-       if (acx_enable_rxchan(sc, chan) != 0) {
-               if_printf(&ic->ic_if, "enable RX on channel %d failed\n", chan);
-               return EIO;
-       }
-
-       if (IEEE80211_IS_CHAN_G(c))
-               flags = IEEE80211_CHAN_G;
-       else
-               flags = IEEE80211_CHAN_B;
-
-       sc->sc_tx_th.wt_chan_freq = sc->sc_rx_th.wr_chan_freq =
-               htole16(c->ic_freq);
-       sc->sc_tx_th.wt_chan_flags = sc->sc_rx_th.wr_chan_flags =
-               htole16(flags);
-       return 0;
-}
-
-static void
-acx_calibrate(void *xsc)
-{
-       struct acx_softc *sc = xsc;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-
-       lwkt_serialize_enter(ifp->if_serializer);
-       if (sc->chip_calibrate != NULL &&
-           sc->sc_ic.ic_state == IEEE80211_S_RUN) {
-               sc->chip_calibrate(sc);
-               callout_reset(&sc->sc_calibrate_timer, hz * sc->sc_calib_intvl,
-                             acx_calibrate, sc);
-       }
-       lwkt_serialize_exit(ifp->if_serializer);
-}
diff --git a/sys/dev/netif/acx/if_acxreg.h b/sys/dev/netif/acx/if_acxreg.h
deleted file mode 100644 (file)
index 425b8ab..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * 
- * $DragonFly: src/sys/dev/netif/acx/if_acxreg.h,v 1.1 2006/04/01 02:55:36 sephe Exp $
- */
-
-#ifndef _IF_ACXREG_H
-#define _IF_ACXREG_H
-
-/*
- * IO register index
- */
-#define ACXREG_SOFT_RESET              0
-#define ACXREG_FWMEM_ADDR              1
-#define ACXREG_FWMEM_DATA              2
-#define ACXREG_FWMEM_CTRL              3
-#define ACXREG_FWMEM_START             4
-#define ACXREG_EVENT_MASK              5
-#define ACXREG_INTR_TRIG               6
-#define ACXREG_INTR_MASK               7
-#define ACXREG_INTR_STATUS             8
-#define ACXREG_INTR_STATUS_CLR         9       /* cleared after being read */
-#define ACXREG_INTR_ACK                        10
-#define ACXREG_HINTR_TRIG              11      /* XXX what's this? */
-#define ACXREG_RADIO_ENABLE            12
-#define ACXREG_EEPROM_INIT             13
-#define ACXREG_EEPROM_CTRL             14
-#define ACXREG_EEPROM_ADDR             15
-#define ACXREG_EEPROM_DATA             16
-#define ACXREG_EEPROM_CONF             17
-#define ACXREG_EEPROM_INFO             18
-#define ACXREG_PHY_ADDR                        19
-#define ACXREG_PHY_DATA                        20
-#define ACXREG_PHY_CTRL                        21
-#define ACXREG_GPIO_OUT_ENABLE         22
-#define ACXREG_GPIO_OUT                        23
-#define ACXREG_CMD_REG_OFFSET          24
-#define ACXREG_INFO_REG_OFFSET         25
-#define ACXREG_RESET_SENSE             26
-#define ACXREG_ECPU_CTRL               27
-#define ACXREG_MAX                     28
-#define ACXREG(reg, val)               [ACXREG_##reg] = val
-
-/*
- * Value read from ACXREG_EEPROM_INFO
- * upper 8bits are radio type
- * lower 8bits are form factor
- */
-#define ACX_EEINFO_RADIO_TYPE_SHIFT    8
-#define ACX_EEINFO_RADIO_TYPE_MASK     (0xff << ACX_EEINFO_RADIO_TYPE_SHIFT)
-#define ACX_EEINFO_FORM_FACTOR_MASK    0xff
-
-#define ACX_EEINFO_HAS_RADIO_TYPE(info)        ((info) & ACX_EEINFO_RADIO_TYPE_MASK)
-#define ACX_EEINFO_RADIO_TYPE(info)    ((info) >> ACX_EEINFO_RADIO_TYPE_SHIFT)
-#define ACX_EEINFO_FORM_FACTOR(info)   ((info) & ACX_EEINFO_FORM_FACTOR_MASK)
-
-/*
- * Size of command register whose location is obtained
- * from ACXREG_CMD_REG_OFFSET IO register
- */
-#define ACX_CMD_REG_SIZE               4       /* 4 bytes */
-
-/*
- * Size of infomation register whose location is obtained
- * from ACXREG_INFO_REG_OFFSET IO register
- */
-#define ACX_INFO_REG_SIZE              4       /* 4 bytes */
-
-/*
- * Offset of EEPROM variables
- */
-#define ACX_EE_VERSION_OFS             0x05
-
-/*
- * Possible values for various IO registers
- */
-
-/* ACXREG_SOFT_RESET */
-#define ACXRV_SOFT_RESET               0x1
-
-/* ACXREG_FWMEM_START */
-#define ACXRV_FWMEM_START_OP           0x0
-
-/* ACXREG_FWMEM_CTRL */
-#define ACXRV_FWMEM_ADDR_AUTOINC       0x10000
-
-/* ACXREG_EVENT_MASK */
-#define ACXRV_EVENT_DISABLE            0x8000  /* XXX What's this?? */
-
-/* ACXREG_INTR_TRIG */
-#define ACXRV_TRIG_CMD_FINI            0x0001
-#define ACXRV_TRIG_TX_FINI             0x0004
-
-/* ACXREG_INTR_MASK */
-#define ACXRV_INTR_RX_DATA             0x0001
-#define ACXRV_INTR_TX_FINI             0x0002
-#define ACXRV_INTR_TX_XFER             0x0004
-#define ACXRV_INTR_RX_FINI             0x0008
-#define ACXRV_INTR_DTIM                        0x0010
-#define ACXRV_INTR_BEACON              0x0020
-#define ACXRV_INTR_TIMER               0x0040
-#define ACXRV_INTR_KEY_MISS            0x0080
-#define ACXRV_INTR_WEP_FAIL            0x0100
-#define ACXRV_INTR_CMD_FINI            0x0200
-#define ACXRV_INTR_INFO                        0x0400
-#define ACXRV_INTR_OVERFLOW            0x0800  /* XXX */
-#define ACXRV_INTR_PROC_ERR            0x1000  /* XXX */
-#define ACXRV_INTR_SCAN_FINI           0x2000
-#define ACXRV_INTR_FCS_THRESH          0x4000  /* XXX */
-#define ACXRV_INTR_UNKN                        0x8000
-#define ACXRV_INTR_ALL                 0xffff
-
-/* ACXREG_EEPROM_INIT */
-#define ACXRV_EEPROM_INIT              0x1
-
-/* ACXREG_EEPROM_CTRL */
-#define ACXRV_EEPROM_READ              0x2
-
-/* ACXREG_PHY_CTRL */
-#define ACXRV_PHY_WRITE                        0x1
-#define ACXRV_PHY_READ                 0x2
-
-/* ACXREG_PHY_ADDR */
-#define ACXRV_PHYREG_TXPOWER           0x11    /* axc100 */
-#define ACXRV_PHYREG_SENSITIVITY       0x30
-
-/* ACXREG_ECPU_CTRL */
-#define ACXRV_ECPU_HALT                        0x1
-#define ACXRV_ECPU_START               0x0
-
-#endif /* !_IF_ACXREG_H */
diff --git a/sys/dev/netif/acx/if_acxvar.h b/sys/dev/netif/acx/if_acxvar.h
deleted file mode 100644 (file)
index 31935a3..0000000
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _IF_ACXVAR_H
-#define _IF_ACXVAR_H
-
-#ifdef ACX_DEBUG
-#define DPRINTF(x)             if_printf x
-#else
-#define DPRINTF(x)             ((void)0)
-#endif
-
-#define ACX_FRAME_HDRLEN       sizeof(struct ieee80211_frame)
-#define ACX_MEMBLOCK_SIZE      256
-
-#define ACX_TX_DESC_CNT                16
-#define ACX_RX_DESC_CNT                16
-
-#define ACX_TX_RING_SIZE       \
-       (2 * ACX_TX_DESC_CNT * sizeof(struct acx_host_desc))
-#define ACX_RX_RING_SIZE       \
-       (ACX_RX_DESC_CNT * sizeof(struct acx_host_desc))
-
-#define CSR_READ_1(sc, reg)                                    \
-       bus_space_read_1((sc)->sc_mem1_bt, (sc)->sc_mem1_bh,    \
-                        (sc)->chip_ioreg[(reg)])
-#define CSR_READ_2(sc, reg)                                    \
-       bus_space_read_2((sc)->sc_mem1_bt, (sc)->sc_mem1_bh,    \
-                        (sc)->chip_ioreg[(reg)])
-#define CSR_READ_4(sc, reg)                                    \
-       bus_space_read_4((sc)->sc_mem1_bt, (sc)->sc_mem1_bh,    \
-                        (sc)->chip_ioreg[(reg)])
-
-#define CSR_WRITE_2(sc, reg, val)                              \
-       bus_space_write_2((sc)->sc_mem1_bt, (sc)->sc_mem1_bh,   \
-                         (sc)->chip_ioreg[(reg)], val)
-#define CSR_WRITE_4(sc, reg, val)                              \
-       bus_space_write_4((sc)->sc_mem1_bt, (sc)->sc_mem1_bh,   \
-                         (sc)->chip_ioreg[(reg)], val)
-
-#define CSR_SETB_2(sc, reg, b)         \
-       CSR_WRITE_2((sc), (reg), CSR_READ_2((sc), (reg)) | (b))
-#define CSR_CLRB_2(sc, reg, b)         \
-       CSR_WRITE_2((sc), (reg), CSR_READ_2((sc), (reg)) & (~(b)))
-
-#define DESC_READ_1(sc, off)           \
-       bus_space_read_1((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (off))
-#define DESC_READ_2(sc, off)           \
-       bus_space_read_2((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (off))
-#define DESC_READ_4(sc, off)           \
-       bus_space_read_4((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (off))
-
-#define DESC_WRITE_1(sc, off, val)     \
-       bus_space_write_1((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (off), (val))
-#define DESC_WRITE_2(sc, off, val)     \
-       bus_space_write_2((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (off), (val))
-#define DESC_WRITE_4(sc, off, val)     \
-       bus_space_write_4((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (off), (val))
-#define DESC_WRITE_REGION_1(sc, off, d, dlen)                          \
-       bus_space_write_region_1((sc)->sc_mem2_bt, (sc)->sc_mem2_bh,    \
-                                (off), (const uint8_t *)(d), (dlen))
-
-#define FW_TXDESC_SETFIELD(sc, mb, field, val, sz)     \
-       DESC_WRITE_##sz((sc), (mb)->tb_fwdesc_ofs +     \
-                             __offsetof(struct acx_fw_txdesc, field), (val))
-
-#define FW_TXDESC_GETFIELD(sc, mb, field, sz)          \
-       DESC_READ_##sz((sc), (mb)->tb_fwdesc_ofs +      \
-                            __offsetof(struct acx_fw_txdesc, field))
-
-#define FW_TXDESC_SETFIELD_1(sc, mb, field, val)       \
-       FW_TXDESC_SETFIELD(sc, mb, field, val, 1)
-#define FW_TXDESC_SETFIELD_2(sc, mb, field, val)       \
-       FW_TXDESC_SETFIELD(sc, mb, field, htole16(val), 2)
-#define FW_TXDESC_SETFIELD_4(sc, mb, field, val)       \
-       FW_TXDESC_SETFIELD(sc, mb, field, htole32(val), 4)
-
-#define FW_TXDESC_GETFIELD_1(sc, mb, field)            \
-       FW_TXDESC_GETFIELD(sc, mb, field, 1)
-#define FW_TXDESC_GETFIELD_2(sc, mb, field)            \
-       le16toh(FW_TXDESC_GETFIELD(sc, mb, field, 2))
-#define FW_TXDESC_GETFIELD_4(sc, mb, field)            \
-       le32toh(FW_TXDESC_GETFIELD(sc, mb, field, 4))
-
-/*
- * Firmware TX descriptor
- * Fields are little endian
- */
-struct acx_fw_txdesc {
-       uint32_t        f_tx_next_desc; /* next acx_fw_txdesc phyaddr */
-       uint32_t        f_tx_host_desc; /* acx_host_desc phyaddr */
-       uint32_t        f_tx_acx_ptr;
-       uint32_t        f_tx_time;
-       uint16_t        f_tx_len;
-       uint16_t        f_tx_reserved;
-
-       uint32_t        f_tx_dev_spec[4];
-
-       uint8_t         f_tx_ctrl;              /* see DESC_CTRL_ */
-       uint8_t         f_tx_ctrl2;
-       uint8_t         f_tx_error;             /* see DESC_ERR_ */
-       uint8_t         f_tx_data_nretry;       /* non-RTS retries */
-       uint8_t         f_tx_rts_nretry;        /* RTS retries */
-       uint8_t         f_tx_rts_ok;
-
-       /* XXX should be moved to chip specific file */
-       union {
-               struct {
-                       uint8_t         rate100;        /* acx100 tx rate */
-                       uint8_t         queue_ctrl;
-               } __packed r1;
-               struct {
-                       uint16_t        rate111;        /* acx111 tx rate */
-               } __packed r2;
-       } u;
-#define f_tx_rate100   u.r1.rate100
-#define f_tx_queue_ctrl        u.r1.queue_ctrl
-#define f_tx_rate111   u.r2.rate111
-       uint32_t        f_tx_queue_info;
-} __packed;
-
-/*
- * Firmware RX descriptor
- * Fields are little endian
- */
-struct acx_fw_rxdesc {
-       uint32_t        f_rx_next_desc; /* next acx_fw_rxdesc phyaddr */
-       uint32_t        f_rx_host_desc; /* acx_host_desc phyaddr */
-       uint32_t        f_rx_acx_ptr;
-       uint32_t        f_rx_time;
-       uint16_t        f_rx_len;
-       uint16_t        f_rx_wep_len;
-       uint32_t        f_rx_wep_ofs;
-
-       uint8_t         f_rx_dev_spec[16];
-
-       uint8_t         f_rx_ctrl;      /* see DESC_CTRL_ */
-       uint8_t         f_rx_rate;
-       uint8_t         f_rx_error;
-       uint8_t         f_rx_snr;       /* signal noise ratio */
-       uint8_t         f_rx_level;
-       uint8_t         f_rx_queue_ctrl;
-       uint16_t        f_rx_unknown0;
-       uint32_t        f_rx_unknown1;
-} __packed;
-
-/*
- * Host TX/RX descriptor
- * Fields are little endian
- */
-struct acx_host_desc {
-       uint32_t        h_data_paddr;   /* data phyaddr */
-       uint16_t        h_data_ofs;
-       uint16_t        h_reserved;
-       uint16_t        h_ctrl;         /* see DESC_CTRL_ */
-       uint16_t        h_data_len;     /* data length */
-       uint32_t        h_next_desc;    /* next acx_host_desc phyaddr */
-       uint32_t        h_pnext;
-       uint32_t        h_status;       /* see DESC_STATUS_ */
-} __packed;
-
-#define DESC_STATUS_FULL               0x80000000
-
-#define DESC_CTRL_SHORT_PREAMBLE       0x01
-#define DESC_CTRL_FIRST_FRAG           0x02
-#define DESC_CTRL_AUTODMA              0x04
-#define DESC_CTRL_RECLAIM              0x08
-#define DESC_CTRL_HOSTDONE             0x20    /* host finished buf proc */
-#define DESC_CTRL_ACXDONE              0x40    /* chip finished buf proc */
-#define DESC_CTRL_HOSTOWN              0x80    /* host controls desc */
-
-#define DESC_ERR_OTHER_FRAG            0x01
-#define DESC_ERR_ABORT                 0x02
-#define DESC_ERR_PARAM                 0x04
-#define DESC_ERR_NO_WEPKEY             0x08
-#define DESC_ERR_MSDU_TIMEOUT          0x10
-#define DESC_ERR_EXCESSIVE_RETRY       0x20
-#define DESC_ERR_BUF_OVERFLOW          0x40
-#define DESC_ERR_DMA                   0x80
-
-/*
- * Extra header in receiving buffer
- * Fields are little endian
- */
-struct acx_rxbuf_hdr {
-       uint16_t        rbh_len;        /* ACX_RXBUG_LEN_MASK part is len */
-       uint8_t         rbh_memblk_cnt;
-       uint8_t         rbh_status;
-       uint8_t         rbh_bbp_stat;   /* see ACX_RXBUF_STAT_ */
-       uint8_t         rbh_plcp;
-       uint8_t         rbh_level;      /* signal level */
-       uint8_t         rbh_snr;        /* signal noise ratio */
-       uint32_t        rbh_time;       /* recv timestamp */
-
-       /*
-        * XXX may have 4~8 byte here which
-        * depends on firmware version 
-        */
-} __packed;
-
-#define ACX_RXBUF_LEN_MASK     0xfff
-
-#define ACX_RXBUF_STAT_OFDM    0x04
-#define ACX_RXBUF_STAT_ANT1    0x10
-#define ACX_RXBUF_STAT_SHPRE   0x80
-
-struct acx_ring_data {
-       struct acx_host_desc    *rx_ring;
-       bus_dma_tag_t           rx_ring_dma_tag;
-       bus_dmamap_t            rx_ring_dmamap;
-       uint32_t                rx_ring_paddr;
-
-       struct acx_host_desc    *tx_ring;
-       bus_dma_tag_t           tx_ring_dma_tag;
-       bus_dmamap_t            tx_ring_dmamap;
-       uint32_t                tx_ring_paddr;
-};
-
-struct acx_txbuf {
-       struct mbuf             *tb_mbuf;
-       bus_dmamap_t            tb_mbuf_dmamap;
-
-       struct acx_host_desc    *tb_desc1;
-       struct acx_host_desc    *tb_desc2;
-
-       uint32_t                tb_fwdesc_ofs;
-
-       /*
-        * TX rate control
-        */
-       struct ieee80211_node   *tb_node;
-       int                     tb_rateidx_len;
-       int                     tb_rateidx[IEEE80211_RATEIDX_MAX];
-};
-
-struct acx_rxbuf {
-       struct mbuf             *rb_mbuf;
-       bus_dmamap_t            rb_mbuf_dmamap;
-
-       struct acx_host_desc    *rb_desc;
-};
-
-struct acx_buf_data {
-       struct acx_rxbuf        rx_buf[ACX_RX_DESC_CNT];
-       struct acx_txbuf        tx_buf[ACX_TX_DESC_CNT];
-       bus_dma_tag_t           mbuf_dma_tag;
-       bus_dmamap_t            mbuf_tmp_dmamap;
-
-       int                     rx_scan_start;
-
-       int                     tx_free_start;
-       int                     tx_used_start;
-       int                     tx_used_count;
-};
-
-struct acx_firmware_hdr {
-       uint32_t        fwh_cksum;
-       uint32_t        fwh_len;
-} __packed;
-
-struct acx_firmware {
-       struct fw_image *base_fw_image;
-       const uint8_t   *base_fw;
-       int             base_fw_len;
-
-       struct fw_image *radio_fw_image;
-       const uint8_t   *radio_fw;
-       int             radio_fw_len;
-
-       int             combined_radio_fw;
-       const char      *fwdir;
-};
-
-struct acx_config {
-       uint8_t eaddr[IEEE80211_ADDR_LEN];
-       uint8_t antenna;
-       uint8_t regdom;
-       uint8_t cca_mode;       /* acx100 */
-       uint8_t ed_thresh;      /* acx100 */
-};
-
-struct acx_stats {
-       uint64_t        err_oth_frag;   /* XXX error in other frag?? */
-       uint64_t        err_abort;      /* tx abortion */
-       uint64_t        err_param;      /* tx desc contains invalid param */
-       uint64_t        err_no_wepkey;  /* no WEP key exists */
-       uint64_t        err_msdu_timeout; /* MSDU timed out */
-       uint64_t        err_ex_retry;   /* excessive tx retry */
-       uint64_t        err_buf_oflow;  /* buffer overflow */
-       uint64_t        err_dma;        /* DMA error */
-       uint64_t        err_unkn;       /* XXX unknown error */
-};
-
-#define ACX_RX_RADIOTAP_PRESENT                                \
-       ((1 << IEEE80211_RADIOTAP_TSFT)         |       \
-        (1 << IEEE80211_RADIOTAP_FLAGS)        |       \
-        (1 << IEEE80211_RADIOTAP_RATE)         |       \
-        (1 << IEEE80211_RADIOTAP_CHANNEL)      |       \
-        (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL)|       \
-        (1 << IEEE80211_RADIOTAP_ANTENNA))
-
-struct acx_rx_radiotap_header {
-       struct ieee80211_radiotap_header wr_ihdr;
-       uint64_t        wr_tsf;
-       uint8_t         wr_flags;
-       uint8_t         wr_rate;
-       uint16_t        wr_chan_freq;
-       uint16_t        wr_chan_flags;
-       uint8_t         wr_antsignal;
-       uint8_t         wr_antenna;
-};
-
-#define ACX_TX_RADIOTAP_PRESENT                                \
-       ((1 << IEEE80211_RADIOTAP_FLAGS)        |       \
-        (1 << IEEE80211_RADIOTAP_RATE)         |       \
-        (1 << IEEE80211_RADIOTAP_CHANNEL))
-
-struct acx_tx_radiotap_header {
-       struct ieee80211_radiotap_header wt_ihdr;
-       uint8_t         wt_flags;
-       uint8_t         wt_rate;
-       uint16_t        wt_chan_freq;
-       uint16_t        wt_chan_flags;
-};
-
-struct acx_softc {
-       /*
-        * sc_xxx are filled in by common code
-        * chip_xxx are filled in by chip specific code
-        */
-       struct ieee80211com     sc_ic;
-
-       /*
-        * Radio tap
-        */
-       struct bpf_if           *sc_drvbpf;
-       union {
-               struct acx_tx_radiotap_header u_tx_th;
-               uint8_t         u_pad[IEEE80211_RADIOTAP_HDRLEN];
-       } sc_u_tx_th;
-       int                     sc_tx_th_len;
-       union {
-               struct acx_rx_radiotap_header u_rx_th;
-               uint8_t         u_pad[IEEE80211_RADIOTAP_HDRLEN];
-       } sc_u_rx_th;
-       int                     sc_rx_th_len;
-#define sc_tx_th       sc_u_tx_th.u_tx_th
-#define sc_rx_th       sc_u_rx_th.u_rx_th
-
-       struct callout          sc_scan_timer;
-       uint32_t                sc_flags;       /* see ACX_FLAG_ */
-       int                     sc_tx_timer;
-
-       struct acx_firmware     sc_firmware;
-       uint32_t                sc_firmware_ver;
-       uint32_t                sc_hardware_id;
-
-       /*
-        * MMIO 1
-        */
-       struct resource         *sc_mem1_res;
-       bus_space_tag_t         sc_mem1_bt;
-       bus_space_handle_t      sc_mem1_bh;
-       int                     chip_mem1_rid;
-
-       /*
-        * MMIO 2
-        */
-       struct resource         *sc_mem2_res;
-       bus_space_tag_t         sc_mem2_bt;
-       bus_space_handle_t      sc_mem2_bh;
-       int                     chip_mem2_rid;
-
-       struct resource         *sc_irq_res;
-       void                    *sc_irq_handle;
-       int                     sc_irq_rid;
-
-       uint32_t                sc_cmd;         /* cmd reg (MMIO 2) */
-       uint32_t                sc_cmd_param;   /* cmd param reg (MMIO 2) */
-       uint32_t                sc_info;        /* unused */
-       uint32_t                sc_info_param;  /* unused */
-
-       const uint16_t          *chip_ioreg;    /* reg map (MMIO 1) */
-
-       /*
-        * NOTE:
-        * chip_intr_enable is not necessarily same as
-        * ~chip_intr_disable
-        */
-       uint16_t                chip_intr_enable;
-       uint16_t                chip_intr_disable;
-
-       int                     chip_hw_crypt;
-       uint16_t                chip_gpio_pled; /* power led */
-       uint16_t                chip_chan_flags; /* see IEEE80211_CHAN_ */
-       uint16_t                chip_txdesc1_len;
-       int                     chip_rxbuf_exhdr; /* based on fw ver */
-       uint32_t                chip_ee_eaddr_ofs;
-       enum ieee80211_phymode  chip_phymode;   /* see IEEE80211_MODE_ */
-       uint8_t                 chip_fw_txdesc_ctrl;
-       int                     chip_rssi_corr;
-
-       uint8_t                 sc_eeprom_ver;  /* unused */
-       uint8_t                 sc_form_factor; /* unused */
-       uint8_t                 sc_radio_type;  /* see ACX_RADIO_TYPE_ */
-
-       struct acx_ring_data    sc_ring_data;
-       struct acx_buf_data     sc_buf_data;
-
-       struct acx_stats        sc_stats;       /* statistics */
-
-       /*
-        * TX rate control
-        */
-       struct ieee80211_onoe_param sc_onoe_param;
-       struct ieee80211_amrr_param sc_amrr_param;
-       int                     sc_long_retry_limit;
-       int                     chip_short_retry_limit;
-       int                     chip_rate_fallback;
-
-       /*
-        * Per interface sysctl variables
-        */
-       int                     sc_msdu_lifetime;
-       int                     sc_scan_dwell;  /* unit: millisecond */
-       int                     sc_calib_intvl; /* unit: minute */
-
-       int                     (*sc_newstate)
-                               (struct ieee80211com *,
-                                enum ieee80211_state, int);
-
-       int                     (*chip_init)            /* non-NULL */
-                               (struct acx_softc *);
-
-       int                     (*chip_set_wepkey)
-                               (struct acx_softc *,
-                                struct ieee80211_key *, int);
-
-       int                     (*chip_read_config)
-                               (struct acx_softc *, struct acx_config *);
-
-       int                     (*chip_write_config)
-                               (struct acx_softc *, struct acx_config *);
-
-       uint8_t                 (*chip_set_fw_txdesc_rate) /* non-NULL */
-                               (struct acx_softc *, struct acx_txbuf *,
-                                struct ieee80211_node *, int);
-
-       void                    (*chip_tx_complete)     /* non-NULL */
-                               (struct acx_softc *, struct acx_txbuf *,
-                                int, int);
-
-       void                    (*chip_set_bss_join_param) /* non-NULL */
-                               (struct acx_softc *, void *, int);
-
-       void                    (*chip_proc_wep_rxbuf)
-                               (struct acx_softc *, struct mbuf *, int *);
-
-       struct callout          sc_calibrate_timer;
-       int                     (*chip_calibrate)
-                               (struct acx_softc *);
-};
-
-#define ACX_FLAG_FW_LOADED     0x1
-#define ACX_FLAG_PROMISC       0x2
-
-#define ACX_RADIO_TYPE_MAXIM   0x0d
-#define ACX_RADIO_TYPE_RFMD    0x11
-#define ACX_RADIO_TYPE_RALINK  0x15
-#define ACX_RADIO_TYPE_RADIA   0x16
-#define ACX_RADIO_TYPE_UNKN17  0x17
-#define ACX_RADIO_TYPE_UNKN19  0x19
-
-#define ACX_BASE_FW_PATH       "acx/%s/wlangen.bin"
-#define ACX_RADIO_FW_PATH      "acx/%s/radio%02x.bin"
-#define ACX_BASE_RADIO_FW_PATH "acx/%s/FwRad%02x.bin"
-
-extern const struct ieee80211_rateset  acx_rates_11b;
-extern const struct ieee80211_rateset  acx_rates_11b_pbcc;
-extern const struct ieee80211_rateset  acx_rates_11g;
-extern const struct ieee80211_rateset  acx_rates_11g_pbcc;
-extern int                             acx_enable_pbcc;
-
-void   acx100_set_param(device_t);
-void   acx111_set_param(device_t);
-
-int    acx_init_tmplt_ordered(struct acx_softc *);
-void   acx_write_phyreg(struct acx_softc *, uint32_t, uint8_t);
-
-#endif /* !_IF_ACXVAR_H */
diff --git a/sys/dev/netif/bwi/Makefile b/sys/dev/netif/bwi/Makefile
deleted file mode 100644 (file)
index d691f2c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-KMOD   = if_bwi
-
-SRCS   = if_bwi.c bwimac.c bwiphy.c bwirf.c
-SRCS   += device_if.h bus_if.h pci_if.h pcidevs.h
-
-.include <bsd.kmod.mk>
diff --git a/sys/dev/netif/bwi/bwimac.c b/sys/dev/netif/bwi/bwimac.c
deleted file mode 100644 (file)
index a31fb67..0000000
+++ /dev/null
@@ -1,1953 +0,0 @@
-/*
- * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
- * 
- * This code is derived from software contributed to The DragonFly Project
- * by Sepherosa Ziehau <sepherosa@gmail.com>
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name of The DragonFly Project nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific, prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
- * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/bitops.h>
-#include <sys/endian.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/firmware.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/rman.h>
-#include <sys/serialize.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysctl.h>
-
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <net/bpf.h>
-#include <net/if_arp.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/ifq_var.h>
-
-#include <netproto/802_11/ieee80211_radiotap.h>
-#include <netproto/802_11/ieee80211_var.h>
-#include <netproto/802_11/wlan_ratectl/onoe/ieee80211_onoe_param.h>
-
-#include <bus/pci/pcireg.h>
-#include <bus/pci/pcivar.h>
-#include "pcidevs.h"
-
-#include <dev/netif/bwi/if_bwireg.h>
-#include <dev/netif/bwi/if_bwivar.h>
-#include <dev/netif/bwi/bwiphy.h>
-#include <dev/netif/bwi/bwirf.h>
-#include <dev/netif/bwi/bwimac.h>
-
-struct bwi_retry_lim {
-       uint16_t        shretry;
-       uint16_t        shretry_fb;
-       uint16_t        lgretry;
-       uint16_t        lgretry_fb;
-};
-
-static int     bwi_mac_test(struct bwi_mac *);
-static int     bwi_mac_get_property(struct bwi_mac *);
-
-static void    bwi_mac_set_retry_lim(struct bwi_mac *,
-                       const struct bwi_retry_lim *);
-static void    bwi_mac_set_ackrates(struct bwi_mac *,
-                       const struct ieee80211_rateset *);
-
-static int     bwi_mac_gpio_init(struct bwi_mac *);
-static int     bwi_mac_gpio_fini(struct bwi_mac *);
-static void    bwi_mac_opmode_init(struct bwi_mac *);
-static void    bwi_mac_hostflags_init(struct bwi_mac *);
-static void    bwi_mac_bss_param_init(struct bwi_mac *);
-
-static int     bwi_mac_fw_alloc(struct bwi_mac *);
-static void    bwi_mac_fw_free(struct bwi_mac *);
-static int     bwi_mac_fw_load(struct bwi_mac *);
-static int     bwi_mac_fw_init(struct bwi_mac *);
-static int     bwi_mac_fw_load_iv(struct bwi_mac *, const struct fw_image *);
-
-static void    bwi_mac_setup_tpctl(struct bwi_mac *);
-static void    bwi_mac_adjust_tpctl(struct bwi_mac *, int, int);
-
-static void    bwi_mac_lock(struct bwi_mac *);
-static void    bwi_mac_unlock(struct bwi_mac *);
-
-static const uint8_t bwi_sup_macrev[] = { 2, 4, 5, 6, 7, 9, 10 };
-
-void
-bwi_tmplt_write_4(struct bwi_mac *mac, uint32_t ofs, uint32_t val)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-
-       if (mac->mac_flags & BWI_MAC_F_BSWAP)
-               val = bswap32(val);
-
-       CSR_WRITE_4(sc, BWI_MAC_TMPLT_CTRL, ofs);
-       CSR_WRITE_4(sc, BWI_MAC_TMPLT_DATA, val);
-}
-
-void
-bwi_hostflags_write(struct bwi_mac *mac, uint64_t flags)
-{
-       uint64_t val;
-
-       val = flags & 0xffff;
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_HFLAGS_LO, val);
-
-       val = (flags >> 16) & 0xffff;
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_HFLAGS_MI, val);
-
-       /* HI has unclear meaning, so leave it as it is */
-}
-
-uint64_t
-bwi_hostflags_read(struct bwi_mac *mac)
-{
-       uint64_t flags, val;
-
-       /* HI has unclear meaning, so don't touch it */
-       flags = 0;
-
-       val = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_HFLAGS_MI);
-       flags |= val << 16;
-
-       val = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_HFLAGS_LO);
-       flags |= val;
-
-       return flags;
-}
-
-uint16_t
-bwi_memobj_read_2(struct bwi_mac *mac, uint16_t obj_id, uint16_t ofs0)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       uint32_t data_reg;
-       int ofs;
-
-       data_reg = BWI_MOBJ_DATA;
-       ofs = ofs0 / 4;
-
-       if (ofs0 % 4 != 0)
-               data_reg = BWI_MOBJ_DATA_UNALIGN;
-
-       CSR_WRITE_4(sc, BWI_MOBJ_CTRL, BWI_MOBJ_CTRL_VAL(obj_id, ofs));
-       return CSR_READ_2(sc, data_reg);
-}
-
-uint32_t
-bwi_memobj_read_4(struct bwi_mac *mac, uint16_t obj_id, uint16_t ofs0)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       int ofs;
-
-       ofs = ofs0 / 4;
-       if (ofs0 % 4 != 0) {
-               uint32_t ret;
-
-               CSR_WRITE_4(sc, BWI_MOBJ_CTRL, BWI_MOBJ_CTRL_VAL(obj_id, ofs));
-               ret = CSR_READ_2(sc, BWI_MOBJ_DATA_UNALIGN);
-               ret <<= 16;
-
-               CSR_WRITE_4(sc, BWI_MOBJ_CTRL,
-                           BWI_MOBJ_CTRL_VAL(obj_id, ofs + 1));
-               ret |= CSR_READ_2(sc, BWI_MOBJ_DATA);
-
-               return ret;
-       } else {
-               CSR_WRITE_4(sc, BWI_MOBJ_CTRL, BWI_MOBJ_CTRL_VAL(obj_id, ofs));
-               return CSR_READ_4(sc, BWI_MOBJ_DATA);
-       }
-}
-
-void
-bwi_memobj_write_2(struct bwi_mac *mac, uint16_t obj_id, uint16_t ofs0,
-                  uint16_t v)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       uint32_t data_reg;
-       int ofs;
-
-       data_reg = BWI_MOBJ_DATA;
-       ofs = ofs0 / 4;
-
-       if (ofs0 % 4 != 0)
-               data_reg = BWI_MOBJ_DATA_UNALIGN;
-
-       CSR_WRITE_4(sc, BWI_MOBJ_CTRL, BWI_MOBJ_CTRL_VAL(obj_id, ofs));
-       CSR_WRITE_2(sc, data_reg, v);
-}
-
-void
-bwi_memobj_write_4(struct bwi_mac *mac, uint16_t obj_id, uint16_t ofs0,
-                  uint32_t v)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       int ofs;
-
-       ofs = ofs0 / 4;
-       if (ofs0 % 4 != 0) {
-               CSR_WRITE_4(sc, BWI_MOBJ_CTRL, BWI_MOBJ_CTRL_VAL(obj_id, ofs));
-               CSR_WRITE_2(sc, BWI_MOBJ_DATA_UNALIGN, v >> 16);
-
-               CSR_WRITE_4(sc, BWI_MOBJ_CTRL,
-                           BWI_MOBJ_CTRL_VAL(obj_id, ofs + 1));
-               CSR_WRITE_2(sc, BWI_MOBJ_DATA, v & 0xffff);
-       } else {
-               CSR_WRITE_4(sc, BWI_MOBJ_CTRL, BWI_MOBJ_CTRL_VAL(obj_id, ofs));
-               CSR_WRITE_4(sc, BWI_MOBJ_DATA, v);
-       }
-}
-
-int
-bwi_mac_lateattach(struct bwi_mac *mac)
-{
-       int error;
-
-       if (mac->mac_rev >= 5)
-               CSR_READ_4(mac->mac_sc, BWI_STATE_HI); /* dummy read */
-
-       bwi_mac_reset(mac, 1);
-
-       error = bwi_phy_attach(mac);
-       if (error)
-               return error;
-
-       error = bwi_rf_attach(mac);
-       if (error)
-               return error;
-
-       /* Link 11B/G PHY, unlink 11A PHY */
-       if (mac->mac_phy.phy_mode == IEEE80211_MODE_11A)
-               bwi_mac_reset(mac, 0);
-       else
-               bwi_mac_reset(mac, 1);
-
-       error = bwi_mac_test(mac);
-       if (error)
-               return error;
-
-       error = bwi_mac_get_property(mac);
-       if (error)
-               return error;
-
-       error = bwi_rf_map_txpower(mac);
-       if (error)
-               return error;
-
-       bwi_rf_off(mac);
-       CSR_WRITE_2(mac->mac_sc, BWI_BBP_ATTEN, BWI_BBP_ATTEN_MAGIC);
-       bwi_regwin_disable(mac->mac_sc, &mac->mac_regwin, 0);
-
-       return 0;
-}
-
-int
-bwi_mac_init(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       int error, i;
-
-       /* Clear MAC/PHY/RF states */
-       bwi_mac_setup_tpctl(mac);
-       bwi_rf_clear_state(&mac->mac_rf);
-       bwi_phy_clear_state(&mac->mac_phy);
-
-       /* Enable MAC and linked it to PHY */
-       if (!bwi_regwin_is_enabled(sc, &mac->mac_regwin))
-               bwi_mac_reset(mac, 1);
-
-       /* Initialize backplane */
-       error = bwi_bus_init(sc, mac);
-       if (error)
-               return error;
-
-       /* XXX work around for hardware bugs? */
-       if (sc->sc_bus_regwin.rw_rev <= 5 &&
-           sc->sc_bus_regwin.rw_type != BWI_REGWIN_T_BUSPCIE) {
-               CSR_SETBITS_4(sc, BWI_CONF_LO,
-               __SHIFTIN(BWI_CONF_LO_SERVTO, BWI_CONF_LO_SERVTO_MASK) |
-               __SHIFTIN(BWI_CONF_LO_REQTO, BWI_CONF_LO_REQTO_MASK));
-       }
-
-       /* Calibrate PHY */
-       error = bwi_phy_calibrate(mac);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "PHY calibrate failed\n");
-               return error;
-       }
-
-       /* Prepare to initialize firmware */
-       CSR_WRITE_4(sc, BWI_MAC_STATUS,
-                   BWI_MAC_STATUS_UCODE_JUMP0 |
-                   BWI_MAC_STATUS_IHREN);
-
-       /*
-        * Load and initialize firmwares
-        */
-       error = bwi_mac_fw_alloc(mac);
-       if (error)
-               return error;
-
-       error = bwi_mac_fw_load(mac);
-       if (error)
-               return error;
-
-       error = bwi_mac_gpio_init(mac);
-       if (error)
-               return error;
-
-       error = bwi_mac_fw_init(mac);
-       if (error)
-               return error;
-
-       /*
-        * Turn on RF
-        */
-       bwi_rf_on(mac);
-
-       /* TODO: LED, hardware rf enabled is only related to LED setting */
-
-       /*
-        * Initialize PHY
-        */
-       CSR_WRITE_2(sc, BWI_BBP_ATTEN, 0);
-       bwi_phy_init(mac);
-
-       /* TODO: interference mitigation */
-
-       /*
-        * Setup antenna mode
-        */
-       bwi_rf_set_ant_mode(mac, mac->mac_rf.rf_ant_mode);
-
-       /*
-        * Initialize operation mode (RX configuration)
-        */
-       bwi_mac_opmode_init(mac);
-
-       /* XXX what's these */
-       if (mac->mac_rev < 3) {
-               CSR_WRITE_2(sc, 0x60e, 0);
-               CSR_WRITE_2(sc, 0x610, 0x8000);
-               CSR_WRITE_2(sc, 0x604, 0);
-               CSR_WRITE_2(sc, 0x606, 0x200);
-       } else {
-               CSR_WRITE_4(sc, 0x188, 0x80000000);
-               CSR_WRITE_4(sc, 0x18c, 0x2000000);
-       }
-
-       /*
-        * Initialize TX/RX interrupts' mask
-        */
-       CSR_WRITE_4(sc, BWI_MAC_INTR_STATUS, BWI_INTR_TIMER1);
-       for (i = 0; i < BWI_TXRX_NRING; ++i) {
-               uint32_t intrs;
-
-               if (BWI_TXRX_IS_RX(i))
-                       intrs = BWI_TXRX_RX_INTRS;
-               else
-                       intrs = BWI_TXRX_TX_INTRS;
-               CSR_WRITE_4(sc, BWI_TXRX_INTR_MASK(i), intrs);
-       }
-
-       /* XXX what's this */
-       CSR_SETBITS_4(sc, BWI_STATE_LO, 0x100000);
-
-       /* Setup MAC power up delay */
-       CSR_WRITE_2(sc, BWI_MAC_POWERUP_DELAY, sc->sc_pwron_delay);
-
-       /* Set MAC regwin revision */
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_MACREV, mac->mac_rev);
-
-       /*
-        * Initialize host flags
-        */
-       bwi_mac_hostflags_init(mac);
-
-       /*
-        * Initialize BSS parameters
-        */
-       bwi_mac_bss_param_init(mac);
-
-       /*
-        * Initialize TX rings
-        */
-       for (i = 0; i < BWI_TX_NRING; ++i) {
-               error = sc->sc_init_tx_ring(sc, i);
-               if (error) {
-                       if_printf(&sc->sc_ic.ic_if,
-                                 "can't initialize %dth TX ring\n", i);
-                       return error;
-               }
-       }
-
-       /*
-        * Initialize RX ring
-        */
-       error = sc->sc_init_rx_ring(sc);
-       if (error) {
-               if_printf(&sc->sc_ic.ic_if, "can't initialize RX ring\n");
-               return error;
-       }
-
-       /*
-        * Initialize TX stats if the current MAC uses that
-        */
-       if (mac->mac_flags & BWI_MAC_F_HAS_TXSTATS) {
-               error = sc->sc_init_txstats(sc);
-               if (error) {
-                       if_printf(&sc->sc_ic.ic_if,
-                                 "can't initialize TX stats ring\n");
-                       return error;
-               }
-       }
-
-       /* XXX what's these */
-       CSR_WRITE_2(sc, 0x612, 0x50);   /* Force Pre-TBTT to 80? */
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, 0x416, 0x50);
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, 0x414, 0x1f4);
-
-       mac->mac_flags |= BWI_MAC_F_INITED;
-       return 0;
-}
-
-void
-bwi_mac_reset(struct bwi_mac *mac, int link_phy)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       uint32_t flags, state_lo, status;
-
-       flags = BWI_STATE_LO_FLAG_PHYRST | BWI_STATE_LO_FLAG_PHYCLKEN;
-       if (link_phy)
-               flags |= BWI_STATE_LO_FLAG_PHYLNK;
-       bwi_regwin_enable(sc, &mac->mac_regwin, flags);
-       DELAY(2000);
-
-       state_lo = CSR_READ_4(sc, BWI_STATE_LO);
-       state_lo |= BWI_STATE_LO_GATED_CLOCK;
-       state_lo &= ~__SHIFTIN(BWI_STATE_LO_FLAG_PHYRST,
-                              BWI_STATE_LO_FLAGS_MASK);
-       CSR_WRITE_4(sc, BWI_STATE_LO, state_lo);
-       /* Flush pending bus write */
-       CSR_READ_4(sc, BWI_STATE_LO);
-       DELAY(1000);
-
-       state_lo &= ~BWI_STATE_LO_GATED_CLOCK;
-       CSR_WRITE_4(sc, BWI_STATE_LO, state_lo);
-       /* Flush pending bus write */
-       CSR_READ_4(sc, BWI_STATE_LO);
-       DELAY(1000);
-
-       CSR_WRITE_2(sc, BWI_BBP_ATTEN, 0);
-
-       status = CSR_READ_4(sc, BWI_MAC_STATUS);
-       status |= BWI_MAC_STATUS_IHREN;
-       if (link_phy)
-               status |= BWI_MAC_STATUS_PHYLNK;
-       else
-               status &= ~BWI_MAC_STATUS_PHYLNK;
-       CSR_WRITE_4(sc, BWI_MAC_STATUS, status);
-
-       if (link_phy) {
-               DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH | BWI_DBG_INIT,
-                       "%s\n", "PHY is linked");
-               mac->mac_phy.phy_flags |= BWI_PHY_F_LINKED;
-       } else {
-               DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH | BWI_DBG_INIT,
-                       "%s\n", "PHY is unlinked");
-               mac->mac_phy.phy_flags &= ~BWI_PHY_F_LINKED;
-       }
-}
-
-void
-bwi_mac_set_tpctl_11bg(struct bwi_mac *mac, const struct bwi_tpctl *new_tpctl)
-{
-       struct bwi_rf *rf = &mac->mac_rf;
-       struct bwi_tpctl *tpctl = &mac->mac_tpctl;
-
-       if (new_tpctl != NULL) {
-               KKASSERT(new_tpctl->bbp_atten <= BWI_BBP_ATTEN_MAX);
-               KKASSERT(new_tpctl->rf_atten <=
-                        (rf->rf_rev < 6 ? BWI_RF_ATTEN_MAX0
-                                        : BWI_RF_ATTEN_MAX1));
-               KKASSERT(new_tpctl->tp_ctrl1 <= BWI_TPCTL1_MAX);
-
-               tpctl->bbp_atten = new_tpctl->bbp_atten;
-               tpctl->rf_atten = new_tpctl->rf_atten;
-               tpctl->tp_ctrl1 = new_tpctl->tp_ctrl1;
-       }
-
-       /* Set BBP attenuation */
-       bwi_phy_set_bbp_atten(mac, tpctl->bbp_atten);
-
-       /* Set RF attenuation */
-       RF_WRITE(mac, BWI_RFR_ATTEN, tpctl->rf_atten);
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_RF_ATTEN,
-                    tpctl->rf_atten);
-
-       /* Set TX power */
-       if (rf->rf_type == BWI_RF_T_BCM2050) {
-               RF_FILT_SETBITS(mac, BWI_RFR_TXPWR, ~BWI_RFR_TXPWR1_MASK,
-                       __SHIFTIN(tpctl->tp_ctrl1, BWI_RFR_TXPWR1_MASK));
-       }
-
-       /* Adjust RF Local Oscillator */
-       if (mac->mac_phy.phy_mode == IEEE80211_MODE_11G)
-               bwi_rf_lo_adjust(mac, tpctl);
-}
-
-static int
-bwi_mac_test(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       uint32_t orig_val, val;
-
-#define TEST_VAL1      0xaa5555aa
-#define TEST_VAL2      0x55aaaa55
-
-       /* Save it for later restoring */
-       orig_val = MOBJ_READ_4(mac, BWI_COMM_MOBJ, 0);
-
-       /* Test 1 */
-       MOBJ_WRITE_4(mac, BWI_COMM_MOBJ, 0, TEST_VAL1);
-       val = MOBJ_READ_4(mac, BWI_COMM_MOBJ, 0);
-       if (val != TEST_VAL1) {
-               device_printf(sc->sc_dev, "TEST1 failed\n");
-               return ENXIO;
-       }
-
-       /* Test 2 */
-       MOBJ_WRITE_4(mac, BWI_COMM_MOBJ, 0, TEST_VAL2);
-       val = MOBJ_READ_4(mac, BWI_COMM_MOBJ, 0);
-       if (val != TEST_VAL2) {
-               device_printf(sc->sc_dev, "TEST2 failed\n");
-               return ENXIO;
-       }
-
-       /* Restore to the original value */
-       MOBJ_WRITE_4(mac, BWI_COMM_MOBJ, 0, orig_val);
-
-       val = CSR_READ_4(sc, BWI_MAC_STATUS);
-       if ((val & ~BWI_MAC_STATUS_PHYLNK) != BWI_MAC_STATUS_IHREN) {
-               device_printf(sc->sc_dev, "%s failed, MAC status 0x%08x\n",
-                             __func__, val);
-               return ENXIO;
-       }
-
-       val = CSR_READ_4(sc, BWI_MAC_INTR_STATUS);
-       if (val != 0) {
-               device_printf(sc->sc_dev, "%s failed, intr status %08x\n",
-                             __func__, val);
-               return ENXIO;
-       }
-
-#undef TEST_VAL2
-#undef TEST_VAL1
-
-       return 0;
-}
-
-static void
-bwi_mac_setup_tpctl(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct bwi_rf *rf = &mac->mac_rf;
-       struct bwi_phy *phy = &mac->mac_phy;
-       struct bwi_tpctl *tpctl = &mac->mac_tpctl;
-
-       /* Calc BBP attenuation */
-       if (rf->rf_type == BWI_RF_T_BCM2050 && rf->rf_rev < 6)
-               tpctl->bbp_atten = 0;
-       else
-               tpctl->bbp_atten = 2;
-
-       /* Calc TX power CTRL1?? */
-       tpctl->tp_ctrl1 = 0;
-       if (rf->rf_type == BWI_RF_T_BCM2050) {
-               if (rf->rf_rev == 1)
-                       tpctl->tp_ctrl1 = 3;
-               else if (rf->rf_rev < 6)
-                       tpctl->tp_ctrl1 = 2;
-               else if (rf->rf_rev == 8)
-                       tpctl->tp_ctrl1 = 1;
-       }
-
-       /* Empty TX power CTRL2?? */
-       tpctl->tp_ctrl2 = 0xffff;
-
-       /*
-        * Calc RF attenuation
-        */
-       if (phy->phy_mode == IEEE80211_MODE_11A) {
-               tpctl->rf_atten = 0x60;
-               goto back;
-       }
-
-       if (BWI_IS_BRCM_BCM4309G(sc) && sc->sc_pci_revid < 0x51) {
-               tpctl->rf_atten = sc->sc_pci_revid < 0x43 ? 2 : 3;
-               goto back;
-       }
-
-       tpctl->rf_atten = 5;
-
-       if (rf->rf_type != BWI_RF_T_BCM2050) {
-               if (rf->rf_type == BWI_RF_T_BCM2053 && rf->rf_rev == 1)
-                       tpctl->rf_atten = 6;
-               goto back;
-       }
-
-       /*
-        * NB: If we reaches here and the card is BRCM_BCM4309G,
-        *     then the card's PCI revision must >= 0x51
-        */
-
-       /* BCM2050 RF */
-       switch (rf->rf_rev) {
-       case 1:
-               if (phy->phy_mode == IEEE80211_MODE_11G) {
-                       if (BWI_IS_BRCM_BCM4309G(sc) || BWI_IS_BRCM_BU4306(sc))
-                               tpctl->rf_atten = 3;
-                       else
-                               tpctl->rf_atten = 1;
-               } else {
-                       if (BWI_IS_BRCM_BCM4309G(sc))
-                               tpctl->rf_atten = 7;
-                       else
-                               tpctl->rf_atten = 6;
-               }
-               break;
-       case 2:
-               if (phy->phy_mode == IEEE80211_MODE_11G) {
-                       /*
-                        * NOTE: Order of following conditions is critical
-                        */
-                       if (BWI_IS_BRCM_BCM4309G(sc))
-                               tpctl->rf_atten = 3;
-                       else if (BWI_IS_BRCM_BU4306(sc))
-                               tpctl->rf_atten = 5;
-                       else if (sc->sc_bbp_id == BWI_BBPID_BCM4320)
-                               tpctl->rf_atten = 4;
-                       else
-                               tpctl->rf_atten = 3;
-               } else {
-                       tpctl->rf_atten = 6;
-               }
-               break;
-       case 4:
-       case 5:
-               tpctl->rf_atten = 1;
-               break;
-       case 8:
-               tpctl->rf_atten = 0x1a;
-               break;
-       }
-back:
-       DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_INIT | BWI_DBG_TXPOWER,
-               "bbp atten: %u, rf atten: %u, ctrl1: %u, ctrl2: %u\n",
-               tpctl->bbp_atten, tpctl->rf_atten,
-               tpctl->tp_ctrl1, tpctl->tp_ctrl2);
-}
-
-void
-bwi_mac_dummy_xmit(struct bwi_mac *mac)
-{
-#define PACKET_LEN     5
-       static const uint32_t   packet_11a[PACKET_LEN] =
-       { 0x000201cc, 0x00d40000, 0x00000000, 0x01000000, 0x00000000 };
-       static const uint32_t   packet_11bg[PACKET_LEN] =
-       { 0x000b846e, 0x00d40000, 0x00000000, 0x01000000, 0x00000000 };
-
-       struct bwi_softc *sc = mac->mac_sc;
-       struct bwi_rf *rf = &mac->mac_rf;
-       const uint32_t *packet;
-       uint16_t val_50c;
-       int wait_max, i;
-
-       if (mac->mac_phy.phy_mode == IEEE80211_MODE_11A) {
-               wait_max = 30;
-               packet = packet_11a;
-               val_50c = 1;
-       } else {
-               wait_max = 250;
-               packet = packet_11bg;
-               val_50c = 0;
-       }
-
-       for (i = 0; i < PACKET_LEN; ++i)
-               TMPLT_WRITE_4(mac, i * 4, packet[i]);
-
-       CSR_READ_4(sc, BWI_MAC_STATUS); /* dummy read */
-
-       CSR_WRITE_2(sc, 0x568, 0);
-       CSR_WRITE_2(sc, 0x7c0, 0);
-       CSR_WRITE_2(sc, 0x50c, val_50c);
-       CSR_WRITE_2(sc, 0x508, 0);
-       CSR_WRITE_2(sc, 0x50a, 0);
-       CSR_WRITE_2(sc, 0x54c, 0);
-       CSR_WRITE_2(sc, 0x56a, 0x14);
-       CSR_WRITE_2(sc, 0x568, 0x826);
-       CSR_WRITE_2(sc, 0x500, 0);
-       CSR_WRITE_2(sc, 0x502, 0x30);
-
-       if (rf->rf_type == BWI_RF_T_BCM2050 && rf->rf_rev <= 5)
-               RF_WRITE(mac, 0x51, 0x17);
-
-       for (i = 0; i < wait_max; ++i) {
-               if (CSR_READ_2(sc, 0x50e) & 0x80)
-                       break;
-               DELAY(10);
-       }
-       for (i = 0; i < 10; ++i) {
-               if (CSR_READ_2(sc, 0x50e) & 0x400)
-                       break;
-               DELAY(10);
-       }
-       for (i = 0; i < 10; ++i) {
-               if ((CSR_READ_2(sc, 0x690) & 0x100) == 0)
-                       break;
-               DELAY(10);
-       }
-
-       if (rf->rf_type == BWI_RF_T_BCM2050 && rf->rf_rev <= 5)
-               RF_WRITE(mac, 0x51, 0x37);
-#undef PACKET_LEN
-}
-
-void
-bwi_mac_init_tpctl_11bg(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct bwi_phy *phy = &mac->mac_phy;
-       struct bwi_rf *rf = &mac->mac_rf;
-       struct bwi_tpctl tpctl_orig;
-       int restore_tpctl = 0;
-
-       KKASSERT(phy->phy_mode != IEEE80211_MODE_11A);
-
-       if (BWI_IS_BRCM_BU4306(sc))
-               return;
-
-       PHY_WRITE(mac, 0x28, 0x8018);
-       CSR_CLRBITS_2(sc, BWI_BBP_ATTEN, 0x20);
-
-       if (phy->phy_mode == IEEE80211_MODE_11G) {
-               if ((phy->phy_flags & BWI_PHY_F_LINKED) == 0)
-                       return;
-               PHY_WRITE(mac, 0x47a, 0xc111);
-       }
-       if (mac->mac_flags & BWI_MAC_F_TPCTL_INITED)
-               return;
-
-       if (phy->phy_mode == IEEE80211_MODE_11B && phy->phy_rev >= 2 &&
-           rf->rf_type == BWI_RF_T_BCM2050) {
-               RF_SETBITS(mac, 0x76, 0x84);
-       } else {
-               struct bwi_tpctl tpctl;
-
-               /* Backup original TX power control variables */
-               bcopy(&mac->mac_tpctl, &tpctl_orig, sizeof(tpctl_orig));
-               restore_tpctl = 1;
-
-               bcopy(&mac->mac_tpctl, &tpctl, sizeof(tpctl));
-               tpctl.bbp_atten = 11;
-               tpctl.tp_ctrl1 = 0;
-#ifdef notyet
-               if (rf->rf_rev >= 6 && rf->rf_rev <= 8)
-                       tpctl.rf_atten = 31;
-               else
-#endif
-                       tpctl.rf_atten = 9;
-
-               bwi_mac_set_tpctl_11bg(mac, &tpctl);
-       }
-
-       bwi_mac_dummy_xmit(mac);
-
-       mac->mac_flags |= BWI_MAC_F_TPCTL_INITED;
-       rf->rf_base_tssi = PHY_READ(mac, 0x29);
-       DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_INIT | BWI_DBG_TXPOWER,
-               "base tssi %d\n", rf->rf_base_tssi);
-
-       if (abs(rf->rf_base_tssi - rf->rf_idle_tssi) >= 20) {
-               if_printf(&sc->sc_ic.ic_if, "base tssi measure failed\n");
-               mac->mac_flags |= BWI_MAC_F_TPCTL_ERROR;
-       }
-
-       if (restore_tpctl)
-               bwi_mac_set_tpctl_11bg(mac, &tpctl_orig);
-       else
-               RF_CLRBITS(mac, 0x76, 0x84);
-
-       bwi_rf_clear_tssi(mac);
-}
-
-void
-bwi_mac_detach(struct bwi_mac *mac)
-{
-       bwi_mac_fw_free(mac);
-}
-
-static __inline int
-bwi_fwimage_is_valid(struct bwi_softc *sc, const struct fw_image *fw,
-                    uint8_t fw_type)
-{
-       const struct bwi_fwhdr *hdr;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-
-       if (fw->fw_imglen < sizeof(*hdr)) {
-               if_printf(ifp, "invalid firmware (%s): invalid size %zu\n",
-                         fw->fw_name, fw->fw_imglen);
-               return 0;
-       }
-
-       hdr = (const struct bwi_fwhdr *)fw->fw_image;
-
-       if (fw_type != BWI_FW_T_IV) {
-               /*
-                * Don't verify IV's size, it has different meaning
-                */
-               if (be32toh(hdr->fw_size) != fw->fw_imglen - sizeof(*hdr)) {
-                       if_printf(ifp,
-                                 "invalid firmware (%s): size mismatch, "
-                                 "fw %u, real %zu\n",
-                                 fw->fw_name, be32toh(hdr->fw_size),
-                                 fw->fw_imglen - sizeof(*hdr));
-                       return 0;
-               }
-       }
-
-       if (hdr->fw_type != fw_type) {
-               if_printf(ifp, "invalid firmware (%s): type mismatch, "
-                         "fw \'%c\', target \'%c\'\n", fw->fw_name,
-                         hdr->fw_type, fw_type);
-               return 0;
-       }
-
-       if (hdr->fw_gen != BWI_FW_GEN_1) {
-               if_printf(ifp, "invalid firmware (%s): wrong generation, "
-                         "fw %d, target %d\n", fw->fw_name,
-                         hdr->fw_gen, BWI_FW_GEN_1);
-               return 0;
-       }
-       return 1;
-}
-
-/*
- * XXX Error cleanup
- */
-static int
-bwi_mac_fw_alloc(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       struct fw_image *img;
-       char fwname[64];
-       int idx;
-
-       /*
-        * NB: serializer need to be released before loading firmware
-        *     image to avoid possible dead lock
-        */
-       ASSERT_SERIALIZED(ifp->if_serializer);
-
-       if (mac->mac_ucode == NULL) {
-               ksnprintf(fwname, sizeof(fwname), BWI_FW_UCODE_PATH,
-                         sc->sc_fw_version,
-                         mac->mac_rev >= 5 ? 5 : mac->mac_rev);
-
-               lwkt_serialize_exit(ifp->if_serializer);
-               img = firmware_image_load(fwname, NULL);
-               lwkt_serialize_enter(ifp->if_serializer);
-
-               mac->mac_ucode = img;
-               if (mac->mac_ucode == NULL) {
-                       if_printf(ifp, "request firmware %s failed\n", fwname);
-                       return ENOMEM;
-               }
-
-               if (!bwi_fwimage_is_valid(sc, mac->mac_ucode, BWI_FW_T_UCODE))
-                       return EINVAL;
-       }
-
-       if (mac->mac_pcm == NULL) {
-               ksnprintf(fwname, sizeof(fwname), BWI_FW_PCM_PATH,
-                         sc->sc_fw_version,
-                         mac->mac_rev < 5 ? 4 : 5);
-
-               lwkt_serialize_exit(ifp->if_serializer);
-               img = firmware_image_load(fwname, NULL);
-               lwkt_serialize_enter(ifp->if_serializer);
-
-               mac->mac_pcm = img;
-               if (mac->mac_pcm == NULL) {
-                       if_printf(ifp, "request firmware %s failed\n", fwname);
-                       return ENOMEM;
-               }
-
-               if (!bwi_fwimage_is_valid(sc, mac->mac_pcm, BWI_FW_T_PCM))
-                       return EINVAL;
-       }
-
-       if (mac->mac_iv == NULL) {
-               /* TODO: 11A */
-               if (mac->mac_rev == 2 || mac->mac_rev == 4) {
-                       idx = 2;
-               } else if (mac->mac_rev >= 5 && mac->mac_rev <= 10) {
-                       idx = 5;
-               } else {
-                       if_printf(ifp, "no suitable IV for MAC rev %d\n",
-                                 mac->mac_rev);
-                       return ENODEV;
-               }
-
-               ksnprintf(fwname, sizeof(fwname), BWI_FW_IV_PATH,
-                         sc->sc_fw_version, idx);
-
-               lwkt_serialize_exit(ifp->if_serializer);
-               img = firmware_image_load(fwname, NULL);
-               lwkt_serialize_enter(ifp->if_serializer);
-
-               mac->mac_iv = img;
-               if (mac->mac_iv == NULL) {
-                       if_printf(ifp, "request firmware %s failed\n", fwname);
-                       return ENOMEM;
-               }
-               if (!bwi_fwimage_is_valid(sc, mac->mac_iv, BWI_FW_T_IV))
-                       return EINVAL;
-       }
-
-       if (mac->mac_iv_ext == NULL) {
-               /* TODO: 11A */
-               if (mac->mac_rev == 2 || mac->mac_rev == 4 ||
-                   mac->mac_rev >= 11) {
-                       /* No extended IV */
-                       goto back;
-               } else if (mac->mac_rev >= 5 && mac->mac_rev <= 10) {
-                       idx = 5;
-               } else {
-                       if_printf(ifp, "no suitible ExtIV for MAC rev %d\n",
-                                 mac->mac_rev);
-                       return ENODEV;
-               }
-
-               ksnprintf(fwname, sizeof(fwname), BWI_FW_IV_EXT_PATH,
-                         sc->sc_fw_version, idx);
-
-               lwkt_serialize_exit(ifp->if_serializer);
-               img = firmware_image_load(fwname, NULL);
-               lwkt_serialize_enter(ifp->if_serializer);
-
-               mac->mac_iv_ext = img;
-               if (mac->mac_iv_ext == NULL) {
-                       if_printf(ifp, "request firmware %s failed\n", fwname);
-                       return ENOMEM;
-               }
-               if (!bwi_fwimage_is_valid(sc, mac->mac_iv_ext, BWI_FW_T_IV))
-                       return EINVAL;
-       }
-back:
-       return 0;
-}
-
-static void
-bwi_mac_fw_free(struct bwi_mac *mac)
-{
-       if (mac->mac_ucode != NULL) {
-               firmware_image_unload(mac->mac_ucode);
-               mac->mac_ucode = NULL;
-       }
-
-       if (mac->mac_pcm != NULL) {
-               firmware_image_unload(mac->mac_pcm);
-               mac->mac_pcm = NULL;
-       }
-
-       if (mac->mac_iv != NULL) {
-               firmware_image_unload(mac->mac_iv);
-               mac->mac_iv = NULL;
-       }
-
-       if (mac->mac_iv_ext != NULL) {
-               firmware_image_unload(mac->mac_iv_ext);
-               mac->mac_iv_ext = NULL;
-       }
-}
-
-static int
-bwi_mac_fw_load(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       const uint32_t *fw;
-       uint16_t fw_rev;
-       int fw_len, i;
-
-       /*
-        * Load ucode image
-        */
-       fw = (const uint32_t *)
-            ((const uint8_t *)mac->mac_ucode->fw_image + BWI_FWHDR_SZ);
-       fw_len = (mac->mac_ucode->fw_imglen - BWI_FWHDR_SZ) / sizeof(uint32_t);
-
-       CSR_WRITE_4(sc, BWI_MOBJ_CTRL,
-                   BWI_MOBJ_CTRL_VAL(
-                   BWI_FW_UCODE_MOBJ | BWI_WR_MOBJ_AUTOINC, 0));
-       for (i = 0; i < fw_len; ++i) {
-               CSR_WRITE_4(sc, BWI_MOBJ_DATA, be32toh(fw[i]));
-               DELAY(10);
-       }
-
-       /*
-        * Load PCM image
-        */
-       fw = (const uint32_t *)
-            ((const uint8_t *)mac->mac_pcm->fw_image + BWI_FWHDR_SZ);
-       fw_len = (mac->mac_pcm->fw_imglen - BWI_FWHDR_SZ) / sizeof(uint32_t);
-
-       CSR_WRITE_4(sc, BWI_MOBJ_CTRL,
-                   BWI_MOBJ_CTRL_VAL(BWI_FW_PCM_MOBJ, 0x01ea));
-       CSR_WRITE_4(sc, BWI_MOBJ_DATA, 0x4000);
-
-       CSR_WRITE_4(sc, BWI_MOBJ_CTRL,
-                   BWI_MOBJ_CTRL_VAL(BWI_FW_PCM_MOBJ, 0x01eb));
-       for (i = 0; i < fw_len; ++i) {
-               CSR_WRITE_4(sc, BWI_MOBJ_DATA, be32toh(fw[i]));
-               DELAY(10);
-       }
-
-       CSR_WRITE_4(sc, BWI_MAC_INTR_STATUS, BWI_ALL_INTRS);
-       CSR_WRITE_4(sc, BWI_MAC_STATUS,
-                   BWI_MAC_STATUS_UCODE_START |
-                   BWI_MAC_STATUS_IHREN |
-                   BWI_MAC_STATUS_INFRA);
-
-#define NRETRY 200
-
-       for (i = 0; i < NRETRY; ++i) {
-               uint32_t intr_status;
-
-               intr_status = CSR_READ_4(sc, BWI_MAC_INTR_STATUS);
-               if (intr_status == BWI_INTR_READY)
-                       break;
-               DELAY(10);
-       }
-       if (i == NRETRY) {
-               if_printf(ifp, "firmware (ucode&pcm) loading timed out\n");
-               return ETIMEDOUT;
-       }
-
-#undef NRETRY
-
-       CSR_READ_4(sc, BWI_MAC_INTR_STATUS);    /* dummy read */
-
-       fw_rev = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWREV);
-       if (fw_rev > BWI_FW_VERSION3_REVMAX) {
-               if_printf(ifp, "firmware version 4 is not supported yet\n");
-               return ENODEV;
-       }
-
-       if_printf(ifp, "firmware rev 0x%04x, patch level 0x%04x\n", fw_rev,
-                 MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_FWPATCHLV));
-       return 0;
-}
-
-static int
-bwi_mac_gpio_init(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct bwi_regwin *old, *gpio_rw;
-       uint32_t filt, bits;
-       int error;
-
-       CSR_CLRBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_GPOSEL_MASK);
-       /* TODO:LED */
-
-       CSR_SETBITS_2(sc, BWI_MAC_GPIO_MASK, 0xf);
-
-       filt = 0x1f;
-       bits = 0xf;
-       if (sc->sc_bbp_id == BWI_BBPID_BCM4301) {
-               filt |= 0x60;
-               bits |= 0x60;
-       }
-       if (sc->sc_card_flags & BWI_CARD_F_PA_GPIO9) {
-               CSR_SETBITS_2(sc, BWI_MAC_GPIO_MASK, 0x200);
-               filt |= 0x200;
-               bits |= 0x200;
-       }
-
-       gpio_rw = BWI_GPIO_REGWIN(sc);
-       error = bwi_regwin_switch(sc, gpio_rw, &old);
-       if (error)
-               return error;
-
-       CSR_FILT_SETBITS_4(sc, BWI_GPIO_CTRL, filt, bits);
-
-       return bwi_regwin_switch(sc, old, NULL);
-}
-
-static int
-bwi_mac_gpio_fini(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct bwi_regwin *old, *gpio_rw;
-       int error;
-
-       gpio_rw = BWI_GPIO_REGWIN(sc);
-       error = bwi_regwin_switch(sc, gpio_rw, &old);
-       if (error)
-               return error;
-
-       CSR_WRITE_4(sc, BWI_GPIO_CTRL, 0);
-
-       return bwi_regwin_switch(sc, old, NULL);
-}
-
-static int
-bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct fw_image *fw)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct ifnet *ifp = &sc->sc_ic.ic_if;
-       const struct bwi_fwhdr *hdr;
-       const struct bwi_fw_iv *iv;
-       int n, i, iv_img_size;
-
-       /* Get the number of IVs in the IV image */
-       hdr = (const struct bwi_fwhdr *)fw->fw_image;
-       n = be32toh(hdr->fw_iv_cnt);
-       DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_INIT | BWI_DBG_FIRMWARE,
-               "IV count %d\n", n);
-
-       /* Calculate the IV image size, for later sanity check */
-       iv_img_size = fw->fw_imglen - sizeof(*hdr);
-
-       /* Locate the first IV */
-       iv = (const struct bwi_fw_iv *)
-            ((const uint8_t *)fw->fw_image + sizeof(*hdr));
-
-       for (i = 0; i < n; ++i) {
-               uint16_t iv_ofs, ofs;
-               int sz = 0;
-
-               if (iv_img_size < sizeof(iv->iv_ofs)) {
-                       if_printf(ifp, "invalid IV image, ofs\n");
-                       return EINVAL;
-               }
-               iv_img_size -= sizeof(iv->iv_ofs);
-               sz += sizeof(iv->iv_ofs);
-
-               iv_ofs = be16toh(iv->iv_ofs);
-
-               ofs = __SHIFTOUT(iv_ofs, BWI_FW_IV_OFS_MASK);
-               if (ofs >= 0x1000) {
-                       if_printf(ifp, "invalid ofs (0x%04x) "
-                                 "for %dth iv\n", ofs, i);
-                       return EINVAL;
-               }
-
-               if (iv_ofs & BWI_FW_IV_IS_32BIT) {
-                       uint32_t val32;
-
-                       if (iv_img_size < sizeof(iv->iv_val.val32)) {
-                               if_printf(ifp, "invalid IV image, val32\n");
-                               return EINVAL;
-                       }
-                       iv_img_size -= sizeof(iv->iv_val.val32);
-                       sz += sizeof(iv->iv_val.val32);
-
-                       val32 = be32toh(iv->iv_val.val32);
-                       CSR_WRITE_4(sc, ofs, val32);
-               } else {
-                       uint16_t val16;
-
-                       if (iv_img_size < sizeof(iv->iv_val.val16)) {
-                               if_printf(ifp, "invalid IV image, val16\n");
-                               return EINVAL;
-                       }
-                       iv_img_size -= sizeof(iv->iv_val.val16);
-                       sz += sizeof(iv->iv_val.val16);
-
-                       val16 = be16toh(iv->iv_val.val16);
-                       CSR_WRITE_2(sc, ofs, val16);
-               }
-
-               iv = (const struct bwi_fw_iv *)((const uint8_t *)iv + sz);
-       }
-
-       if (iv_img_size != 0) {
-               if_printf(ifp, "invalid IV image, size left %d\n", iv_img_size);
-               return EINVAL;
-       }
-       return 0;
-}
-
-static int
-bwi_mac_fw_init(struct bwi_mac *mac)
-{
-       struct ifnet *ifp = &mac->mac_sc->sc_ic.ic_if;
-       int error;
-
-       error = bwi_mac_fw_load_iv(mac, mac->mac_iv);
-       if (error) {
-               if_printf(ifp, "load IV failed\n");
-               return error;
-       }
-
-       if (mac->mac_iv_ext != NULL) {
-               error = bwi_mac_fw_load_iv(mac, mac->mac_iv_ext);
-               if (error)
-                       if_printf(ifp, "load ExtIV failed\n");
-       }
-       return error;
-}
-
-static void
-bwi_mac_opmode_init(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct ieee80211com *ic = &sc->sc_ic;
-       uint32_t mac_status;
-       uint16_t pre_tbtt;
-
-       CSR_CLRBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_INFRA);
-       CSR_SETBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_INFRA);
-       CSR_SETBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_PASS_BCN);
-
-       /* Set probe resp timeout to infinite */
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_PROBE_RESP_TO, 0);
-
-       /*
-        * TODO: factor out following part
-        */
-
-       mac_status = CSR_READ_4(sc, BWI_MAC_STATUS);
-       mac_status &= ~(BWI_MAC_STATUS_OPMODE_HOSTAP |
-                       BWI_MAC_STATUS_PASS_CTL |
-                       BWI_MAC_STATUS_PASS_BADPLCP |
-                       BWI_MAC_STATUS_PASS_BADFCS |
-                       BWI_MAC_STATUS_PROMISC);
-       mac_status |= BWI_MAC_STATUS_INFRA;
-
-       /* Always turn on PROMISC on old hardware */
-       if (mac->mac_rev < 5)
-               mac_status |= BWI_MAC_STATUS_PROMISC;
-
-       switch (ic->ic_opmode) {
-       case IEEE80211_M_IBSS:
-               mac_status &= ~BWI_MAC_STATUS_INFRA;
-               break;
-       case IEEE80211_M_HOSTAP:
-               mac_status |= BWI_MAC_STATUS_OPMODE_HOSTAP;
-               break;
-       case IEEE80211_M_MONITOR:
-#if 0
-               /* Do you want data from your microwave oven? */
-               mac_status |= BWI_MAC_STATUS_PASS_CTL |
-                             BWI_MAC_STATUS_PASS_BADPLCP |
-                             BWI_MAC_STATUS_PASS_BADFCS;
-#else
-               mac_status |= BWI_MAC_STATUS_PASS_CTL;
-#endif
-               /* Promisc? */
-               break;
-       default:
-               break;
-       }
-
-       if (ic->ic_if.if_flags & IFF_PROMISC)
-               mac_status |= BWI_MAC_STATUS_PROMISC;
-
-       CSR_WRITE_4(sc, BWI_MAC_STATUS, mac_status);
-
-       if (ic->ic_opmode != IEEE80211_M_IBSS &&
-           ic->ic_opmode != IEEE80211_M_HOSTAP) {
-               if (sc->sc_bbp_id == BWI_BBPID_BCM4306 && sc->sc_bbp_rev == 3)
-                       pre_tbtt = 100;
-               else
-                       pre_tbtt = 50;
-       } else {
-               pre_tbtt = 2;
-       }
-       CSR_WRITE_2(sc, BWI_MAC_PRE_TBTT, pre_tbtt);
-}
-
-static void
-bwi_mac_hostflags_init(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct bwi_phy *phy = &mac->mac_phy;
-       struct bwi_rf *rf = &mac->mac_rf;
-       uint64_t host_flags;
-
-       if (phy->phy_mode == IEEE80211_MODE_11A)
-               return;
-
-       host_flags = HFLAGS_READ(mac);
-       host_flags |= BWI_HFLAG_SYM_WA;
-
-       if (phy->phy_mode == IEEE80211_MODE_11G) {
-               if (phy->phy_rev == 1)
-                       host_flags |= BWI_HFLAG_GDC_WA;
-               if (sc->sc_card_flags & BWI_CARD_F_PA_GPIO9)
-                       host_flags |= BWI_HFLAG_OFDM_PA;
-       } else if (phy->phy_mode == IEEE80211_MODE_11B) {
-               if (phy->phy_rev >= 2 && rf->rf_type == BWI_RF_T_BCM2050)
-                       host_flags &= ~BWI_HFLAG_GDC_WA;
-       } else {
-               panic("unknown PHY mode %u", phy->phy_mode);
-       }
-
-       HFLAGS_WRITE(mac, host_flags);
-}
-
-static void
-bwi_mac_bss_param_init(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       struct bwi_phy *phy = &mac->mac_phy;
-       struct bwi_retry_lim lim;
-       uint16_t cw_min;
-
-       /*
-        * Set short/long retry limits
-        */
-       bzero(&lim, sizeof(lim));
-       lim.shretry = BWI_SHRETRY;
-       lim.shretry_fb = BWI_SHRETRY_FB;
-       lim.lgretry = BWI_LGRETRY;
-       lim.lgretry_fb = BWI_LGRETRY_FB;
-       bwi_mac_set_retry_lim(mac, &lim);
-
-       /*
-        * Implicitly prevent firmware from sending probe response
-        * by setting its "probe response timeout" to 1us.
-        */
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_PROBE_RESP_TO, 1);
-
-       /*
-        * XXX MAC level acknowledge and CW min/max should depend
-        * on the char rateset of the IBSS/BSS to join.
-        */
-
-       /*
-        * Set MAC level acknowledge rates
-        */
-       bwi_mac_set_ackrates(mac, &sc->sc_ic.ic_sup_rates[phy->phy_mode]);
-
-       /*
-        * Set CW min
-        */
-       if (phy->phy_mode == IEEE80211_MODE_11B)
-               cw_min = IEEE80211_CW_MIN_0;
-       else
-               cw_min = IEEE80211_CW_MIN_1;
-       MOBJ_WRITE_2(mac, BWI_80211_MOBJ, BWI_80211_MOBJ_CWMIN, cw_min);
-
-       /*
-        * Set CW max
-        */
-       MOBJ_WRITE_2(mac, BWI_80211_MOBJ, BWI_80211_MOBJ_CWMAX,
-                    IEEE80211_CW_MAX);
-}
-
-static void
-bwi_mac_set_retry_lim(struct bwi_mac *mac, const struct bwi_retry_lim *lim)
-{
-       /* Short/Long retry limit */
-       MOBJ_WRITE_2(mac, BWI_80211_MOBJ, BWI_80211_MOBJ_SHRETRY,
-                    lim->shretry);
-       MOBJ_WRITE_2(mac, BWI_80211_MOBJ, BWI_80211_MOBJ_LGRETRY,
-                    lim->lgretry);
-
-       /* Short/Long retry fallback limit */
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_SHRETRY_FB,
-                    lim->shretry_fb);
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_LGRETEY_FB,
-                    lim->lgretry_fb);
-}
-
-static void
-bwi_mac_set_ackrates(struct bwi_mac *mac, const struct ieee80211_rateset *rs)
-{
-       int i;
-
-       /* XXX not standard conforming */
-       for (i = 0; i < rs->rs_nrates; ++i) {
-               enum ieee80211_modtype modtype;
-               uint16_t ofs;
-
-               modtype = ieee80211_rate2modtype(rs->rs_rates[i]);
-               switch (modtype) {
-               case IEEE80211_MODTYPE_DS:
-                       ofs = 0x4c0;
-                       break;
-               case IEEE80211_MODTYPE_OFDM:
-                       ofs = 0x480;
-                       break;
-               default:
-                       panic("unsupported modtype %u", modtype);
-               }
-               ofs += (bwi_rate2plcp(rs->rs_rates[i]) & 0xf) * 2;
-
-               MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, ofs + 0x20,
-                            MOBJ_READ_2(mac, BWI_COMM_MOBJ, ofs));
-       }
-}
-
-int
-bwi_mac_start(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-
-       CSR_SETBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_ENABLE);
-       CSR_WRITE_4(sc, BWI_MAC_INTR_STATUS, BWI_INTR_READY);
-
-       /* Flush pending bus writes */
-       CSR_READ_4(sc, BWI_MAC_STATUS);
-       CSR_READ_4(sc, BWI_MAC_INTR_STATUS);
-
-       return bwi_mac_config_ps(mac);
-}
-
-int
-bwi_mac_stop(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       int error, i;
-
-       error = bwi_mac_config_ps(mac);
-       if (error)
-               return error;
-
-       CSR_CLRBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_ENABLE);
-
-       /* Flush pending bus write */
-       CSR_READ_4(sc, BWI_MAC_STATUS);
-
-#define NRETRY 10000
-       for (i = 0; i < NRETRY; ++i) {
-               if (CSR_READ_4(sc, BWI_MAC_INTR_STATUS) & BWI_INTR_READY)
-                       break;
-               DELAY(1);
-       }
-       if (i == NRETRY) {
-               if_printf(&sc->sc_ic.ic_if, "can't stop MAC\n");
-               return ETIMEDOUT;
-       }
-#undef NRETRY
-
-       return 0;
-}
-
-int
-bwi_mac_config_ps(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       uint32_t status;
-
-       status = CSR_READ_4(sc, BWI_MAC_STATUS);
-
-       status &= ~BWI_MAC_STATUS_HW_PS;
-       status |= BWI_MAC_STATUS_WAKEUP;
-       CSR_WRITE_4(sc, BWI_MAC_STATUS, status);
-
-       /* Flush pending bus write */
-       CSR_READ_4(sc, BWI_MAC_STATUS);
-
-       if (mac->mac_rev >= 5) {
-               int i;
-
-#define NRETRY 100
-               for (i = 0; i < NRETRY; ++i) {
-                       if (MOBJ_READ_2(mac, BWI_COMM_MOBJ,
-                           BWI_COMM_MOBJ_UCODE_STATE) != BWI_UCODE_STATE_PS)
-                               break;
-                       DELAY(10);
-               }
-               if (i == NRETRY) {
-                       if_printf(&sc->sc_ic.ic_if, "config PS failed\n");
-                       return ETIMEDOUT;
-               }
-#undef NRETRY
-       }
-       return 0;
-}
-
-void
-bwi_mac_reset_hwkeys(struct bwi_mac *mac)
-{
-       /* TODO: firmware crypto */
-       MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_KEYTABLE_OFS);
-}
-
-void
-bwi_mac_shutdown(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       int i;
-
-       if (mac->mac_flags & BWI_MAC_F_HAS_TXSTATS)
-               sc->sc_free_txstats(sc);
-
-       sc->sc_free_rx_ring(sc);
-
-       for (i = 0; i < BWI_TX_NRING; ++i)
-               sc->sc_free_tx_ring(sc, i);
-
-       bwi_rf_off(mac);
-
-       /* TODO:LED */
-
-       bwi_mac_gpio_fini(mac);
-
-       bwi_rf_off(mac); /* XXX again */
-       CSR_WRITE_2(sc, BWI_BBP_ATTEN, BWI_BBP_ATTEN_MAGIC);
-       bwi_regwin_disable(sc, &mac->mac_regwin, 0);
-
-       mac->mac_flags &= ~BWI_MAC_F_INITED;
-}
-
-static int
-bwi_mac_get_property(struct bwi_mac *mac)
-{
-       struct bwi_softc *sc = mac->mac_sc;
-       enum bwi_bus_space old_bus_space;
-       uint32_t val;
-
-       /*
-        * Byte swap
-        */
-       val = CSR_READ_4(sc, BWI_MAC_STATUS);
-       if (val & BWI_MAC_STATUS_BSWAP) {
-               DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
-                       "need byte swap");
-               mac->mac_flags |= BWI_MAC_F_BSWAP;
-       }
-
-       /*
-        * DMA address space
-        */
-       old_bus_space = sc->sc_bus_space;
-
-       val = CSR_READ_4(sc, BWI_STATE_HI);
-       if (__SHIFTOUT(val, BWI_STATE_HI_FLAGS_MASK) &
-           BWI_STATE_HI_FLAG_64BIT) {
-               /* 64bit address */
-               sc->sc_bus_space = BWI_BUS_SPACE_64BIT;
-               DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
-                       "64bit bus space");
-       } else {
-               uint32_t txrx_reg = BWI_TXRX_CTRL_BASE + BWI_TX32_CTRL;
-
-               CSR_WRITE_4(sc, txrx_reg, BWI_TXRX32_CTRL_ADDRHI_MASK);
-               if (CSR_READ_4(sc, txrx_reg) & BWI_TXRX32_CTRL_ADDRHI_MASK) {
-                       /* 32bit address */
-                       sc->sc_bus_space = BWI_BUS_SPACE_32BIT;
-                       DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
-                               "32bit bus space");
-               } else {
-                       /* 30bit address */
-                       sc->sc_bus_space = BWI_BUS_SPACE_30BIT;
-                       DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
-                               "30bit bus space");
-               }
-       }
-
-       if (old_bus_space != 0 && old_bus_space != sc->sc_bus_space) {
-               device_printf(sc->sc_dev, "MACs bus space mismatch!\n");
-               return ENXIO;
-       }
-       return 0;
-}
-
-void
-bwi_mac_updateslot(struct bwi_mac *mac, int shslot)
-{
-       uint16_t slot_time;
-
-       if (mac->mac_phy.phy_mode == IEEE80211_MODE_11B)
-               return;
-
-       if (shslot)
-               slot_time = IEEE80211_DUR_SHSLOT;
-       else
-               slot_time = IEEE80211_DUR_SLOT;
-
-       CSR_WRITE_2(mac->mac_sc, BWI_MAC_SLOTTIME,
-                   slot_time + BWI_MAC_SLOTTIME_ADJUST);
-       MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_SLOTTIME, slot_time);
-}
-
-int
-bwi_mac_attach(struct bwi_softc *sc, int id, uint8_t rev)
-{
-       struct bwi_mac *mac;
-       int i;
-
-       KKASSERT(sc->sc_nmac <= BWI_MAC_MAX && sc->sc_nmac >= 0);
-
-       if (sc->sc_nmac == BWI_MAC_MAX) {
-               device_printf(sc->sc_dev, "too many MACs\n");
-               return 0;
-       }
-
-       /*
-        * More than one MAC is only supported by BCM4309
-        */
-       if (sc->sc_nmac != 0 &&
-           pci_get_device(sc->sc_dev) != PCI_PRODUCT_BROADCOM_BCM4309) {
-               DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
-                       "ignore second MAC");
-               return 0;
-       }
-
-       mac = &sc->sc_mac[sc->sc_nmac];
-
-       /* XXX will this happen? */
-       if (BWI_REGWIN_EXIST(&mac->mac_regwin)) {
-               device_printf(sc->sc_dev, "%dth MAC already attached\n",
-                             sc->sc_nmac);
-               return 0;
-       }
-
-       /*
-        * Test whether the revision of this MAC is supported
-        */
-       for (i = 0; i < NELEM(bwi_sup_macrev); ++i) {
-               if (bwi_sup_macrev[i] == rev)
-                       break;
-       }
-       if (i == NELEM(bwi_sup_macrev)) {
-               device_printf(sc->sc_dev, "MAC rev %u is "
-                             "not supported\n", rev);
-               return ENXIO;
-       }
-
-       BWI_CREATE_MAC(mac, sc, id, rev);
-       sc->sc_nmac++;
-
-       if (mac->mac_rev < 5) {
-               mac->mac_flags |= BWI_MAC_F_HAS_TXSTATS;
-               DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
-        &