diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 49691f3d3482..962caf8a795e 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -32,7 +32,6 @@ MAN= aac.4 \ audit.4 \ auditpipe.4 \ aue.4 \ - awi.4 \ axe.4 \ bce.4 \ bfe.4 \ @@ -436,7 +435,6 @@ MLINKS+=ata.4 acd.4 \ ata.4 afd.4 \ ata.4 ast.4 MLINKS+=aue.4 if_aue.4 -MLINKS+=awi.4 if_awi.4 MLINKS+=axe.4 if_axe.4 MLINKS+=bce.4 if_bce.4 MLINKS+=bfe.4 if_bfe.4 diff --git a/share/man/man4/altq.4 b/share/man/man4/altq.4 index bc807d347de5..7fd6ec17a89b 100644 --- a/share/man/man4/altq.4 +++ b/share/man/man4/altq.4 @@ -118,7 +118,6 @@ They have been applied to the following hardware drivers: .Xr an 4 , .Xr ath 4 , .Xr aue 4 , -.Xr awi 4 , .Xt axe 4 , .Xr bce 4 , .Xr bfe 4 , diff --git a/share/man/man4/awi.4 b/share/man/man4/awi.4 deleted file mode 100644 index 02fd2164bcb4..000000000000 --- a/share/man/man4/awi.4 +++ /dev/null @@ -1,155 +0,0 @@ -.\" $NetBSD: awi.4,v 1.6 2000/03/22 11:24:33 onoe Exp $ -.\" $FreeBSD$ -.\" -.Dd July 16, 2005 -.Dt AWI 4 -.Os -.Sh NAME -.Nm awi -.Nd "AMD PCnetMobile IEEE 802.11 PCMCIA 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 awi" -.Cd "device wlan" -.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_awi_load="YES" -.Ed -.Sh DESCRIPTION -The -.Nm -driver supports various IEEE 802.11 wireless cards -which run AMD PCnetMobile firmware based on AMD 79c930 controller -with Intersil (formerly Harris) PRISM radio chipset. -It provides access to 32kb of memory shared between the controller -and the host. -All host/device interaction is via this shared memory, which can be -accessed either via PCMCIA memory space or I/O space. -The -.Nm -driver encapsulates all IP and ARP traffic as 802.11 frames. -.Pp -The driver works both in infrastructure mode and in adhoc (independent -BSS) mode. -.Pp -In infrastructure mode, it communicates with an Access Point -which serves as a link-layer bridge between an Ethernet and -the wireless network. -An access point also provides roaming capability -which allows wireless nodes to move between access points. -.Pp -In adhoc mode, it communicates peer to peer. -Though it is more efficient to communicate between wireless nodes, -the coverage is limited spatially due to lack of roaming capability. -.Pp -In addition to these two modes in the IEEE 802.11 specification, the -.Nm -driver also supports a variant of adhoc mode out of spec for DS radio cards, -which makes it possible to communicate with adhoc mode of -.Xr wi 4 -driver. -The NWID does not affect in this mode. -.Pp -For more information on configuring this device, see -.Xr ifconfig 8 . -.Sh HARDWARE -Cards supported by the -.Nm -driver include: -.Pp -.Bl -tag -width BayStack_650x -offset indent -.It BayStack 650 -1Mbps Frequency Hopping PCCARD adapter -.It BayStack 660 -2Mbps Direct Sequence PCCARD adapter -.It Icom SL-200 -2Mbps Direct Sequence PCCARD adapter -.It Melco WLI-PCM -2Mbps Direct Sequence PCCARD adapter -.It NEL SSMagic -2Mbps Direct Sequence PCCARD adapter -.It Netwave AirSurfer Plus -1Mbps Frequency Hopping PCCARD adapter -.It Netwave AirSurfer Pro -2Mbps Direct Sequence PCCARD adapter -.It Nokia C020 WLAN -2Mbps Direct Sequence PCCARD adapter -.It Farallon SkyLINE -2Mbps Direct Sequence PCCARD adapter -.El -.Pp -The original Xircom Netwave AirSurfer is supported by the -.Xr cnw 4 -driver. -.Sh MEDIA SELECTION -The DS cards support -.Em DS1 -and -.Em DS2 -media types, while the FH cards support -.Em FH1 -media type. -For each media type, -.Em adhoc -mediaopt can be used to indicate the driver to operate in adhoc mode. -For DS radio cards, -.Em adhoc , Ns Em flag0 -mediaopt can be used for -.Xr wi 4 -compatible adhoc mode. -In addition to these station modes, -.Em hostap -mediaopt can be used to create a host-based access point. -.Sh DIAGNOSTICS -.Bl -diag -.It "awi0: awi_pccard_probe: bad banner:" -The device failed to initialize its firmware. -.It "awi0: failed to complete selftest (%s)" -The device failed to complete its self test. -In some circumstances, resetting device after power on fails. -Re-inserting the card or down-then-up interface may be helpful. -.It "awi0: transmit timeout" -The device failed to generate an interrupt to acknowledge a -transmitted packet. -.It "awi0: failed to lock interrupt" -The system was unable to obtain the lock to access shared memory. -.It "awi0: command %d failed %x" -The device failed to complete the request from the system. -.El -.Sh SEE ALSO -.Xr altq 4 , -.Xr arp 4 , -.Xr cnw 4 , -.Xr miibus 4 , -.Xr netintro 4 , -.Xr pccard 4 , -.Xr wi 4 , -.Xr wlan 4 , -.Xr ifconfig 8 -.Rs -.%T Am79C930 PCnet Mobile Single-Chip Wireless LAN Media Access Controller -.%O http://www.amd.com -.Re -.Sh HISTORY -The -.Nm -device driver first appeared in -.Nx 1.5 . -.Sh AUTHORS -.An -nosplit -The initial version of the -.Nm -driver was written by -.An Bill Sommerfeld Aq sommerfeld@netbsd.org . -Then the -.Nm -driver module was completely rewritten to support cards with DS phy and -to support adhoc mode by -.An Atsushi Onoe Aq onoe@netbsd.org . diff --git a/share/man/man4/cnw.4 b/share/man/man4/cnw.4 index c15312bf2282..91f5a124c5b4 100644 --- a/share/man/man4/cnw.4 +++ b/share/man/man4/cnw.4 @@ -56,9 +56,6 @@ Note that the driver does not support newer devices such as the Netwave AirSurfer .Dq Plus , or the BayStack 650/660. -These devices are supported by the -.Xr awi 4 -driver. .Pp Netwave devices are not compatible with IEEE 802.11 wireless networks. Also note that there are Netwave devices with different wireless frequency, @@ -106,7 +103,6 @@ and increase memory available to the PC Card controller. .El .Sh SEE ALSO .Xr arp 4 , -.Xr awi 4 , .Xr inet 4 , .Xr intro 4 , .Xr pccard 4 diff --git a/share/man/man4/wlan.4 b/share/man/man4/wlan.4 index 84405922721d..d636395a8ee6 100644 --- a/share/man/man4/wlan.4 +++ b/share/man/man4/wlan.4 @@ -44,7 +44,6 @@ The is required for the .Xr an 4 , .Xr ath 4 , -.Xr awi 4 , .Xr ipw 4 , .Xr iwi 4 , .Xr ral 4 , @@ -123,7 +122,6 @@ was used to be compatible with .Sh SEE ALSO .Xr an 4 , .Xr ath 4 , -.Xr awi 4 , .Xr ipw 4 , .Xr iwi 4 , .Xr netintro 4 , diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index f8db8d8e48cd..8a3566aa489d 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -245,7 +245,6 @@ device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) device ath_rate_sample # SampleRate tx rate control for ath -device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 2fa843698d4b..34564a50e84d 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -707,7 +707,7 @@ device mn # Munich32x/Falc54 Nx64kbit/sec cards. # according to IEEE 802.1Q. It requires `device miibus'. # The `wlan' device provides generic code to support 802.11 # drivers, including host AP mode; it is MANDATORY for the wi, -# ath, and awi drivers and will eventually be required by all 802.11 drivers. +# and ath drivers and will eventually be required by all 802.11 drivers. # The `wlan_wep', `wlan_tkip', and `wlan_ccmp' devices provide # support for WEP, TKIP, and AES-CCMP crypto protocols optionally # used with 802.11 devices that depend on the `wlan' module. @@ -1744,8 +1744,6 @@ device miibus # an: Aironet 4500/4800 802.11 wireless adapters. Supports the PCMCIA, # PCI and ISA varieties. -# awi: Support for IEEE 802.11 PC Card devices using the AMD Am79C930 and -# Harris (Intersil) Chipset with PCnetMobile firmware by AMD. # bce: Broadcom NetXtreme II (BCM5706/BCM5708) PCI/PCIe Gigabit Ethernet # adapters. # bfe: Broadcom BCM4401 Ethernet adapter. @@ -1881,7 +1879,6 @@ hint.sn.0.at="isa" hint.sn.0.port="0x300" hint.sn.0.irq="10" device an -device awi device cnw device wi device xe diff --git a/sys/conf/files b/sys/conf/files index f2f6f1147b01..125d2baccb8b 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -486,9 +486,6 @@ dev/ath/if_ath.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/if_ath_pci.c optional ath pci \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/awi/am79c930.c optional awi -dev/awi/awi.c optional awi -dev/awi/if_awi_pccard.c optional awi pccard dev/bce/if_bce.c optional bce dev/bfe/if_bfe.c optional bfe dev/bge/if_bge.c optional bge diff --git a/sys/dev/awi/am79c930.c b/sys/dev/awi/am79c930.c deleted file mode 100644 index a2eddd4bd768..000000000000 --- a/sys/dev/awi/am79c930.c +++ /dev/null @@ -1,419 +0,0 @@ -/* $NetBSD: am79c930.c,v 1.9 2004/01/15 09:33:48 onoe Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * 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 NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -/* - * Am79c930 chip driver. - * - * This is used by the awi driver to use the shared - * memory attached to the 79c930 to communicate with the firmware running - * in the 930's on-board 80188 core. - * - * The 79c930 can be mapped into just I/O space, or also have a - * memory mapping; the mapping must be set up by the bus front-end - * before am79c930_init is called. - */ - -/* - * operations: - * - * read_8, read_16, read_32, read_64, read_bytes - * write_8, write_16, write_32, write_64, write_bytes - * (two versions, depending on whether memory-space or i/o space is in use). - * - * interrupt E.C. - * start isr - * end isr - */ - -#include -#ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: am79c930.c,v 1.9 2004/01/15 09:33:48 onoe Exp $"); -#endif -#ifdef __FreeBSD__ -__FBSDID("$FreeBSD$"); -#endif - -#include -#include -#include -#ifndef __FreeBSD__ -#include -#endif - -#include -#include -#ifdef __NetBSD__ -#include -#endif - -#ifdef __NetBSD__ -#include -#include -#endif -#ifdef __FreeBSD__ -#include -#include -#endif - -#define AM930_DELAY(x) /*nothing*/ - -void am79c930_regdump(struct am79c930_softc *sc); - -static void io_write_1(struct am79c930_softc *, u_int32_t, u_int8_t); -static void io_write_2(struct am79c930_softc *, u_int32_t, u_int16_t); -static void io_write_4(struct am79c930_softc *, u_int32_t, u_int32_t); -static void io_write_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t); - -static u_int8_t io_read_1(struct am79c930_softc *, u_int32_t); -static u_int16_t io_read_2(struct am79c930_softc *, u_int32_t); -static u_int32_t io_read_4(struct am79c930_softc *, u_int32_t); -static void io_read_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t); - -static void mem_write_1(struct am79c930_softc *, u_int32_t, u_int8_t); -static void mem_write_2(struct am79c930_softc *, u_int32_t, u_int16_t); -static void mem_write_4(struct am79c930_softc *, u_int32_t, u_int32_t); -static void mem_write_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t); - -static u_int8_t mem_read_1(struct am79c930_softc *, u_int32_t); -static u_int16_t mem_read_2(struct am79c930_softc *, u_int32_t); -static u_int32_t mem_read_4(struct am79c930_softc *, u_int32_t); -static void mem_read_bytes(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t); - -static struct am79c930_ops iospace_ops = { - io_write_1, - io_write_2, - io_write_4, - io_write_bytes, - io_read_1, - io_read_2, - io_read_4, - io_read_bytes -}; - -struct am79c930_ops memspace_ops = { - mem_write_1, - mem_write_2, - mem_write_4, - mem_write_bytes, - mem_read_1, - mem_read_2, - mem_read_4, - mem_read_bytes -}; - -static void -io_write_1( struct am79c930_softc *sc, u_int32_t off, u_int8_t val) -{ - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA, val); - AM930_DELAY(1); -} - -static void -io_write_2(struct am79c930_softc *sc, u_int32_t off, u_int16_t val) -{ - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, val & 0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, (val>>8)&0xff); - AM930_DELAY(1); -} - -static void -io_write_4(struct am79c930_softc *sc, u_int32_t off, u_int32_t val) -{ - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,val & 0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>8)&0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>16)&0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>24)&0xff); - AM930_DELAY(1); -} - -static void -io_write_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr, - size_t len) -{ - int i; - - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - for (i=0; isc_iot,sc->sc_ioh,AM79C930_IODPA,ptr[i]); -} - -static u_int8_t -io_read_1(struct am79c930_softc *sc, u_int32_t off) -{ - u_int8_t val; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA); - AM930_DELAY(1); - return val; -} - -static u_int16_t -io_read_2(struct am79c930_softc *sc, u_int32_t off) -{ - u_int16_t val; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA); - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8; - AM930_DELAY(1); - return val; -} - -static u_int32_t -io_read_4(struct am79c930_softc *sc, u_int32_t off) -{ - u_int32_t val; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA); - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8; - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 16; - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 24; - AM930_DELAY(1); - return val; -} - -static void -io_read_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr, - size_t len) -{ - int i; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - for (i=0; isc_iot, sc->sc_ioh, - AM79C930_IODPA); -} - -static void -mem_write_1(struct am79c930_softc *sc, u_int32_t off, u_int8_t val) -{ - bus_space_write_1(sc->sc_memt, sc->sc_memh, off, val); -} - -static -void mem_write_2(struct am79c930_softc *sc, u_int32_t off, u_int16_t val) -{ - bus_space_tag_t t = sc->sc_memt; - bus_space_handle_t h = sc->sc_memh; - - /* could be unaligned */ - if ((off & 0x1) == 0) - bus_space_write_2(t, h, off, htole16(val)); - else { - bus_space_write_1(t, h, off, val & 0xff); - bus_space_write_1(t, h, off+1, (val >> 8) & 0xff); - } -} - -static void -mem_write_4(struct am79c930_softc *sc, u_int32_t off, u_int32_t val) -{ - bus_space_tag_t t = sc->sc_memt; - bus_space_handle_t h = sc->sc_memh; - - /* could be unaligned */ - if ((off & 0x3) == 0) - bus_space_write_4(t, h, off, htole32(val)); - else { - bus_space_write_1(t, h, off, val & 0xff); - bus_space_write_1(t, h, off+1, (val >> 8) & 0xff); - bus_space_write_1(t, h, off+2, (val >> 16) & 0xff); - bus_space_write_1(t, h, off+3, (val >> 24) & 0xff); - } -} - -static void -mem_write_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr, - size_t len) -{ - bus_space_write_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len); -} - -static u_int8_t -mem_read_1(struct am79c930_softc *sc, u_int32_t off) -{ - return bus_space_read_1(sc->sc_memt, sc->sc_memh, off); -} - -static u_int16_t -mem_read_2(struct am79c930_softc *sc, u_int32_t off) -{ - /* could be unaligned */ - if ((off & 0x1) == 0) - return le16toh(bus_space_read_2(sc->sc_memt, sc->sc_memh, off)); - else - return - bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8); -} - -static u_int32_t -mem_read_4(struct am79c930_softc *sc, u_int32_t off) -{ - /* could be unaligned */ - if ((off & 0x3) == 0) - return le32toh(bus_space_read_4(sc->sc_memt, sc->sc_memh, off)); - else - return - bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+2) <<16) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+3) <<24); -} - -static void -mem_read_bytes(struct am79c930_softc *sc, u_int32_t off, u_int8_t *ptr, - size_t len) -{ - bus_space_read_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len); -} - - -/* - * Set bits in GCR. - */ - -void -am79c930_gcr_setbits(struct am79c930_softc *sc, u_int8_t bits) -{ - u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR); - - gcr |= bits; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr); -} - -/* - * Clear bits in GCR. - */ - -void -am79c930_gcr_clearbits(struct am79c930_softc *sc, u_int8_t bits) -{ - u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR); - - gcr &= ~bits; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr); -} - -u_int8_t -am79c930_gcr_read(struct am79c930_softc *sc) -{ - return bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR); -} - -#if 0 -void -am79c930_regdump(struct am79c930_softc *sc) -{ - u_int8_t buf[8]; - int i; - - AM930_DELAY(5); - for (i=0; i<8; i++) { - buf[i] = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, i); - AM930_DELAY(5); - } - printf("am79c930: regdump:"); - for (i=0; i<8; i++) { - printf(" %02x", buf[i]); - } - printf("\n"); -} -#endif - -void -am79c930_chip_init(struct am79c930_softc *sc, int how) -{ - /* zero the bank select register, and leave it that way.. */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_BSS, 0); - if (how) - sc->sc_ops = &memspace_ops; - else - sc->sc_ops = &iospace_ops; -} diff --git a/sys/dev/awi/am79c930reg.h b/sys/dev/awi/am79c930reg.h deleted file mode 100644 index 74d38bf38b37..000000000000 --- a/sys/dev/awi/am79c930reg.h +++ /dev/null @@ -1,126 +0,0 @@ -/* $NetBSD: am79c930reg.h,v 1.4 2003/11/02 11:07:45 wiz Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * 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 NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -/* - * Device register definitions gleaned from from the AMD "Am79C930 - * PCnet(tm)-Mobile Single Chip Wireless LAN Media Access Controller" - * data sheet, AMD Pub #20183, Rev B, amendment/0, issue date August 1997. - * - * As of 1999/10/23, this was available from AMD's web site in PDF - * form. - */ - - -/* - * The 79c930 contains a bus interface unit, a media access - * controller, and a tranceiver attachment interface. - * The MAC contains an 80188 CPU core. - * typical devices built around this chip typically add 32k or 64k of - * memory for buffers. - * - * The 80188 runs firmware which handles most of the 802.11 gorp, and - * communicates with the host using shared data structures in this - * memory; the specifics of the shared memory layout are not covered - * in this source file; see for details of that layer. - */ - -/* - * Device Registers - */ - -#define AM79C930_IO_BASE 0 -#define AM79C930_IO_SIZE 16 -#define AM79C930_IO_SIZE_BIG 40 -#define AM79C930_IO_ALIGN 0x40 /* am79c930 decodes lower 6bits */ - - -#define AM79C930_GCR 0 /* General Config Register */ - -#define AM79C930_GCR_SWRESET 0x80 /* software reset */ -#define AM79C930_GCR_CORESET 0x40 /* core reset */ -#define AM79C930_GCR_DISPWDN 0x20 /* disable powerdown */ -#define AM79C930_GCR_ECWAIT 0x10 /* embedded controller wait */ -#define AM79C930_GCR_ECINT 0x08 /* interrupt from embedded ctrlr */ -#define AM79C930_GCR_INT2EC 0x04 /* interrupt to embedded ctrlr */ -#define AM79C930_GCR_ENECINT 0x02 /* enable interrupts from e.c. */ -#define AM79C930_GCR_DAM 0x01 /* direct access mode (read only) */ - -#define AM79C930_GCR_BITS "\020\1DAM\2ENECINT\3INT2EC\4ECINT\5ECWAIT\6DISPWDN\7CORESET\010SWRESET" - -#define AM79C930_BSS 1 /* Bank Switching Select register */ - -#define AM79C930_BSS_ECATR 0x80 /* E.C. ALE test read */ -#define AM79C930_BSS_FS 0x20 /* Flash Select */ -#define AM79C930_BSS_MBS 0x18 /* Memory Bank Select */ -#define AM79C930_BSS_EIOW 0x04 /* Expand I/O Window */ -#define AM79C930_BSS_TBS 0x03 /* TAI Bank Select */ - -#define AM79C930_LMA_LO 2 /* Local Memory Address register (low byte) */ - -#define AM79C930_LMA_HI 3 /* Local Memory Address register (high byte) */ - - /* set this bit to turn off ISAPnP version */ -#define AM79C930_LMA_HI_ISAPWRDWN 0x80 - -/* - * mmm, inconsistency in chip documentation: - * According to page 79--80, all four of the following are equivalent - * and address the single byte pointed at by BSS_{FS,MBS} | LMA_{HI,LO} - * According to tables on p63 and p67, they're the LSB through MSB - * of a 32-bit word. - */ - -#define AM79C930_IODPA 4 /* I/O Data port A */ -#define AM79C930_IODPB 5 /* I/O Data port B */ -#define AM79C930_IODPC 6 /* I/O Data port C */ -#define AM79C930_IODPD 7 /* I/O Data port D */ - - -/* - * Tranceiver Attachment Interface Registers (TIR space) - * (omitted for now, since host access to them is for diagnostic - * purposes only). - */ - -/* - * memory space goo. - */ - -#define AM79C930_MEM_SIZE 0x8000 /* 32k */ -#define AM79C930_MEM_BASE 0x0 /* starting at 0 */ diff --git a/sys/dev/awi/am79c930var.h b/sys/dev/awi/am79c930var.h deleted file mode 100644 index 3836521f1e29..000000000000 --- a/sys/dev/awi/am79c930var.h +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: am79c930var.h,v 1.3 2004/01/15 09:33:48 onoe Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * 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 NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -#define AM79C930_BUS_PCMCIA 1 -#define AM79C930_BUS_ISAPNP 2 /* not implemented */ - -struct am79c930_softc -{ - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; - - bus_space_tag_t sc_memt; - bus_space_handle_t sc_memh; - - struct am79c930_ops *sc_ops; - - int sc_bustype; -}; - -struct am79c930_ops -{ - void (*write_1)(struct am79c930_softc *, u_int32_t, u_int8_t); - void (*write_2)(struct am79c930_softc *, u_int32_t, u_int16_t); - void (*write_4)(struct am79c930_softc *, u_int32_t, u_int32_t); - void (*write_bytes)(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t); - - u_int8_t (*read_1)(struct am79c930_softc *, u_int32_t); - u_int16_t (*read_2)(struct am79c930_softc *, u_int32_t); - u_int32_t (*read_4)(struct am79c930_softc *, u_int32_t); - void (*read_bytes)(struct am79c930_softc *, u_int32_t, u_int8_t *, size_t); -}; - -void am79c930_chip_init(struct am79c930_softc *sc, int); - -void am79c930_gcr_setbits(struct am79c930_softc *sc, u_int8_t bits); -void am79c930_gcr_clearbits(struct am79c930_softc *sc, u_int8_t bits); - -u_int8_t am79c930_gcr_read(struct am79c930_softc *sc); - -#define am79c930_hard_reset(sc) am79c930_gcr_setbits(sc, AM79C930_GCR_CORESET) -#define am79c930_hard_reset_off(sc) am79c930_gcr_clearbits(sc, AM79C930_GCR_CORESET) - - diff --git a/sys/dev/awi/awi.c b/sys/dev/awi/awi.c deleted file mode 100644 index 954a83175db2..000000000000 --- a/sys/dev/awi/awi.c +++ /dev/null @@ -1,2219 +0,0 @@ -/* $NetBSD: awi.c,v 1.62 2004/01/16 14:13:15 onoe Exp $ */ - -/*- - * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * 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 NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ -/* - * Driver for AMD 802.11 firmware. - * Uses am79c930 chip driver to talk to firmware running on the am79c930. - * - * More-or-less a generic ethernet-like if driver, with 802.11 gorp added. - */ - -/* - * todo: - * - flush tx queue on resynch. - * - clear oactive on "down". - * - rewrite copy-into-mbuf code - * - mgmt state machine gets stuck retransmitting assoc requests. - * - multicast filter. - * - fix device reset so it's more likely to work - * - show status goo through ifmedia. - * - * more todo: - * - deal with more 802.11 frames. - * - send reassoc request - * - deal with reassoc response - * - send/deal with disassociation - * - deal with "full" access points (no room for me). - * - power save mode - * - * later: - * - SSID preferences - * - need ioctls for poking at the MIBs - * - implement ad-hoc mode (including bss creation). - * - decide when to do "ad hoc" vs. infrastructure mode (IFF_LINK flags?) - * (focus on inf. mode since that will be needed for ietf) - * - deal with DH vs. FH versions of the card - * - deal with faster cards (2mb/s) - * - ?WEP goo (mmm, rc4) (it looks not particularly useful). - * - ifmedia revision. - * - common 802.11 mibish things. - * - common 802.11 media layer. - */ - -/* - * Driver for AMD 802.11 PCnetMobile firmware. - * Uses am79c930 chip driver to talk to firmware running on the am79c930. - * - * The initial version of the driver was written by - * Bill Sommerfeld . - * Then the driver module completely rewritten to support cards with DS phy - * and to support adhoc mode by Atsushi Onoe - */ - -#include -#ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.62 2004/01/16 14:13:15 onoe Exp $"); -#endif -#ifdef __FreeBSD__ -__FBSDID("$FreeBSD$"); -#endif - -#include "opt_inet.h" -#ifdef __NetBSD__ -#include "bpfilter.h" -#endif -#ifdef __FreeBSD__ -#define NBPFILTER 1 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __FreeBSD__ -#include -#endif -#ifdef __NetBSD__ -#include -#endif - -#include -#include -#ifdef __NetBSD__ -#include -#endif -#ifdef __FreeBSD__ -#include -#include -#endif -#include -#include - -#include -#ifdef __NetBSD__ -#include -#endif - -#if NBPFILTER > 0 -#include -#endif - -#include -#include - -#ifdef __NetBSD__ -#include -#include -#include -#include -#endif -#ifdef __FreeBSD__ -#include -#include -#include -#include -#endif - -#ifdef __FreeBSD__ -static void awi_init0(void *); -#endif -static int awi_init(struct ifnet *); -static void awi_stop(struct ifnet *, int); -static void awi_start(struct ifnet *); -static void awi_watchdog(struct ifnet *); -static int awi_ioctl(struct ifnet *, u_long, caddr_t); -static int awi_media_change(struct ifnet *); -static void awi_media_status(struct ifnet *, struct ifmediareq *); -static int awi_mode_init(struct awi_softc *); -static void awi_rx_int(struct awi_softc *); -static void awi_tx_int(struct awi_softc *); -static struct mbuf *awi_devget(struct awi_softc *, u_int32_t, u_int16_t); -static int awi_hw_init(struct awi_softc *); -static int awi_init_mibs(struct awi_softc *); -static int awi_mib(struct awi_softc *, u_int8_t, u_int8_t, int); -static int awi_cmd(struct awi_softc *, u_int8_t, int); -static int awi_cmd_wait(struct awi_softc *); -static void awi_cmd_done(struct awi_softc *); -static int awi_next_txd(struct awi_softc *, int, u_int32_t *, u_int32_t *); -static int awi_lock(struct awi_softc *); -static void awi_unlock(struct awi_softc *); -static int awi_intr_lock(struct awi_softc *); -static void awi_intr_unlock(struct awi_softc *); -static int awi_newstate(struct ieee80211com *, enum ieee80211_state, int); -static void awi_recv_mgmt(struct ieee80211com *, struct mbuf *, - struct ieee80211_node *, int, int, int, u_int32_t); -static int awi_send_mgmt(struct ieee80211com *, struct ieee80211_node *, int, - int); -static struct mbuf *awi_ether_encap(struct awi_softc *, struct mbuf *); -static struct mbuf *awi_ether_modcap(struct awi_softc *, struct mbuf *); - -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8)) -#define LE_READ_4(p) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \ - (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24)) -#define LE_WRITE_2(p, v) \ - ((((u_int8_t *)(p))[0] = (((u_int32_t)(v) ) & 0xff)), \ - (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff))) -#define LE_WRITE_4(p, v) \ - ((((u_int8_t *)(p))[0] = (((u_int32_t)(v) ) & 0xff)), \ - (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)), \ - (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)), \ - (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff))) - -struct awi_chanset awi_chanset[] = { - /* PHY type domain min max def */ - { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_JP, 6, 17, 6 }, - { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_ES, 0, 26, 1 }, - { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_FR, 0, 32, 1 }, - { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_US, 0, 77, 1 }, - { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_CA, 0, 77, 1 }, - { AWI_PHY_TYPE_FH, AWI_REG_DOMAIN_EU, 0, 77, 1 }, - { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_JP, 14, 14, 14 }, - { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_ES, 10, 11, 10 }, - { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_FR, 10, 13, 10 }, - { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_US, 1, 11, 3 }, - { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_CA, 1, 11, 3 }, - { AWI_PHY_TYPE_DS, AWI_REG_DOMAIN_EU, 1, 13, 3 }, - { 0, 0 } -}; - -#ifdef __FreeBSD__ -devclass_t awi_devclass; - -#if __FreeBSD_version < 500043 -static char *ether_sprintf(u_int8_t *); - -static char * -ether_sprintf(u_int8_t *enaddr) -{ - static char strbuf[18]; - - sprintf(strbuf, "%6D", enaddr, ":"); - return strbuf; -} -#endif - -#if 0 /* ALTQ */ -#define IFQ_PURGE(ifq) IF_DRAIN(ifq) -#define IF_POLL(ifq, m) ((m) = (ifq)->ifq_head) -#define IFQ_POLL(ifq, m) IF_POLL((ifq), (m)) -#define IFQ_DEQUEUE(ifq, m) IF_DEQUEUE((ifq), (m)) -#endif - -#endif - -#ifdef AWI_DEBUG -int awi_debug = 0; - -#define DPRINTF(X) if (awi_debug) printf X -#define DPRINTF2(X) if (awi_debug > 1) printf X -#else -#define DPRINTF(X) -#define DPRINTF2(X) -#endif - -int -awi_attach(struct awi_softc *sc) -{ - struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - int s, i, error, nrate; - int mword; - enum ieee80211_phymode mode; - - s = splnet(); - sc->sc_busy = 1; - sc->sc_attached = 0; - sc->sc_substate = AWI_ST_NONE; - if ((error = awi_hw_init(sc)) != 0) { - sc->sc_invalid = 1; - splx(s); - return error; - } - error = awi_init_mibs(sc); - if (error != 0) { - sc->sc_invalid = 1; - splx(s); - return error; - } - ifp->if_softc = sc; - ifp->if_flags = -#ifdef IFF_NOTRAILERS - IFF_NOTRAILERS | -#endif - IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST | IFF_NEEDSGIANT; - ifp->if_ioctl = awi_ioctl; - ifp->if_start = awi_start; - ifp->if_watchdog = awi_watchdog; -#ifdef __NetBSD__ - ifp->if_init = awi_init; - ifp->if_stop = awi_stop; - IFQ_SET_READY(&ifp->if_snd); - memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ); -#endif -#ifdef __FreeBSD__ - ifp->if_init = awi_init0; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - if_initname(ifp, device_get_name(sc->sc_dev), - device_get_unit(sc->sc_dev)); -#endif - - ic->ic_ifp = ifp; - ic->ic_caps = IEEE80211_C_WEP | IEEE80211_C_IBSS | IEEE80211_C_HOSTAP; - if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) { - ic->ic_phytype = IEEE80211_T_FH; - mode = IEEE80211_MODE_FH; - } else { - ic->ic_phytype = IEEE80211_T_DS; - ic->ic_caps |= IEEE80211_C_AHDEMO; - mode = IEEE80211_MODE_11B; - } - ic->ic_opmode = IEEE80211_M_STA; - nrate = sc->sc_mib_phy.aSuprt_Data_Rates[1]; - memcpy(ic->ic_sup_rates[mode].rs_rates, - sc->sc_mib_phy.aSuprt_Data_Rates + 2, nrate); - ic->ic_sup_rates[mode].rs_nrates = nrate; - IEEE80211_ADDR_COPY(ic->ic_myaddr, sc->sc_mib_addr.aMAC_Address); - - printf("%s: IEEE802.11 %s (firmware %s)\n", ifp->if_xname, - (ic->ic_phytype == IEEE80211_T_FH) ? "FH" : "DS", sc->sc_banner); - -#ifdef __NetBSD__ - if_attach(ifp); -#endif - ieee80211_ifattach(ic); - - sc->sc_newstate = ic->ic_newstate; - ic->ic_newstate = awi_newstate; - - sc->sc_recv_mgmt = ic->ic_recv_mgmt; - ic->ic_recv_mgmt = awi_recv_mgmt; - - sc->sc_send_mgmt = ic->ic_send_mgmt; - ic->ic_send_mgmt = awi_send_mgmt; - - ieee80211_media_init(ic, awi_media_change, awi_media_status); - - /* Melco compatibility mode. */ -#define ADD(s, o) ifmedia_add(&ic->ic_media, \ - IFM_MAKEWORD(IFM_IEEE80211, (s), (o), 0), 0, NULL) - ADD(IFM_AUTO, IFM_FLAG0); - - for (i = 0; i < nrate; i++) { - mword = ieee80211_rate2media(ic, - ic->ic_sup_rates[mode].rs_rates[i], mode); - if (mword == 0) - continue; - ADD(mword, IFM_FLAG0); - } -#undef ADD - -#ifdef __NetBSD__ - if ((sc->sc_sdhook = shutdownhook_establish(awi_shutdown, sc)) == NULL) - printf("%s: WARNING: unable to establish shutdown hook\n", - ifp->if_xname); - if ((sc->sc_powerhook = powerhook_establish(awi_power, sc)) == NULL) - printf("%s: WARNING: unable to establish power hook\n", - ifp->if_xname); -#endif - sc->sc_attached = 1; - splx(s); - - /* ready to accept ioctl */ - awi_unlock(sc); - - ieee80211_announce(ic); - - return 0; -} - -int -awi_detach(struct awi_softc *sc) -{ - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - int s; - - if (!sc->sc_attached) - return 0; - - s = splnet(); - sc->sc_invalid = 1; - awi_stop(ifp, 1); - - while (sc->sc_sleep_cnt > 0) { - wakeup(sc); - (void)tsleep(sc, PWAIT, "awidet", 1); - } - sc->sc_attached = 0; - ieee80211_ifdetach(&sc->sc_ic); -#ifdef __NetBSD__ - if_detach(ifp); - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_powerhook); -#endif - splx(s); - return 0; -} - -#ifdef __NetBSD__ -int -awi_activate(struct device *self, enum devact act) -{ - struct awi_softc *sc = (struct awi_softc *)self; - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - int s, error = 0; - - s = splnet(); - switch (act) { - case DVACT_ACTIVATE: - error = EOPNOTSUPP; - break; - case DVACT_DEACTIVATE: - sc->sc_invalid = 1; - if_deactivate(ifp); - break; - } - splx(s); - return error; -} - -void -awi_power(int why, void *arg) -{ - struct awi_softc *sc = arg; - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - int s; - int ocansleep; - - DPRINTF(("awi_power: %d\n", why)); - s = splnet(); - ocansleep = sc->sc_cansleep; - sc->sc_cansleep = 0; - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - awi_stop(ifp, 1); - break; - case PWR_RESUME: - if (ifp->if_flags & IFF_UP) { - awi_init(ifp); - (void)awi_intr(sc); /* make sure */ - } - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - sc->sc_cansleep = ocansleep; - splx(s); -} -#endif /* __NetBSD__ */ - -void -awi_shutdown(void *arg) -{ - struct awi_softc *sc = arg; - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - - if (sc->sc_attached) - awi_stop(ifp, 1); -} - -int -awi_intr(void *arg) -{ - struct awi_softc *sc = arg; - u_int16_t status; - int handled = 0, ocansleep; -#ifdef AWI_DEBUG - static const char *intname[] = { - "CMD", "RX", "TX", "SCAN_CMPLT", - "CFP_START", "DTIM", "CFP_ENDING", "GROGGY", - "TXDATA", "TXBCAST", "TXPS", "TXCF", - "TXMGT", "#13", "RXDATA", "RXMGT" - }; -#endif - - if (!sc->sc_enabled || !sc->sc_enab_intr || sc->sc_invalid) { - DPRINTF(("awi_intr: stray interrupt: " - "enabled %d enab_intr %d invalid %d\n", - sc->sc_enabled, sc->sc_enab_intr, sc->sc_invalid)); - return 0; - } - - am79c930_gcr_setbits(&sc->sc_chip, - AM79C930_GCR_DISPWDN | AM79C930_GCR_ECINT); - awi_write_1(sc, AWI_DIS_PWRDN, 1); - ocansleep = sc->sc_cansleep; - sc->sc_cansleep = 0; - - for (;;) { - if (awi_intr_lock(sc) != 0) - break; - status = awi_read_1(sc, AWI_INTSTAT); - awi_write_1(sc, AWI_INTSTAT, 0); - awi_write_1(sc, AWI_INTSTAT, 0); - status |= awi_read_1(sc, AWI_INTSTAT2) << 8; - awi_write_1(sc, AWI_INTSTAT2, 0); - DELAY(10); - awi_intr_unlock(sc); - if (!sc->sc_cmd_inprog) - status &= ~AWI_INT_CMD; /* make sure */ - if (status == 0) - break; -#ifdef AWI_DEBUG - if (awi_debug > 1) { - int i; - - printf("awi_intr: status 0x%04x", status); - for (i = 0; i < sizeof(intname)/sizeof(intname[0]); - i++) { - if (status & (1 << i)) - printf(" %s", intname[i]); - } - printf("\n"); - } -#endif - handled = 1; - if (status & AWI_INT_RX) - awi_rx_int(sc); - if (status & AWI_INT_TX) - awi_tx_int(sc); - if (status & AWI_INT_CMD) - awi_cmd_done(sc); - if (status & AWI_INT_SCAN_CMPLT) { - /* XXX revisit scanning */ - if (sc->sc_ic.ic_state == IEEE80211_S_SCAN && - sc->sc_substate == AWI_ST_NONE) - ; - } - } - sc->sc_cansleep = ocansleep; - am79c930_gcr_clearbits(&sc->sc_chip, AM79C930_GCR_DISPWDN); - awi_write_1(sc, AWI_DIS_PWRDN, 0); - return handled; -} - -#ifdef __FreeBSD__ -static void -awi_init0(void *arg) -{ - struct awi_softc *sc = arg; - - (void)awi_init(AC2IFP(&sc->sc_arp)); -} -#endif - -static int -awi_init(struct ifnet *ifp) -{ - struct awi_softc *sc = ifp->if_softc; - struct ieee80211com *ic = &sc->sc_ic; - struct ieee80211_node *ni = ic->ic_bss; - struct ieee80211_rateset *rs; - int error, rate, i; - - DPRINTF(("awi_init: enabled=%d\n", sc->sc_enabled)); - if (sc->sc_enabled) { - awi_stop(ifp, 0); - } else { - if (sc->sc_enable) - (*sc->sc_enable)(sc); - sc->sc_enabled = 1; - if ((error = awi_hw_init(sc)) != 0) { - if (sc->sc_disable) - (*sc->sc_disable)(sc); - sc->sc_enabled = 0; - return error; - } - } - ic->ic_state = IEEE80211_S_INIT; - - ic->ic_flags &= ~IEEE80211_F_IBSSON; - switch (ic->ic_opmode) { - case IEEE80211_M_STA: - sc->sc_mib_local.Network_Mode = 1; - sc->sc_mib_local.Acting_as_AP = 0; - break; - case IEEE80211_M_IBSS: - ic->ic_flags |= IEEE80211_F_IBSSON; - /* FALLTHRU */ - case IEEE80211_M_AHDEMO: - sc->sc_mib_local.Network_Mode = 0; - sc->sc_mib_local.Acting_as_AP = 0; - break; - case IEEE80211_M_HOSTAP: - sc->sc_mib_local.Network_Mode = 1; - sc->sc_mib_local.Acting_as_AP = 1; - break; - case IEEE80211_M_MONITOR: - case IEEE80211_M_WDS: - return ENODEV; - } -#if 0 - IEEE80211_ADDR_COPY(ic->ic_myaddr, LLADDR(ifp->if_sadl)); -#endif - memset(&sc->sc_mib_mac.aDesired_ESS_ID, 0, AWI_ESS_ID_SIZE); - sc->sc_mib_mac.aDesired_ESS_ID[0] = IEEE80211_ELEMID_SSID; - sc->sc_mib_mac.aDesired_ESS_ID[1] = ic->ic_des_ssid[0].len; - memcpy(&sc->sc_mib_mac.aDesired_ESS_ID[2], ic->ic_des_ssid[0].ssid, - ic->ic_des_ssid[0].len); - - /* configure basic rate */ - if (ic->ic_phytype == IEEE80211_T_FH) - rs = &ic->ic_sup_rates[IEEE80211_MODE_FH]; - else - rs = &ic->ic_sup_rates[IEEE80211_MODE_11B]; - if (ic->ic_fixed_rate != IEEE80211_FIXED_RATE_NONE) { - rate = ic->ic_fixed_rate; - } else { - rate = 0; - for (i = 0; i < rs->rs_nrates; i++) { - if ((rs->rs_rates[i] & IEEE80211_RATE_BASIC) && - rate < (rs->rs_rates[i] & IEEE80211_RATE_VAL)) - rate = rs->rs_rates[i] & IEEE80211_RATE_VAL; - } - } - rate *= 5; - LE_WRITE_2(&sc->sc_mib_mac.aStation_Basic_Rate, rate); - - if ((error = awi_mode_init(sc)) != 0) { - DPRINTF(("awi_init: awi_mode_init failed %d\n", error)); - awi_stop(ifp, 1); - return error; - } - - /* start transmitter */ - sc->sc_txdone = sc->sc_txnext = sc->sc_txbase; - awi_write_4(sc, sc->sc_txbase + AWI_TXD_START, 0); - awi_write_4(sc, sc->sc_txbase + AWI_TXD_NEXT, 0); - awi_write_4(sc, sc->sc_txbase + AWI_TXD_LENGTH, 0); - awi_write_1(sc, sc->sc_txbase + AWI_TXD_RATE, 0); - awi_write_4(sc, sc->sc_txbase + AWI_TXD_NDA, 0); - awi_write_4(sc, sc->sc_txbase + AWI_TXD_NRA, 0); - awi_write_1(sc, sc->sc_txbase + AWI_TXD_STATE, 0); - awi_write_4(sc, AWI_CA_TX_DATA, sc->sc_txbase); - awi_write_4(sc, AWI_CA_TX_MGT, 0); - awi_write_4(sc, AWI_CA_TX_BCAST, 0); - awi_write_4(sc, AWI_CA_TX_PS, 0); - awi_write_4(sc, AWI_CA_TX_CF, 0); - if ((error = awi_cmd(sc, AWI_CMD_INIT_TX, AWI_WAIT)) != 0) { - DPRINTF(("awi_init: failed to start transmitter: %d\n", error)); - awi_stop(ifp, 1); - return error; - } - - /* start receiver */ - if ((error = awi_cmd(sc, AWI_CMD_INIT_RX, AWI_WAIT)) != 0) { - DPRINTF(("awi_init: failed to start receiver: %d\n", error)); - awi_stop(ifp, 1); - return error; - } - sc->sc_rxdoff = awi_read_4(sc, AWI_CA_IRX_DATA_DESC); - sc->sc_rxmoff = awi_read_4(sc, AWI_CA_IRX_PS_DESC); - - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - ic->ic_state = IEEE80211_S_INIT; - - if (ic->ic_opmode == IEEE80211_M_AHDEMO || - ic->ic_opmode == IEEE80211_M_HOSTAP) { - ni->ni_chan = ic->ic_des_chan; /* XXX? */ - ni->ni_intval = ic->ic_bintval; - ni->ni_rssi = 0; - ni->ni_rstamp = 0; - memset(&ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); - ni->ni_rates = - ic->ic_sup_rates[ieee80211_chan2mode(ni->ni_chan)]; - IEEE80211_ADDR_COPY(ni->ni_macaddr, ic->ic_myaddr); - if (ic->ic_opmode == IEEE80211_M_HOSTAP) { - IEEE80211_ADDR_COPY(ni->ni_bssid, ic->ic_myaddr); - ni->ni_esslen = ic->ic_des_ssid[0].len; - memcpy(ni->ni_essid, ic->ic_des_ssid[0].ssid, ni->ni_esslen); - ni->ni_capinfo = IEEE80211_CAPINFO_ESS; - if (ic->ic_phytype == IEEE80211_T_FH) { - ni->ni_fhdwell = 200; /* XXX */ - ni->ni_fhindex = 1; - } - } else { - ni->ni_capinfo = IEEE80211_CAPINFO_IBSS; - memset(ni->ni_bssid, 0, IEEE80211_ADDR_LEN); - ni->ni_esslen = 0; - } - if (ic->ic_flags & IEEE80211_F_PRIVACY) - ni->ni_capinfo |= IEEE80211_CAPINFO_PRIVACY; - if (ic->ic_opmode != IEEE80211_M_AHDEMO) - ic->ic_flags |= IEEE80211_F_SIBSS; - ic->ic_state = IEEE80211_S_SCAN; /*XXX*/ - sc->sc_substate = AWI_ST_NONE; - ieee80211_new_state(ic, IEEE80211_S_RUN, -1); - } else { - /* XXX check sc->sc_cur_chan */ - ni->ni_chan = &ic->ic_channels[sc->sc_cur_chan]; - ic->ic_curchan = ni->ni_chan; - ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); - } - return 0; -} - -static void -awi_stop(struct ifnet *ifp, int disable) -{ - struct awi_softc *sc = ifp->if_softc; - - if (!sc->sc_enabled) - return; - - DPRINTF(("awi_stop(%d)\n", disable)); - - ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1); - - if (!sc->sc_invalid) { - if (sc->sc_cmd_inprog) - (void)awi_cmd_wait(sc); - (void)awi_cmd(sc, AWI_CMD_KILL_RX, AWI_WAIT); - sc->sc_cmd_inprog = AWI_CMD_FLUSH_TX; - awi_write_1(sc, AWI_CA_FTX_DATA, 1); - awi_write_1(sc, AWI_CA_FTX_MGT, 0); - awi_write_1(sc, AWI_CA_FTX_BCAST, 0); - awi_write_1(sc, AWI_CA_FTX_PS, 0); - awi_write_1(sc, AWI_CA_FTX_CF, 0); - (void)awi_cmd(sc, AWI_CMD_FLUSH_TX, AWI_WAIT); - } - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING|IFF_DRV_OACTIVE); - ifp->if_timer = 0; - sc->sc_tx_timer = sc->sc_rx_timer = 0; - if (sc->sc_rxpend != NULL) { - m_freem(sc->sc_rxpend); - sc->sc_rxpend = NULL; - } - IFQ_PURGE(&ifp->if_snd); - - if (disable) { - if (!sc->sc_invalid) - am79c930_gcr_setbits(&sc->sc_chip, - AM79C930_GCR_CORESET); - if (sc->sc_disable) - (*sc->sc_disable)(sc); - sc->sc_enabled = 0; - } -} - -static void -awi_start(struct ifnet *ifp) -{ - struct awi_softc *sc = ifp->if_softc; - struct ieee80211com *ic = &sc->sc_ic; - struct ieee80211_node *ni; - struct ieee80211_frame *wh; - struct ether_header *eh; - struct mbuf *m, *m0; - int len, dowep; - u_int32_t txd, frame, ntxd; - u_int8_t rate; - - if (!sc->sc_enabled || sc->sc_invalid) - return; - - for (;;) { - txd = sc->sc_txnext; - IF_POLL(&ic->ic_mgtq, m0); - dowep = 0; - ni = NULL; - if (m0 != NULL) { - len = m0->m_pkthdr.len; - if (awi_next_txd(sc, len, &frame, &ntxd)) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - break; - } - IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *) m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; - } else { - if (ic->ic_state != IEEE80211_S_RUN) - break; - IFQ_POLL(&ifp->if_snd, m0); - if (m0 == NULL) - break; - /* - * Need to calculate the real length to determine - * if the transmit buffer has a room for the packet. - */ - len = m0->m_pkthdr.len + sizeof(struct ieee80211_frame); - if (!(ifp->if_flags & IFF_LINK0) && !sc->sc_adhoc_ap) - len += sizeof(struct llc) - - sizeof(struct ether_header); - if (ic->ic_flags & IEEE80211_F_PRIVACY) { - /* XXX other crypto */ - dowep = 1; - len += IEEE80211_WEP_IVLEN + - IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN; - } - if (awi_next_txd(sc, len, &frame, &ntxd)) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - break; - } - IFQ_DEQUEUE(&ifp->if_snd, m0); -#if NBPFILTER > 0 - BPF_MTAP(ifp, m0); -#endif - if ((ifp->if_flags & IFF_LINK0) || sc->sc_adhoc_ap) - m0 = awi_ether_encap(sc, m0); - else { - if (m0->m_len < sizeof(struct ether_header) && - ((m0 = m_pullup(m0, sizeof(struct ether_header)))) == NULL) { - ifp->if_oerrors++; - continue; - } - eh = mtod(m0, struct ether_header *); - ni = ieee80211_find_txnode(ic, eh->ether_dhost); - if (ni == NULL) - goto bad; - if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && - (m0->m_flags & M_PWR_SAV) == 0) { - ieee80211_pwrsave(ni, m0); - continue; - } - m0 = ieee80211_encap(ic, m0, ni); - } - if (m0 == NULL) - goto bad; - wh = mtod(m0, struct ieee80211_frame *); - if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && - (ic->ic_opmode == IEEE80211_M_HOSTAP || - ic->ic_opmode == IEEE80211_M_IBSS) && - sc->sc_adhoc_ap == 0 && - (ifp->if_flags & IFF_LINK0) == 0 && - (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == - IEEE80211_FC0_TYPE_DATA && ni == NULL) { - bad: - if (m0 != NULL) - m_freem(m0); - ifp->if_oerrors++; - if (ni != NULL) - ieee80211_free_node(ni); - continue; - } - ifp->if_opackets++; - } -#if NBPFILTER > 0 - if (bpf_peers_present(ic->ic_rawbpf)) - bpf_mtap(ic->ic_rawbpf, m0); -#endif - if (dowep) { - struct ieee80211_key *k; - - k = ieee80211_crypto_encap(ic, ni, m0); - if (k == NULL) { - if (ni != NULL) - ieee80211_free_node(ni); - m_freem(m0); - continue; - } - } -#ifdef DIAGNOSTIC - if (m0->m_pkthdr.len != len) { - if_printf(ifp, "length %d should be %d\n", - m0->m_pkthdr.len, len); - m_freem(m0); - ifp->if_oerrors++; - if (ni != NULL) - ieee80211_free_node(ni); - continue; - } -#endif - - if ((ifp->if_flags & IFF_DEBUG) && (ifp->if_flags & IFF_LINK2)) - ieee80211_dump_pkt(ic, m0->m_data, m0->m_len, - ic->ic_bss->ni_rates. - rs_rates[ic->ic_bss->ni_txrate] & - IEEE80211_RATE_VAL, -1); - - for (m = m0, len = 0; m != NULL; m = m->m_next) { - awi_write_bytes(sc, frame + len, mtod(m, u_int8_t *), - m->m_len); - len += m->m_len; - } - m_freem(m0); - rate = (ic->ic_bss->ni_rates.rs_rates[ic->ic_bss->ni_txrate] & - IEEE80211_RATE_VAL) * 5; - awi_write_1(sc, ntxd + AWI_TXD_STATE, 0); - awi_write_4(sc, txd + AWI_TXD_START, frame); - awi_write_4(sc, txd + AWI_TXD_NEXT, ntxd); - awi_write_4(sc, txd + AWI_TXD_LENGTH, len); - awi_write_1(sc, txd + AWI_TXD_RATE, rate); - awi_write_4(sc, txd + AWI_TXD_NDA, 0); - awi_write_4(sc, txd + AWI_TXD_NRA, 0); - awi_write_1(sc, txd + AWI_TXD_STATE, AWI_TXD_ST_OWN); - sc->sc_txnext = ntxd; - - sc->sc_tx_timer = 5; - ifp->if_timer = 1; - } -} - -static void -awi_watchdog(struct ifnet *ifp) -{ - struct awi_softc *sc = ifp->if_softc; - u_int32_t prevdone; - int ocansleep; - - ifp->if_timer = 0; - if (!sc->sc_enabled || sc->sc_invalid) - return; - - ocansleep = sc->sc_cansleep; - sc->sc_cansleep = 0; - if (sc->sc_tx_timer) { - if (--sc->sc_tx_timer == 0) { - printf("%s: device timeout\n", ifp->if_xname); - prevdone = sc->sc_txdone; - awi_tx_int(sc); - if (sc->sc_txdone == prevdone) { - ifp->if_oerrors++; - awi_init(ifp); - goto out; - } - } - ifp->if_timer = 1; - } - if (sc->sc_rx_timer) { - if (--sc->sc_rx_timer == 0) { - if (sc->sc_ic.ic_state == IEEE80211_S_RUN) { - ieee80211_new_state(&sc->sc_ic, - IEEE80211_S_SCAN, -1); - goto out; - } - } else - ifp->if_timer = 1; - } - /* TODO: rate control */ - out: - sc->sc_cansleep = ocansleep; -} - -static int -awi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) -{ - struct awi_softc *sc = ifp->if_softc; - struct ifreq *ifr = (struct ifreq *)data; - int s, error; - - s = splnet(); - /* serialize ioctl, since we may sleep */ - if ((error = awi_lock(sc)) != 0) - goto cantlock; - - switch (cmd) { - case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (sc->sc_enabled) { - /* - * To avoid rescanning another access point, - * do not call awi_init() here. Instead, - * only reflect promisc mode settings. - */ - error = awi_mode_init(sc); - } else - error = awi_init(ifp); - } else if (sc->sc_enabled) - awi_stop(ifp, 1); - break; - case SIOCSIFMEDIA: - case SIOCGIFMEDIA: - error = ifmedia_ioctl(ifp, ifr, &sc->sc_ic.ic_media, cmd); - break; - case SIOCADDMULTI: - case SIOCDELMULTI: -#ifdef __FreeBSD__ - error = ENETRESET; /* XXX */ -#else - error = (cmd == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->sc_ic.ic_ec) : - ether_delmulti(ifr, &sc->sc_ic.ic_ec); -#endif - if (error == ENETRESET) { - /* do not rescan */ - if (sc->sc_enabled) - error = awi_mode_init(sc); - else - error = 0; - } - break; - default: - error = ieee80211_ioctl(&sc->sc_ic, cmd, data); - if (error == ENETRESET) { - if (sc->sc_enabled) - error = awi_init(ifp); - else - error = 0; - } - break; - } - awi_unlock(sc); - cantlock: - splx(s); - return error; -} - -/* - * Called from ifmedia_ioctl via awi_ioctl with lock obtained. - * - * TBD factor with ieee80211_media_change - */ -static int -awi_media_change(struct ifnet *ifp) -{ - struct awi_softc *sc = ifp->if_softc; - struct ieee80211com *ic = &sc->sc_ic; - struct ifmedia_entry *ime; - enum ieee80211_opmode newmode; - int i, rate, newadhoc_ap, error = 0; - - ime = ic->ic_media.ifm_cur; - if (IFM_SUBTYPE(ime->ifm_media) == IFM_AUTO) { - i = -1; - rate = ic->ic_fixed_rate; - } else { - struct ieee80211_rateset *rs = - &ic->ic_sup_rates[(ic->ic_phytype == IEEE80211_T_FH) - ? IEEE80211_MODE_FH : IEEE80211_MODE_11B]; - rate = ieee80211_media2rate(ime->ifm_media); - if (rate == 0) - return EINVAL; - for (i = 0; i < rs->rs_nrates; i++) { - if ((rs->rs_rates[i] & IEEE80211_RATE_VAL) == rate) - break; - } - if (i == rs->rs_nrates) - return EINVAL; - } - if (ic->ic_fixed_rate != rate) { - ic->ic_fixed_rate = rate; - error = ENETRESET; - } - - /* - * combination of mediaopt - * - * hostap adhoc flag0 opmode adhoc_ap comment - * + - - HOSTAP 0 HostAP - * - + - IBSS 0 IBSS - * - + + AHDEMO 0 WaveLAN adhoc - * - - + IBSS 1 Melco old Sta - * also LINK0 - * - - - STA 0 Infra Station - */ - newadhoc_ap = 0; - if (ime->ifm_media & IFM_IEEE80211_HOSTAP) - newmode = IEEE80211_M_HOSTAP; - else if (ime->ifm_media & IFM_IEEE80211_ADHOC) { - if (ic->ic_phytype == IEEE80211_T_DS && - (ime->ifm_media & IFM_FLAG0)) - newmode = IEEE80211_M_AHDEMO; - else - newmode = IEEE80211_M_IBSS; - } else if (ime->ifm_media & IFM_FLAG0) { - newmode = IEEE80211_M_IBSS; - newadhoc_ap = 1; - } else - newmode = IEEE80211_M_STA; - if (ic->ic_opmode != newmode || sc->sc_adhoc_ap != newadhoc_ap) { - ic->ic_opmode = newmode; - sc->sc_adhoc_ap = newadhoc_ap; - error = ENETRESET; - } - - if (error == ENETRESET) { - if (sc->sc_enabled) - error = awi_init(ifp); - else - error = 0; - } - return error; -} - -static void -awi_media_status(struct ifnet *ifp, struct ifmediareq *imr) -{ - struct awi_softc *sc = ifp->if_softc; - struct ieee80211com *ic = &sc->sc_ic; - int rate; - enum ieee80211_phymode mode; - - imr->ifm_status = IFM_AVALID; - if (ic->ic_state == IEEE80211_S_RUN) - imr->ifm_status |= IFM_ACTIVE; - imr->ifm_active = IFM_IEEE80211; - if (ic->ic_phytype == IEEE80211_T_FH) - mode = IEEE80211_MODE_FH; - else - mode = IEEE80211_MODE_11B; - if (ic->ic_state == IEEE80211_S_RUN) { - rate = ic->ic_bss->ni_rates.rs_rates[ic->ic_bss->ni_txrate] & - IEEE80211_RATE_VAL; - } else { - if (ic->ic_fixed_rate == IEEE80211_FIXED_RATE_NONE) - rate = 0; - else - rate = ic->ic_fixed_rate; - } - imr->ifm_active |= ieee80211_rate2media(ic, rate, mode); - switch (ic->ic_opmode) { - case IEEE80211_M_MONITOR: /* we should never reach here */ - case IEEE80211_M_WDS: - break; - case IEEE80211_M_STA: - break; - case IEEE80211_M_IBSS: - if (sc->sc_adhoc_ap) - imr->ifm_active |= IFM_FLAG0; - else - imr->ifm_active |= IFM_IEEE80211_ADHOC; - break; - case IEEE80211_M_AHDEMO: - imr->ifm_active |= IFM_IEEE80211_ADHOC | IFM_FLAG0; - break; - case IEEE80211_M_HOSTAP: - imr->ifm_active |= IFM_IEEE80211_HOSTAP; - break; - } -} - -static int -awi_mode_init(struct awi_softc *sc) -{ - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - int n, error; -#ifdef __FreeBSD__ - struct ifmultiaddr *ifma; -#else - struct ether_multi *enm; - struct ether_multistep step; -#endif - - /* reinitialize muticast filter */ - n = 0; - sc->sc_mib_local.Accept_All_Multicast_Dis = 0; - if (sc->sc_ic.ic_opmode != IEEE80211_M_HOSTAP && - (ifp->if_flags & IFF_PROMISC)) { - sc->sc_mib_mac.aPromiscuous_Enable = 1; - goto set_mib; - } - sc->sc_mib_mac.aPromiscuous_Enable = 0; -#ifdef __FreeBSD__ - if (ifp->if_flags & IFF_ALLMULTI) - goto set_mib; - IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - if (n == AWI_GROUP_ADDR_SIZE) { - IF_ADDR_UNLOCK(ifp); - goto set_mib; - } - IEEE80211_ADDR_COPY(sc->sc_mib_addr.aGroup_Addresses[n], - LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); - n++; - } - IF_ADDR_UNLOCK(ifp); -#else - ETHER_FIRST_MULTI(step, &sc->sc_ic.ic_ec, enm); - while (enm != NULL) { - if (n == AWI_GROUP_ADDR_SIZE || - !IEEE80211_ADDR_EQ(enm->enm_addrlo, enm->enm_addrhi)) - goto set_mib; - IEEE80211_ADDR_COPY(sc->sc_mib_addr.aGroup_Addresses[n], - enm->enm_addrlo); - n++; - ETHER_NEXT_MULTI(step, enm); - } -#endif - for (; n < AWI_GROUP_ADDR_SIZE; n++) - memset(sc->sc_mib_addr.aGroup_Addresses[n], 0, - IEEE80211_ADDR_LEN); - sc->sc_mib_local.Accept_All_Multicast_Dis = 1; - - set_mib: -#ifndef __FreeBSD__ - if (sc->sc_mib_local.Accept_All_Multicast_Dis) - ifp->if_flags &= ~IFF_ALLMULTI; - else - ifp->if_flags |= IFF_ALLMULTI; -#endif - sc->sc_mib_mgt.Wep_Required = - (sc->sc_ic.ic_flags & IEEE80211_F_PRIVACY) ? AWI_WEP_ON : AWI_WEP_OFF; - - if ((error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_LOCAL, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_ADDR, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_MAC, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_MGT, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_PHY, AWI_WAIT))) { - DPRINTF(("awi_mode_init: MIB set failed: %d\n", error)); - return error; - } - return 0; -} - -static void -awi_rx_int(struct awi_softc *sc) -{ - struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - struct ieee80211_node *ni; - u_int8_t state, rate, rssi; - u_int16_t len; - u_int32_t frame, next, rstamp, rxoff; - struct mbuf *m; - - rxoff = sc->sc_rxdoff; - for (;;) { - state = awi_read_1(sc, rxoff + AWI_RXD_HOST_DESC_STATE); - if (state & AWI_RXD_ST_OWN) - break; - if (!(state & AWI_RXD_ST_CONSUMED)) { - if (sc->sc_substate != AWI_ST_NONE) - goto rx_next; - if (state & AWI_RXD_ST_RXERROR) { - ifp->if_ierrors++; - goto rx_next; - } - len = awi_read_2(sc, rxoff + AWI_RXD_LEN); - rate = awi_read_1(sc, rxoff + AWI_RXD_RATE); - rssi = awi_read_1(sc, rxoff + AWI_RXD_RSSI); - frame = awi_read_4(sc, rxoff + AWI_RXD_START_FRAME) & - 0x7fff; - rstamp = awi_read_4(sc, rxoff + AWI_RXD_LOCALTIME); - m = awi_devget(sc, frame, len); - if (m == NULL) { - ifp->if_ierrors++; - goto rx_next; - } - if (state & AWI_RXD_ST_LF) { - /* TODO check my bss */ - if (!(sc->sc_ic.ic_flags & IEEE80211_F_SIBSS) && - sc->sc_ic.ic_state == IEEE80211_S_RUN) { - sc->sc_rx_timer = 10; - ifp->if_timer = 1; - } - if ((ifp->if_flags & IFF_DEBUG) && - (ifp->if_flags & IFF_LINK2)) - ieee80211_dump_pkt(ic, - m->m_data, m->m_len, - rate / 5, rssi); - if ((ifp->if_flags & IFF_LINK0) || - sc->sc_adhoc_ap) - m = awi_ether_modcap(sc, m); - else - m = m_pullup(m, - sizeof(struct ieee80211_frame_min)); - if (m == NULL) { - ifp->if_ierrors++; - goto rx_next; - } - ni = ieee80211_find_rxnode(ic, - mtod(m, struct ieee80211_frame_min *)); - /* XXX 0 for noise floor */ - ieee80211_input(ic, m, ni, rssi, 0, rstamp); - ieee80211_free_node(ni); - } else - sc->sc_rxpend = m; - rx_next: - state |= AWI_RXD_ST_CONSUMED; - awi_write_1(sc, rxoff + AWI_RXD_HOST_DESC_STATE, state); - } - next = awi_read_4(sc, rxoff + AWI_RXD_NEXT); - if (next & AWI_RXD_NEXT_LAST) - break; - /* make sure the next pointer is correct */ - if (next != awi_read_4(sc, rxoff + AWI_RXD_NEXT)) - break; - state |= AWI_RXD_ST_OWN; - awi_write_1(sc, rxoff + AWI_RXD_HOST_DESC_STATE, state); - rxoff = next & 0x7fff; - } - sc->sc_rxdoff = rxoff; -} - -static void -awi_tx_int(struct awi_softc *sc) -{ - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - u_int8_t flags; - - while (sc->sc_txdone != sc->sc_txnext) { - flags = awi_read_1(sc, sc->sc_txdone + AWI_TXD_STATE); - if ((flags & AWI_TXD_ST_OWN) || !(flags & AWI_TXD_ST_DONE)) - break; - if (flags & AWI_TXD_ST_ERROR) - ifp->if_oerrors++; - sc->sc_txdone = awi_read_4(sc, sc->sc_txdone + AWI_TXD_NEXT) & - 0x7fff; - } - DPRINTF2(("awi_txint: txdone %d txnext %d txbase %d txend %d\n", - sc->sc_txdone, sc->sc_txnext, sc->sc_txbase, sc->sc_txend)); - sc->sc_tx_timer = 0; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - awi_start(ifp); -} - -static struct mbuf * -awi_devget(struct awi_softc *sc, u_int32_t off, u_int16_t len) -{ - struct ifnet *ifp = AC2IFP(&sc->sc_arp); - struct mbuf *m; - struct mbuf *top, **mp; - u_int tlen; - - top = sc->sc_rxpend; - mp = ⊤ - if (top != NULL) { - sc->sc_rxpend = NULL; - top->m_pkthdr.len += len; - m = top; - while (*mp != NULL) { - m = *mp; - mp = &m->m_next; - } - if (m->m_flags & M_EXT) - tlen = m->m_ext.ext_size; - else if (m->m_flags & M_PKTHDR) - tlen = MHLEN; - else - tlen = MLEN; - tlen -= m->m_len; - if (tlen > len) - tlen = len; - awi_read_bytes(sc, off, mtod(m, u_int8_t *) + m->m_len, tlen); - off += tlen; - len -= tlen; - } - - while (len > 0) { - if (top == NULL) { - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) - return NULL; - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = len; - m->m_len = MHLEN; - } else { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == NULL) { - m_freem(top); - return NULL; - } - m->m_len = MLEN; - } - if (len >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - m->m_len = m->m_ext.ext_size; - } - if (top == NULL) { - int hdrlen = sizeof(struct ieee80211_frame) + - sizeof(struct llc); - caddr_t newdata = (caddr_t) - ALIGN(m->m_data + hdrlen) - hdrlen; - m->m_len -= newdata - m->m_data; - m->m_data = newdata; - } - if (m->m_len > len) - m->m_len = len; - awi_read_bytes(sc, off, mtod(m, u_int8_t *), m->m_len); - off += m->m_len; - len -= m->m_len; - *mp = m; - mp = &m->m_next; - } - if (top != NULL) { - /* Strip trailing 802.11 MAC FCS. */ - m_adj(top, -IEEE80211_CRC_LEN); - } - return top; -} - -/* - * Initialize hardware and start firmware to accept commands. - * Called everytime after power on firmware. - */ - -static int -awi_hw_init(struct awi_softc *sc) -{ - u_int8_t status; - u_int16_t intmask; - int i, error; - - sc->sc_enab_intr = 0; - sc->sc_invalid = 0; /* XXX: really? */ - awi_drvstate(sc, AWI_DRV_RESET); - - /* reset firmware */ - am79c930_gcr_setbits(&sc->sc_chip, AM79C930_GCR_CORESET); - DELAY(100); - awi_write_1(sc, AWI_SELFTEST, 0); - awi_write_1(sc, AWI_CMD, 0); - awi_write_1(sc, AWI_BANNER, 0); - am79c930_gcr_clearbits(&sc->sc_chip, AM79C930_GCR_CORESET); - DELAY(100); - - /* wait for selftest completion */ - for (i = 0; ; i++) { - if (sc->sc_invalid) - return ENXIO; - if (i >= AWI_SELFTEST_TIMEOUT*hz/1000) { - printf("%s: failed to complete selftest (timeout)\n", - AC2IFP(&sc->sc_arp)->if_xname); - return ENXIO; - } - status = awi_read_1(sc, AWI_SELFTEST); - if ((status & 0xf0) == 0xf0) - break; - if (sc->sc_cansleep) { - sc->sc_sleep_cnt++; - (void)tsleep(sc, PWAIT, "awitst", 1); - sc->sc_sleep_cnt--; - } else { - DELAY(1000*1000/hz); - } - } - if (status != AWI_SELFTEST_PASSED) { - printf("%s: failed to complete selftest (code %x)\n", - AC2IFP(&sc->sc_arp)->if_xname, status); - return ENXIO; - } - - /* check banner to confirm firmware write it */ - awi_read_bytes(sc, AWI_BANNER, sc->sc_banner, AWI_BANNER_LEN); - if (memcmp(sc->sc_banner, "PCnetMobile:", 12) != 0) { - printf("%s: failed to complete selftest (bad banner)\n", - AC2IFP(&sc->sc_arp)->if_xname); - for (i = 0; i < AWI_BANNER_LEN; i++) - printf("%s%02x", i ? ":" : "\t", sc->sc_banner[i]); - printf("\n"); - return ENXIO; - } - - /* initializing interrupt */ - sc->sc_enab_intr = 1; - error = awi_intr_lock(sc); - if (error) - return error; - intmask = AWI_INT_GROGGY | AWI_INT_SCAN_CMPLT | - AWI_INT_TX | AWI_INT_RX | AWI_INT_CMD; - awi_write_1(sc, AWI_INTMASK, ~intmask & 0xff); - awi_write_1(sc, AWI_INTMASK2, 0); - awi_write_1(sc, AWI_INTSTAT, 0); - awi_write_1(sc, AWI_INTSTAT2, 0); - awi_intr_unlock(sc); - am79c930_gcr_setbits(&sc->sc_chip, AM79C930_GCR_ENECINT); - - /* issuing interface test command */ - error = awi_cmd(sc, AWI_CMD_NOP, AWI_WAIT); - if (error) { - printf("%s: failed to complete selftest", - AC2IFP(&sc->sc_arp)->if_xname); - if (error == ENXIO) - printf(" (no hardware)\n"); - else if (error != EWOULDBLOCK) - printf(" (error %d)\n", error); - else if (sc->sc_cansleep) - printf(" (lost interrupt)\n"); - else - printf(" (command timeout)\n"); - return error; - } - - /* Initialize VBM */ - awi_write_1(sc, AWI_VBM_OFFSET, 0); - awi_write_1(sc, AWI_VBM_LENGTH, 1); - awi_write_1(sc, AWI_VBM_BITMAP, 0); - return 0; -} - -/* - * Extract the factory default MIB value from firmware and assign the driver - * default value. - * Called once at attaching the interface. - */ - -static int -awi_init_mibs(struct awi_softc *sc) -{ - int chan, i, error; - struct ieee80211com *ic = &sc->sc_ic; - struct awi_chanset *cs; - - if ((error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_LOCAL, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_ADDR, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_MAC, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_MGT, AWI_WAIT)) || - (error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_PHY, AWI_WAIT))) { - printf("%s: failed to get default mib value (error %d)\n", - AC2IFP(&sc->sc_arp)->if_xname, error); - return error; - } - - memset(&sc->sc_ic.ic_chan_avail, 0, sizeof(sc->sc_ic.ic_chan_avail)); - for (cs = awi_chanset; ; cs++) { - if (cs->cs_type == 0) { - printf("%s: failed to set available channel\n", - AC2IFP(&sc->sc_arp)->if_xname); - return ENXIO; - } - if (cs->cs_type == sc->sc_mib_phy.IEEE_PHY_Type && - cs->cs_region == sc->sc_mib_phy.aCurrent_Reg_Domain) - break; - } - if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) { - for (i = cs->cs_min; i <= cs->cs_max; i++) { - chan = IEEE80211_FH_CHAN(i % 3 + 1, i); - setbit(sc->sc_ic.ic_chan_avail, chan); - /* XXX for FHSS, does frequency matter? */ - ic->ic_channels[chan].ic_freq = 0; - ic->ic_channels[chan].ic_flags = IEEE80211_CHAN_FHSS; - /* - * According to the IEEE 802.11 specification, - * hop pattern parameter for FH phy should be - * incremented by 3 for given hop chanset, i.e., - * the chanset parameter is calculated for given - * hop patter. However, BayStack 650 Access Points - * apparently use fixed hop chanset parameter value - * 1 for any hop pattern. So we also try this - * combination of hop chanset and pattern. - */ - chan = IEEE80211_FH_CHAN(1, i); - setbit(sc->sc_ic.ic_chan_avail, chan); - ic->ic_channels[chan].ic_freq = 0; /* XXX */ - ic->ic_channels[chan].ic_flags = IEEE80211_CHAN_FHSS; - } - } else { - for (i = cs->cs_min; i <= cs->cs_max; i++) { - setbit(sc->sc_ic.ic_chan_avail, i); - ic->ic_channels[i].ic_freq = - ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ); - ic->ic_channels[i].ic_flags = IEEE80211_CHAN_B; - } - } - sc->sc_cur_chan = cs->cs_def; - ic->ic_curchan = &ic->ic_channels[cs->cs_def]; /* XXX? */ - - sc->sc_mib_local.Fragmentation_Dis = 1; - sc->sc_mib_local.Add_PLCP_Dis = 0; - sc->sc_mib_local.MAC_Hdr_Prsv = 0; - sc->sc_mib_local.Rx_Mgmt_Que_En = 0; - sc->sc_mib_local.Re_Assembly_Dis = 1; - sc->sc_mib_local.Strip_PLCP_Dis = 0; - sc->sc_mib_local.Power_Saving_Mode_Dis = 1; - sc->sc_mib_local.Accept_All_Multicast_Dis = 1; - sc->sc_mib_local.Check_Seq_Cntl_Dis = 0; - sc->sc_mib_local.Flush_CFP_Queue_On_CF_End = 0; - sc->sc_mib_local.Network_Mode = 1; - sc->sc_mib_local.PWD_Lvl = 0; - sc->sc_mib_local.CFP_Mode = 0; - - /* allocate buffers */ - sc->sc_txbase = AWI_BUFFERS; - sc->sc_txend = sc->sc_txbase + - (AWI_TXD_SIZE + sizeof(struct ieee80211_frame) + - sizeof(struct ether_header) + ETHERMTU) * AWI_NTXBUFS; - LE_WRITE_4(&sc->sc_mib_local.Tx_Buffer_Offset, sc->sc_txbase); - LE_WRITE_4(&sc->sc_mib_local.Tx_Buffer_Size, - sc->sc_txend - sc->sc_txbase); - LE_WRITE_4(&sc->sc_mib_local.Rx_Buffer_Offset, sc->sc_txend); - LE_WRITE_4(&sc->sc_mib_local.Rx_Buffer_Size, - AWI_BUFFERS_END - sc->sc_txend); - sc->sc_mib_local.Acting_as_AP = 0; - sc->sc_mib_local.Fill_CFP = 0; - - memset(&sc->sc_mib_mac.aDesired_ESS_ID, 0, AWI_ESS_ID_SIZE); - sc->sc_mib_mac.aDesired_ESS_ID[0] = IEEE80211_ELEMID_SSID; - - sc->sc_mib_mgt.aPower_Mgt_Mode = 0; - sc->sc_mib_mgt.aDTIM_Period = 1; - LE_WRITE_2(&sc->sc_mib_mgt.aATIM_Window, 0); - return 0; -} - -static int -awi_mib(struct awi_softc *sc, u_int8_t cmd, u_int8_t mib, int wflag) -{ - int error; - u_int8_t size, *ptr; - - switch (mib) { - case AWI_MIB_LOCAL: - ptr = (u_int8_t *)&sc->sc_mib_local; - size = sizeof(sc->sc_mib_local); - break; - case AWI_MIB_ADDR: - ptr = (u_int8_t *)&sc->sc_mib_addr; - size = sizeof(sc->sc_mib_addr); - break; - case AWI_MIB_MAC: - ptr = (u_int8_t *)&sc->sc_mib_mac; - size = sizeof(sc->sc_mib_mac); - break; - case AWI_MIB_STAT: - ptr = (u_int8_t *)&sc->sc_mib_stat; - size = sizeof(sc->sc_mib_stat); - break; - case AWI_MIB_MGT: - ptr = (u_int8_t *)&sc->sc_mib_mgt; - size = sizeof(sc->sc_mib_mgt); - break; - case AWI_MIB_PHY: - ptr = (u_int8_t *)&sc->sc_mib_phy; - size = sizeof(sc->sc_mib_phy); - break; - default: - return EINVAL; - } - if (sc->sc_cmd_inprog) { - if ((error = awi_cmd_wait(sc)) != 0) { - if (error == EWOULDBLOCK) - DPRINTF(("awi_mib: cmd %d inprog", - sc->sc_cmd_inprog)); - return error; - } - } - sc->sc_cmd_inprog = cmd; - if (cmd == AWI_CMD_SET_MIB) - awi_write_bytes(sc, AWI_CA_MIB_DATA, ptr, size); - awi_write_1(sc, AWI_CA_MIB_TYPE, mib); - awi_write_1(sc, AWI_CA_MIB_SIZE, size); - awi_write_1(sc, AWI_CA_MIB_INDEX, 0); - if ((error = awi_cmd(sc, cmd, wflag)) != 0) - return error; - if (cmd == AWI_CMD_GET_MIB) { - awi_read_bytes(sc, AWI_CA_MIB_DATA, ptr, size); -#ifdef AWI_DEBUG - if (awi_debug) { - int i; - - printf("awi_mib: #%d:", mib); - for (i = 0; i < size; i++) - printf(" %02x", ptr[i]); - printf("\n"); - } -#endif - } - return 0; -} - -static int -awi_cmd(struct awi_softc *sc, u_int8_t cmd, int wflag) -{ - u_int8_t status; - int error = 0; -#ifdef AWI_DEBUG - static const char *cmdname[] = { - "IDLE", "NOP", "SET_MIB", "INIT_TX", "FLUSH_TX", "INIT_RX", - "KILL_RX", "SLEEP", "WAKE", "GET_MIB", "SCAN", "SYNC", "RESUME" - }; -#endif - -#ifdef AWI_DEBUG - if (awi_debug > 1) { - if (cmd >= sizeof(cmdname)/sizeof(cmdname[0])) - printf("awi_cmd: #%d", cmd); - else - printf("awi_cmd: %s", cmdname[cmd]); - printf(" %s\n", wflag == AWI_NOWAIT ? "nowait" : "wait"); - } -#endif - sc->sc_cmd_inprog = cmd; - awi_write_1(sc, AWI_CMD_STATUS, AWI_STAT_IDLE); - awi_write_1(sc, AWI_CMD, cmd); - if (wflag == AWI_NOWAIT) - return EINPROGRESS; - if ((error = awi_cmd_wait(sc)) != 0) - return error; - status = awi_read_1(sc, AWI_CMD_STATUS); - awi_write_1(sc, AWI_CMD, 0); - switch (status) { - case AWI_STAT_OK: - break; - case AWI_STAT_BADPARM: - return EINVAL; - default: - printf("%s: command %d failed %x\n", - AC2IFP(&sc->sc_arp)->if_xname, cmd, status); - return ENXIO; - } - return 0; -} - -static int -awi_cmd_wait(struct awi_softc *sc) -{ - int i, error = 0; - - i = 0; - while (sc->sc_cmd_inprog) { - if (sc->sc_invalid) - return ENXIO; - if (awi_read_1(sc, AWI_CMD) != sc->sc_cmd_inprog) { - printf("%s: failed to access hardware\n", - AC2IFP(&sc->sc_arp)->if_xname); - sc->sc_invalid = 1; - return ENXIO; - } - if (sc->sc_cansleep) { - sc->sc_sleep_cnt++; - error = tsleep(sc, PWAIT, "awicmd", - AWI_CMD_TIMEOUT*hz/1000); - sc->sc_sleep_cnt--; - } else { - if (awi_read_1(sc, AWI_CMD_STATUS) != AWI_STAT_IDLE) { - awi_cmd_done(sc); - break; - } - if (i++ >= AWI_CMD_TIMEOUT*1000/10) - error = EWOULDBLOCK; - else - DELAY(10); - } - if (error) - break; - } - if (error) { - DPRINTF(("awi_cmd_wait: cmd 0x%x, error %d\n", - sc->sc_cmd_inprog, error)); - } - return error; -} - -static void -awi_cmd_done(struct awi_softc *sc) -{ - u_int8_t cmd, status; - - status = awi_read_1(sc, AWI_CMD_STATUS); - if (status == AWI_STAT_IDLE) - return; /* stray interrupt */ - - cmd = sc->sc_cmd_inprog; - sc->sc_cmd_inprog = 0; - wakeup(sc); - awi_write_1(sc, AWI_CMD, 0); - - if (status != AWI_STAT_OK) { - printf("%s: command %d failed %x\n", - AC2IFP(&sc->sc_arp)->if_xname, cmd, status); - sc->sc_substate = AWI_ST_NONE; - return; - } - if (sc->sc_substate != AWI_ST_NONE) - (void)ieee80211_new_state(&sc->sc_ic, sc->sc_nstate, -1); -} - -static int -awi_next_txd(struct awi_softc *sc, int len, u_int32_t *framep, u_int32_t *ntxdp) -{ - u_int32_t txd, ntxd, frame; - - txd = sc->sc_txnext; - frame = txd + AWI_TXD_SIZE; - if (frame + len > sc->sc_txend) - frame = sc->sc_txbase; - ntxd = frame + len; - if (ntxd + AWI_TXD_SIZE > sc->sc_txend) - ntxd = sc->sc_txbase; - *framep = frame; - *ntxdp = ntxd; - /* - * Determine if there are any room in ring buffer. - * --- send wait, === new data, +++ conflict (ENOBUFS) - * base........................end - * done----txd=====ntxd OK - * --txd=====done++++ntxd-- full - * --txd=====ntxd done-- OK - * ==ntxd done----txd=== OK - * ==done++++ntxd----txd=== full - * ++ntxd txd=====done++ full - */ - if (txd < ntxd) { - if (txd < sc->sc_txdone && ntxd + AWI_TXD_SIZE > sc->sc_txdone) - return ENOBUFS; - } else { - if (txd < sc->sc_txdone || ntxd + AWI_TXD_SIZE > sc->sc_txdone) - return ENOBUFS; - } - return 0; -} - -static int -awi_lock(struct awi_softc *sc) -{ - int error = 0; - -#ifdef __NetBSD__ - if (curlwp == NULL) -#else - if (curproc == NULL) -#endif - { - /* - * XXX - * Though driver ioctl should be called with context, - * KAME ipv6 stack calls ioctl in interrupt for now. - * We simply abort the request if there are other - * ioctl requests in progress. - */ - if (sc->sc_busy) { - if (sc->sc_invalid) - return ENXIO; - return EWOULDBLOCK; - } - sc->sc_busy = 1; - sc->sc_cansleep = 0; - return 0; - } - while (sc->sc_busy) { - if (sc->sc_invalid) - return ENXIO; - sc->sc_sleep_cnt++; - error = tsleep(sc, PWAIT | PCATCH, "awilck", 0); - sc->sc_sleep_cnt--; - if (error) - return error; - } - sc->sc_busy = 1; - sc->sc_cansleep = 1; - return 0; -} - -static void -awi_unlock(struct awi_softc *sc) -{ - sc->sc_busy = 0; - sc->sc_cansleep = 0; - if (sc->sc_sleep_cnt) - wakeup(sc); -} - -static int -awi_intr_lock(struct awi_softc *sc) -{ - u_int8_t status; - int i, retry; - - status = 1; - for (retry = 0; retry < 10; retry++) { - for (i = 0; i < AWI_LOCKOUT_TIMEOUT*1000/5; i++) { - if ((status = awi_read_1(sc, AWI_LOCKOUT_HOST)) == 0) - break; - DELAY(5); - } - if (status != 0) - break; - awi_write_1(sc, AWI_LOCKOUT_MAC, 1); - if ((status = awi_read_1(sc, AWI_LOCKOUT_HOST)) == 0) - break; - awi_write_1(sc, AWI_LOCKOUT_MAC, 0); - } - if (status != 0) { - printf("%s: failed to lock interrupt\n", - AC2IFP(&sc->sc_arp)->if_xname); - return ENXIO; - } - return 0; -} - -static void -awi_intr_unlock(struct awi_softc *sc) -{ - - awi_write_1(sc, AWI_LOCKOUT_MAC, 0); -} - -static int -awi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) -{ - struct ifnet *ifp = ic->ic_ifp; - struct awi_softc *sc = ifp->if_softc; - struct ieee80211_node *ni; - int error; - u_int8_t newmode; - enum ieee80211_state ostate; -#ifdef AWI_DEBUG - static const char *stname[] = - { "INIT", "SCAN", "AUTH", "ASSOC", "RUN" }; - static const char *substname[] = - { "NONE", "SCAN_INIT", "SCAN_SETMIB", "SCAN_SCCMD", - "SUB_INIT", "SUB_SETSS", "SUB_SYNC" }; -#endif /* AWI_DEBUG */ - - ostate = ic->ic_state; - DPRINTF(("awi_newstate: %s (%s/%s) -> %s\n", stname[ostate], - stname[sc->sc_nstate], substname[sc->sc_substate], stname[nstate])); - - /* set LED */ - switch (nstate) { - case IEEE80211_S_INIT: - awi_drvstate(sc, AWI_DRV_RESET); - break; - case IEEE80211_S_SCAN: - if (ic->ic_opmode == IEEE80211_M_IBSS || - ic->ic_opmode == IEEE80211_M_AHDEMO) - awi_drvstate(sc, AWI_DRV_ADHSC); - else - awi_drvstate(sc, AWI_DRV_INFSY); - break; - case IEEE80211_S_AUTH: - awi_drvstate(sc, AWI_DRV_INFSY); - break; - case IEEE80211_S_ASSOC: - awi_drvstate(sc, AWI_DRV_INFAUTH); - break; - case IEEE80211_S_RUN: - if (ic->ic_opmode == IEEE80211_M_IBSS || - ic->ic_opmode == IEEE80211_M_AHDEMO) - awi_drvstate(sc, AWI_DRV_ADHSY); - else - awi_drvstate(sc, AWI_DRV_INFASSOC); - break; - default: - break; - } - - if (nstate == IEEE80211_S_INIT) { - sc->sc_substate = AWI_ST_NONE; - ic->ic_flags &= ~IEEE80211_F_SIBSS; - return (*sc->sc_newstate)(ic, nstate, arg); - } - - /* state transition */ - if (nstate == IEEE80211_S_SCAN) { - /* SCAN substate */ - if (sc->sc_substate == AWI_ST_NONE) { - sc->sc_nstate = nstate; /* next state in transition */ - sc->sc_substate = AWI_ST_SCAN_INIT; - } - switch (sc->sc_substate) { - case AWI_ST_SCAN_INIT: - sc->sc_substate = AWI_ST_SCAN_SETMIB; - switch (ostate) { - case IEEE80211_S_RUN: - /* beacon miss */ - if (ifp->if_flags & IFF_DEBUG) - printf("%s: no recent beacons from %s;" - " rescanning\n", - ifp->if_xname, - ether_sprintf(ic->ic_bss->ni_bssid)); - /* FALLTHRU */ - case IEEE80211_S_AUTH: - case IEEE80211_S_ASSOC: - case IEEE80211_S_INIT: - /* XXX revisit scanning */; - break; - case IEEE80211_S_SCAN: - /* scan next */ - break; - default: - break; - } - if (ic->ic_flags & IEEE80211_F_ASCAN) - newmode = AWI_SCAN_ACTIVE; - else - newmode = AWI_SCAN_PASSIVE; - if (sc->sc_mib_mgt.aScan_Mode != newmode) { - sc->sc_mib_mgt.aScan_Mode = newmode; - if ((error = awi_mib(sc, AWI_CMD_SET_MIB, - AWI_MIB_MGT, AWI_NOWAIT)) != 0) - break; - } - /* FALLTHRU */ - case AWI_ST_SCAN_SETMIB: - sc->sc_substate = AWI_ST_SCAN_SCCMD; - if (sc->sc_cmd_inprog) { - if ((error = awi_cmd_wait(sc)) != 0) - break; - } - sc->sc_cmd_inprog = AWI_CMD_SCAN; - ni = ic->ic_bss; - awi_write_2(sc, AWI_CA_SCAN_DURATION, - (ic->ic_flags & IEEE80211_F_ASCAN) ? - AWI_ASCAN_DURATION : AWI_PSCAN_DURATION); - if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) { - awi_write_1(sc, AWI_CA_SCAN_SET, - IEEE80211_FH_CHANSET( - ieee80211_chan2ieee(ic, ic->ic_curchan))); - awi_write_1(sc, AWI_CA_SCAN_PATTERN, - IEEE80211_FH_CHANPAT( - ieee80211_chan2ieee(ic, ic->ic_curchan))); - awi_write_1(sc, AWI_CA_SCAN_IDX, 1); - } else { - awi_write_1(sc, AWI_CA_SCAN_SET, - ieee80211_chan2ieee(ic, ic->ic_curchan)); - awi_write_1(sc, AWI_CA_SCAN_PATTERN, 0); - awi_write_1(sc, AWI_CA_SCAN_IDX, 0); - } - awi_write_1(sc, AWI_CA_SCAN_SUSP, 0); - sc->sc_cur_chan = ieee80211_chan2ieee(ic, ic->ic_curchan); - if ((error = awi_cmd(sc, AWI_CMD_SCAN, AWI_NOWAIT)) - != 0) - break; - /* FALLTHRU */ - case AWI_ST_SCAN_SCCMD: - ic->ic_state = nstate; - sc->sc_substate = AWI_ST_NONE; - error = EINPROGRESS; - break; - default: - DPRINTF(("awi_newstate: unexpected state %s/%s\n", - stname[nstate], substname[sc->sc_substate])); - sc->sc_substate = AWI_ST_NONE; - error = EIO; - break; - } - goto out; - } - - if (ostate == IEEE80211_S_SCAN) { - /* set SSID and channel */ - /* substate */ - if (sc->sc_substate == AWI_ST_NONE) { - sc->sc_nstate = nstate; /* next state in transition */ - sc->sc_substate = AWI_ST_SUB_INIT; - } - ni = ic->ic_bss; - switch (sc->sc_substate) { - case AWI_ST_SUB_INIT: - sc->sc_substate = AWI_ST_SUB_SETSS; - IEEE80211_ADDR_COPY(&sc->sc_mib_mgt.aCurrent_BSS_ID, - ni->ni_bssid); - memset(&sc->sc_mib_mgt.aCurrent_ESS_ID, 0, - AWI_ESS_ID_SIZE); - sc->sc_mib_mgt.aCurrent_ESS_ID[0] = - IEEE80211_ELEMID_SSID; - sc->sc_mib_mgt.aCurrent_ESS_ID[1] = ni->ni_esslen; - memcpy(&sc->sc_mib_mgt.aCurrent_ESS_ID[2], - ni->ni_essid, ni->ni_esslen); - LE_WRITE_2(&sc->sc_mib_mgt.aBeacon_Period, - ni->ni_intval); - if ((error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_MGT, - AWI_NOWAIT)) != 0) - break; - /* FALLTHRU */ - case AWI_ST_SUB_SETSS: - sc->sc_substate = AWI_ST_SUB_SYNC; - if (sc->sc_cmd_inprog) { - if ((error = awi_cmd_wait(sc)) != 0) - break; - } - sc->sc_cmd_inprog = AWI_CMD_SYNC; - if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) { - awi_write_1(sc, AWI_CA_SYNC_SET, - IEEE80211_FH_CHANSET( - ieee80211_chan2ieee(ic, ni->ni_chan))); - awi_write_1(sc, AWI_CA_SYNC_PATTERN, - IEEE80211_FH_CHANPAT( - ieee80211_chan2ieee(ic, ni->ni_chan))); - awi_write_1(sc, AWI_CA_SYNC_IDX, - ni->ni_fhindex); - awi_write_2(sc, AWI_CA_SYNC_DWELL, - ni->ni_fhdwell); - } else { - awi_write_1(sc, AWI_CA_SYNC_SET, - ieee80211_chan2ieee(ic, ni->ni_chan)); - awi_write_1(sc, AWI_CA_SYNC_PATTERN, 0); - awi_write_1(sc, AWI_CA_SYNC_IDX, 0); - awi_write_2(sc, AWI_CA_SYNC_DWELL, 0); - } - if (ic->ic_flags & IEEE80211_F_SIBSS) { - memset(&ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); - ni->ni_rstamp = 0; - awi_write_1(sc, AWI_CA_SYNC_STARTBSS, 1); - } else - awi_write_1(sc, AWI_CA_SYNC_STARTBSS, 0); - awi_write_2(sc, AWI_CA_SYNC_MBZ, 0); - awi_write_bytes(sc, AWI_CA_SYNC_TIMESTAMP, - ni->ni_tstamp.data, 8); - awi_write_4(sc, AWI_CA_SYNC_REFTIME, ni->ni_rstamp); - sc->sc_cur_chan = ieee80211_chan2ieee(ic, ni->ni_chan); - if ((error = awi_cmd(sc, AWI_CMD_SYNC, AWI_NOWAIT)) - != 0) - break; - /* FALLTHRU */ - case AWI_ST_SUB_SYNC: - sc->sc_substate = AWI_ST_NONE; - if (ic->ic_flags & IEEE80211_F_SIBSS) { - if ((error = awi_mib(sc, AWI_CMD_GET_MIB, - AWI_MIB_MGT, AWI_WAIT)) != 0) - break; - IEEE80211_ADDR_COPY(ni->ni_bssid, - &sc->sc_mib_mgt.aCurrent_BSS_ID); - } else { - if (nstate == IEEE80211_S_RUN) { - sc->sc_rx_timer = 10; - ifp->if_timer = 1; - } - } - error = 0; - break; - default: - DPRINTF(("awi_newstate: unexpected state %s/%s\n", - stname[nstate], substname[sc->sc_substate])); - sc->sc_substate = AWI_ST_NONE; - error = EIO; - break; - } - goto out; - } - - sc->sc_substate = AWI_ST_NONE; - - return (*sc->sc_newstate)(ic, nstate, arg); -out: - if (error != 0) { - if (error == EINPROGRESS) - error = 0; - return error; - } - return (*sc->sc_newstate)(ic, nstate, arg); -} - -static void -awi_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0, - struct ieee80211_node *ni, - int subtype, int rssi, int nf, u_int32_t rstamp) -{ - struct awi_softc *sc = ic->ic_ifp->if_softc; - - /* probe request is handled by hardware */ - if (subtype == IEEE80211_FC0_SUBTYPE_PROBE_REQ) - return; - (*sc->sc_recv_mgmt)(ic, m0, ni, subtype, rssi, nf, rstamp); -} - -static int -awi_send_mgmt(struct ieee80211com *ic, struct ieee80211_node *ni, - int type, int arg) -{ - struct awi_softc *sc = ic->ic_ifp->if_softc; - - /* probe request is handled by hardware */ - if (type == IEEE80211_FC0_SUBTYPE_PROBE_REQ) - return 0; - return (*sc->sc_send_mgmt)(ic, ni, type, arg); -} - -static struct mbuf * -awi_ether_encap(struct awi_softc *sc, struct mbuf *m) -{ - struct ieee80211com *ic = &sc->sc_ic; - struct ieee80211_node *ni = ic->ic_bss; - struct ether_header *eh; - struct ieee80211_frame *wh; - - if (m->m_len < sizeof(struct ether_header)) { - m = m_pullup(m, sizeof(struct ether_header)); - if (m == NULL) - return NULL; - } - eh = mtod(m, struct ether_header *); - M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT); - if (m == NULL) - return NULL; - wh = mtod(m, struct ieee80211_frame *); - wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_DATA; - *(u_int16_t *)wh->i_dur = 0; - *(u_int16_t *)wh->i_seq = - htole16(ni->ni_txseqs[0] << IEEE80211_SEQ_SEQ_SHIFT); - ni->ni_txseqs[0]++; - if (ic->ic_opmode == IEEE80211_M_IBSS || - ic->ic_opmode == IEEE80211_M_AHDEMO) { - wh->i_fc[1] = IEEE80211_FC1_DIR_NODS; - if (sc->sc_adhoc_ap) - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_macaddr); - else - IEEE80211_ADDR_COPY(wh->i_addr1, eh->ether_dhost); - IEEE80211_ADDR_COPY(wh->i_addr2, eh->ether_shost); - IEEE80211_ADDR_COPY(wh->i_addr3, ni->ni_bssid); - } else { - wh->i_fc[1] = IEEE80211_FC1_DIR_TODS; - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_bssid); - IEEE80211_ADDR_COPY(wh->i_addr2, eh->ether_shost); - IEEE80211_ADDR_COPY(wh->i_addr3, eh->ether_dhost); - } - return m; -} - -static struct mbuf * -awi_ether_modcap(struct awi_softc *sc, struct mbuf *m) -{ - struct ieee80211com *ic = &sc->sc_ic; - struct ether_header eh; - struct ieee80211_frame wh; - struct llc *llc; - - if (m->m_len < sizeof(wh) + sizeof(eh)) { - m = m_pullup(m, sizeof(wh) + sizeof(eh)); - if (m == NULL) - return NULL; - } - memcpy(&wh, mtod(m, caddr_t), sizeof(wh)); - if (wh.i_fc[0] != (IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_DATA)) - return m; - memcpy(&eh, mtod(m, caddr_t) + sizeof(wh), sizeof(eh)); - m_adj(m, sizeof(eh) - sizeof(*llc)); - if (ic->ic_opmode == IEEE80211_M_IBSS || - ic->ic_opmode == IEEE80211_M_AHDEMO) - IEEE80211_ADDR_COPY(wh.i_addr2, eh.ether_shost); - memcpy(mtod(m, caddr_t), &wh, sizeof(wh)); - llc = (struct llc *)(mtod(m, caddr_t) + sizeof(wh)); - llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; - llc->llc_control = LLC_UI; - llc->llc_snap.org_code[0] = 0; - llc->llc_snap.org_code[1] = 0; - llc->llc_snap.org_code[2] = 0; - llc->llc_snap.ether_type = eh.ether_type; - return m; -} diff --git a/sys/dev/awi/awireg.h b/sys/dev/awi/awireg.h deleted file mode 100644 index 555e058b3d14..000000000000 --- a/sys/dev/awi/awireg.h +++ /dev/null @@ -1,464 +0,0 @@ -/* $NetBSD: awireg.h,v 1.8 2003/01/20 05:30:06 simonb Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * 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 NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 _DEV_IC_AWIREG_H -#define _DEV_IC_AWIREG_H - -/* - * The firmware typically loaded onto Am79C930-based 802.11 interfaces - * uses a 32k or larger shared memory buffer to communicate with the - * host. - * - * Depending on the exact configuration of the device, this buffer may - * either be mapped into PCMCIA memory space, or accessible a byte at - * a type through PCMCIA I/O space. - * - * This header defines offsets into this shared memory. - */ - - -/* - * LAST_TXD block. 5 32-bit words. - * - * There are five different output queues; this defines pointers to - * the last completed descriptor for each one. - */ -#define AWI_LAST_TXD 0x3ec /* last completed Tx Descr */ - -#define AWI_LAST_BCAST_TXD AWI_LAST_TXD+0 -#define AWI_LAST_MGT_TXD AWI_LAST_TXD+4 -#define AWI_LAST_DATA_TXD AWI_LAST_TXD+8 -#define AWI_LAST_PS_POLL_TXD AWI_LAST_TXD+12 -#define AWI_LAST_CF_POLL_TXD AWI_LAST_TXD+16 - -/* - * Banner block; null-terminated string. - * - * The doc says it contains - * "PCnetMobile:v2.00 mmddyy APIx.x\0" - */ - -#define AWI_BANNER 0x480 /* Version string */ -#define AWI_BANNER_LEN 0x20 - -/* - * Command block protocol: - * write command byte to a zero value. - * write command status to a zero value. - * write arguments to AWI_COMMAND_PARAMS - * write command byte to a non-zero value. - * wait for command status to be non-zero. - * write command byte to a zero value. - * write command status to a zero value. - */ - -#define AWI_CMD 0x4a0 /* Command opcode byte */ - -#define AWI_CMD_IDLE 0x0 -#define AWI_CMD_NOP 0x1 - -#define AWI_CMD_SET_MIB 0x2 -#define AWI_CMD_GET_MIB 0x9 -#define AWI_CA_MIB_TYPE (AWI_CMD_PARAMS + 0x0) -#define AWI_CA_MIB_SIZE (AWI_CMD_PARAMS + 0x1) -#define AWI_CA_MIB_INDEX (AWI_CMD_PARAMS + 0x2) -#define AWI_CA_MIB_DATA (AWI_CMD_PARAMS + 0x4) -#define AWI_MIB_LOCAL 0 -#define AWI_MIB_ADDR 2 -#define AWI_MIB_MAC 3 -#define AWI_MIB_STAT 4 -#define AWI_MIB_MGT 5 -#define AWI_MIB_DRVR 6 -#define AWI_MIB_PHY 7 - -#define AWI_CMD_INIT_TX 0x3 -#define AWI_CA_TX_LEN 20 -#define AWI_CA_TX_DATA (AWI_CMD_PARAMS + 0x0) -#define AWI_CA_TX_MGT (AWI_CMD_PARAMS + 0x4) -#define AWI_CA_TX_BCAST (AWI_CMD_PARAMS + 0x8) -#define AWI_CA_TX_PS (AWI_CMD_PARAMS + 0xc) -#define AWI_CA_TX_CF (AWI_CMD_PARAMS + 0x10) - -#define AWI_CMD_FLUSH_TX 0x4 -#define AWI_CA_FTX_LEN 5 -#define AWI_CA_FTX_DATA (AWI_CMD_PARAMS + 0x0) -#define AWI_CA_FTX_MGT (AWI_CMD_PARAMS + 0x1) -#define AWI_CA_FTX_BCAST (AWI_CMD_PARAMS + 0x2) -#define AWI_CA_FTX_PS (AWI_CMD_PARAMS + 0x3) -#define AWI_CA_FTX_CF (AWI_CMD_PARAMS + 0x4) - -#define AWI_CMD_INIT_RX 0x5 -#define AWI_CA_IRX_LEN 0x8 -#define AWI_CA_IRX_DATA_DESC (AWI_CMD_PARAMS + 0x0) /* return */ -#define AWI_CA_IRX_PS_DESC (AWI_CMD_PARAMS + 0x4) /* return */ - -#define AWI_CMD_KILL_RX 0x6 - -#define AWI_CMD_SLEEP 0x7 -#define AWI_CA_SLEEP_LEN 8 -#define AWI_CA_WAKEUP (AWI_CMD_PARAMS + 0x0) /* uint64 */ - -#define AWI_CMD_WAKE 0x8 - -#define AWI_CMD_SCAN 0xa -#define AWI_CA_SCAN_LEN 6 -#define AWI_CA_SCAN_DURATION (AWI_CMD_PARAMS + 0x0) -#define AWI_CA_SCAN_SET (AWI_CMD_PARAMS + 0x2) -#define AWI_CA_SCAN_PATTERN (AWI_CMD_PARAMS + 0x3) -#define AWI_CA_SCAN_IDX (AWI_CMD_PARAMS + 0x4) -#define AWI_CA_SCAN_SUSP (AWI_CMD_PARAMS + 0x5) - -#define AWI_CMD_SYNC 0xb -#define AWI_CA_SYNC_LEN 20 -#define AWI_CA_SYNC_SET (AWI_CMD_PARAMS + 0x0) -#define AWI_CA_SYNC_PATTERN (AWI_CMD_PARAMS + 0x1) -#define AWI_CA_SYNC_IDX (AWI_CMD_PARAMS + 0x2) -#define AWI_CA_SYNC_STARTBSS (AWI_CMD_PARAMS + 0x3) -#define AWI_CA_SYNC_DWELL (AWI_CMD_PARAMS + 0x4) -#define AWI_CA_SYNC_MBZ (AWI_CMD_PARAMS + 0x6) -#define AWI_CA_SYNC_TIMESTAMP (AWI_CMD_PARAMS + 0x8) -#define AWI_CA_SYNC_REFTIME (AWI_CMD_PARAMS + 0x10) - -#define AWI_CMD_RESUME 0xc - -#define AWI_CMD_STATUS 0x4a1 /* Command status */ - -#define AWI_STAT_IDLE 0x0 -#define AWI_STAT_OK 0x1 -#define AWI_STAT_BADCMD 0x2 -#define AWI_STAT_BADPARM 0x3 -#define AWI_STAT_NOTIMP 0x4 -#define AWI_STAT_BADRES 0x5 -#define AWI_STAT_BADMODE 0x6 - -#define AWI_ERROR_OFFSET 0x4a2 /* Offset to erroneous parameter */ -#define AWI_CMD_PARAMS 0x4a4 /* Command parameters */ - -#define AWI_CSB 0x4f0 /* Control/Status block */ - -#define AWI_SELFTEST 0x4f0 - -#define AWI_SELFTEST_INIT 0x00 /* initial */ -#define AWI_SELFTEST_FIRMCKSUM 0x01 /* firmware cksum running */ -#define AWI_SELFTEST_HARDWARE 0x02 /* hardware tests running */ -#define AWI_SELFTEST_MIB 0x03 /* mib initializing */ - -#define AWI_SELFTEST_MIB_FAIL 0xfa -#define AWI_SELFTEST_RADIO_FAIL 0xfb -#define AWI_SELFTEST_MAC_FAIL 0xfc -#define AWI_SELFTEST_FLASH_FAIL 0xfd -#define AWI_SELFTEST_RAM_FAIL 0xfe -#define AWI_SELFTEST_PASSED 0xff - -#define AWI_STA_STATE 0x4f1 - -#define AWI_STA_AP 0x20 /* acting as AP */ -#define AWI_STA_NOPSP 0x10 /* Power Saving disabled */ -#define AWI_STA_DOZE 0x08 /* about to go to sleep */ -#define AWI_STA_PSP 0x04 /* enable PSP */ -#define AWI_STA_RXEN 0x02 /* enable RX */ -#define AWI_STA_TXEN 0x01 /* enable TX */ - -#define AWI_INTSTAT 0x4f3 -#define AWI_INTMASK 0x4f4 - -/* Bits in AWI_INTSTAT/AWI_INTMASK */ - -#define AWI_INT_GROGGY 0x80 /* about to wake up */ -#define AWI_INT_CFP_ENDING 0x40 /* cont. free period ending */ -#define AWI_INT_DTIM 0x20 /* beacon outgoing */ -#define AWI_INT_CFP_START 0x10 /* cont. free period starting */ -#define AWI_INT_SCAN_CMPLT 0x08 /* scan complete */ -#define AWI_INT_TX 0x04 /* tx done */ -#define AWI_INT_RX 0x02 /* rx done */ -#define AWI_INT_CMD 0x01 /* cmd done */ - -/* - * The following are used to implement a locking protocol between host - * and MAC to protect the interrupt status and mask fields. - * - * driver: read lockout_host byte; if zero, set lockout_mac to non-zero, - * then reread lockout_host byte; if still zero, host has lock. - * if non-zero, clear lockout_mac, loop. - */ - -#define AWI_LOCKOUT_MAC 0x4f5 -#define AWI_LOCKOUT_HOST 0x4f6 - - -#define AWI_INTSTAT2 0x4f7 -#define AWI_INTMASK2 0x4fd - -/* Bits in AWI_INTSTAT2/INTMASK2 */ -#define AWI_INT2_RXMGT 0x80 /* mgt/ps received */ -#define AWI_INT2_RXDATA 0x40 /* data received */ -#define AWI_INT2_TXMGT 0x10 /* mgt tx done */ -#define AWI_INT2_TXCF 0x08 /* CF tx done */ -#define AWI_INT2_TXPS 0x04 /* PS tx done */ -#define AWI_INT2_TXBCAST 0x02 /* Broadcast tx done */ -#define AWI_INT2_TXDATA 0x01 /* data tx done */ - -#define AWI_DIS_PWRDN 0x4fc /* disable powerdown if set */ - -#define AWI_DRIVERSTATE 0x4fe /* driver state */ - -#define AWI_DRV_STATEMASK 0x0f - -#define AWI_DRV_RESET 0x0 -#define AWI_DRV_INFSY 0x1 /* inf synced */ -#define AWI_DRV_ADHSC 0x2 /* adhoc scan */ -#define AWI_DRV_ADHSY 0x3 /* adhoc synced */ -#define AWI_DRV_INFSC 0x4 /* inf scanning */ -#define AWI_DRV_INFAUTH 0x5 /* inf authed */ -#define AWI_DRV_INFASSOC 0x6 /* inf associated */ -#define AWI_DRV_INFTOSS 0x7 /* inf handoff */ -#define AWI_DRV_APNONE 0x8 /* AP activity: no assoc */ -#define AWI_DRV_APQUIET 0xc /* AP: >=one assoc, no traffic */ -#define AWI_DRV_APLO 0xd /* AP: >=one assoc, light tfc */ -#define AWI_DRV_APMED 0xe /* AP: >=one assoc, mod tfc */ -#define AWI_DRV_APHIGH 0xf /* AP: >=one assoc, heavy tfc */ - -#define AWI_DRV_AUTORXLED 0x10 -#define AWI_DRV_AUTOTXLED 0x20 -#define AWI_DRV_RXLED 0x40 -#define AWI_DRV_TXLED 0x80 - -#define AWI_VBM_OFFSET 0x500 /* Virtual Bit Map */ -#define AWI_VBM_LENGTH 0x501 -#define AWI_VBM_BITMAP 0x502 - -#define AWI_BUFFERS 0x600 /* Buffers */ -#define AWI_BUFFERS_END 0x6000 - -/* - * Receive descriptors; there are a linked list of these chained - * through the "NEXT" fields, starting from XXX - */ - -#define AWI_RXD_SIZE 0x18 - -#define AWI_RXD_NEXT 0x4 -#define AWI_RXD_NEXT_LAST 0x80000000 - - -#define AWI_RXD_HOST_DESC_STATE 0x9 - -#define AWI_RXD_ST_OWN 0x80 /* host owns this */ -#define AWI_RXD_ST_CONSUMED 0x40 /* host is done */ -#define AWI_RXD_ST_LF 0x20 /* last frag */ -#define AWI_RXD_ST_CRC 0x08 /* CRC error */ -#define AWI_RXD_ST_OFLO 0x02 /* possible buffer overrun */ -#define AWI_RXD_ST_RXERROR 0x01 /* this frame is borked; discard me */ - -#define AWI_RXD_RSSI 0xa /* 1 byte: radio strength indicator */ -#define AWI_RXD_INDEX 0xb /* 1 byte: FH hop index or DS channel */ -#define AWI_RXD_LOCALTIME 0xc /* 4 bytes: local time of RX */ -#define AWI_RXD_START_FRAME 0x10 /* 4 bytes: ptr to first received byte */ -#define AWI_RXD_LEN 0x14 /* 2 bytes: rx len in bytes */ -#define AWI_RXD_RATE 0x16 /* 1 byte: rx rate in 1e5 bps */ - -/* - * Transmit descriptors. - */ - -#define AWI_TXD_SIZE 0x18 - -#define AWI_TXD_START 0x00 /* pointer to start of frame */ -#define AWI_TXD_NEXT 0x04 /* pointer to next TXD */ -#define AWI_TXD_LENGTH 0x08 /* length of frame */ -#define AWI_TXD_STATE 0x0a /* state */ - -#define AWI_TXD_ST_OWN 0x80 /* MAC owns this */ -#define AWI_TXD_ST_DONE 0x40 /* MAC is done */ -#define AWI_TXD_ST_REJ 0x20 /* MAC doesn't like */ -#define AWI_TXD_ST_MSDU 0x10 /* MSDU timeout */ -#define AWI_TXD_ST_ABRT 0x08 /* TX aborted */ -#define AWI_TXD_ST_RETURNED 0x04 /* TX returned */ -#define AWI_TXD_ST_RETRY 0x02 /* TX retries exceeded */ -#define AWI_TXD_ST_ERROR 0x01 /* TX error */ - -#define AWI_TXD_RATE 0x0b /* rate */ - -#define AWI_RATE_1MBIT 10 -#define AWI_RATE_2MBIT 20 - -#define AWI_TXD_NDA 0x0c /* num DIFS attempts */ -#define AWI_TXD_NDF 0x0d /* num DIFS failures */ -#define AWI_TXD_NSA 0x0e /* num SIFS attempts */ -#define AWI_TXD_NSF 0x0f /* num SIFS failures */ - -#define AWI_TXD_NRA 0x14 /* num RTS attempts */ -#define AWI_TXD_NDTA 0x15 /* num data attempts */ -#define AWI_TXD_CTL 0x16 /* control */ - -#define AWI_TXD_CTL_PSN 0x80 /* preserve sequence in MAC frame */ -#define AWI_TXD_CTL_BURST 0x02 /* host is doing 802.11 fragmt. */ -#define AWI_TXD_CTL_FRAGS 0x01 /* override normal fragmentation */ - -/* - * MIB structures. - */ - -#define AWI_ESS_ID_SIZE (IEEE80211_NWID_LEN+2) -struct awi_mib_local { - u_int8_t Fragmentation_Dis; - u_int8_t Add_PLCP_Dis; - u_int8_t MAC_Hdr_Prsv; - u_int8_t Rx_Mgmt_Que_En; - u_int8_t Re_Assembly_Dis; - u_int8_t Strip_PLCP_Dis; - u_int8_t Rx_Error_Dis; - u_int8_t Power_Saving_Mode_Dis; - u_int8_t Accept_All_Multicast_Dis; - u_int8_t Check_Seq_Cntl_Dis; - u_int8_t Flush_CFP_Queue_On_CF_End; - u_int8_t Network_Mode; - u_int8_t PWD_Lvl; - u_int8_t CFP_Mode; - u_int8_t Tx_Buffer_Offset[4]; - u_int8_t Tx_Buffer_Size[4]; - u_int8_t Rx_Buffer_Offset[4]; - u_int8_t Rx_Buffer_Size[4]; - u_int8_t Acting_as_AP; - u_int8_t Fill_CFP; -} __attribute__((__packed__)); - -struct awi_mib_mac { - u_int8_t _Reserved1[2]; - u_int8_t _Reserved2[2]; - u_int8_t aRTS_Threshold[2]; - u_int8_t aCW_max[2]; - u_int8_t aCW_min[2]; - u_int8_t aPromiscuous_Enable; - u_int8_t _Reserved3; - u_int8_t _Reserved4[4]; - u_int8_t aShort_Retry_Limit; - u_int8_t aLong_Retry_Limit; - u_int8_t aMax_Frame_Length[2]; - u_int8_t aFragmentation_Threshold[2]; - u_int8_t aProbe_Delay[2]; - u_int8_t aMin_Probe_Response_Time[2]; - u_int8_t aMax_Probe_Response_Time[2]; - u_int8_t aMax_Transmit_MSDU_Lifetime[4]; - u_int8_t aMax_Receive_MSDU_Lifetime[4]; - u_int8_t aStation_Basic_Rate[2]; - u_int8_t aDesired_ESS_ID[AWI_ESS_ID_SIZE]; -} __attribute__((__packed__)); - -struct awi_mib_stat { - u_int8_t aTransmitted_MPDU_Count[4]; - u_int8_t aTransmitted_MSDU_Count[4]; - u_int8_t aOctets_Transmitted_Cnt[4]; - u_int8_t aMulticast_Transmitted_Frame_Count[2]; - u_int8_t aBroadcast_Transmitted_Frame_Count[2]; - u_int8_t aFailed_Count[4]; - u_int8_t aRetry_Count[4]; - u_int8_t aMultiple_Retry_Count[4]; - u_int8_t aFrame_Duplicate_Count[4]; - u_int8_t aRTS_Success_Count[4]; - u_int8_t aRTS_Failure_Count[4]; - u_int8_t aACK_Failure_Count[4]; - u_int8_t aReceived_Frame_Count [4]; - u_int8_t aOctets_Received_Count[4]; - u_int8_t aMulticast_Received_Count[2]; - u_int8_t aBroadcast_Received_Count[2]; - u_int8_t aFCS_Error_Count[4]; - u_int8_t aError_Count[4]; - u_int8_t aWEP_Undecryptable_Count[4]; -} __attribute__((__packed__)); - -struct awi_mib_mgt { - u_int8_t aPower_Mgt_Mode; - u_int8_t aScan_Mode; -#define AWI_SCAN_PASSIVE 0x00 -#define AWI_SCAN_ACTIVE 0x01 -#define AWI_SCAN_BACKGROUND 0x02 - u_int8_t aScan_State; - u_int8_t aDTIM_Period; - u_int8_t aATIM_Window[2]; - u_int8_t Wep_Required; -#define AWI_WEP_ON 0x10 -#define AWI_WEP_OFF 0x00 - u_int8_t _Reserved1; - u_int8_t aBeacon_Period[2]; - u_int8_t aPassive_Scan_Duration[2]; - u_int8_t aListen_Interval[2]; - u_int8_t aMedium_Occupancy_Limit[2]; - u_int8_t aMax_MPDU_Time[2]; - u_int8_t aCFP_Max_Duration[2]; - u_int8_t aCFP_Rate; - u_int8_t Do_Not_Receive_DTIMs; - u_int8_t aStation_ID[2]; - u_int8_t aCurrent_BSS_ID[ETHER_ADDR_LEN]; - u_int8_t aCurrent_ESS_ID[AWI_ESS_ID_SIZE]; -} __attribute__((__packed__)); - -#define AWI_GROUP_ADDR_SIZE 4 -struct awi_mib_addr { - u_int8_t aMAC_Address[ETHER_ADDR_LEN]; - u_int8_t aGroup_Addresses[AWI_GROUP_ADDR_SIZE][ETHER_ADDR_LEN]; - u_int8_t aTransmit_Enable_Status; - u_int8_t _Reserved1; -} __attribute__((__packed__)); - -#define AWI_PWR_LEVEL_SIZE 4 -struct awi_mib_phy { - u_int8_t aSlot_Time[2]; - u_int8_t aSIFS[2]; - u_int8_t aMPDU_Maximum[2]; - u_int8_t aHop_Time[2]; - u_int8_t aSuprt_Data_Rates[4]; - u_int8_t aCurrent_Reg_Domain; -#define AWI_REG_DOMAIN_US 0x10 -#define AWI_REG_DOMAIN_CA 0x20 -#define AWI_REG_DOMAIN_EU 0x30 -#define AWI_REG_DOMAIN_ES 0x31 -#define AWI_REG_DOMAIN_FR 0x32 -#define AWI_REG_DOMAIN_JP 0x40 - u_int8_t aPreamble_Lngth; - u_int8_t aPLCP_Hdr_Lngth; - u_int8_t Pwr_Up_Time[AWI_PWR_LEVEL_SIZE][2]; - u_int8_t IEEE_PHY_Type; -#define AWI_PHY_TYPE_FH 1 -#define AWI_PHY_TYPE_DS 2 -#define AWI_PHY_TYPE_IR 3 - u_int8_t RCR_33A_Bits[8]; -} __attribute__((__packed__)); - -#endif /* _DEV_IC_AWIREG_H */ diff --git a/sys/dev/awi/awivar.h b/sys/dev/awi/awivar.h deleted file mode 100644 index 762d1dad4d83..000000000000 --- a/sys/dev/awi/awivar.h +++ /dev/null @@ -1,161 +0,0 @@ -/* $NetBSD: awivar.h,v 1.20 2004/01/15 09:39:15 onoe Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * 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 NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 _DEV_IC_AWIVAR_H -#define _DEV_IC_AWIVAR_H - -/* timer values in msec */ -#define AWI_SELFTEST_TIMEOUT 5000 -#define AWI_CMD_TIMEOUT 2000 -#define AWI_LOCKOUT_TIMEOUT 50 -#define AWI_ASCAN_DURATION 100 -#define AWI_ASCAN_WAIT 3000 -#define AWI_PSCAN_DURATION 200 -#define AWI_PSCAN_WAIT 5000 -#define AWI_TRANS_TIMEOUT 5000 - -#define AWI_NTXBUFS 4 - -enum awi_sub_state { - AWI_ST_NONE, - AWI_ST_SCAN_INIT, - AWI_ST_SCAN_SETMIB, - AWI_ST_SCAN_SCCMD, - AWI_ST_SUB_INIT, - AWI_ST_SUB_SETSS, - AWI_ST_SUB_SYNC -}; - -#define AWI_WAIT 0 /* must wait for completion */ -#define AWI_NOWAIT 1 /* do not wait */ - -struct awi_chanset { - u_int8_t cs_type; - u_int8_t cs_region; - u_int8_t cs_min; - u_int8_t cs_max; - u_int8_t cs_def; -}; - -struct awi_softc { -#ifdef __NetBSD__ - struct device sc_dev; - void (*sc_power)(struct awi_softc *, int); -#endif -#ifdef __FreeBSD__ - struct arpcom sc_arp; - device_t sc_dev; -#endif - struct am79c930_softc sc_chip; - struct ieee80211com sc_ic; - u_char sc_banner[AWI_BANNER_LEN]; - int (*sc_enable)(struct awi_softc *); - void (*sc_disable)(struct awi_softc *); - - int (*sc_newstate)(struct ieee80211com *, - enum ieee80211_state, int); - void (*sc_recv_mgmt)(struct ieee80211com *, - struct mbuf *, struct ieee80211_node *, - int, int, int, u_int32_t); - int (*sc_send_mgmt)(struct ieee80211com *, - struct ieee80211_node *, int, int); - - void *sc_sdhook; /* shutdown hook */ - void *sc_powerhook; /* power management hook */ - unsigned int sc_attached:1, - sc_enabled:1, - sc_busy:1, - sc_cansleep:1, - sc_enab_intr:1, - sc_adhoc_ap:1, - sc_invalid:1; - enum ieee80211_state sc_nstate; - enum awi_sub_state sc_substate; - int sc_sleep_cnt; - u_int8_t sc_cmd_inprog; - u_int8_t sc_cur_chan; - - int sc_rx_timer; - u_int32_t sc_rxdoff; - u_int32_t sc_rxmoff; - struct mbuf *sc_rxpend; - - int sc_tx_timer; - u_int32_t sc_txbase; - u_int32_t sc_txend; - u_int32_t sc_txnext; - u_int32_t sc_txdone; - - struct awi_mib_local sc_mib_local; - struct awi_mib_addr sc_mib_addr; - struct awi_mib_mac sc_mib_mac; - struct awi_mib_stat sc_mib_stat; - struct awi_mib_mgt sc_mib_mgt; - struct awi_mib_phy sc_mib_phy; -}; - -#define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off) -#define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off) -#define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off) -#define awi_read_bytes(sc, off, ptr, len) \ - ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len) - -#define awi_write_1(sc, off, val) \ - ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val) -#define awi_write_2(sc, off, val) \ - ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val) -#define awi_write_4(sc, off, val) \ - ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val) -#define awi_write_bytes(sc, off, ptr, len) \ - ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len) - -#define awi_drvstate(sc, state) \ - awi_write_1(sc, AWI_DRIVERSTATE, \ - ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED)) - -int awi_attach(struct awi_softc *); -int awi_detach(struct awi_softc *); -#ifdef __NetBSD__ -int awi_activate(struct device *, enum devact); -void awi_power(int, void *); -#endif -void awi_shutdown(void *); -int awi_intr(void *); - -#endif /* _DEV_IC_AWIVAR_H */ diff --git a/sys/dev/awi/if_awi_pccard.c b/sys/dev/awi/if_awi_pccard.c deleted file mode 100644 index 815b15bcbaed..000000000000 --- a/sys/dev/awi/if_awi_pccard.c +++ /dev/null @@ -1,283 +0,0 @@ -/*- - * Copyright (c) 2000 Atsushi Onoe - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include "card_if.h" -#include "pccarddevs.h" - -struct awi_pccard_softc { - struct awi_softc sc_awi; - - u_int8_t sc_version[AWI_BANNER_LEN]; - int sc_intr_mask; - void *sc_intrhand; - struct resource *sc_irq_res; - int sc_irq_rid; - struct resource *sc_port_res; - int sc_port_rid; - struct resource *sc_mem_res; - int sc_mem_rid; -}; - -static const struct pccard_product awi_pccard_products[] = { - PCMCIA_CARD(AMD, AM79C930), - PCMCIA_CARD(BAY, STACK_650), - PCMCIA_CARD(BAY, STACK_660), - PCMCIA_CARD(BAY, SURFER_PRO), - PCMCIA_CARD(ICOM, SL200), - PCMCIA_CARD(NOKIA, C020_WLAN), - PCMCIA_CARD(FARALLON, SKYLINE), - PCMCIA_CARD(ZOOM, AIR_4000), - { NULL } -}; - -static int awi_pccard_probe(device_t); -static int awi_pccard_attach(device_t); -static int awi_pccard_detach(device_t); -static void awi_pccard_shutdown(device_t); -static int awi_pccard_enable(struct awi_softc *); -static void awi_pccard_disable(struct awi_softc *); - -static int -awi_pccard_probe(device_t dev) -{ - const struct pccard_product *pp; - - if ((pp = pccard_product_lookup(dev, awi_pccard_products, - sizeof(awi_pccard_products[0]), NULL)) != NULL) { - if (pp->pp_name != NULL) - device_set_desc(dev, pp->pp_name); - return 0; - } - return ENXIO; -} - -/* - * Initialize the device - called from Slot manager. - */ -static int -awi_pccard_attach(device_t dev) -{ - struct awi_pccard_softc *psc = device_get_softc(dev); - struct awi_softc *sc = &psc->sc_awi; - int error = 0; - - psc->sc_port_rid = 0; - psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, - &psc->sc_port_rid, 0, ~0, AM79C930_IO_SIZE, - rman_make_alignment_flags(AM79C930_IO_ALIGN) | RF_ACTIVE); - if (!psc->sc_port_res) - return ENOMEM; - - sc->sc_chip.sc_iot = rman_get_bustag(psc->sc_port_res); - sc->sc_chip.sc_ioh = rman_get_bushandle(psc->sc_port_res); - am79c930_chip_init(&sc->sc_chip, 0); - tsleep(sc, PWAIT, "awiprb", 1); - - awi_read_bytes(sc, AWI_BANNER, psc->sc_version, AWI_BANNER_LEN); - if (memcmp(psc->sc_version, "PCnetMobile:", 12) != 0) { - device_printf(dev, "awi_pccard_probe: bad banner: %12D\n", - psc->sc_version, " "); - error = ENXIO; - } else - device_set_desc(dev, psc->sc_version); - - psc->sc_irq_res = 0; - psc->sc_mem_res = 0; - psc->sc_intrhand = 0; - - psc->sc_port_rid = 0; - psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, - &psc->sc_port_rid, 0, ~0, 16, RF_ACTIVE); - if (!psc->sc_port_res) { - device_printf(dev, "awi_pccard_attach: port alloc failed\n"); - goto fail; - } - sc->sc_chip.sc_iot = rman_get_bustag(psc->sc_port_res); - sc->sc_chip.sc_ioh = rman_get_bushandle(psc->sc_port_res); - - psc->sc_irq_rid = 0; - psc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &psc->sc_irq_rid, RF_ACTIVE); - if (!psc->sc_irq_res) { - device_printf(dev, "awi_pccard_attach: irq alloc failed\n"); - goto fail; - } - - psc->sc_mem_rid = 0; -#if 1 - /* - * XXX: awi needs to access memory with 8bit, - * but OLDCARD apparently maps memory with MDF_16BITS flag. - * So memory mapped access is disabled and use IO port instead. - * XXX: Should check to see if this is true of NEWCARD - */ - psc->sc_mem_res = 0; -#else - psc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, - &psc->sc_mem_rid, 0, ~0, 0x8000, RF_ACTIVE); -#endif - if (psc->sc_mem_res) { - sc->sc_chip.sc_memt = rman_get_bustag(psc->sc_mem_res); - sc->sc_chip.sc_memh = rman_get_bushandle(psc->sc_mem_res); - am79c930_chip_init(&sc->sc_chip, 1); - } else - am79c930_chip_init(&sc->sc_chip, 0); - - sc->sc_dev = dev; - sc->sc_cansleep = 1; - sc->sc_enable = awi_pccard_enable; - sc->sc_disable = awi_pccard_disable; - - if (awi_pccard_enable(sc)) - goto fail; - sc->sc_enabled = 1; - error = awi_attach(sc); - sc->sc_enabled = 0; /*XXX*/ - awi_pccard_disable(sc); - if (error == 0) - return 0; - device_printf(dev, "awi_pccard_attach: awi_attach failed\n"); - - fail: - awi_pccard_detach(dev); - if (error == 0) - error = ENXIO; - return error; -} - -static int -awi_pccard_detach(device_t dev) -{ - struct awi_pccard_softc *psc = device_get_softc(dev); - struct awi_softc *sc = &psc->sc_awi; - - awi_detach(sc); - if (psc->sc_mem_res) { - bus_release_resource(dev, SYS_RES_MEMORY, psc->sc_mem_rid, - psc->sc_mem_res); - psc->sc_mem_res = 0; - } - if (psc->sc_irq_res) { - bus_release_resource(dev, SYS_RES_IRQ, psc->sc_irq_rid, - psc->sc_irq_res); - psc->sc_irq_res = 0; - } - if (psc->sc_port_res) { - bus_release_resource(dev, SYS_RES_IOPORT, psc->sc_port_rid, - psc->sc_port_res); - psc->sc_port_res = 0; - } - return 0; -} - -static void -awi_pccard_shutdown(device_t dev) -{ - struct awi_pccard_softc *psc = device_get_softc(dev); - struct awi_softc *sc = &psc->sc_awi; - - awi_shutdown(sc); -} - -static int -awi_pccard_enable(struct awi_softc *sc) -{ - device_t dev = sc->sc_dev; - struct awi_pccard_softc *psc = device_get_softc(dev); - int error; - - if (psc->sc_intrhand == 0) { - error = bus_setup_intr(dev, psc->sc_irq_res, INTR_TYPE_NET, - NULL, (void (*)(void *))awi_intr, sc, &psc->sc_intrhand); - if (error) { - device_printf(dev, - "couldn't establish interrupt error=%d\n", error); - return error; - } - } - return 0; -} - -static void -awi_pccard_disable(struct awi_softc *sc) -{ - device_t dev = sc->sc_dev; - struct awi_pccard_softc *psc = device_get_softc(dev); - - if (psc->sc_intrhand) { - bus_teardown_intr(dev, psc->sc_irq_res, psc->sc_intrhand); - psc->sc_intrhand = 0; - } -} - -static device_method_t awi_pccard_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, awi_pccard_probe), - DEVMETHOD(device_attach, awi_pccard_attach), - DEVMETHOD(device_detach, awi_pccard_detach), - DEVMETHOD(device_shutdown, awi_pccard_shutdown), - - { 0, 0 } -}; - -static driver_t awi_pccard_driver = { - "awi", - awi_pccard_methods, - sizeof(struct awi_pccard_softc), -}; - -extern devclass_t awi_devclass; - -DRIVER_MODULE(awi, pccard, awi_pccard_driver, awi_devclass, 0, 0); -MODULE_DEPEND(awi, wlan, 1, 1, 1); diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index b5a45a7ed0e0..36d68d169a95 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -259,7 +259,6 @@ device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) device ath_rate_sample # SampleRate tx rate control for ath -device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. #device wl # Older non 802.11 Wavelan wireless NIC. diff --git a/sys/i386/conf/PAE b/sys/i386/conf/PAE index 30fe7cc8a746..bd1677b0dcaf 100644 --- a/sys/i386/conf/PAE +++ b/sys/i386/conf/PAE @@ -80,6 +80,5 @@ nodevice an nodevice ath # Atheros pci/cardbus NIC's nodevice ath_hal # Atheros HAL (Hardware Access Layer) nodevice ath_rate_sample # SampleRate tx rate control for ath -nodevice awi nodevice ral nodevice wi diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 249042f6ebcf..b5de9b8e0c54 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -33,7 +33,6 @@ SUBDIR= ${_3dfx} \ ${_ath_rate_sample} \ aue \ ${_auxio} \ - ${_awi} \ axe \ bce \ bfe \ @@ -377,7 +376,6 @@ _ath_hal= ath_hal _ath_rate_amrr= ath_rate_amrr _ath_rate_onoe= ath_rate_onoe _ath_rate_sample=ath_rate_sample -_awi= awi _bktr= bktr _cardbus= cardbus _cbb= cbb diff --git a/sys/modules/awi/Makefile b/sys/modules/awi/Makefile deleted file mode 100644 index 228d9c13023b..000000000000 --- a/sys/modules/awi/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../../dev/awi - -KMOD= if_awi -SRCS= am79c930.c awi.c if_awi_pccard.c -SRCS+= bus_if.h card_if.h device_if.h opt_inet.h pccarddevs.h - -.if !defined(KERNBUILDDIR) -opt_inet.h: - echo "#define INET 1" > opt_inet.h -.endif - -.include diff --git a/sys/pc98/conf/GENERIC b/sys/pc98/conf/GENERIC index b8fdcedee99f..91d582d863ed 100644 --- a/sys/pc98/conf/GENERIC +++ b/sys/pc98/conf/GENERIC @@ -221,7 +221,6 @@ device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) device ath_rate_sample # SampleRate tx rate control for ath -device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. #device wl # Older non 802.11 Wavelan wireless NIC.