Restructuring the repository layout in response to ath5k.

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@2721 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
mrenzmann 2007-10-04 13:07:51 +00:00
commit 2c0d8db912
209 changed files with 226850 additions and 0 deletions

70
BuildCaps.inc Normal file
View File

@ -0,0 +1,70 @@
#
# defaults
#
ifndef ATH_CAP_SUPERG_FF
export ATH_CAP_SUPERG_FF=1
endif
ifndef ATH_CAP_DYNTURBO
export ATH_CAP_DYNTURBO=1
endif
ifndef ATH_CAP_SUPERG_COMP
export ATH_CAP_SUPERG_COMP=0
endif
ifndef ATH_CAP_XR
export ATH_CAP_XR=1
endif
ifndef ATH_CAP_TPC
export ATH_CAP_TPC=1
endif
ifndef ATH_CAP_TX99
export ATH_CAP_TX99=0
endif
# WARNING: The use of these extensions may introduce a security risk (someone can peek/poke registers on your Atheros device)
ifndef ATH_REVERSE_ENGINEERING
export ATH_REVERSE_ENGINEERING=0
endif
ifndef ATH_REVERSE_ENGINEERING_WITH_NO_FEAR
export ATH_REVERSE_ENGINEERING_WITH_NO_FEAR=0
endif
#
# directives
#
ifneq ($(strip $(ATH_CAP_SUPERG_FF)),0)
COPTS+= -DATH_SUPERG_FF=1
endif
ifneq ($(strip $(ATH_CAP_DYNTURBO)),0)
COPTS+= -DATH_SUPERG_DYNTURBO=1 -DATH_TURBO_SCAN=1
endif
ifneq ($(strip $(ATH_CAP_SUPERG_COMP)),0)
COPTS+= -DATH_SUPERG_COMP=1
endif
ifneq ($(strip $(ATH_CAP_XR)),0)
COPTS+= -DATH_SUPERG_XR=1
endif
ifneq ($(strip $(ATH_CAP_TPC)),0)
COPTS+= -DATH_CAP_TPC=1
endif
ifneq ($(strip $(ATH_CAP_TX99)),0)
COPTS+= -DATH_TX99_DIAG=1
endif
# WARNING: The use of these extensions may introduce a security risk (someone can peek/poke registers on your Atheros device)
ifneq ($(strip $(ATH_REVERSE_ENGINEERING)),0)
COPTS+= -DATH_REVERSE_ENGINEERING=1
endif
ifneq ($(strip $(ATH_REVERSE_ENGINEERING_WITH_NO_FEAR)),0)
COPTS+= -DATH_REVERSE_ENGINEERING_WITH_NO_FEAR=1 -DATH_REVERSE_ENGINEERING=1
endif

40
COPYRIGHT Normal file
View File

@ -0,0 +1,40 @@
All files contained in this distribution are covered by the following
copyright unless explicitly identified otherwise.
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id: COPYRIGHT,v 1.4 2004/01/13 18:05:41 samleffler Exp $
*/

210
INSTALL Normal file
View File

@ -0,0 +1,210 @@
MADWIFI: Multimode Atheros Driver for WiFi on Linux (VAP branch)
================================================================
* Copyright (c) 2002-2005 Sam Leffler. All rights reserved.
Read the file COPYRIGHT for the complete copyright.
Requirements
------------
- Configured kernel sources of the target kernel. Some Linux
distributions provide headers, makefiles and configuration data - it
should suffice.
- Wireless Extensions support (14 or later, 17 preferred) - option
CONFIG_NET_RADIO in kernel .config file.
- Sysctl support - option CONFIG_SYSCTL in kernel .config file.
- Crypto API support - option CONFIG_CRYPTO in kernel .config file (AES
support is used if present, otherwise the AES-CCMP cipher module falls
back to a private implementation).
- gcc of same version that was used to compile the kernel. At least
make sure that the first two version numbers or the compiler are the
same (e.g. it's OK to use gcc 3.4.6 to compile MadWifi if the kernel
was compiled by gcc 3.4.2). Ignoring this rule will cause "Invalid
module format" errors during module load.
Linux 2.4.x kernels starting with 2.4.22 and 2.6 kernels should work
without problems. Due to quick pace of Linux development, there is no
way compatibility with the future 2.6 kernels can be ensured. However,
the latest 2.6 kernel at the time of the release should be expected to
work.
Automatic module loading support (CONFIG_KMOD) is recommended; otherwise,
care will have to be taken to manually load needed modules.
Building the driver
-------------------
The driver is built using the Linux kernel build mechanism. This means
you must have some part of the kernel source distribution installed on
the machine where you want to build the driver. In particular, the
kernel include files, makefiles, build scripts and configuration must be
available.
This will be present if you built your kernel from source. Otherwise
you may need to install an additional kernel development package from
your distribution that would match your kernel. For example, the
development package for the default kernel is called linux-headers on
Debian and kernel-devel on Fedora Core. Installing a package with full
kernel sources should not be generally necessary.
Note: in the following examples "$" stands for your system prompt;
you're not expected to type that as part of the actual command. "#"
stands for the command prompt when the commands must be executed by
root.
Most people can just type:
$ make
in the top-level MadWifi source directory to build all the modules for
the currently running system.
You MUST do a "make clean" before compiling for a different version of
Linux, e.g. building for 2.6 after building for 2.4.
If you want to compile MadWifi for a different kernel, you need to
specify the location of the kernel build tree, e.g.:
$ make KERNELPATH=/usr/src/linux-2.6.3
Note that you can also specify this path by setting an environment
variable; e.g.
$ export KERNELPATH=/usr/src/linux-2.6.3
$ make
If the kernel was built outside the source directory, KERNELPATH should
point to the output directory where .config is located, not to the
sources.
MadWifi currently provides four different rate control algorithms,
ONOE, AMRR, SAMPLE and MINSTREL. SAMPLE and MINSTREL are both very
advanced, but MINSTREL is quite new. Consequently, SAMPLE is used by
default. In order to make MadWifi use e.g. AMRR instead, you have to
specify that as the module parameter e.g.
# modprobe ath_pci ratectl=amrr
NOTE: Changing the rate control is only required (and recommended) for
users who want to setup an access point using MadWifi in difficult
(e.g. lossy) environments and who know what they are doing.
This distribution includes support for a variety of target platforms.
Because of the binary nature of the HAL not all platforms are supported
(the list grows as time permits). The supported target platforms can be
found with:
$ ls hal/public/*.inc
A target specifies the CPU architecture, byte order (unless implied by
the CPU), and the ABI/file format. For most popular platforms, the
build system will find the appropriate files. When cross-compiling or
compiling for less common platforms, the target platform may need to be
specified using the TARGET variable, e.g:
$ make TARGET=armv4-le-elf
Consult the contents of the .inc file to find out what the target
platform is and what toolchain was used to build the HAL object module.
Beware of mixing toolchains; some target platforms require that the HAL
and driver be built with the same toolchain (i.e. compiler, assembler,
and linker) and the same compiler flags. If you get warnings about
incompatible compiler flags, chances are that you are compiling for a
wrong target or using an incompatible compiler.
Cross-compiling
---------------
The build system is designed to support cross-compiling without any
modification to the distribution files. It should be sufficient to
specify any parameters on the make command line.
In most cases, only KERNELPATH and CROSS_COMPILE need to be defined.
CROSS_COMPILE is the prefix for cross-compiling tools. For instance, if
the cross compiler is called arm-linux-gcc, set CROSS_COMPILE to
"arm-linux-":
$ make KERNELPATH=/usr/src/linux-arm CROSS_COMPILE=arm-linux-
The build system determines ARCH and TARGET based on the .config file in
the Linux build tree. TARGET still may need to be provided on the
command line some uncommon systems. If ARCH is determined incorrectly,
please report it.
If the compiler needs additional flags to compile userspace binaries,
you can redefine CC to include those flags.
When installing MadWifi, set DESTDIR to the root of the target
filesystem, so that the cross-compiled binaries don't overwrite the
native ones.
Loading the modules
-------------------
Building the software will generate numerous loadable modules:
ath_pci Atheros driver for PCI/Cardbus devices
ath_hal Atheros HAL
wlan 802.11 support layer
wlan_wep WEP cipher support
wlan_tkip TKIP cipher support
wlan_ccmp AES-CCMP cipher support
wlan_xauth external authenticator
wlan_acl MAC ACL support for AP operation
wlan_scan_ap AP scanning support
wlan_scan_sta station scanning support
ath_rate_onoe ONOE rate control
ath_rate_amrr AMRR rate control
ath_rate_sample SAMPLE rate control
The ath_pci module must be loaded either manually or by the system, e.g.
through the hotplug or card manager support. The remaining modules are
loaded automatically as needed, so after doing a "make install" you only
need to run following:
# modprobe ath_pci
For automatic module loading you may need to modify your system's
configuration files so the necessary modules are loaded when an Atheros
device is recognized. The exact procedure varies from system to system.
There are module parameters available to fit your needs, e.g. you can
set the countrycode manually if your card's EEPROM does not contain the
correct one for your location. See
http://www.unicode.org/onlinedat/countries.html to find your code.
To activate German frequencies you would specify:
# modprobe ath_pci countrycode=276
To see all available module parameters type:
$ modinfo ath_pci
Integrating into the kernel sources
-----------------------------------
It is also possible to patch Linux kernel sources to integrate MadWifi
directly into the kernel tree. This allows building MadWifi as part of
the kernel. This could be useful for embedded systems that don't
support loadable modules. Please refer to patch-kernel/README for
details.
Further information
-------------------
Further information on how to work with the driver can be found in the
file README. In addition, the project's wiki has a lot of valuable
information:
http://madwifi.org/

201
Makefile Normal file
View File

@ -0,0 +1,201 @@
#
# Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/Makefile $
#
#
# Makefile for the HAL-based Atheros driver.
#
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)
ifneq (svnversion.h,$(MAKECMDGOALS))
include $(TOP)/Makefile.inc
endif
DIRS_MODULES = $(ATH) $(ATH_HAL) $(ATH_RATE) $(WLAN)
obj-y := ath/ ath_hal/ ath_rate/ net80211/
all: modules tools
modules: configcheck svnversion.h
ifdef LINUX24
for i in $(DIRS_MODULES); do \
$(MAKE) -C $$i || exit 1; \
done
else
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
endif
.PHONY: svnversion.h
svnversion.h:
@if [ -d .svn ]; then \
ver=`svnversion -nc . | sed -e 's/^[^:]*://;s/[A-Za-z]//'`; \
echo "#define SVNVERSION \"svn r$$ver\"" > $@.tmp; \
elif [ -s SNAPSHOT ]; then \
ver=`sed -e '/^Revision: */!d;s///;q' SNAPSHOT`; \
echo "#define SVNVERSION \"svn r$$ver\"" > $@.tmp; \
else \
touch $@.tmp; \
fi || exit 1; \
diff $@ $@.tmp >/dev/null 2>&1 || cp -f $@.tmp $@; rm -f $@.tmp
# conflicts with the 'tools' subdirectory
.PHONY: tools
tools:
$(MAKE) -C $(TOOLS) all || exit 1
install: install-modules install-tools
install-modules: modules
@# check if there are modules left from an old installation
@# might cause make to abort the build
sh scripts/find-madwifi-modules.sh -r $(KERNELRELEASE) $(DESTDIR)
for i in $(DIRS_MODULES); do \
$(MAKE) -C $$i install || exit 1; \
done
ifeq ($(DESTDIR),)
(export KMODPATH=$(KMODPATH); /sbin/depmod -ae $(KERNELRELEASE))
endif
install-tools: tools
$(MAKE) -C $(TOOLS) install || exit 1
uninstall: uninstall-tools uninstall-modules
uninstall-modules:
sh scripts/find-madwifi-modules.sh -r $(KERNELRELEASE) $(DESTDIR)
list-modules: find-modules
find-modules:
sh scripts/find-madwifi-modules.sh -l $(KERNELRELEASE)
uninstall-tools:
$(MAKE) -C $(TOOLS) uninstall
reinstall: uninstall install
reinstall-tools: uninstall-tools install-tools
reinstall-modules: uninstall-modules install-modules
clean:
for i in $(DIRS_MODULES); do \
$(MAKE) -C $$i clean; \
done
-$(MAKE) -C $(TOOLS) clean
rm -rf .tmp_versions
rm -f *.symvers svnversion.h
info:
@echo "The following settings will be used for compilation:"
@echo "TARGET : $(TARGET)"
@echo "ARCH : $(ARCH)"
@echo "BUS : $(BUS)"
@if [ -n "$(TOOLPATH)" ]; then \
@echo "TOOLPATH : $(TOOLPATH)"; \
fi
@echo "KERNELRELEASE: $(KERNELRELEASE)"
@echo "KERNELPATH : $(KERNELPATH)"
@echo "KERNELCONF : $(KERNELCONF)"
@echo "KMODPATH : $(KMODPATH)"
@echo "KMODSUF : $(KMODSUF)"
sanitycheck:
@echo -n "Checking requirements... "
@# check if specified rate control is available
@if [ ! -d $(ATH_RATE) ]; then \
echo "FAILED"; \
echo "Selected rate control $(ATH_RATE) not available."; \
exit 1; \
fi
@echo "ok."
.PHONY: release
release:
sh scripts/make-release.bash
.PHONY: unload
unload:
bash scripts/madwifi-unload
configcheck: sanitycheck
@echo -n "Checking kernel configuration... "
@# check version of kernel
@echo $(KERNELRELEASE) | grep -q -i '^[2-9]\.[4-9]\.' || { \
echo "FAILED"; \
echo "Only kernel versions 2.4.x and above are supported."; \
echo "You have $(KERNELRELEASE)."; \
exit 1; \
}
@# check kernel configuration
@if [ -z "$(CONFIG_SYSCTL)" ]; then \
echo "FAILED"; \
echo "Please enable sysctl support."; \
exit 1; \
fi
ifeq ($(strip $(BUS)),PCI)
@# check PCI support
@if [ -z "$(CONFIG_PCI)" ]; then \
echo "FAILED"; \
echo "Please enable PCI support."; \
exit 1; \
fi
endif
@# check wireless extensions support is enabled
@if [ -z "$(CONFIG_NET_RADIO)$(CONFIG_WIRELESS_EXT)" ]; then \
echo "FAILED"; \
echo "Please enable wireless extensions."; \
exit 1; \
fi
@# check crypto support is enabled
@if [ -z "$(CONFIG_CRYPTO)" ]; then \
echo "FAILED"; \
echo "Please enable crypto API."; \
exit 1; \
fi
@echo "ok."

213
Makefile.inc Normal file
View File

@ -0,0 +1,213 @@
#
# Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/Makefile.inc#11 $
#
# other locales sometimes cause trouble
export LC_ALL = POSIX
# BUS defines the bus type to which the wireless devices is attached.
# Currently, the valid BUS types are PCI and AHB. If BUS is not
# defined, then, we assume the bus type is PCI
ifndef BUS
BUS= PCI
endif
# DESTDIR is used as path prefix during installation.
DESTDIR ?=
# KERNELPATH is the path to the Linux kernel build tree. Unless a
# separate build directory was used for the kernel build, it's the same
# as the kernel source tree. KERNELPATH is used to access the kernel
# configuration, include files and the build system. To build for
# another kernel, set KERNELPATH manually, for example with:
# make KERNELPATH=/path/to/kernel/source
# The default KERNELPATH points to the directory where the currently
# running kernel was compiled. Note that the configuration and the
# version of the kernel tree might have changed since then.
ifeq ($(wildcard $(KERNELPATH)),)
KERNELPATH = /lib/modules/$(shell uname -r)/build
# sanity check: does KERNELPATH exist?
ifeq ($(shell cd $(KERNELPATH) && pwd),)
$(error $(KERNELPATH) is missing, please set KERNELPATH)
endif
export KERNELPATH
endif
# KERNELRELEASE is the target kernel's version. It's always taken from
# the kernel build tree. Kernel Makefile doesn't always know the exact
# kernel version (especially for vendor stock kernels), so we get it
# from <linux/version.h> instead. But simply grepping it from version.h
# doesn't work, since some distributions have multiple UTS_RELEASE
# in that file.
# This trick has been inspired by the lm_sensors project.
ifndef KERNELRELEASE
KERNELRELEASE := $(shell $(CC) -I $(KERNELPATH)/include -E $(TOP)/kernelversion.c | grep uts_release | cut -f2 -d'"')
ifeq (,$(KERNELRELEASE))
$(error Cannot detect kernel version - please check compiler and KERNELPATH)
endif
endif
# KERNELCONF is the name of the file that holds the configuration
# of the target kernel.
KERNELCONF ?= $(KERNELPATH)/.config
# sanity check: does KERNELCONF exist?
ifeq ($(wildcard $(KERNELCONF)),)
$(error KERNELCONF: $(KERNELCONF) does not exist.)
endif
include $(KERNELCONF)
# Determine architecture of the kernel.
include $(TOP)/scripts/get_arch.mk
export ARCH
# Determine TARGET
include $(TOP)/ath_hal/ah_target.inc
export TARGET
COPTS += -DTARGET='"$(TARGET)"'
# KMODPATH nominates the directory where the modules will be
# installed to
KMODPATH := /lib/modules/$(KERNELRELEASE)/net
# Recognize 2.4.x kernels to support the old build system
ifeq ($(filter-out 2.4%,$(KERNELRELEASE)),)
LINUX24 = y
endif
ifndef LINUX24
KMODSUF := ko
else
export-objs = $(foreach m, $(obj-m), $($(m:.o=-objs)))
list-multi = $(obj-m)
KMODSUF := o
endif
NM= nm
#
# Path to the HAL source code.
#
ifeq ($(HAL),)
HAL= $(TOP)/hal
endif
#
# Path to HAL/OS interface code
#
ATH_HAL= $(TOP)/ath_hal
#
# Path to the 802.11 include files.
#
WLAN= $(TOP)/net80211
#
# Path to the Atheros device driver.
#
ATH= $(TOP)/ath
#
# Path to the rate control algorithms.
#
ATH_RATE= $(TOP)/ath_rate
#
# Path to the userspace utilities.
#
TOOLS= $(TOP)/tools
WARNINGS = -Werror
COPTS+= $(WARNINGS)
INCS= -include $(TOP)/include/compat.h -I$(TOP)/include
# TARGET defines the target platform architecture. It must match one of
# the target platforms supported by the HAL. The default target is the
# host machine architecture. You can override TARGET on the make command
# line or in the environment. See hal/linux/*.inc for the list of
# supported targets.
ifeq (,$(wildcard $(HAL)/public/$(TARGET).inc))
TARGETS=$(basename $(notdir $(wildcard $(HAL)/public/*.inc)))
$(error TARGET $(TARGET) is invalid, valid targets are: $(TARGETS))
endif
# HAL_DEBUG enables HAL debugging code
# At the moment this consists of wrappers around HAL functions so that
# stack traces are more decipherable.
ifdef HAL_DEBUG
COPTS+= -fno-inline
endif
# Don't let HAL mess with the toolchain - save toolchain variables
save_CC := $(CC)
save_LD := $(LD)
save_STRIP := $(STRIP)
save_OBJCOPY := $(OBJCOPY)
save_NM := $(NM)
include $(HAL)/public/$(TARGET).inc
# Restore toolchain variables
CC := $(save_CC)
LD := $(save_LD)
STRIP := $(save_STRIP)
OBJCOPY := $(save_OBJCOPY)
NM := $(save_NM)
include $(TOP)/BuildCaps.inc
# Ensure correct endianess
LDFLAGS += $(LDOPTS)
# Filter out compiler options that are not supported by all compilers
# and that are not needed to ensure compatible architecture and calling
# conventions.
COPTS := $(filter-out -mshort-load-bytes,$(COPTS))
# The following variables will affect developers only, and are used in the
# make-release.bash script.
#
# RELEASE_TMP is used as a temporary store for the files needed to create the
# release tarball. Packaging will take place in TMPDIR/madwifi-release.
# Defaults to /tmp.
RELEASE_TMP=/tmp
# RELEASE_STORE is the (local) directory where the release tarball should be
# stored in. Defaults to the parent directory of the working copy used to
# create the release.
RELEASE_STORE=..
# expose these settings to make-release.bash
export RELEASE_TMP RELEASE_STORE

37
Makefile.kernel Normal file
View File

@ -0,0 +1,37 @@
ifeq ($(VERSION).$(PATCHLEVEL),2.4)
# Linux 2.4 support
O_TARGET := madwifi.o
subdir-$(CONFIG_ATHEROS) += ath ath_hal net80211
subdir-$(CONFIG_ATHEROS_RATE_AMRR) += ath_rate/amrr
subdir-$(CONFIG_ATHEROS_RATE_MINSTREL) += ath_rate/minstrel
subdir-$(CONFIG_ATHEROS_RATE_ONOE) += ath_rate/onoe
subdir-$(CONFIG_ATHEROS_RATE_SAMPLE) += ath_rate/sample
ifeq ($(CONFIG_ATHEROS),y)
obj-$(CONFIG_ATHEROS_RATE_AMRR) += ath_rate/amrr/ath_rate.o
obj-$(CONFIG_ATHEROS_RATE_MINSTREL) += ath_rate/minstrel/ath_rate.o
obj-$(CONFIG_ATHEROS_RATE_ONOE) += ath_rate/onoe/ath_rate.o
obj-$(CONFIG_ATHEROS_RATE_SAMPLE) += ath_rate/sample/ath_rate.o
ifeq ($(strip $(BUS)),AHB)
obj-y += ath/ath_ahb.o
else
obj-y += ath/ath_pci.o
endif
obj-y += ath_hal/ath_hal.o
obj-y += net80211/net80211.o
endif
include $(TOPDIR)/Rules.make
else
# Linux 2.6 support
obj-$(CONFIG_ATHEROS_RATE_AMRR) += ath_rate/amrr/
obj-$(CONFIG_ATHEROS_RATE_MINSTREL) += ath_rate/minstrel/
obj-$(CONFIG_ATHEROS_RATE_ONOE) += ath_rate/onoe/
obj-$(CONFIG_ATHEROS_RATE_SAMPLE) += ath_rate/sample/
obj-$(CONFIG_ATHEROS) += ath/ ath_hal/ net80211/
endif

377
README Normal file
View File

@ -0,0 +1,377 @@
MADWIFI: Multimode Atheros Driver for WiFi on Linux (VAP branch)
================================================================
* Copyright (c) 2002-2005 Sam Leffler. All rights reserved.
Read the file COPYRIGHT for the complete copyright.
WARNING: THIS IS A BETA DISTRIBUTION. THIS SOFTWARE HAS KNOWN PROBLEMS
WARNING: AND LIMITATIONS THAT WILL BE CORRECTED BEFORE A PRODUCTION
WARNING: RELEASE. DON'T BLAME US IF THE SOFTWARE EATS YOUR SYSTEM,
WARNING: DESTROYS YOUR DISK OR MAKES YOUR CORN-FLAKES SOGGY.
WARNING: USE AT YOUR OWN RISK!
Introduction
------------
This software contains a Linux kernel driver for Atheros-based Wireless
LAN devices. The driver supports station, AP, ad-hoc, and monitor modes
of operation. The Atheros driver depends on a device-independent
implementation of the 802.11 protocols that originated in the BSD
community (NetBSD in particular).
The driver functions as a normal network device and uses the Wireless
Extensions API. As such normal Linux tools can and should be used with
it. Where the wireless extensions are lacking private ioctls have been
added.
There is only one driver included here; it supports PCI, MiniPCI and
Cardbus devices - USB devices are currently not supported by this
driver! The driver can be built as a module or linked directly into the
kernel. Note however that the net80211 layer is device-independent;
there is no reason it cannot be used with any 802.11 device (in fact
this is the case on BSD systems).
This software is broken into multiple modules. The Atheros-specific
device support is found in the ath_pci module; it should be loaded when
an Atheros wireless device is recognized. The ath_pci module requires
an additional device specific module, ath_hal, which is described more
below. In addition the driver requires the wlan module which contains
the 802.11 state machine, protocol support, and other device-independent
support needed by any 802.11 device. This code is derived from work
that first appeared in NetBSD and then FreeBSD. The wlan module may
also force the loading of additional modules for crypto support
(wlan_wep, wlan_tkip, wlan_ccmp, etc.), for MAC-based ACL support
(wlan_acl), and for 802.1x authenticator support (wlan_auth,
wlan_radius). The latter modules are only used when operating as an AP.
The crypto modules are loaded when keys of that type are created.
The ath_hal module contains the Atheros Hardware Access Layer (HAL).
This code manages much of the chip-specific operation of the driver.
The HAL is provided in a binary-only form in order to comply with FCC
regulations. In particular, a radio transmitter can only be operated at
power levels and on frequency channels for which it is approved. The
FCC requires that a software-defined radio cannot be configured by the
user to operate outside the approved power levels and frequency
channels. This makes it difficult to open-source code that enforces
limits on the power levels, frequency channels and other parameters of
the radio transmitter. See
http://ftp.fcc.gov/Bureaus/Engineering_Technology/Orders/2001/fcc01264.pdf
for the specific FCC regulation. Because the module is provided in a
binary-only form it is marked "Proprietary"; this means when you load it
you will see messages that your system is now "tainted".
A detailed discussion of the pros and cons of this design can be found
at http://madwifi.org/wiki/HAL
If you wish to use this driver on a platform for which an ath_hal module
is not already provided please contact the author. Note that this is
only necessary for new _architectures_; the HAL is not tied to any
specific version of Linux - in fact the identical HAL binary code is
used unchanged with other operating systems.
Atheros Hardware
----------------
There are currently three "programming generations" of Atheros 802.11
wireless devices (some of these have multiple hardware implementations
but otherwise appear identical to users):
5210 supports 11a only
5211 supports both 11a and 11b
5212 supports 11a, 11b, and 11g
These parts have been incorporated in a variety of retail products
including Cardbus cards from D-Link, Linksys, Netgear, Orinoco, Proxim,
and 3Com; and mini-pci cards from some of these same vendors. In
addition, many laptop vendors use Atheros mini-pci cards for their
built-in wireless support.
For an up-to-date list of cards based on Atheros parts visit:
http://customerproducts.atheros.com/customerproducts
A list of products that have been reported to be supported by MadWifi
can be found here:
http://madwifi.org/wiki/Compatibility
In general, if a device is identified as ``11a only'', it is almost
certain to contain an Atheros 5210 part in it. Most retail a+b products
use the 5211. Many a+b+g combo products use the 5212 though other
vendors have started to offer dual-band support. When in doubt, check
the PCI vendor ID with a tool like lspci, the Atheros vendor ID is
0x168c; e.g.
00:13.0 Ethernet controller: Unknown device 168c:0012 (rev 01)
but beware that some vendors use alternate vendor IDs (e.g 3Com, IBM).
The file hal/ah_devid.h has a list of known PCI IDs.
Building the driver
-------------------
The procedure to build the driver is described in the file INSTALL.
Using the driver
----------------
The driver should support any Atheros-based Cardbus or PCI device. This
version of the driver is managed and controlled by the usual Linux tools
(ifconfig, iwconfig, iwpriv) plus the wlanconfig tool, which is included
with the driver in the tools directory and gets installed on your system
with make install.
First, run "modprobe ath_pci" or the equivalent using "insmod". When
the driver is successfully loaded it creates two devices, named "wifi0"
and "ath0". The output from iwconfig should look like this:
lo no wireless extensions.
wifi0 no wireless extensions.
ath0 IEEE 802.11b ESSID:""
Mode:Managed Channel:0 Access Point: Not-Associated
Bit Rate:0 kb/s Tx-Power:50 dBm Sensitivity=0/3
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=0/94 Signal level=-95 dBm Noise level=-95 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
This driver uses wifi%d only as a placeholder for the physical device,
and will create one wifi device for each wireless NIC in the system.
These wifi devices will reject ifconfig and iwconfig commands. The wifi
interface indicates the existence of a physical MadWifi device, but it
is not of any functional interest other than as the starting point for
VAP creation via wlanconfig (see Virtual AP section below).
By default, an ath%d Managed mode interface is also created. This
device is a "virtual ap" (VAP) of the wifi%d physical device, and is
configurable by the standard networking tools - ifconfig, iwconfig,
iwpriv.
The autocreation function can be manipulated to create any one of the
other supported device types automatically by using the autocreate=mode
option when the ath_pci module is first loaded. The following example
will cause ath%d to be in Master mode:
modprobe ath_pci autocreate=ap
Autocreation can be disabled:
modprobe ath_pci autocreate=none
Please see the following link for more information:
http://madwifi.org/wiki/UserDocs/autocreate
Virtual APs (VAPs) and wlanconfig
---------------------------------
An interesting feature of MadWifi is Virtual AP (VAP) mode, which allows
the operation of multiple concurrent (virtual) access points, and
concurrent interfaces running in both AP and station mode. To
manipulate VAPs, MadWifi comes with a tool called wlanconfig which is
used to create and destroy VAPS with various different modes.
The following examples assume that the "autocreate=none" option has been
parsed to the module at load time. This allows fine control over
management of VAPs, as the creation of a Managed mode station should be
delayed until all other required VAPs are first created, as only one
sta mode VAP can exist per physical device.
To create an access point, use:
wlanconfig ath0 create wlandev wifi0 wlanmode ap
To create an access point and a station, use:
wlanconfig ath0 create wlandev wifi0 wlanmode ap
wlanconfig ath1 create wlandev wifi0 wlanmode sta nosbeacon
To create APs that share a single MAC address, use the -bssid flag when
creating the VAPs:
wlanconfig ath0 create wlandev wifi0 wlanmode ap -bssid
wlanconfig ath1 create wlandev wifi0 wlanmode ap -bssid
Finally, to destroy a VAP, issue the command:
wlanconfig ath0 destroy
For more information about Virtual APs, please refer to the users-guide
document distributed with the MadWifi source code.
For more information about wlanconfig, see its manpage, it is installed
when you run "make install".
Operating Mode
--------------
If you have a multi-mode card, use one of the following commands to lock
the operating mode to one of 11a, 11b, or 11g:
iwpriv ath0 mode 1 lock operation to 11a only
iwpriv ath0 mode 2 lock operation to 11b only
iwpriv ath0 mode 3 lock operation to 11g only
iwpriv ath0 mode 0 autoselect from 11a/b/g (default)
Debugging
---------
There are some debugging mechanisms for the curious/masochistic:
sysctl -w dev.ath.debug=0xXXX enable console msgs from the driver
sysctl -w net.wlan0.debug=0xYYY enable console msgs from the wlan module
The values specified for 0XXX and 0xYYY are bit masks that enable
debugging in various parts of each module. For the wlan module these
values are found in the file net80211/ieee80211_var.h (search for MSG_).
For the ath driver look in ath/if_ath.c (search for ATH_DEBUG). Beware
that enabling some debugging msgs can affect the operation of the
software by slowing it down too much.
A more comfortable way to manipulate the debug settings is to make use
of athdebug and 80211debug tools. Call them with the parameter "-h" to
learn how they are used, or refer to the appropriate man pages.
In addition the programs tools/athstats and tools/80211stats can be very
useful in understanding what is going on. In particular, something like
athstats 1
will give a running display of the most interesting statistics sampled
every 1 second. Running athstats without any options will display a
summary of all non-zero statistics from the time the driver was loaded.
By default the ath0 device is used; to override this use the -i option.
A wiki page describes common MadWifi debugging methods here:
http://madwifi.org/wiki/DevDocs/AthDebug
Security/Crypto Support
-----------------------
All Atheros devices implement fixed/shared key WEP in hardware. Newer
Atheros hardware is capable of much more (e.g. AES, TKIP and Michael).
When hardware support is not available for a cipher the net80211 layer
will automatically do the work in software.
WPA/802.11i station operation (aka supplicant) is supported using Jouni
Malinen's wpa_supplicant program. This can be obtained from:
http://hostap.epitest.fi/wpa_supplicant/
wpa_supplicant also supports a wide range of 802.1x EAP methods, either
together with WPA/WPA2 or without; consult the wpa_supplicant
documentation for an up to date list.
MadWifi supports the use of the Wireless Extensions ioctls equal to or
greater than WE18 (linux 2.6.15). When using wpa_supplicant with a
recent linux kernel, it is preferred to use the 'wext' driver backend,
rather than the private MadWifi ioctls. This means that '-D wext'
option should be used with wpa_supplicant when the linux kernel version
is 2.6.15 or above.
NOTE: the in-kernel authenticator is being replaced; to use it you need
to follow the directions in net80211/Makefile.
When operating as an AP, you can use fixed/shared key ciphers and/or
802.1x authentication. The authentication mode is specified using
iwpriv:
iwpriv ath0 authmode 1 # open authentication
iwpriv ath0 authmode 2 # shared key authentication
iwpriv ath0 authmode 3 # 802.1x authentication
To use the 802.1x authenticator you must install and configure the
hostapd program from the same place you got wpa_supplicant from.
Consult the hostapd documentation for further information.
Live Monitoring and Writing Raw 802.11 Packets
----------------------------------------------
The driver can be used in a live "monitor" mode, by creating a monitor
VAP and sending packets to it. All packets sent to a monitor mode VAP
will bypass any state machine.
To create a monitor VAP, use:
wlanconfig ath1 create wlandev wifi0 wlanmode monitor
ifconfig ath1 up
Finally, you can choose to receive packets on ath1 in several different
packet formats:
echo '801' > /proc/sys/net/ath1/dev_type # only 802.11 headers
echo '802' > /proc/sys/net/ath1/dev_type # prism2 headers
echo '803' > /proc/sys/net/ath1/dev_type # radiotap headers
echo '804' > /proc/sys/net/ath1/dev_type # atheros descriptors
Known Problems
--------------
[All these problems are to be fixed in future revisions.]
1. Ad-hoc mode is broken; symptoms are intermittent operation.
Other issues might be mentioned in our ticket tracker:
http://madwifi.org/report/1
Getting Support
---------------
User support is provided via the madwifi-users mailing list, which can
be reached at:
madwifi-users@lists.sourceforge.net
Contact this mailing list if you need help in getting your installation
up and running. We suggest that you subscribe to the list before
sending your request (see below).
We also offer an IRC channel that might be a better help in urgent
cases. Learn more about the different ways to get support by visiting:
http://madwifi.org/wiki/Support
When sending a support request or problem report be sure to include the
version of the driver and the part identification the driver prints to
the console when the module is loaded. For example:
ath_hal: 0.8.2.0
wlan: 0.7.0.0
ath_pci: 0.8.2.0
PCI: Found IRQ 11 for device 00:13.0
ath0: 11a rates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
ath0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ath0: 802.11 address: 00:05:5d:6f:99:5f
ath0: Atheros 5211: mem=0xfebf0000, irq=11
This says the HAL module is version 0.8.2, the wlan module is version
0.7, the driver is version 0.8.2 and the hardware uses an Atheros 5211
chip (which supports 11a and 11b modes).
We will try to respond in a timely manner but understand this software
is provided as-is, without any promise of support.
Feedback and Contributions
--------------------------
Reports about reproducible bugs, feature requests and patches should be
submitted in the form of a trouble ticket:
http://madwifi.org/newticket
Fixes and enhancements are encouraged.

176
THANKS Normal file
View File

@ -0,0 +1,176 @@
Acknowledgments
================
This work could not have been done without the support of Atheros
and in particular the efforts of Greg Chesson. Comments from David
Miller were helpful in cleaning up some of the roughest edges in
early versions of the driver.
Many people have contributed fixes and improvements to this software,
including (in no particular order):
Joerg Albert
Mathieu Lacage
Henry Qian
giova+mwfdev@fagl
Vivien Chappelier
Eric Lammerts
Mark Rakes
Stephen Walton
Tong Chia
Stephane Laroche
Michael Renzmann
Dale Whitfield
Joachim Gleissner
Georg Lukas
Paul Stewart
Alexander Wirtz
Guy Erb
Tom Marshall
D. Stolte
Kevin Yu
Kristian Hoffmann
Nick Moss
Bindu Therthala
William S. Kish
Nick Petroni
Carl Thompson
Thorsten von Eicken
Jouni Malinen
Satish Balay
Richard Dawe
Bruno Randolf
Sebastian Weitzel
Rajendra Singh
Tai-hwa Liang
Divy Le Ray
John Bicket
Takayuki Kaiso
Owen Stampflee
Kel Modderman
Matt Foster
Patrick Pichon
Pavel Roskin
Stijn Tintel
jonty at electrichamster dot net
Aaron Dummer
Dustin McIntire
Frank Schaeckermann
Antonio Ospite
Jon Anderson
Wang Wenjuan
Bell Kin
Ilia Baldine
David Overton
Andreas Schultz
David Fort
Sven Schnelle
Rudger van Brenk
John Byrne
Jae-don Shin
Stefan Becker
Mark Glines
Matt Brown
Steffen Pfendtner
Jick Nan
Charles Bovy
Ian M. Rawley
Beat Meier
Alexander Warg
Jiri Fojtasek
Joshua Wright
Dan Williams
Aurelien Jarno
Daniel Wu
Paolo Cristiani
"stiabhan"
Elias Oltmanns
Imre Kaloz
Brian Eaton
"paolo"
Daniel J Blueman
Digger Vermont
Felix Fietkau
Colubris Networks
Matthew W. S. Bell
Ivan S. Subrov
Jochem Berndsen
Nicholas J Kreucher
Terry Todd
Dave Platt
Scott Raynel
Christian Buennig
Joe Parks
Pavel Novak
Wade Mealing
Tony Espy
Joerg Albert
Oliver Stampfli
Till Wollenberg
Mats Hojlund
Michal Wrobel
Tim Harvey
Andrew Lunn
Chris Hessing
Zilvinas Valinskas
Pramod Babu Gummaraj
Chris Pearson
Helge Deller
Pavol Gono
Laurent Butti
Julien Tinnes
Tjalling Hattink
Jiri Fojtasek
Brian Braunstein
Frank Zdarsky
Andrew Lunn
Michael Plourde
Mike Taylor
Derek J Smithies
jhansen
Benoit Papillault
Apologies to anyone whose name was unintentionally left off.
Please let us know if you think your name should be mentioned here!
We also would like to thank the following individuals and companies
(listed in alphabetic order) who supported us with donations:
* Compex Systems Pte Ltd, Singapore - http://www.compex.com.sg
two donations with a total of 7 MiniPCI cards
* IndraNet Technologies Ltd, New Zealand - http://www.indranet.com.nz
Minstrel rate control module
* Linux-Consulting, USA - http://www.linux-consulting.com
madwifi.org domain name, DNS server maintenance
* Rusty Mellinger, USA
donation of a MiniPCI card with AR5211
* minipci.biz, Germany
donation of two AR5008-based cards plus one desktop antenna and
three pigtails
* Netgate, USA - http://www.netgate.com
1U server (P3/850, 1GB RAM, 2x200GB HDD)
A special thanks goes to Will Herrick, who invested a lot of
personal time and money to pick up the server and ship it to
Germany!
* Suzo, Slovakia - http://www.suzo.sk
1 Wistron DCMA-81 MiniPCI card
* true global communications GmbH, Germany - http://www.tgc.de
Free server and bandwidth for madwifi.org
* Voyage, Hong Kong - htt://www.voyage.hk
1 Senao NMP-8602 Plus MiniPCI card, 2 pigtails and 2 rubber
antenna
To learn more about donations to our project visit:
http://madwifi.org/wiki/Donations
If you want to support MadWifi this way, please contact:
Michael Renzmann <mrenzmann@otaku42.de>

85
ath/Makefile Normal file
View File

@ -0,0 +1,85 @@
#
# Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath/Makefile#12 $
#
#
# Makefile for the Atheros WLAN driver.
#
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)/..
ifeq ($(strip $(BUS)),AHB)
BUSNAME=ahb
COPTS+= -DATH_AHB
else
BUSNAME=pci
COPTS+= -DATH_PCI
endif
include $(TOP)/Makefile.inc
obj-m += ath_$(BUSNAME).o
ath_$(BUSNAME)-objs := if_ath.o if_ath_$(BUSNAME).o
INCS += -I$(TOP) -I$(ATH_HAL) -I$(HAL) -I$(WLAN)
EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
-include $(TOPDIR)/Rules.make
all:
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
install:
test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
install ath_$(BUSNAME).$(KMODSUF) $(DESTDIR)/$(KMODPATH)
clean:
rm -f *~ *.o *.ko *.mod.c .*.cmd
rm -f .depend .version .*.o.flags .*.o.d
rm -rf .tmp_versions
ath_$(BUSNAME).o: $(ath_$(BUSNAME)-objs)
$(LD) $(LDOPTS) -o ath_$(BUSNAME).$(KMODSUF) -r $(ath_$(BUSNAME)-objs)
if_ath_hal.h: $(HAL)/ah.h
$(TOP)/scripts/if_ath_hal_generator.pl $< $@
$(TOP)/scripts/madwifi-indent $@

48
ath/Makefile.kernel Normal file
View File

@ -0,0 +1,48 @@
#
# Makefile for the Atheros WLAN driver.
#
obj ?= .
src ?= .
srctree ?= .
TOP = $(srctree)/$(src)/..
include $(TOP)/BuildCaps.inc
include $(TOP)/ath_hal/ah_target.inc
ATH_HAL=$(TOP)/ath_hal
HAL= $(TOP)/hal
WLAN= $(TOP)/net80211
COMPAT= $(TOP)/include
#
# Select bus-specific code. Note that this defaults to PCI.
#
ifeq ($(strip $(BUS)),AHB)
BUSNAME=ahb
EXTRA_CFLAGS+= -DATH_AHB
else
BUSNAME=pci
EXTRA_CFLAGS+= -DATH_PCI
endif
INCS = -include $(COMPAT)/compat.h -I$(COMPAT)
INCS += -I$(TOP) -I$(ATH_HAL) -I$(HAL) -I$(WLAN)
EXTRA_CFLAGS += $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
ifneq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) += ath_$(BUSNAME).o
ath_$(BUSNAME)-objs := if_ath.o if_ath_$(BUSNAME).o
endif
ifeq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) := if_ath.o if_ath_$(BUSNAME).o
O_TARGET := ath_$(BUSNAME).o
include $(TOPDIR)/Rules.make
export-objs := if_ath_$(BUSNAME).o
list-multi := ath_$(BUSNAME).o
endif

10706
ath/if_ath.c Normal file

File diff suppressed because it is too large Load Diff

358
ath/if_ath_ahb.c Normal file
View File

@ -0,0 +1,358 @@
/*-
* Copyright (c) 2004 Atheros Communications, Inc.
* All rights reserved
*
* $Id$
*/
#include "opt_ah.h"
#ifndef EXPORT_SYMTAB
#define EXPORT_SYMTAB
#endif
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/if.h>
#include <linux/netdevice.h>
#include <linux/cache.h>
#include <linux/platform_device.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include "if_media.h"
#include <net80211/ieee80211_var.h>
#include "if_athvar.h"
#include "ah_devid.h"
#include "if_ath_ahb.h"
#include "ah_soc.h"
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
#error "Kernel versions older than 2.6.19 are not supported!"
#endif
struct ath_ahb_softc {
struct ath_softc aps_sc;
#ifdef CONFIG_PM
u32 aps_pmstate[16];
#endif
};
static struct ath_ahb_softc *sclist[2] = {NULL, NULL};
static u_int8_t num_activesc = 0;
/* set bus cachesize in 4B word units */
void
bus_read_cachesize(struct ath_softc *sc, u_int8_t *csz)
{
/* XXX: get the appropriate value! PCI case reads from config space,
* and I think this is the data cache line-size.
*/
*csz = L1_CACHE_BYTES / sizeof(u_int32_t);
}
/* NOTE: returns uncached (kseg1) address. */
void *
bus_alloc_consistent(void *hwdev, size_t size, dma_addr_t *dma_handle)
{
void *ret;
ret = (void *) __get_free_pages(GFP_ATOMIC, get_order(size));
if (ret != NULL) {
memset(ret, 0, size);
*dma_handle = __pa(ret);
dma_cache_wback_inv((unsigned long) ret, size);
ret = UNCAC_ADDR(ret);
}
return ret;
}
void
bus_free_consistent(void *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle)
{
unsigned long addr = (unsigned long) vaddr;
addr = CAC_ADDR(addr);
free_pages(addr, get_order(size));
}
static int
ahb_enable_wmac(u_int16_t devid, u_int16_t wlanNum)
{
u_int32_t reset;
u_int32_t enable;
if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
u_int32_t reg;
u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
KASSERT(wlanNum == 0, ("invalid wlan # %d", wlanNum));
/* Enable Arbitration for WLAN */
*en |= AR5315_ARB_WLAN;
/* Enable global swapping so this looks like a normal BE system */
reg = REG_READ(AR5315_ENDIAN_CTL);
reg |= AR5315_CONFIG_WLAN;
REG_WRITE(AR5315_ENDIAN_CTL, reg);
/* wake up the MAC */
/* NOTE: for the following write to succeed the
* RST_AHB_ARB_CTL should be set to 0. This driver
* assumes that the register has been set to 0 by boot loader
*/
reg = REG_READ(AR5315_PCI_MAC_SCR);
reg = (reg & ~AR5315_PCI_MAC_SCR_SLMODE_M) |
(AR5315_PCI_MAC_SCR_SLM_FWAKE << AR5315_PCI_MAC_SCR_SLMODE_S);
REG_WRITE(AR5315_PCI_MAC_SCR, reg);
/* wait for the MAC to wakeup */
while (REG_READ(AR5315_PCI_MAC_PCICFG) & AR5315_PCI_MAC_PCICFG_SPWR_DN);
} else {
switch (wlanNum) {
case AR531X_WLAN0_NUM:
reset = (AR531X_RESET_WLAN0 |
AR531X_RESET_WARM_WLAN0_MAC |
AR531X_RESET_WARM_WLAN0_BB);
enable = AR531X_ENABLE_WLAN0;
break;
case AR531X_WLAN1_NUM:
reset = (AR531X_RESET_WLAN1 |
AR531X_RESET_WARM_WLAN1_MAC |
AR531X_RESET_WARM_WLAN1_BB);
enable = AR531X_ENABLE_WLAN1;
break;
default:
return -ENODEV;
}
/* reset the MAC or suffer lots of AHB PROC errors */
REG_WRITE(AR531X_RESETCTL, REG_READ(AR531X_RESETCTL) | reset);
mdelay(15);
/* take it out of reset */
REG_WRITE(AR531X_RESETCTL, REG_READ(AR531X_RESETCTL) & ~reset);
udelay(25);
/* enable it */
REG_WRITE(AR531X_ENABLE, REG_READ(AR531X_ENABLE) | enable);
}
return 0;
}
static int
ahb_disable_wmac(u_int16_t devid, u_int16_t wlanNum)
{
u_int32_t enable;
if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
KASSERT(wlanNum == 0, ("invalid wlan # %d", wlanNum) );
/* Enable Arbitration for WLAN */
*en &= ~AR5315_ARB_WLAN;
} else {
switch (wlanNum) {
case AR531X_WLAN0_NUM:
enable = AR531X_ENABLE_WLAN0;
break;
case AR531X_WLAN1_NUM:
enable = AR531X_ENABLE_WLAN1;
break;
default:
return -ENODEV;
}
REG_WRITE(AR531X_ENABLE, REG_READ(AR531X_ENABLE) & ~enable);
}
return 0;
}
static int
exit_ath_wmac(u_int16_t wlanNum, struct ar531x_config *config)
{
struct ath_ahb_softc *sc = sclist[wlanNum];
struct net_device *dev;
u_int16_t devid;
if (sc == NULL)
return -ENODEV; /* XXX: correct return value? */
dev = sc->aps_sc.sc_dev;
ath_detach(dev);
if (dev->irq)
free_irq(dev->irq, dev);
devid = sc->aps_sc.devid;
config->tag = (unsigned long) devid;
ahb_disable_wmac(devid, wlanNum);
free_netdev(dev);
sclist[wlanNum] = NULL;
return 0;
}
static int
init_ath_wmac(u_int16_t devid, u_int16_t wlanNum, struct ar531x_config *config)
{
const char *athname;
struct net_device *dev;
struct ath_ahb_softc *sc;
if (((wlanNum != 0) && (wlanNum != 1)) ||
(sclist[wlanNum] != NULL))
goto bad;
ahb_enable_wmac(devid, wlanNum);
dev = alloc_netdev(sizeof(struct ath_ahb_softc), "wifi%d", ether_setup);
if (dev == NULL) {
printk(KERN_ERR "ath_dev_probe: no memory for device state\n");
goto bad2;
}
sc = dev->priv;
sc->aps_sc.sc_dev = dev;
/*
* Mark the device as detached to avoid processing
* interrupts until setup is complete.
*/
sc->aps_sc.sc_invalid = 1;
SET_MODULE_OWNER(dev);
sclist[wlanNum] = sc;
switch (wlanNum) {
case AR531X_WLAN0_NUM:
if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
dev->irq = AR5315_IRQ_WLAN0_INTRS;
dev->mem_start = AR5315_WLAN0;
} else {
dev->irq = AR531X_IRQ_WLAN0_INTRS;
dev->mem_start = AR531X_WLAN0;
}
break;
case AR531X_WLAN1_NUM:
dev->irq = AR531X_IRQ_WLAN1_INTRS;
dev->mem_start = KSEG1ADDR(AR531X_WLAN1);
break;
default:
goto bad3;
}
dev->mem_end = dev->mem_start + AR531X_WLANX_LEN;
sc->aps_sc.sc_iobase = (void __iomem *) dev->mem_start;
sc->aps_sc.sc_bdev = NULL;
if (request_irq(dev->irq, ath_intr, SA_SHIRQ, dev->name, dev)) {
printk(KERN_WARNING "%s: request_irq failed\n", dev->name);
goto bad3;
}
if (ath_attach(devid, dev, config) != 0)
goto bad4;
athname = ath_hal_probe(ATHEROS_VENDOR_ID, devid);
printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
dev->name, athname ? athname : "Atheros ???", dev->mem_start, dev->irq);
num_activesc++;
/* Ready to process interrupts */
sc->aps_sc.sc_invalid = 0;
return 0;
bad4:
free_irq(dev->irq, dev);
bad3:
free_netdev(dev);
sclist[wlanNum] = NULL;
bad2:
ahb_disable_wmac(devid, wlanNum);
bad:
return -ENODEV;
}
static int ahb_wmac_probe(struct platform_device *pdev)
{
u_int16_t devid;
struct ar531x_config *config;
config = (struct ar531x_config *) pdev->dev.platform_data;
devid = (long) config->tag;
config->tag = NULL;
return init_ath_wmac(devid, pdev->id, config);
}
static int ahb_wmac_remove(struct platform_device *pdev)
{
exit_ath_wmac(pdev->id, (struct ar531x_config *) pdev->dev.platform_data);
return 0;
}
static struct platform_driver ahb_wmac_driver = {
.driver.name = "ar531x-wmac",
.probe = ahb_wmac_probe,
.remove = ahb_wmac_remove
};
/*
* Module glue.
*/
#include "version.h"
#include "release.h"
static char *version = ATH_PCI_VERSION " (" RELEASE_VERSION ")";
static char *dev_info = "ath_ahb";
#include <linux/ethtool.h>
int
ath_ioctl_ethtool(struct ath_softc *sc, int cmd, void __user *addr)
{
struct ethtool_drvinfo info;
if (cmd != ETHTOOL_GDRVINFO)
return -EOPNOTSUPP;
memset(&info, 0, sizeof(info));
info.cmd = cmd;
strncpy(info.driver, dev_info, sizeof(info.driver) - 1);
strncpy(info.version, version, sizeof(info.version) - 1);
return copy_to_user(addr, &info, sizeof(info)) ? -EFAULT : 0;
}
MODULE_AUTHOR("Atheros Communications, Inc.");
MODULE_DESCRIPTION("Support for Atheros 802.11 wireless LAN cards.");
#ifdef MODULE_VERSION
MODULE_VERSION(RELEASE_VERSION);
#endif
MODULE_SUPPORTED_DEVICE("Atheros WLAN cards");
#ifdef MODULE_LICENSE
MODULE_LICENSE("Dual BSD/GPL");
#endif
static int __init
init_ath_ahb(void)
{
printk(KERN_INFO "%s: %s\n", dev_info, version);
platform_driver_register(&ahb_wmac_driver);
ath_sysctl_register();
return 0;
}
module_init(init_ath_ahb);
static void __exit
exit_ath_ahb(void)
{
ath_sysctl_unregister();
platform_driver_unregister(&ahb_wmac_driver);
printk(KERN_INFO "%s: driver unloaded\n", dev_info);
}
module_exit(exit_ath_ahb);

145
ath/if_ath_ahb.h Normal file
View File

@ -0,0 +1,145 @@
/*
* Copyright (c) 2004 Atheros Communications, Inc.
* All rights reserved.
*
* $Id$
*/
#ifndef _DEV_ATH_AHB_H_
#define _DEV_ATH_AHB_H_
#include <asm/io.h>
#include <asm/uaccess.h>
#define AR531X_WLAN0_NUM 0
#define AR531X_WLAN1_NUM 1
#define REG_WRITE(_reg,_val) *((volatile u_int32_t *)(_reg)) = (_val);
#define REG_READ(_reg) *((volatile u_int32_t *)(_reg))
/*
* 5315 specific registers
*/
/*
* PCI-MAC Configuration registers
*/
#define AR5315_PCI 0xB0100000 /* PCI MMR */
#define AR5315_PCI_MAC_RC (AR5315_PCI + 0x4000)
#define AR5315_PCI_MAC_SCR (AR5315_PCI + 0x4004)
#define AR5315_PCI_MAC_INTPEND (AR5315_PCI + 0x4008)
#define AR5315_PCI_MAC_SFR (AR5315_PCI + 0x400C)
#define AR5315_PCI_MAC_PCICFG (AR5315_PCI + 0x4010)
#define AR5315_PCI_MAC_SREV (AR5315_PCI + 0x4020)
#define AR5315_PCI_MAC_RC_MAC 0x00000001
#define AR5315_PCI_MAC_RC_BB 0x00000002
#define AR5315_PCI_MAC_SCR_SLMODE_M 0x00030000
#define AR5315_PCI_MAC_SCR_SLMODE_S 16
#define AR5315_PCI_MAC_SCR_SLM_FWAKE 0
#define AR5315_PCI_MAC_SCR_SLM_FSLEEP 1
#define AR5315_PCI_MAC_SCR_SLM_NORMAL 2
#define AR5315_PCI_MAC_SFR_SLEEP 0x00000001
#define AR5315_PCI_MAC_PCICFG_SPWR_DN 0x00010000
#define AR5315_IRQ_WLAN0_INTRS 3
#define AR5315_WLAN0 0xb0000000
#define AR5315_ENDIAN_CTL 0xb100000c
#define AR5315_CONFIG_WLAN 0x00000002 /* WLAN byteswap */
#define AR5315_AHB_ARB_CTL 0xb1000008
#define AR5315_ARB_WLAN 0x00000002
/*
* Revision Register - Initial value is 0x3010 (WMAC 3.0, AR531X 1.0).
*/
#define AR5315_SREV 0xb1000014
#define AR5315_REV_MAJ 0x0080
#define AR5317_REV_MAJ 0x0090
#define AR5315_REV_MAJ_M 0x00f0
#define AR5315_REV_MAJ_S 4
#define AR5315_REV_MIN_M 0x000f
#define AR5315_REV_MIN_S 0
#define AR5315_REV_CHIP (REV_MAJ|REV_MIN)
#define AR531X_IRQ_WLAN0_INTRS 2
#define AR531X_IRQ_WLAN1_INTRS 5
#define AR531X_WLAN0 0xb8000000
#define AR531X_WLAN1 0xb8500000
#define AR531X_WLANX_LEN 0x000ffffc
#define AR531X_RESETCTL 0xbc003020
#define AR531X_RESET_WLAN0 0x00000004 /* mac & bb */
#define AR531X_RESET_WLAN1 0x00000200 /* mac & bb */
#define AR531X_RESET_WARM_WLAN0_MAC 0x00002000
#define AR531X_RESET_WARM_WLAN0_BB 0x00004000
#define AR531X_RESET_WARM_WLAN1_MAC 0x00020000
#define AR531X_RESET_WARM_WLAN1_BB 0x00040000
#define AR531X_ENABLE 0xbc003080
#define AR531X_ENABLE_WLAN0 0x0001
#define AR531X_ENABLE_WLAN1 0x0018 /* both DMA and PIO */
#define AR531X_RADIO_MASK_OFF 0xc8
#define AR531X_RADIO0_MASK 0x0003
#define AR531X_RADIO1_MASK 0x000c
#define AR531X_RADIO1_S 2
#define BUS_DMA_FROMDEVICE 0
#define BUS_DMA_TODEVICE 1
#define AR531X_APBBASE 0xbc000000
#define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
#define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
#define AR531X_REV_MAJ 0x00f0
#define AR531X_REV_MAJ_S 4
#define AR531X_REV_MIN 0x000f
#define AR531X_REV_MIN_S 0
#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
/* set bus cachesize in 4B word units */
static __inline void bus_dma_sync_single(void *hwdev, dma_addr_t dma_handle,
size_t size, int direction)
{
unsigned long addr;
addr = (unsigned long) __va(dma_handle);
dma_cache_wback_inv(addr, size);
}
static __inline dma_addr_t bus_map_single(void *hwdev, void *ptr,
size_t size, int direction)
{
dma_cache_wback_inv((unsigned long) ptr, size);
return __pa(ptr);
}
static __inline void bus_unmap_single(void *hwdev, dma_addr_t dma_addr,
size_t size, int direction)
{
if (direction != BUS_DMA_TODEVICE) {
unsigned long addr;
addr = (unsigned long)__va(dma_addr);
dma_cache_wback_inv(addr, size);
}
}
void *bus_alloc_consistent(void *, size_t, dma_addr_t *);
void bus_free_consistent(void *, size_t, void *, dma_addr_t);
#define sysRegRead(phys) (*(volatile u_int32_t *)phys)
/* Allow compiling on non-mips platforms for code verification */
#ifndef __mips__
#define CAC_ADDR(addr) (addr)
#define UNCAC_ADDR(addr) (addr)
#define KSEG1ADDR(addr) (addr)
#endif
#endif /* _DEV_ATH_AHB_H_ */

1055
ath/if_ath_hal.h Normal file

File diff suppressed because it is too large Load Diff

64
ath/if_ath_hal_macros.h Normal file
View File

@ -0,0 +1,64 @@
/*-
* Copyright (c) 2007 Michael Taylor
* 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,
without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id: foo mtaylor $
*/
/*
* This file provides some macros that are used by if_ath_hal.h,
* if_ath_hal_wrappers.h, and if_ath_hal_wrappers.c.
*
* The macros are provided for the HAL lock and for dynamically deciding whether
* to define the HAL wrapper functions as inline or in the implementation file
* at build time. i.e. inline for speed, or non-inline for debugging visibility
* into the HAL methods being called (despite obfuscation).
*
* The if_ath_hal.h file is generated from hal/ah.h at build time by the build
* system.
*/
#ifndef _IF_ATH_HAL_MACROS_H_
#define _IF_ATH_HAL_MACROS_H_
#define ATH_HAL_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_hal_lock)
#define ATH_HAL_LOCK_DESTROY(_sc)
#define ATH_HAL_LOCK_IRQ(_sc) do { \
unsigned long __sc_halLockflags; \
spin_lock_irqsave(&(_sc)->sc_hal_lock, __sc_halLockflags);
#define ATH_HAL_UNLOCK_IRQ(_sc) \
spin_unlock_irqrestore(&(_sc)->sc_hal_lock, __sc_halLockflags); \
} while(0)
#define ATH_HAL_UNLOCK_IRQ_EARLY(_sc) \
spin_unlock_irqrestore(&(_sc)->sc_hal_lock, __sc_halLockflags);
#endif /* #ifndef _IF_ATH_HAL_MACROS_H_ */

274
ath/if_ath_hal_wrappers.h Normal file
View File

@ -0,0 +1,274 @@
/*-
* Copyright (c) 2007 Michael Taylor
* 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,
without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id: foo mtaylor $
*/
/* This file provides some wrapper functions that invoke functions in
* if_ath_hal.h. Since all the functions in the generated file, if_ath_hal.h
* have locks to protect them... no further locking is required in these
* additional helper functions. Mostly these just provide a series of nicknames
* for specific sets of arguments to HAL functions that are commonly needed. */
#ifndef _IF_ATH_HAL_WRAPPERS_H_
#define _IF_ATH_HAL_WRAPPERS_H_
static inline void ath_reg_write(struct ath_softc *sc, u_int reg, u_int32_t val)
{
ATH_HAL_LOCK_IRQ(sc);
OS_REG_WRITE(sc->sc_ah, reg, val);
ATH_HAL_UNLOCK_IRQ(sc);
}
static inline u_int32_t ath_reg_read(struct ath_softc *sc, u_int reg)
{
u_int32_t ret;
ATH_HAL_LOCK_IRQ(sc);
ret = OS_REG_READ(sc->sc_ah, reg);
ATH_HAL_UNLOCK_IRQ(sc);
return ret;
}
static inline HAL_BOOL ath_hal_burstsupported(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_BURST, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_ciphersupported(struct ath_hal *ah, u_int32_t cipher)
{
return (ath_hal_getcapability(ah, HAL_CAP_CIPHER, cipher, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_compressionsupported(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_COMPRESSION, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_fastframesupported(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_FASTFRAME, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_getcountrycode(struct ath_hal *ah, u_int32_t *destination)
{
return ((*(destination) = ah->ah_countryCode), AH_TRUE);
}
static inline HAL_BOOL ath_hal_getdiversity(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_DIVERSITY, 1, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_getmaxtxpow(struct ath_hal *ah, u_int32_t *destination)
{
return (ath_hal_getcapability(ah, HAL_CAP_TXPOW, 2, destination) == HAL_OK);
}
static inline HAL_BOOL ath_hal_getmcastkeysearch(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_MCAST_KEYSRCH, 1, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_getnumtxqueues(struct ath_hal *ah, u_int32_t *destination)
{
return (ath_hal_getcapability(ah, HAL_CAP_NUM_TXQUEUES, 0, destination) == HAL_OK);
}
static inline HAL_BOOL ath_hal_getregdomain(struct ath_hal *ah, u_int32_t *destination)
{
return (ath_hal_getcapability(ah, HAL_CAP_REG_DMN, 0, destination) == HAL_OK);
}
static inline HAL_BOOL ath_hal_gettkipmic(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TKIP_MIC, 1, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_gettkipsplit(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TKIP_SPLIT, 1, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_gettpc(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TPC, 1, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_gettpscale(struct ath_hal *ah, u_int32_t *destination)
{
return (ath_hal_getcapability(ah, HAL_CAP_TXPOW, 3, destination) == HAL_OK);
}
static inline HAL_BOOL ath_hal_gettsfadjust(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TSF_ADJUST, 1, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_gettxpowlimit(struct ath_hal *ah, u_int32_t *destination)
{
return (ath_hal_getcapability(ah, HAL_CAP_TXPOW, 1, destination) == HAL_OK);
}
static inline HAL_BOOL ath_hal_halfrate_chansupported(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_CHAN_HALFRATE, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hasbssidmask(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_BSSIDMASK, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hasbursting(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_BURST, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hascompression(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_COMPRESSION, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hasdiversity(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_DIVERSITY, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hasfastframes(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_FASTFRAME, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hasmcastkeysearch(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_MCAST_KEYSRCH, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hasrfsilent(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_RFSILENT, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hastkipmic(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TKIP_MIC, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hastkipsplit(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TKIP_SPLIT, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hastpc(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TPC, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hastsfadjust(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TSF_ADJUST, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hastxpowlimit(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_TXPOW, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hasveol(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_VEOL, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_hwphycounters(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_PHYCOUNTERS, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_quarterrate_chansupported(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_CHAN_QUARTERRATE, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_setdiversity(struct ath_hal *ah, int v)
{
return (ath_hal_setcapability(ah, HAL_CAP_DIVERSITY, 1, v, NULL));
}
static inline HAL_BOOL ath_hal_setrfsilent(struct ath_hal *ah, u_int32_t v)
{
return (ath_hal_setcapability(ah, HAL_CAP_RFSILENT, 1, v, NULL));
}
static inline HAL_BOOL ath_hal_settkipmic(struct ath_hal *ah, u_int32_t v)
{
return (ath_hal_setcapability(ah, HAL_CAP_TKIP_MIC, 1, v, NULL));
}
static inline HAL_BOOL ath_hal_settkipsplit(struct ath_hal *ah, int v)
{
return (ath_hal_setcapability(ah, HAL_CAP_TKIP_SPLIT, 1, v, NULL));
}
static inline HAL_BOOL ath_hal_settpc(struct ath_hal *ah, u_int32_t v)
{
return (ath_hal_setcapability(ah, HAL_CAP_TPC, 1, v, NULL));
}
static inline HAL_BOOL ath_hal_settpscale(struct ath_hal *ah, u_int32_t v)
{
return (ath_hal_setcapability(ah, HAL_CAP_TXPOW, 3, v, NULL));
}
static inline HAL_BOOL ath_hal_settsfadjust(struct ath_hal *ah, u_int32_t v)
{
return (ath_hal_setcapability(ah, HAL_CAP_TSF_ADJUST, 1, v, NULL));
}
static inline HAL_BOOL ath_hal_turboagsupported(struct ath_hal *ah, int countrycode)
{
return (ath_hal_getwirelessmodes(ah, countrycode) & (HAL_MODE_108G | HAL_MODE_TURBO));
}
static inline HAL_BOOL ath_hal_wmetkipmic(struct ath_hal *ah)
{
return (ath_hal_getcapability(ah, HAL_CAP_WME_TKIPMIC, 0, NULL) == HAL_OK);
}
static inline HAL_BOOL ath_hal_xrsupported(struct ath_hal *ah)
{
return ath_hal_getcapability(ah, HAL_CAP_XR, 0, NULL) == HAL_OK;
}
#endif /* #ifndef _IF_ATH_HAL_WRAPPERS_H_ */

415
ath/if_ath_pci.c Normal file
View File

@ -0,0 +1,415 @@
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* Copyright (c) 2004-2005 Atheros Communications, Inc.
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
#include "opt_ah.h"
#ifndef EXPORT_SYMTAB
#define EXPORT_SYMTAB
#endif
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/netdevice.h>
#include <linux/cache.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include "if_media.h"
#include <net80211/ieee80211_var.h>
#include "if_athvar.h"
#include "ah_devid.h"
#include "if_ath_pci.h"
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
/*
* PCI initialization uses Linux 2.4.x version and
* older kernels do not support this
*/
#error Atheros PCI version requires at least Linux kernel version 2.4.0
#endif /* kernel < 2.4.0 */
struct ath_pci_softc {
struct ath_softc aps_sc;
#ifdef CONFIG_PM
u32 aps_pmstate[16];
#endif
};
/*
* User a static table of PCI IDs for now. While this is the
* "new way" to do things, we may want to switch back to having
* the HAL check them by defining a probe method.
*/
static struct pci_device_id ath_pci_id_table[] __devinitdata = {
{ 0x168c, 0x0007, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x0012, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x0013, PCI_ANY_ID, PCI_ANY_ID },
{ 0xa727, 0x0013, PCI_ANY_ID, PCI_ANY_ID }, /* 3com */
{ 0x10b7, 0x0013, PCI_ANY_ID, PCI_ANY_ID }, /* 3com 3CRDAG675 */
{ 0x168c, 0x1014, PCI_ANY_ID, PCI_ANY_ID }, /* IBM minipci 5212 */
{ 0x168c, 0x101a, PCI_ANY_ID, PCI_ANY_ID }, /* some Griffin-Lite */
{ 0x168c, 0x0015, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x0016, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x0017, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x0018, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x0019, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x001a, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x001b, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x001c, PCI_ANY_ID, PCI_ANY_ID }, /* PCI Express 5424 */
{ 0x168c, 0x001d, PCI_ANY_ID, PCI_ANY_ID }, /* PCI Express ??? */
{ 0x168c, 0x0023, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x0024, PCI_ANY_ID, PCI_ANY_ID },
{ 0x168c, 0x9013, PCI_ANY_ID, PCI_ANY_ID }, /* sonicwall */
{ 0 }
};
static u16 ath_devidmap[][2] = {
{ 0x9013, 0x0013 }
};
static int
ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
unsigned long phymem;
void __iomem *mem;
struct ath_pci_softc *sc;
struct net_device *dev;
const char *athname;
u_int8_t csz;
u32 val;
u16 vdevice;
int i;
if (pci_enable_device(pdev))
return -EIO;
/* XXX 32-bit addressing only */
if (pci_set_dma_mask(pdev, 0xffffffff)) {
printk(KERN_ERR "ath_pci: 32-bit DMA not available\n");
goto bad;
}
/*
* Cache line size is used to size and align various
* structures used to communicate with the hardware.
*/
pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &csz);
if (csz == 0) {
/*
* Linux 2.4.18 (at least) writes the cache line size
* register as a 16-bit wide register which is wrong.
* We must have this setup properly for rx buffer
* DMA to work so force a reasonable value here if it
* comes up zero.
*/
csz = L1_CACHE_BYTES / sizeof(u_int32_t);
pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, csz);
}
/*
* The default setting of latency timer yields poor results,
* set it to the value used by other systems. It may be worth
* tweaking this setting more.
*/
pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xa8);
pci_set_master(pdev);
/*
* Disable the RETRY_TIMEOUT register (0x41) to keep
* PCI Tx retries from interfering with C3 CPU state.
*
* Code taken from ipw2100 driver - jg
*/
pci_read_config_dword(pdev, 0x40, &val);
if ((val & 0x0000ff00) != 0)
pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
phymem = pci_resource_start(pdev, 0);
if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "ath")) {
printk(KERN_ERR "ath_pci: cannot reserve PCI memory region\n");
goto bad;
}
mem = ioremap(phymem, pci_resource_len(pdev, 0));
if (!mem) {
printk(KERN_ERR "ath_pci: cannot remap PCI memory region\n") ;
goto bad1;
}
dev = alloc_netdev(sizeof(struct ath_pci_softc), "wifi%d", ether_setup);
if (dev == NULL) {
printk(KERN_ERR "ath_pci: no memory for device state\n");
goto bad2;
}
sc = dev->priv;
sc->aps_sc.sc_dev = dev;
sc->aps_sc.sc_iobase = mem;
/*
* Mark the device as detached to avoid processing
* interrupts until setup is complete.
*/
sc->aps_sc.sc_invalid = 1;
dev->irq = pdev->irq;
/*
* Don't leave arp type as ARPHRD_ETHER as this is no eth device
*/
dev->type = ARPHRD_IEEE80211;
SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &pdev->dev);
sc->aps_sc.sc_bdev = (void *) pdev;
pci_set_drvdata(pdev, dev);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
if (request_irq(dev->irq, ath_intr, IRQF_SHARED, dev->name, dev)) {
#else
if (request_irq(dev->irq, ath_intr, SA_SHIRQ, dev->name, dev)) {
#endif
printk(KERN_WARNING "%s: request_irq failed\n", dev->name);
goto bad3;
}
/* looking for device type from broken device id */
vdevice = id->device;
for (i = 0; i < (sizeof(ath_devidmap) / sizeof(ath_devidmap[0])); i++) {
if (id->device == ath_devidmap[i][0]) {
vdevice = ath_devidmap[i][1];
break;
}
}
/*
* Auto-enable soft led processing for IBM cards and for
* 5211 minipci cards. Users can also manually enable/disable
* support with a sysctl.
*/
if (vdevice == AR5212_DEVID_IBM || vdevice == AR5211_DEVID) {
sc->aps_sc.sc_softled = 1;
sc->aps_sc.sc_ledpin = 0;
}
/* Enable softled on PIN1 on HP Compaq nc6xx, nc4000 & nx5000 laptops */
if (pdev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ) {
sc->aps_sc.sc_softled = 1;
sc->aps_sc.sc_ledpin = 1;
}
if (ath_attach(vdevice, dev, NULL) != 0)
goto bad4;
athname = ath_hal_probe(id->vendor, vdevice);
printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
dev->name, athname ? athname : "Atheros ???", phymem, dev->irq);
/* ready to process interrupts */
sc->aps_sc.sc_invalid = 0;
return 0;
bad4:
free_irq(dev->irq, dev);
bad3:
free_netdev(dev);
bad2:
iounmap(mem);
bad1:
release_mem_region(phymem, pci_resource_len(pdev, 0));
bad:
pci_disable_device(pdev);
return (-ENODEV);
}
static void
ath_pci_remove(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
struct ath_pci_softc *sc = dev->priv;
ath_detach(dev);
if (dev->irq)
free_irq(dev->irq, dev);
iounmap(sc->aps_sc.sc_iobase);
release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
pci_disable_device(pdev);
free_netdev(dev);
}
#ifdef CONFIG_PM
static int
ath_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct net_device *dev = pci_get_drvdata(pdev);
ath_suspend(dev);
PCI_SAVE_STATE(pdev, ((struct ath_pci_softc *)dev->priv)->aps_pmstate);
pci_disable_device(pdev);
return pci_set_power_state(pdev, PCI_D3hot);
}
static int
ath_pci_resume(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
u32 val;
int err;
err = pci_set_power_state(pdev, PCI_D0);
if (err)
return err;
/* XXX - Should this return nonzero on fail? */
PCI_RESTORE_STATE(pdev, ((struct ath_pci_softc *)dev->priv)->aps_pmstate);
err = pci_enable_device(pdev);
if (err)
return err;
pci_set_master(pdev);
/*
* Suspend/Resume resets the PCI configuration space, so we have to
* re-disable the RETRY_TIMEOUT register (0x41) to keep
* PCI Tx retries from interfering with C3 CPU state
*
* Code taken from ipw2100 driver - jg
*/
pci_read_config_dword(pdev, 0x40, &val);
if ((val & 0x0000ff00) != 0)
pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
ath_resume(dev);
return 0;
}
#endif /* CONFIG_PM */
MODULE_DEVICE_TABLE(pci, ath_pci_id_table);
static struct pci_driver ath_pci_drv_id = {
.name = "ath_pci",
.id_table = ath_pci_id_table,
.probe = ath_pci_probe,
.remove = ath_pci_remove,
#ifdef CONFIG_PM
.suspend = ath_pci_suspend,
.resume = ath_pci_resume,
#endif /* CONFIG_PM */
/* Linux 2.4.6 has save_state and enable_wake that are not used here */
};
/*
* Module glue.
*/
#include "version.h"
#include "release.h"
static char *version = ATH_PCI_VERSION " (" RELEASE_VERSION ")";
static char *dev_info = "ath_pci";
#include <linux/ethtool.h>
int
ath_ioctl_ethtool(struct ath_softc *sc, int cmd, void __user *addr)
{
struct ethtool_drvinfo info;
if (cmd != ETHTOOL_GDRVINFO)
return -EOPNOTSUPP;
memset(&info, 0, sizeof(info));
info.cmd = cmd;
strncpy(info.driver, dev_info, sizeof(info.driver) - 1);
strncpy(info.version, version, sizeof(info.version) - 1);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22)
/* include the device name so later versions of kudzu DTRT */
strncpy(info.bus_info, pci_name((struct pci_dev *)sc->sc_bdev),
sizeof(info.bus_info) - 1);
#endif
return copy_to_user(addr, &info, sizeof(info)) ? -EFAULT : 0;
}
MODULE_AUTHOR("Errno Consulting, Sam Leffler");
MODULE_DESCRIPTION("Support for Atheros 802.11 wireless LAN cards.");
#ifdef MODULE_VERSION
MODULE_VERSION(RELEASE_VERSION);
#endif
MODULE_SUPPORTED_DEVICE("Atheros WLAN cards");
#ifdef MODULE_LICENSE
MODULE_LICENSE("Dual BSD/GPL");
#endif
static int __init
init_ath_pci(void)
{
printk(KERN_INFO "%s: %s\n", dev_info, version);
if (pci_register_driver(&ath_pci_drv_id) < 0) {
printk("ath_pci: No devices found, driver not installed.\n");
return (-ENODEV);
}
ath_sysctl_register();
return (0);
}
module_init(init_ath_pci);
static void __exit
exit_ath_pci(void)
{
ath_sysctl_unregister();
pci_unregister_driver(&ath_pci_drv_id);
printk(KERN_INFO "%s: driver unloaded\n", dev_info);
}
module_exit(exit_ath_pci);
/* return bus cachesize in 4B word units */
void
bus_read_cachesize(struct ath_softc *sc, u_int8_t *csz)
{
pci_read_config_byte(sc->sc_bdev, PCI_CACHE_LINE_SIZE, csz);
}

74
ath/if_ath_pci.h Normal file
View File

@ -0,0 +1,74 @@
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* Copyright (c) 2004-2005 Atheros Communications, Inc.
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
#ifndef _DEV_ATH_PCI_H_
#define _DEV_ATH_PCI_H_
#include <linux/pci.h>
#define bus_map_single pci_map_single
#define bus_unmap_single pci_unmap_single
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
#define bus_dma_sync_single pci_dma_sync_single_for_cpu
#define PCI_SAVE_STATE(a,b) pci_save_state(a)
#define PCI_RESTORE_STATE(a,b) pci_restore_state(a)
#else
#define bus_dma_sync_single pci_dma_sync_single
#define PCI_SAVE_STATE(a,b) pci_save_state(a,b)
#define PCI_RESTORE_STATE(a,b) pci_restore_state(a,b)
#endif
#define bus_alloc_consistent pci_alloc_consistent
#define bus_free_consistent pci_free_consistent
#define BUS_DMA_FROMDEVICE PCI_DMA_FROMDEVICE
#define BUS_DMA_TODEVICE PCI_DMA_TODEVICE
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
#define pm_message_t u32
#endif
#ifndef PCI_D0
#define PCI_D0 0
#endif
#ifndef PCI_D3hot
#define PCI_D3hot 3
#endif
#endif /* _DEV_ATH_PCI_H_ */

127
ath/if_athioctl.h Normal file
View File

@ -0,0 +1,127 @@
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
/*
* Ioctl-related defintions for the Atheros Wireless LAN controller driver.
*/
#ifndef _DEV_ATH_ATHIOCTL_H
#define _DEV_ATH_ATHIOCTL_H
struct ath_stats {
u_int32_t ast_watchdog; /* device reset by watchdog */
u_int32_t ast_hardware; /* fatal hardware error interrupts */
u_int32_t ast_bmiss; /* beacon miss interrupts */
u_int32_t ast_rxorn; /* rx overrun interrupts */
u_int32_t ast_rxeol; /* rx eol interrupts */
u_int32_t ast_txurn; /* tx underrun interrupts */
u_int32_t ast_mib; /* mib interrupts */
u_int32_t ast_tx_packets; /* packet sent on the interface */
u_int32_t ast_tx_mgmt; /* management frames transmitted */
u_int32_t ast_tx_discard; /* frames discarded prior to assoc */
u_int32_t ast_tx_invalid; /* frames discarded due to is device gone */
u_int32_t ast_tx_qstop; /* tx queue stopped because it's full */
u_int32_t ast_tx_encap; /* tx encapsulation failed */
u_int32_t ast_tx_nonode; /* tx failed due to of no node */
u_int32_t ast_tx_nobuf; /* tx failed due to of no tx buffer (data) */
u_int32_t ast_tx_nobufmgt; /* tx failed due to of no tx buffer (mgmt)*/
u_int32_t ast_tx_xretries; /* tx failed due to of too many retries */
u_int32_t ast_tx_fifoerr; /* tx failed due to of FIFO underrun */
u_int32_t ast_tx_filtered; /* tx failed due to xmit filtered */
u_int32_t ast_tx_shortretry; /* tx on-chip retries (short) */
u_int32_t ast_tx_longretry; /* tx on-chip retries (long) */
u_int32_t ast_tx_badrate; /* tx failed due to of bogus xmit rate */
u_int32_t ast_tx_noack; /* tx frames with no ack marked */
u_int32_t ast_tx_rts; /* tx frames with rts enabled */
u_int32_t ast_tx_cts; /* tx frames with cts enabled */
u_int32_t ast_tx_shortpre; /* tx frames with short preamble */
u_int32_t ast_tx_altrate; /* tx frames with alternate rate */
u_int32_t ast_tx_protect; /* tx frames with protection */
u_int32_t ast_rx_orn; /* rx failed due to of desc overrun */
u_int32_t ast_rx_crcerr; /* rx failed due to of bad CRC */
u_int32_t ast_rx_fifoerr; /* rx failed due to of FIFO overrun */
u_int32_t ast_rx_badcrypt; /* rx failed due to of decryption */
u_int32_t ast_rx_badmic; /* rx failed due to of MIC failure */
u_int32_t ast_rx_phyerr; /* rx PHY error summary count */
u_int32_t ast_rx_phy[32]; /* rx PHY error per-code counts */
u_int32_t ast_rx_tooshort; /* rx discarded due to frame too short */
u_int32_t ast_rx_toobig; /* rx discarded due to frame too large */
u_int32_t ast_rx_nobuf; /* rx setup failed due to of no skbuff */
u_int32_t ast_rx_packets; /* packet recv on the interface */
u_int32_t ast_rx_mgt; /* management frames received */
u_int32_t ast_rx_ctl; /* control frames received */
int8_t ast_tx_rssi; /* tx rssi of last ack */
int8_t ast_rx_rssi; /* rx rssi from histogram */
u_int32_t ast_be_xmit; /* beacons transmitted */
u_int32_t ast_be_nobuf; /* no skbuff available for beacon */
u_int32_t ast_per_cal; /* periodic calibration calls */
u_int32_t ast_per_calfail; /* periodic calibration failed */
u_int32_t ast_per_rfgain; /* periodic calibration rfgain reset */
u_int32_t ast_rate_calls; /* rate control checks */
u_int32_t ast_rate_raise; /* rate control raised xmit rate */
u_int32_t ast_rate_drop; /* rate control dropped xmit rate */
u_int32_t ast_ant_defswitch; /* rx/default antenna switches */
u_int32_t ast_ant_txswitch; /* tx antenna switches */
u_int32_t ast_ant_rx[8]; /* rx frames with antenna */
u_int32_t ast_ant_tx[8]; /* tx frames with antenna */
};
struct ath_diag {
char ad_name[IFNAMSIZ]; /* if name, e.g. "ath0" */
u_int16_t ad_id;
#define ATH_DIAG_DYN 0x8000 /* allocate buffer in caller */
#define ATH_DIAG_IN 0x4000 /* copy in parameters */
#define ATH_DIAG_OUT 0x0000 /* copy out results (always) */
#define ATH_DIAG_ID 0x0fff
u_int16_t ad_in_size; /* pack to fit, yech */
void __user *ad_in_data;
void __user *ad_out_data;
u_int ad_out_size;
};
#define ATH_RADAR_MUTE_TIME 1 /* Set dfs mute time for dfs test mode */
#ifdef __linux__
#define SIOCGATHSTATS (SIOCDEVPRIVATE+0)
#define SIOCGATHDIAG (SIOCDEVPRIVATE+1)
#define SIOCGATHRADARSIG (SIOCDEVPRIVATE+2)
#else
#define SIOCGATHSTATS _IOWR('i', 137, struct ifreq)
#define SIOCGATHDIAG _IOWR('i', 138, struct ath_diag)
#endif
#endif /* _DEV_ATH_ATHIOCTL_H */

752
ath/if_athvar.h Normal file
View File

@ -0,0 +1,752 @@
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
/*
* Defintions for the Atheros Wireless LAN controller driver.
*/
#ifndef _DEV_ATH_ATHVAR_H
#define _DEV_ATH_ATHVAR_H
#include "ah.h"
#include "ah_desc.h"
#include "ah_os.h"
#include "if_athioctl.h"
#include "net80211/ieee80211.h" /* XXX for WME_NUM_AC */
#include <asm/io.h>
#include <linux/list.h>
/*
* Deduce if tasklets are available. If not then
* fall back to using the immediate work queue.
*/
#include <linux/interrupt.h>
#ifdef DECLARE_TASKLET /* native tasklets */
#define ATH_TQ_STRUCT tasklet_struct
#define ATH_INIT_TQUEUE(a,b,c) tasklet_init((a), (b), (unsigned long)(c))
#define ATH_SCHEDULE_TQUEUE(a,b) tasklet_schedule((a))
typedef unsigned long TQUEUE_ARG;
#define mark_bh(a) do {} while (0)
#else /* immediate work queue */
#define ATH_TQ_STRUCT tq_struct
#define ATH_INIT_TQUEUE(a,b,c) INIT_TQUEUE(a,b,c)
#define ATH_SCHEDULE_TQUEUE(a,b) do { \
*(b) |= queue_task((a), &tq_immediate); \
} while (0)
typedef void *TQUEUE_ARG;
#define tasklet_disable(t) do { (void) t; local_bh_disable(); } while (0)
#define tasklet_enable(t) do { (void) t; local_bh_enable(); } while (0)
#endif /* !DECLARE_TASKLET */
#include <linux/sched.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,41)
#include <linux/tqueue.h>
#define work_struct tq_struct
#define schedule_work(t) schedule_task((t))
#define flush_scheduled_work() flush_scheduled_tasks()
#define ATH_INIT_WORK(t, f) do { \
memset((t), 0, sizeof(struct tq_struct)); \
(t)->routine = (void (*)(void*)) (f); \
(t)->data=(void *) (t); \
} while (0)
#else
#include <linux/workqueue.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
#define ATH_INIT_WORK(_t, _f) INIT_WORK((_t), (void (*)(void *))(_f), (_t));
#else
#define ATH_INIT_WORK(_t, _f) INIT_WORK((_t), (_f));
#endif
#endif /* KERNEL_VERSION < 2.5.41 */
/*
* Guess how the interrupt handler should work.
*/
#if !defined(IRQ_NONE)
typedef void irqreturn_t;
#define IRQ_NONE
#define IRQ_HANDLED
#endif /* !defined(IRQ_NONE) */
#ifndef SET_MODULE_OWNER
#define SET_MODULE_OWNER(dev) do { \
dev->owner = THIS_MODULE; \
} while (0)
#endif
#ifndef SET_NETDEV_DEV
#define SET_NETDEV_DEV(ndev, pdev)
#endif
#ifdef to_net_dev
#define ATH_GET_NETDEV_DEV(ndev) ((ndev)->dev.parent)
#else
#define ATH_GET_NETDEV_DEV(ndev) ((ndev)->class_dev.dev)
#endif
#ifndef NETDEV_TX_OK
#define NETDEV_TX_OK 0
#define NETDEV_TX_BUSY 1
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
static inline struct net_device *_alloc_netdev(int sizeof_priv, const char *mask,
void (*setup)(struct net_device *))
{
struct net_device *dev;
int alloc_size;
/* ensure 32-byte alignment of the private area */
alloc_size = sizeof (*dev) + sizeof_priv + 31;
dev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
if (dev == NULL)
{
printk(KERN_ERR "alloc_dev: Unable to allocate device memory.\n");
return NULL;
}
memset(dev, 0, alloc_size);
if (sizeof_priv)
dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
setup(dev);
strcpy(dev->name, mask);
return dev;
}
/* Avoid name collision - some vendor kernels backport alloc_netdev() */
#undef alloc_netdev
#define alloc_netdev(s,m,d) _alloc_netdev(s, m, d)
/* Some vendors backport PDE, so make it a macro here */
#undef PDE
#define PDE(inode) ((struct proc_dir_entry *)(inode)->u.generic_ip)
#endif
/*
* Macro to expand scalars to 64-bit objects
*/
#define ito64(x) (sizeof(x)==8) ? (((unsigned long long int)(x)) & (0xff)) : \
(sizeof(x)==16) ? (((unsigned long long int)(x)) & 0xffff) : \
((sizeof(x)==32) ? (((unsigned long long int)(x)) & 0xffffffff): (unsigned long long int)(x))
/*
* Deal with the sysctl handler api changing.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
#define ATH_SYSCTL_DECL(f, ctl, write, filp, buffer, lenp, ppos) \
f(ctl_table *ctl, int write, struct file *filp, \
void __user *buffer, size_t *lenp)
#define ATH_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos) \
proc_dointvec(ctl, write, filp, buffer, lenp)
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) */
#define ATH_SYSCTL_DECL(f, ctl, write, filp, buffer, lenp, ppos) \
f(ctl_table *ctl, int write, struct file *filp, \
void __user *buffer, size_t *lenp, loff_t *ppos)
#define ATH_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos) \
proc_dointvec(ctl, write, filp, buffer, lenp, ppos)
#endif
#define ATH_TIMEOUT 1000
#define ATH_DFS_WAIT_POLL_PERIOD 2 /* 2 seconds */
#define ATH_LONG_CALINTERVAL 30 /* 30 seconds between calibrations */
#define ATH_SHORT_CALINTERVAL 1 /* 1 second between calibrations */
/*
* Maximum acceptable MTU
* MAXFRAMEBODY - WEP - QOS - RSN/WPA:
* 2312 - 8 - 2 - 12 = 2290
*/
#define ATH_MAX_MTU 2290
#define ATH_MIN_MTU 32
#define ATH_RXBUF 40 /* number of RX buffers */
#define ATH_TXBUF 200 /* number of TX buffers */
#define ATH_BCBUF 4 /* number of beacon buffers */
/* free buffer threshold to restart net dev */
#define ATH_TXBUF_FREE_THRESHOLD (ATH_TXBUF / 20)
#define TAIL_DROP_COUNT 50 /* maximum number of queued frames allowed */
/*
* dynamic turbo specific macros.
*/
#define ATH_TURBO_UP_THRESH 750000 /* bytes/sec */
#define ATH_TURBO_DN_THRESH 1000000 /* bytes/sec */
#define ATH_TURBO_PERIOD_HOLD 1 /* in seconds */
/*
* The only case where we see skbuff chains is due to FF aggregation in
* the driver.
*/
#ifdef ATH_SUPERG_FF
#define ATH_TXDESC 2 /* number of descriptors per buffer */
#else
#define ATH_TXDESC 1 /* number of descriptors per buffer */
#endif
#define ATH_TXMAXTRY 11 /* max number of transmit attempts */
/* Compress settings */
#define ATH_COMP_THRESHOLD 256 /* no compression for frames
longer than this threshold */
#define ATH_COMP_PROC_NO_COMP_NO_CCS 3
#define ATH_COMP_PROC_NO_COMP_ADD_CCS 2
#define ATH_COMP_PROC_COMP_NO_OPTIAML 1
#define ATH_COMP_PROC_COMP_OPTIMAL 0
#define ATH_DEFAULT_COMP_PROC ATH_COMP_PROC_COMP_OPTIMAL
#define INVALID_DECOMP_INDEX 0xFFFF
#define WEP_IV_FIELD_SIZE 4 /* wep IV field size */
#define WEP_ICV_FIELD_SIZE 4 /* wep ICV field size */
#define AES_ICV_FIELD_SIZE 8 /* AES ICV field size */
#define EXT_IV_FIELD_SIZE 4 /* ext IV field size */
/* XR specific macros */
#define XR_DEFAULT_GRPPOLL_RATE_STR "0.25 1 1 3 3 6 6 20"
#define GRPPOLL_RATE_STR_LEN 64
#define XR_SLOT_DELAY 30 /* in usec */
#define XR_AIFS 0
#define XR_NUM_RATES 5
#define XR_NUM_SUP_RATES 8
/* XR uplink should have same cwmin/cwmax value */
#define XR_CWMIN_CWMAX 7
#define XR_DATA_AIFS 3
#define XR_DATA_CWMIN 31
#define XR_DATA_CWMAX 1023
/* pick the threshold so that we meet most of the regulatory constraints */
#define XR_FRAGMENTATION_THRESHOLD 540
#define XR_TELEC_FRAGMENTATION_THRESHOLD 442
#define XR_MAX_GRP_POLL_PERIOD 1000 /* Maximum Group Poll Periodicity */
#define XR_DEFAULT_POLL_INTERVAL 100
#define XR_MIN_POLL_INTERVAL 30
#define XR_MAX_POLL_INTERVAL 1000
#define XR_DEFAULT_POLL_COUNT 32
#define XR_MIN_POLL_COUNT 16
#define XR_MAX_POLL_COUNT 64
#define XR_POLL_UPDATE_PERIOD 10 /* number of XR beacons */
#define XR_GRPPOLL_PERIOD_FACTOR 5 /* factor used in calculating grp poll interval */
#define XR_4MS_FRAG_THRESHOLD 128 /* fragmentation threshold for 4msec frame limit */
/*
* Maximum Values in ms for group poll periodicty
*/
#define GRP_POLL_PERIOD_NO_XR_STA_MAX 100
#define GRP_POLL_PERIOD_XR_STA_MAX 30
/*
* Percentage of the configured poll periodicity
*/
#define GRP_POLL_PERIOD_FACTOR_XR_STA 30 /* When XR Stations associated freq is 30% higher */
#define A_MAX(a,b) ((a) > (b) ? (a) : (b))
/*
* Macros to obtain the Group Poll Periodicity in various situations
*
* Curerntly there are the two cases
* (a) When there are no XR STAs associated
* (b) When there is atleast one XR STA associated
*/
#define GRP_POLL_PERIOD_NO_XR_STA(sc) (sc->sc_xrpollint)
#define GRP_POLL_PERIOD_XR_STA(sc) \
A_MAX(GRP_POLL_PERIOD_FACTOR_XR_STA * (sc->sc_xrpollint / 100), GRP_POLL_PERIOD_XR_STA_MAX)
/*
* When there are no XR STAs and a valid double chirp is received then the Group Polls are
* transmitted for 10 seconds from the time of the last valid double double-chirp
*/
#define NO_XR_STA_GRPPOLL_TX_DUR 10000
/*
* The key cache is used for h/w cipher state and also for
* tracking station state such as the current tx antenna.
* We also setup a mapping table between key cache slot indices
* and station state to short-circuit node lookups on rx.
* Different parts have different size key caches. We handle
* up to ATH_KEYMAX entries (could dynamically allocate state).
*/
#define ATH_KEYMAX 128 /* max key cache size we handle */
#define ATH_KEYBYTES (ATH_KEYMAX / NBBY) /* storage space in bytes */
#ifdef ATH_REVERSE_ENGINEERING
#define MIN_REGISTER_ADDRESS 0x0000 /* PCI register addresses are taken as releative to the appropriate BAR */
#define MAX_REGISTER_ADDRESS 0xc000 /* AR5212/AR5213 seems to have a 48k address range */
#define MAX_REGISTER_NAME_LEN 32 /* Maximum length of register nicknames in debug output */
#define UNKNOWN_NAME "(unknown)" /* Name used when reading/listing undocumented registers */
#endif /* #ifdef ATH_REVERSE_ENGINEERING */
/*
* Convert from net80211 layer values to Ath layer values. Hopefully this will
* be optimised away when the two constants are the same.
*/
typedef unsigned int ath_keyix_t;
#define ATH_KEY(_keyix) ((_keyix == IEEE80211_KEYIX_NONE) ? HAL_TXKEYIX_INVALID : _keyix)
#define ATH_MIN_FF_RATE 12000 /* min rate for ff aggregation in kbps */
#define ATH_MIN_FF_RATE 12000 /* min rate for ff aggregation in kbps */
struct ath_buf;
typedef STAILQ_HEAD(, ath_buf) ath_bufhead;
/* driver-specific node state */
struct ath_node {
struct ieee80211_node an_node; /* base class */
u_int16_t an_decomp_index; /* decompression mask index */
u_int32_t an_avgrssi; /* average rssi over all rx frames */
u_int8_t an_prevdatarix; /* rate ix of last data frame */
u_int16_t an_minffrate; /* min rate in kbps for ff to aggregate */
HAL_NODE_STATS an_halstats; /* rssi statistics used by hal */
struct ath_buf *an_tx_ffbuf[WME_NUM_AC]; /* ff staging area */
ath_bufhead an_uapsd_q; /* U-APSD delivery queue */
int an_uapsd_qdepth; /* U-APSD delivery queue depth */
ath_bufhead an_uapsd_overflowq; /* U-APSD overflow queue (for > MaxSp frames) */
int an_uapsd_overflowqdepth; /* U-APSD overflow queue depth */
spinlock_t an_uapsd_lock; /* U-APSD delivery queue lock */
/* variable-length rate control state follows */
};
#define ATH_NODE(_n) ((struct ath_node *)(_n))
#define ATH_NODE_CONST(ni) ((const struct ath_node *)(ni))
#define ATH_NODE_UAPSD_LOCK_INIT(_an) spin_lock_init(&(_an)->an_uapsd_lock)
#define ATH_NODE_UAPSD_LOCK_IRQ(_an) do { \
unsigned long __an_uapsd_lockflags; \
spin_lock_irqsave(&(_an)->an_uapsd_lock, __an_uapsd_lockflags);
#define ATH_NODE_UAPSD_UNLOCK_IRQ(_an) \
spin_unlock_irqrestore(&(_an)->an_uapsd_lock, __an_uapsd_lockflags); \
} while (0)
#define ATH_NODE_UAPSD_UNLOCK_IRQ_EARLY(_an) \
spin_unlock_irqrestore(&(_an)->an_uapsd_lock, __an_uapsd_lockflags);
#define ATH_RSSI_LPF_LEN 10
#define ATH_RSSI_DUMMY_MARKER 0x127
#define ATH_EP_MUL(x, mul) ((x) * (mul))
#define ATH_RSSI_IN(x) (ATH_EP_MUL((x), HAL_RSSI_EP_MULTIPLIER))
#define ATH_LPF_RSSI(x, y, len) \
((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y))
#define ATH_RSSI_LPF(x, y) do { \
if ((y) >= -20) \
x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \
} while (0)
#define ATH_ANTENNA_DIFF 2 /* Num frames difference in
* tx to flip default recv
* antenna
*/
struct ath_buf {
/* FFXXX: convert both list types to TAILQ to save a field? */
STAILQ_ENTRY(ath_buf) bf_list;
#ifdef ATH_SUPERG_FF
TAILQ_ENTRY(ath_buf) bf_stagelist; /* fast-frame staging list */
#endif
struct ath_desc *bf_desc; /* virtual addr of desc */
struct ath_desc_status bf_dsstatus; /* tx/rx descriptor status */
dma_addr_t bf_daddr; /* physical addr of desc */
struct sk_buff *bf_skb; /* skbuff for buf */
dma_addr_t bf_skbaddr; /* physical addr of skb data - always used by one desc*/
struct ieee80211_node *bf_node; /* pointer to the node */
u_int32_t bf_status; /* status flags */
u_int16_t bf_flags; /* tx descriptor flags */
u_int64_t bf_tsf;
int16_t bf_channoise;
#ifdef ATH_SUPERG_FF
/* XXX: combine this with bf_skbaddr if it ever changes to accommodate
* multiple segments.
*/
u_int16_t bf_numdescff; /* number of descs used for FF (these are extra) */
u_int32_t bf_queueage; /* "age" of txq when this buffer placed on stageq */
dma_addr_t bf_skbaddrff[ATH_TXDESC - 1]; /* extra addrs for FF */
#endif
};
/*
* reset the rx buffer.
* any new fields added to the athbuf and require
* reset need to be added to this macro.
* currently bf_status is the only one that
* requires reset.
*/
#define ATH_RXBUF_RESET(bf) bf->bf_status=0
/* XXX: only managed for rx at the moment */
#define ATH_BUFSTATUS_DONE 0x00000001 /* hw processing complete, desc processed by hal */
#define ATH_BUFSTATUS_RADAR_DONE 0x00000002 /* marker to indicate a PHYERR for radar pulse
has already been handled. We may receive
multiple interrupts before the rx_tasklet
clears the queue */
/* DMA state for tx/rx descriptors. */
struct ath_descdma {
const char *dd_name;
struct ath_desc *dd_desc; /* descriptors */
dma_addr_t dd_desc_paddr; /* physical addr of dd_desc */
size_t dd_desc_len; /* size of dd_desc */
struct ath_buf *dd_bufptr; /* associated buffers */
};
struct ath_hal;
struct ath_desc;
struct ath_ratectrl;
struct ath_tx99;
struct proc_dir_entry;
/*
* Data transmit queue state. One of these exists for each
* hardware transmit queue. Packets sent to us from above
* are assigned to queues based on their priority. Not all
* devices support a complete set of hardware transmit queues.
* For those devices the array sc_ac2q will map multiple
* priorities to fewer hardware queues (typically all to one
* hardware queue).
*/
struct ath_txq {
u_int axq_qnum; /* hardware q number */
u_int32_t *axq_link; /* link ptr in last TX desc */
STAILQ_HEAD(, ath_buf) axq_q; /* transmit queue */
spinlock_t axq_lock; /* lock on q and link */
int axq_depth; /* queue depth */
u_int32_t axq_totalqueued; /* total ever queued */
u_int axq_intrcnt; /* count to determine if descriptor
* should generate int on this txq.
*/
/*
* Staging queue for frames awaiting a fast-frame pairing.
*/
TAILQ_HEAD(axq_headtype, ath_buf) axq_stageq;
/* scratch compression buffer */
char *axq_compbuf; /* scratch comp buffer */
dma_addr_t axq_compbufp; /* scratch comp buffer (phys)*/
u_int axq_compbufsz; /* scratch comp buffer size */
};
/* driver-specific vap state */
struct ath_vap {
struct ieee80211vap av_vap; /* base class */
int (*av_newstate)(struct ieee80211vap *, enum ieee80211_state, int);
/* XXX beacon state */
struct ath_buf *av_bcbuf; /* beacon buffer */
struct ieee80211_beacon_offsets av_boff;/* dynamic update state */
int av_bslot; /* beacon slot index */
struct ath_txq av_mcastq; /* multicast transmit queue */
u_int8_t av_dfswait_run;
};
#define ATH_VAP(_v) ((struct ath_vap *)(_v))
#define ATH_BEACON_AIFS_DEFAULT 0 /* Default aifs for ap beacon q */
#define ATH_BEACON_CWMIN_DEFAULT 0 /* Default cwmin for ap beacon q */
#define ATH_BEACON_CWMAX_DEFAULT 0 /* Default cwmax for ap beacon q */
#define ATH_TXQ_INTR_PERIOD 5 /* axq_intrcnt period for intr gen */
#define ATH_TXQ_LOCK_INIT(_tq) spin_lock_init(&(_tq)->axq_lock)
#define ATH_TXQ_LOCK_DESTROY(_tq)
#define ATH_TXQ_LOCK_IRQ(_tq) do { \
unsigned long __axq_lockflags; \
spin_lock_irqsave(&(_tq)->axq_lock, __axq_lockflags);
#define ATH_TXQ_UNLOCK_IRQ(_tq) \
spin_unlock_irqrestore(&(_tq)->axq_lock, __axq_lockflags); \
} while (0)
#define ATH_TXQ_UNLOCK_IRQ_EARLY(_tq) \
spin_unlock_irqrestore(&(_tq)->axq_lock, __axq_lockflags);
#define ATH_TXQ_LOCK_IRQ_INSIDE(_tq) spin_lock(&(_tq)->axq_lock);
#define ATH_TXQ_UNLOCK_IRQ_INSIDE(_tq) spin_unlock(&(_tq)->axq_lock);
#define ATH_TXQ_LOCK_ASSERT(_tq) \
KASSERT(spin_is_locked(&(_tq)->axq_lock), ("txq not locked!"))
#define ATH_TXQ_INSERT_TAIL(_tq, _elm, _field) do { \
STAILQ_INSERT_TAIL( &(_tq)->axq_q, (_elm), _field); \
(_tq)->axq_depth++; \
(_tq)->axq_totalqueued++; \
} while (0)
#define ATH_TXQ_REMOVE_HEAD(_tq, _field) do { \
STAILQ_REMOVE_HEAD(&(_tq)->axq_q, _field); \
(_tq)->axq_depth--; \
} while (0)
/* move buffers from MCASTQ to CABQ */
#define ATH_TXQ_MOVE_MCASTQ(_tqs,_tqd) do { \
(_tqd)->axq_depth += (_tqs)->axq_depth; \
(_tqd)->axq_totalqueued += (_tqs)->axq_totalqueued; \
(_tqd)->axq_link = (_tqs)->axq_link; \
STAILQ_CONCAT(&(_tqd)->axq_q, &(_tqs)->axq_q); \
(_tqs)->axq_depth=0; \
(_tqs)->axq_totalqueued = 0; \
(_tqs)->axq_link = NULL; \
} while (0)
/*
* concat buffers from one queue to other
*/
#define ATH_TXQ_MOVE_Q(_tqs,_tqd) ATH_TXQ_MOVE_MCASTQ(_tqs,_tqd)
#define BSTUCK_THRESH 10 /* # of stuck beacons before resetting NB: this is a guess*/
struct ath_softc {
struct ieee80211com sc_ic; /* NB: must be first */
struct net_device *sc_dev;
void __iomem *sc_iobase; /* address of the device */
struct semaphore sc_lock; /* dev-level lock */
struct net_device_stats sc_devstats; /* device statistics */
struct ath_stats sc_stats; /* private statistics */
int devid;
int sc_debug;
void (*sc_recv_mgmt)(struct ieee80211_node *, struct sk_buff *, int, int, u_int64_t);
void (*sc_node_cleanup)(struct ieee80211_node *);
void (*sc_node_free)(struct ieee80211_node *);
void *sc_bdev; /* associated bus device */
struct ath_hal *sc_ah; /* Atheros HAL */
spinlock_t sc_hal_lock; /* hardware access lock */
struct ath_ratectrl *sc_rc; /* tx rate control support */
struct ath_tx99 *sc_tx99; /* tx99 support */
void (*sc_setdefantenna)(struct ath_softc *, u_int);
unsigned int sc_invalid:1, /* being detached */
sc_mrretry:1, /* multi-rate retry support */
sc_softled:1, /* enable LED gpio status */
sc_splitmic:1, /* split TKIP MIC keys */
sc_needmib:1, /* enable MIB stats intr */
sc_hasdiversity:1, /* rx diversity available */
sc_diversity:1, /* enable rx diversity */
sc_olddiversity:1, /* diversity setting before XR enable */
sc_hasveol:1, /* tx VEOL support */
sc_hastpc:1, /* per-packet TPC support */
sc_dturbo:1, /* dynamic turbo capable */
sc_dturbo_switch:1, /* turbo switch mode*/
sc_dturbo_hold:1, /* dynamic turbo hold state */
sc_rate_recn_state:1, /* dynamic turbo state recmded by ratectrl */
sc_ignore_ar:1, /* ignore AR during transition */
sc_ledstate:1, /* LED on/off state */
sc_blinking:1, /* LED blink operation active */
sc_beacons:1, /* beacons running */
sc_hasbmask:1, /* bssid mask support */
sc_mcastkey:1, /* mcast key cache search */
sc_hastsfadd:1, /* tsf adjust support */
sc_scanning:1, /* scanning active */
sc_nostabeacons:1, /* no beacons for station */
sc_xrgrppoll:1, /* xr group polls are active */
sc_syncbeacon:1, /* sync/resync beacon timers */
sc_hasclrkey:1, /* CLR key supported */
sc_devstopped:1, /* stopped due to of no tx bufs */
sc_stagbeacons:1, /* use staggered beacons */
sc_dfswait:1, /* waiting on channel for radar detect */
sc_ackrate:1; /* send acks at high bitrate */
/* rate tables */
const HAL_RATE_TABLE *sc_rates[IEEE80211_MODE_MAX];
const HAL_RATE_TABLE *sc_currates; /* current rate table */
const HAL_RATE_TABLE *sc_xr_rates; /* XR rate table */
const HAL_RATE_TABLE *sc_half_rates; /* half rate table */
const HAL_RATE_TABLE *sc_quarter_rates; /* quarter rate table */
HAL_OPMODE sc_opmode; /* current hal operating mode */
enum ieee80211_phymode sc_curmode; /* current phy mode */
u_int16_t sc_curtxpow; /* current tx power limit */
u_int16_t sc_curaid; /* current association id */
HAL_CHANNEL sc_curchan; /* current h/w channel */
u_int8_t sc_curbssid[IEEE80211_ADDR_LEN];
u_int8_t sc_rixmap[256]; /* IEEE to h/w rate table ix */
struct {
u_int8_t ieeerate; /* IEEE rate */
u_int8_t flags; /* radiotap flags */
u_int16_t ledon; /* softled on time */
u_int16_t ledoff; /* softled off time */
} sc_hwmap[32]; /* h/w rate ix mappings */
u_int8_t sc_minrateix; /* min h/w rate index */
u_int8_t sc_protrix; /* protection rate index */
u_int8_t sc_mcastantenna; /* Multicast antenna number */
u_int8_t sc_txantenna; /* data tx antenna (fixed or auto) */
u_int16_t sc_nvaps; /* # of active virtual APs */
u_int8_t sc_nstavaps; /* # of active station VAPs */
u_int8_t sc_nmonvaps; /* # of monitor VAPs */
u_int8_t sc_nbcnvaps; /* # of vaps sending beacons */
u_int sc_fftxqmin; /* aggregation threshold */
HAL_INT sc_imask; /* interrupt mask copy */
u_int sc_keymax; /* size of key cache */
u_int8_t sc_keymap[ATH_KEYBYTES]; /* key use bit map */
struct ieee80211_node *sc_keyixmap[ATH_KEYMAX];/* key ix->node map */
u_int8_t sc_bssidmask[IEEE80211_ADDR_LEN];
u_int sc_ledpin; /* GPIO pin for driving LED */
u_int sc_ledon; /* pin setting for LED on */
u_int sc_ledidle; /* idle polling interval */
int sc_ledevent; /* time of last LED event */
u_int8_t sc_rxrate; /* current rx rate for LED */
u_int8_t sc_txrate; /* current tx rate for LED */
u_int16_t sc_ledoff; /* off time for current blink */
struct timer_list sc_ledtimer; /* led off timer */
struct timer_list sc_dfswaittimer; /* dfs wait timer */
struct ATH_TQ_STRUCT sc_fataltq; /* fatal error intr tasklet */
int sc_rxbufsize; /* rx size based on mtu */
struct ath_descdma sc_rxdma; /* RX descriptors */
ath_bufhead sc_rxbuf; /* receive buffer */
struct ath_buf *sc_rxbufcur; /* current rx buffer */
u_int32_t *sc_rxlink; /* link ptr in last RX desc */
spinlock_t sc_rxbuflock;
struct ATH_TQ_STRUCT sc_rxtq; /* rx intr tasklet */
struct ATH_TQ_STRUCT sc_rxorntq; /* rxorn intr tasklet */
u_int8_t sc_defant; /* current default antenna */
u_int8_t sc_rxotherant; /* RXs on non-default antenna */
u_int16_t sc_cachelsz; /* cache line size */
struct ath_descdma sc_txdma; /* TX descriptors */
ath_bufhead sc_txbuf; /* transmit buffer */
spinlock_t sc_txbuflock; /* txbuf lock */
u_int sc_txqsetup; /* h/w queues setup */
u_int sc_txintrperiod; /* tx interrupt batching */
struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
struct ath_txq *sc_ac2q[WME_NUM_AC]; /* WME AC -> h/w qnum */
struct ATH_TQ_STRUCT sc_txtq; /* tx intr tasklet */
u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];
struct ath_descdma sc_bdma; /* beacon descriptors */
ath_bufhead sc_bbuf; /* beacon buffers */
u_int sc_bhalq; /* HAL q for outgoing beacons */
u_int sc_bmisscount; /* missed beacon transmits */
u_int32_t sc_ant_tx[8]; /* recent tx frames/antenna */
struct ath_txq *sc_cabq; /* tx q for cab frames */
struct ath_txq sc_grpplq; /* tx q for XR group polls */
struct ath_txq *sc_xrtxq; /* tx q for XR data */
struct ath_descdma sc_grppolldma; /* TX descriptors for grppoll */
ath_bufhead sc_grppollbuf; /* transmit buffers for grouppoll */
u_int16_t sc_xrpollint; /* xr poll interval */
u_int16_t sc_xrpollcount; /* xr poll count */
struct ath_txq *sc_uapsdq; /* tx q for uapsd */
struct ATH_TQ_STRUCT sc_bmisstq; /* bmiss intr tasklet */
struct ATH_TQ_STRUCT sc_bstucktq; /* beacon stuck intr tasklet */
enum {
OK, /* no change needed */
UPDATE, /* update pending */
COMMIT /* beacon sent, commit change */
} sc_updateslot; /* slot time update fsm */
int sc_slotupdate; /* slot to next advance fsm */
struct ieee80211vap *sc_bslot[ATH_BCBUF];/* beacon xmit slots */
int sc_bnext; /* next slot for beacon xmit */
struct timer_list sc_cal_ch; /* calibration timer */
HAL_NODE_STATS sc_halstats; /* station-mode rssi stats */
struct ctl_table_header *sc_sysctl_header;
struct ctl_table *sc_sysctls;
u_int16_t sc_reapcount; /* # of tx buffers reaped after net dev stopped */
struct timer_list sc_mib_enable;
#ifdef ATH_REVERSE_ENGINEERING
u_int8_t register_snapshot[MAX_REGISTER_ADDRESS];
#endif /* #ifdef ATH_REVERSE_ENGINEERING */
#ifdef ATH_SUPERG_DYNTURBO
struct timer_list sc_dturbo_switch_mode;/* AP scan timer */
u_int32_t sc_dturbo_tcount; /* beacon intval count */
u_int32_t sc_dturbo_hold_max; /* hold count before switching to base*/
u_int16_t sc_dturbo_hold_count; /* hold count before switching to base*/
u_int16_t sc_dturbo_turbo_tmin; /* min turbo count */
u_int32_t sc_dturbo_bytes; /* bandwidth stats */
u_int32_t sc_dturbo_base_tmin; /* min time in base */
u_int32_t sc_dturbo_turbo_tmax; /* max time in turbo */
u_int32_t sc_dturbo_bw_base; /* bandwidth threshold */
u_int32_t sc_dturbo_bw_turbo; /* bandwidth threshold */
#endif
u_int sc_slottimeconf; /* manual override for slottime */
u_int64_t sc_tsf; /* TSF at last rx interrupt */
};
typedef void (*ath_callback) (struct ath_softc *);
#define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1 << i))
#define ATH_TXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_txbuflock)
#define ATH_TXBUF_LOCK_DESTROY(_sc)
#define ATH_TXBUF_LOCK_IRQ(_sc) do { \
unsigned long __txbuflockflags; \
spin_lock_irqsave(&(_sc)->sc_txbuflock, __txbuflockflags);
#define ATH_TXBUF_UNLOCK_IRQ(_sc) \
spin_unlock_irqrestore(&(_sc)->sc_txbuflock, __txbuflockflags); \
} while (0)
#define ATH_TXBUF_UNLOCK_IRQ_EARLY(_sc) \
spin_unlock_irqrestore(&(_sc)->sc_txbuflock, __txbuflockflags);
#define ATH_TXBUF_LOCK_ASSERT(_sc) \
KASSERT(spin_is_locked(&(_sc)->sc_txbuflock), ("txbuf not locked!"))
#define ATH_RXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_rxbuflock)
#define ATH_RXBUF_LOCK_DESTROY(_sc)
#define ATH_RXBUF_LOCK_IRQ(_sc) do { \
unsigned long __rxbuflockflags; \
spin_lock_irqsave(&(_sc)->sc_rxbuflock, __rxbuflockflags);
#define ATH_RXBUF_UNLOCK_IRQ(_sc) \
spin_unlock_irqrestore(&(_sc)->sc_rxbuflock, __rxbuflockflags); \
} while (0)
#define ATH_RXBUF_UNLOCK_IRQ_EARLY(_sc) \
spin_unlock_irqrestore(&(_sc)->sc_rxbuflock, __rxbuflockflags);
/* Protects the device from concurrent accesses */
#define ATH_LOCK_INIT(_sc) init_MUTEX(&(_sc)->sc_lock)
#define ATH_LOCK_DESTROY(_sc)
#define ATH_LOCK(_sc) down(&(_sc)->sc_lock)
#define ATH_UNLOCK(_sc) up(&(_sc)->sc_lock)
int ath_attach(u_int16_t, struct net_device *, HAL_BUS_TAG);
int ath_detach(struct net_device *);
void ath_resume(struct net_device *);
void ath_suspend(struct net_device *);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
irqreturn_t ath_intr(int, void *);
#else
irqreturn_t ath_intr(int, void *, struct pt_regs *);
#endif
int ath_ioctl_ethtool(struct ath_softc *, int, void __user *);
void bus_read_cachesize(struct ath_softc *, u_int8_t *);
void ath_sysctl_register(void);
void ath_sysctl_unregister(void);
#endif /* _DEV_ATH_ATHVAR_H */

38
ath/version.h Normal file
View File

@ -0,0 +1,38 @@
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
#define ATH_PCI_VERSION "0.9.4.5"

101
ath_hal/Makefile Normal file
View File

@ -0,0 +1,101 @@
#
# Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath/Makefile#12 $
#
#
# Makefile for the Atheros WLAN driver.
#
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)/..
include $(TOP)/Makefile.inc
obj-m += ath_hal.o
ath_hal-objs := ah_os.o $(TARGET).hal.o
hostprogs-y := uudecode
# For older 2.6 kernels
host-progs := $(hostprogs-y)
ifdef LINUX24
export-objs := ah_os.o
endif
INCS += -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
ifneq (,$(filter xscale% arm%,$(TARGET)))
LDFLAGS += --no-warn-mismatch
endif
-include $(TOPDIR)/Rules.make
all:
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
ifdef LINUX24
$(obj)/uudecode: $(obj)/uudecode.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
endif
quiet_cmd_uudecode = UUDECODE $@
cmd_uudecode = $(obj)/uudecode -o $@ $<
$(obj)/$(TARGET).hal.o: $(HAL)/public/$(TARGET).hal.o.uu $(obj)/uudecode
ifdef LINUX24
$(Q)$(obj)/uudecode -o $@ $<
else
$(call if_changed,uudecode)
endif
install:
test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
install ath_hal.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
clean:
rm -f *~ *.o *.ko *.mod.c uudecode .*.cmd
rm -f .depend .version .*.o.flags .*.o.d
rm -rf .tmp_versions
ath_hal.o: $(ath_hal-objs)
$(LD) $(LDFLAGS) -o ath_hal.$(KMODSUF) -r $(ath_hal-objs)

51
ath_hal/Makefile.kernel Normal file
View File

@ -0,0 +1,51 @@
#
# Makefile for the Atheros WLAN driver.
#
obj ?= .
src ?= .
srctree ?= .
TOP = $(srctree)/$(src)/..
include $(TOP)/BuildCaps.inc
include $(TOP)/ath_hal/ah_target.inc
ATH_HAL=$(TOP)/ath_hal
COMPAT= $(TOP)/include
HAL= $(TOP)/hal
INCS = -include $(COMPAT)/compat.h -I$(COMPAT)
INCS += -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS += $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\" \
-DTARGET=\"$(TARGET)\"
ifneq (,$(filter xscale% arm%,$(TARGET)))
LDFLAGS := --no-warn-mismatch
endif
ifneq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) += ath_hal.o
ath_hal-objs := ah_os.o $(TARGET).hal.o
hostprogs-y := uudecode
host-progs := $(hostprogs-y)
endif
ifeq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) += ah_os.o $(TARGET).hal.o
O_TARGET := ath_hal.o
include $(TOPDIR)/Rules.make
export-objs := ah_os.o
list-multi := ath_hal.o
uudecode: uudecode.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
endif
$(obj)/$(TARGET).hal.o: $(HAL)/public/$(TARGET).hal.o.uu $(obj)/uudecode
$(Q)echo "deps_$@ :=" >$(@D)/.$(@F).cmd
$(Q)$(obj)/uudecode -o $@ $<

607
ath_hal/ah_os.c Normal file
View File

@ -0,0 +1,607 @@
/*-
* Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
#include "opt_ah.h"
#ifndef EXPORT_SYMTAB
#define EXPORT_SYMTAB
#endif
/* Don't use virtualized timer in Linux 2.6.20+ */
#define USE_REAL_TIME_DELAY
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <asm/io.h>
#include <ah.h>
#include <ah_os.h>
#ifdef AH_DEBUG
static int ath_hal_debug = 0;
#endif
int ath_hal_dma_beacon_response_time = 2; /* in TUs */
int ath_hal_sw_beacon_response_time = 10; /* in TUs */
int ath_hal_additional_swba_backoff = 0; /* in TUs */
struct ath_hal *
_ath_hal_attach(u_int16_t devid, HAL_SOFTC sc,
HAL_BUS_TAG t, HAL_BUS_HANDLE h, HAL_STATUS *s)
{
struct ath_hal *ah = ath_hal_attach(devid, sc, t, h, s);
if (ah)
#ifndef __MOD_INC_USE_COUNT
if (!try_module_get(THIS_MODULE)) {
printk(KERN_WARNING "%s: try_module_get failed\n",
__func__);
_ath_hal_detach(ah);
return NULL;
}
#else
MOD_INC_USE_COUNT;
#endif
return ah;
}
void
_ath_hal_detach(struct ath_hal *ah)
{
(*ah->ah_detach)(ah);
#ifndef __MOD_INC_USE_COUNT
module_put(THIS_MODULE);
#else
MOD_DEC_USE_COUNT;
#endif
}
/*
* Print/log message support.
*/
void __ahdecl
ath_hal_vprintf(struct ath_hal *ah, const char* fmt, va_list ap)
{
char buf[1024]; /* XXX */
vsnprintf(buf, sizeof(buf), fmt, ap);
printk("%s", buf);
}
void __ahdecl
ath_hal_printf(struct ath_hal *ah, const char* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
ath_hal_vprintf(ah, fmt, ap);
va_end(ap);
}
EXPORT_SYMBOL(ath_hal_printf);
/*
* Format an Ethernet MAC for printing.
*/
const char* __ahdecl
ath_hal_ether_sprintf(const u_int8_t *mac)
{
static char etherbuf[18];
snprintf(etherbuf, sizeof(etherbuf), "%02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return etherbuf;
}
#ifdef AH_ASSERT
void __ahdecl
ath_hal_assert_failed(const char* filename, int lineno, const char *msg)
{
printk("Atheros HAL assertion failure: %s: line %u: %s\n",
filename, lineno, msg);
panic("ath_hal_assert");
}
#endif /* AH_ASSERT */
#ifdef AH_DEBUG_ALQ
/*
* ALQ register tracing support.
*
* Setting hw.ath.hal.alq=1 enables tracing of all register reads and
* writes to the file /tmp/ath_hal.log. The file format is a simple
* fixed-size array of records. When done logging set hw.ath.hal.alq=0
* and then decode the file with the ardecode program (that is part of the
* HAL). If you start+stop tracing the data will be appended to an
* existing file.
*
* NB: doesn't handle multiple devices properly; only one DEVICE record
* is emitted and the different devices are not identified.
*/
#include "alq/alq.h"
#include "ah_decode.h"
static struct alq *ath_hal_alq;
static int ath_hal_alq_emitdev; /* need to emit DEVICE record */
static u_int ath_hal_alq_lost; /* count of lost records */
static const char *ath_hal_logfile = "/tmp/ath_hal.log";
static u_int ath_hal_alq_qsize = 8*1024;
static int
ath_hal_setlogging(int enable)
{
int error;
if (enable) {
if (!capable(CAP_NET_ADMIN))
return -EPERM;
error = alq_open(&ath_hal_alq, ath_hal_logfile,
sizeof (struct athregrec), ath_hal_alq_qsize);
ath_hal_alq_lost = 0;
ath_hal_alq_emitdev = 1;
printk("ath_hal: logging to %s %s\n", ath_hal_logfile,
error == 0 ? "enabled" : "could not be setup");
} else {
if (ath_hal_alq)
alq_close(ath_hal_alq);
ath_hal_alq = NULL;
printk("ath_hal: logging disabled\n");
error = 0;
}
return error;
}
/*
* Deal with the sysctl handler api changing.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
#define AH_SYSCTL_ARGS_DECL \
ctl_table *ctl, int write, struct file *filp, void *buffer, \
size_t *lenp
#define AH_SYSCTL_ARGS ctl, write, filp, buffer, lenp
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8) */
#define AH_SYSCTL_ARGS_DECL \
ctl_table *ctl, int write, struct file *filp, void *buffer,\
size_t *lenp, loff_t *ppos
#define AH_SYSCTL_ARGS ctl, write, filp, buffer, lenp, ppos
#endif
static int
sysctl_hw_ath_hal_log(AH_SYSCTL_ARGS_DECL)
{
int error, enable;
ctl->data = &enable;
ctl->maxlen = sizeof(enable);
enable = (ath_hal_alq != NULL);
error = proc_dointvec(AH_SYSCTL_ARGS);
if (error || !write)
return error;
else
return ath_hal_setlogging(enable);
}
/*
This should only be called while holding the lock, sc->sc_hal_lock.
*/
static struct ale *
ath_hal_alq_get(struct ath_hal *ah)
{
struct ale *ale;
if (ath_hal_alq_emitdev) {
ale = alq_get(ath_hal_alq, ALQ_NOWAIT);
if (ale) {
struct athregrec *r =
(struct athregrec *) ale->ae_data;
r->op = OP_DEVICE;
r->reg = 0;
r->val = ah->ah_devid;
alq_post(ath_hal_alq, ale);
ath_hal_alq_emitdev = 0;
} else
ath_hal_alq_lost++;
}
ale = alq_get(ath_hal_alq, ALQ_NOWAIT);
if (!ale)
ath_hal_alq_lost++;
return ale;
}
/*
This should only be called while holding the lock, sc->sc_hal_lock.
*/
void __ahdecl
ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val)
{
if (ath_hal_alq) {
unsigned long flags;
struct ale *ale;
local_irq_save(flags);
ale = ath_hal_alq_get(ah);
if (ale) {
struct athregrec *r = (struct athregrec *) ale->ae_data;
r->op = OP_WRITE;
r->reg = reg;
r->val = val;
alq_post(ath_hal_alq, ale);
}
local_irq_restore(flags);
}
_OS_REG_WRITE(ah, reg, val);
}
EXPORT_SYMBOL(ath_hal_reg_write);
/*
This should only be called while holding the lock, sc->sc_hal_lock.
*/
u_int32_t __ahdecl
ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg)
{
u_int32_t val;
val = _OS_REG_READ(ah, reg);
if (ath_hal_alq) {
unsigned long flags;
struct ale *ale;
ale = ath_hal_alq_get(ah);
if (ale) {
struct athregrec *r = (struct athregrec *) ale->ae_data;
r->op = OP_READ;
r->reg = reg;
r->val = val;
alq_post(ath_hal_alq, ale);
}
}
return val;
}
EXPORT_SYMBOL(ath_hal_reg_read);
/*
* This should only be called while holding the lock, sc->sc_hal_lock.
*/
void __ahdecl
OS_MARK(struct ath_hal *ah, u_int id, u_int32_t v)
{
if (ath_hal_alq) {
struct ale *ale;
ale = ath_hal_alq_get(ah);
if (ale) {
struct athregrec *r = (struct athregrec *) ale->ae_data;
r->op = OP_MARK;
r->reg = id;
r->val = v;
alq_post(ath_hal_alq, ale);
}
}
}
EXPORT_SYMBOL(OS_MARK);
#elif defined(AH_DEBUG) || defined(AH_REGOPS_FUNC)
#ifdef AH_DEBUG
/* Store the current function name (should be called by wrapper functions)
* useful for debugging and figuring out, which hal function sets which
* registers */
char *ath_hal_func = NULL;
#endif
/*
* Memory-mapped device register read/write. These are here
* as routines when debugging support is enabled and/or when
* explicitly configured to use function calls. The latter is
* for architectures that might need to do something before
* referencing memory (e.g. remap an i/o window).
*
* This should only be called while holding the lock, sc->sc_hal_lock.
*
* NB: see the comments in ah_osdep.h about byte-swapping register
* reads and writes to understand what's going on below.
*/
void __ahdecl
ath_hal_reg_write(struct ath_hal *ah, u_int reg, u_int32_t val)
{
#ifdef AH_DEBUG
if (ath_hal_debug > 1)
ath_hal_printf(ah, "%s: WRITE 0x%x <= 0x%x\n",
(ath_hal_func ?: "unknown"), reg, val);
#endif
_OS_REG_WRITE(ah, reg, val);
}
EXPORT_SYMBOL(ath_hal_reg_write);
/* This should only be called while holding the lock, sc->sc_hal_lock. */
u_int32_t __ahdecl
ath_hal_reg_read(struct ath_hal *ah, u_int reg)
{
u_int32_t val;
val = _OS_REG_READ(ah, reg);
#ifdef AH_DEBUG
if (ath_hal_debug > 1)
ath_hal_printf(ah, "%s: READ 0x%x => 0x%x\n",
(ath_hal_func ?: "unknown"), reg, val);
#endif
return val;
}
EXPORT_SYMBOL(ath_hal_reg_read);
#endif /* AH_DEBUG || AH_REGOPS_FUNC */
#ifdef AH_DEBUG
void __ahdecl
HALDEBUG(struct ath_hal *ah, const char* fmt, ...)
{
if (ath_hal_debug) {
__va_list ap;
va_start(ap, fmt);
ath_hal_vprintf(ah, fmt, ap);
va_end(ap);
}
}
void __ahdecl
HALDEBUGn(struct ath_hal *ah, u_int level, const char* fmt, ...)
{
if (ath_hal_debug >= level) {
__va_list ap;
va_start(ap, fmt);
ath_hal_vprintf(ah, fmt, ap);
va_end(ap);
}
}
#endif /* AH_DEBUG */
/*
* Delay n microseconds.
*/
void __ahdecl
ath_hal_delay(int n)
{
udelay(n);
}
u_int32_t __ahdecl
ath_hal_getuptime(struct ath_hal *ah)
{
return ((jiffies / HZ) * 1000) + (jiffies % HZ) * (1000 / HZ);
}
EXPORT_SYMBOL(ath_hal_getuptime);
/*
* Allocate/free memory.
*/
void * __ahdecl
ath_hal_malloc(size_t size)
{
void *p;
p = kmalloc(size, GFP_KERNEL);
if (p)
OS_MEMZERO(p, size);
return p;
}
void __ahdecl
ath_hal_free(void* p)
{
kfree(p);
}
void __ahdecl
ath_hal_memzero(void *dst, size_t n)
{
memset(dst, 0, n);
}
EXPORT_SYMBOL(ath_hal_memzero);
void * __ahdecl
ath_hal_memcpy(void *dst, const void *src, size_t n)
{
return memcpy(dst, src, n);
}
EXPORT_SYMBOL(ath_hal_memcpy);
int __ahdecl
ath_hal_memcmp(const void *a, const void *b, size_t n)
{
return memcmp(a, b, n);
}
EXPORT_SYMBOL(ath_hal_memcmp);
enum {
DEV_ATH = 9, /* XXX must match driver */
};
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
static ctl_table ath_hal_sysctls[] = {
#ifdef AH_DEBUG
{ .ctl_name = CTL_AUTO,
.procname = "debug",
.mode = 0644,
.data = &ath_hal_debug,
.maxlen = sizeof(ath_hal_debug),
.proc_handler = proc_dointvec
},
#endif
{ .ctl_name = CTL_AUTO,
.procname = "dma_beacon_response_time",
.data = &ath_hal_dma_beacon_response_time,
.maxlen = sizeof(ath_hal_dma_beacon_response_time),
.mode = 0644,
.proc_handler = proc_dointvec
},
{ .ctl_name = CTL_AUTO,
.procname = "sw_beacon_response_time",
.mode = 0644,
.data = &ath_hal_sw_beacon_response_time,
.maxlen = sizeof(ath_hal_sw_beacon_response_time),
.proc_handler = proc_dointvec
},
{ .ctl_name = CTL_AUTO,
.procname = "swba_backoff",
.mode = 0644,
.data = &ath_hal_additional_swba_backoff,
.maxlen = sizeof(ath_hal_additional_swba_backoff),
.proc_handler = proc_dointvec
},
#ifdef AH_DEBUG_ALQ
{ .ctl_name = CTL_AUTO,
.procname = "alq",
.mode = 0644,
.proc_handler = sysctl_hw_ath_hal_log
},
{ .ctl_name = CTL_AUTO,
.procname = "alq_size",
.mode = 0644,
.data = &ath_hal_alq_qsize,
.maxlen = sizeof(ath_hal_alq_qsize),
.proc_handler = proc_dointvec
},
{ .ctl_name = CTL_AUTO,
.procname = "alq_lost",
.mode = 0644,
.data = &ath_hal_alq_lost,
.maxlen = sizeof(ath_hal_alq_lost),
.proc_handler = proc_dointvec
},
#endif
{ 0 }
};
static ctl_table ath_hal_table[] = {
{ .ctl_name = CTL_AUTO,
.procname = "hal",
.mode = 0555,
.child = ath_hal_sysctls
}, { 0 }
};
static ctl_table ath_ath_table[] = {
{ .ctl_name = DEV_ATH,
.procname = "ath",
.mode = 0555,
.child = ath_hal_table
}, { 0 }
};
static ctl_table ath_root_table[] = {
{ .ctl_name = CTL_DEV,
.procname = "dev",
.mode = 0555,
.child = ath_ath_table
}, { 0 }
};
static struct ctl_table_header *ath_hal_sysctl_header;
static void
ath_hal_sysctl_register(void)
{
static int initialized = 0;
if (!initialized) {
ath_hal_sysctl_header =
ATH_REGISTER_SYSCTL_TABLE(ath_root_table);
initialized = 1;
}
}
static void
ath_hal_sysctl_unregister(void)
{
if (ath_hal_sysctl_header)
unregister_sysctl_table(ath_hal_sysctl_header);
}
/*
* Module glue.
*/
#include "version.h"
static char *dev_info = "ath_hal";
MODULE_AUTHOR("Errno Consulting, Sam Leffler");
MODULE_DESCRIPTION("Atheros Hardware Access Layer (HAL)");
MODULE_SUPPORTED_DEVICE("Atheros WLAN devices");
#ifdef MODULE_VERSION
MODULE_VERSION(TARGET ": " ATH_HAL_VERSION);
#endif
#ifdef MODULE_LICENSE
MODULE_LICENSE("Proprietary");
#endif
EXPORT_SYMBOL(ath_hal_probe);
EXPORT_SYMBOL(_ath_hal_attach);
EXPORT_SYMBOL(_ath_hal_detach);
EXPORT_SYMBOL(ath_hal_init_channels);
EXPORT_SYMBOL(ath_hal_getwirelessmodes);
EXPORT_SYMBOL(ath_hal_computetxtime);
EXPORT_SYMBOL(ath_hal_mhz2ieee);
EXPORT_SYMBOL(ath_hal_process_noisefloor);
static int __init
init_ath_hal(void)
{
const char *sep;
int i;
printk(KERN_INFO "%s: %s (", dev_info, ath_hal_version);
sep = "";
for (i = 0; ath_hal_buildopts[i] != NULL; i++) {
printk("%s%s", sep, ath_hal_buildopts[i]);
sep = ", ";
}
printk(")\n");
ath_hal_sysctl_register();
return (0);
}
module_init(init_ath_hal);
static void __exit
exit_ath_hal(void)
{
ath_hal_sysctl_unregister();
printk(KERN_INFO "%s: driver unloaded\n", dev_info);
}
module_exit(exit_ath_hal);

256
ath_hal/ah_os.h Normal file
View File

@ -0,0 +1,256 @@
/*-
* Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
#ifndef _ATH_AH_OS_H_
#define _ATH_AH_OS_H_
/*
* Atheros Hardware Access Layer (HAL) OS Dependent Definitions.
*/
/*
MadWifi safe register operations:
When hacking on registers directly we need to use the macros
below, to avoid concurrent PCI access and abort mode errors.
* ath_reg_read
* ATH_REG_WRITE
HAL-ONLY register operations:
* _OS_REG_READ
* _OS_REG_WRITE
* OS_REG_READ
* OS_REG_WRITE
* ath_hal_reg_read.
* ath_hal_reg_write
When compiled in HAL:
* We do not require locking overhead and function call unless user is debugging.
* All HAL operations are executed in the context of a MadWifi wrapper call which holds
the HAL lock.
* Normally HAL is build with the non-modified version of this file so it doesnt have our
funny macros anyway.
When compiled in MadWifi:
* The HAL wrapper API takes the HAL lock before invoking the HAL.
* HAL access is already protected, and MadWifi must NOT access the functions listed above.
*/
/*
* When building the HAL proper we use no GPL-contaminated include
* files and must define these types ourself. Beware of these being
* mismatched against the contents of <linux/types.h>
*/
#ifndef _LINUX_TYPES_H
/* NB: arm defaults to unsigned so be explicit */
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
typedef unsigned long long u_int64_t;
typedef unsigned int size_t;
typedef unsigned int u_int;
typedef void* va_list;
#endif
/*
* Linux/BSD gcc compatibility shims.
*/
#define __printflike(_a,_b) \
__attribute__ ((__format__ (__printf__, _a, _b)))
#define __va_list va_list
#define OS_INLINE __inline
extern int ath_hal_dma_beacon_response_time;
extern int ath_hal_sw_beacon_response_time;
extern int ath_hal_additional_swba_backoff;
void __ahdecl ath_hal_vprintf(struct ath_hal *ah, const char* fmt,
va_list ap);
void __ahdecl ath_hal_printf(struct ath_hal *ah, const char* fmt, ...);
const char* __ahdecl ath_hal_ether_sprintf(const u_int8_t *mac);
int __ahdecl ath_hal_memcmp(const void *a, const void *b, size_t n);
void * __ahdecl ath_hal_malloc(size_t size);
void __ahdecl ath_hal_free(void* p);
/* Delay n microseconds. */
extern void __ahdecl ath_hal_delay(int);
#define OS_DELAY(_n) ath_hal_delay(_n)
#define OS_MEMZERO(_a, _n) ath_hal_memzero((_a), (_n))
extern void __ahdecl ath_hal_memzero(void *, size_t);
#define OS_MEMCPY(_d, _s, _n) ath_hal_memcpy(_d,_s,_n)
extern void * __ahdecl ath_hal_memcpy(void *, const void *, size_t);
#ifndef abs
#define abs(_a) __builtin_abs(_a)
#endif
struct ath_hal;
extern u_int32_t __ahdecl ath_hal_getuptime(struct ath_hal *);
#define OS_GETUPTIME(_ah) ath_hal_getuptime(_ah)
/* Byte order/swapping support. */
#define AH_LITTLE_ENDIAN 1234
#define AH_BIG_ENDIAN 4321
#ifndef AH_BYTE_ORDER
/*
* When the .inc file is not available (e.g. when building
* in a kernel source tree); look for some other way to
* setup the host byte order.
*/
#ifdef __LITTLE_ENDIAN
#define AH_BYTE_ORDER AH_LITTLE_ENDIAN
#endif
#ifdef __BIG_ENDIAN
#define AH_BYTE_ORDER AH_BIG_ENDIAN
#endif
#ifndef AH_BYTE_ORDER
#error "Do not know host byte order"
#endif
#endif /* AH_BYTE_ORDER */
/*
* Note that register accesses are done using target-specific
* functions when debugging is enabled (AH_DEBUG) or we are
* explicitly configured this way.
*
* The hardware registers are native little-endian byte order.
* Big-endian hosts are handled by enabling hardware byte-swap
* of register reads and writes at reset. But the PCI clock
* domain registers are not byte swapped! Thus, on big-endian
* platforms we have to byte-swap thoese registers specifically.
* Most of this code is collapsed at compile time because the
* register values are constants.
*
* Presumably when talking about hardware byte-swapping, the above
* text is referring to the Atheros chipset, as the registers
* referred to are in the PCI memory address space, and these are
* never byte-swapped by PCI chipsets or bridges, but always
* written directly (i.e. the format defined by the manufacturer).
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
# if (AH_BYTE_ORDER == AH_BIG_ENDIAN)
#define _OS_REG_WRITE(_ah, _reg, _val) do { \
(0x4000 <= (_reg) && (_reg) < 0x5000) ? \
iowrite32((_val), (_ah)->ah_sh + (_reg)) : \
iowrite32be((_val), (_ah)->ah_sh + (_reg)); \
} while (0)
#define _OS_REG_READ(_ah, _reg) \
((0x4000 <= (_reg) && (_reg) < 0x5000) ? \
ioread32((_ah)->ah_sh + (_reg)) : \
ioread32be((_ah)->ah_sh + (_reg)));
# else /* AH_LITTLE_ENDIAN */
#define _OS_REG_WRITE(_ah, _reg, _val) do { \
iowrite32(_val, (_ah)->ah_sh + (_reg)); \
} while (0)
#define _OS_REG_READ(_ah, _reg) \
ioread32((_ah)->ah_sh + (_reg))
# endif /* AH_BYTE_ORDER */
#else
# if (AH_BYTE_ORDER == AH_BIG_ENDIAN)
#define _OS_REG_WRITE(_ah, _reg, _val) do { \
writel((0x4000 <= (_reg) && (_reg) < 0x5000) ? \
(_val) : cpu_to_le32(_val), \
(_ah)->ah_sh + (_reg)); \
} while (0)
#define _OS_REG_READ(_ah, _reg) \
((0x4000 <= (_reg) && (_reg) < 0x5000) ? \
readl((_ah)->ah_sh + (_reg)) : \
cpu_to_le32(readl((_ah)->ah_sh + (_reg))))
# else /* AH_LITTLE_ENDIAN */
#define _OS_REG_WRITE(_ah, _reg, _val) do { \
writel(_val, (_ah)->ah_sh + (_reg)); \
} while (0)
#define _OS_REG_READ(_ah, _reg) \
readl((_ah)->ah_sh + (_reg))
# endif /* AH_BYTE_ORDER */
#endif /* KERNEL_VERSON(2,6,12) */
/*
The functions in this section are not intended to be invoked by MadWifi driver
code, but by the HAL. They are NOT safe for direct invocation when the
sc->sc_hal_lock is not held. Use ath_reg_read and ATH_REG_WRITE instead!
*/
#if defined(AH_DEBUG) || defined(AH_REGOPS_FUNC) || defined(AH_DEBUG_ALQ)
#define OS_REG_WRITE(_ah, _reg, _val) ath_hal_reg_write(_ah, _reg, _val)
#define OS_REG_READ(_ah, _reg) ath_hal_reg_read(_ah, _reg)
extern void __ahdecl ath_hal_reg_write(struct ath_hal *ah, u_int reg, u_int32_t val);
extern u_int32_t __ahdecl ath_hal_reg_read(struct ath_hal *ah, u_int reg);
#else
#define OS_REG_WRITE(_ah, _reg, _val) _OS_REG_WRITE(_ah, _reg, _val)
#define OS_REG_READ(_ah, _reg) _OS_REG_READ(_ah, _reg)
#endif /* AH_DEBUG || AH_REGFUNC || AH_DEBUG_ALQ */
extern char *ath_hal_func;
static inline void ath_hal_set_function(const char *name)
#if defined(AH_DEBUG)
{
ath_hal_func = (char *)name;
}
#else
{ }
#endif
#ifdef AH_DEBUG_ALQ
extern void __ahdecl OS_MARK(struct ath_hal *, u_int id, u_int32_t value);
#else
#define OS_MARK(_ah, _id, _v)
#endif
/*
* Linux-specific attach/detach methods needed for module reference counting.
*
* NB: These are intentionally not marked __ahdecl since they are
* compiled with the default calling convention and are not called
* from within the HAL.
*/
extern struct ath_hal *_ath_hal_attach(u_int16_t devid, HAL_SOFTC,
HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
extern void _ath_hal_detach(struct ath_hal *);
#endif /* _ATH_AH_OSDEP_H_ */

62
ath_hal/ah_osdep.h Normal file
View File

@ -0,0 +1,62 @@
/*-
* Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
#ifndef _ATH_AH_OSDEP_H_
#define _ATH_AH_OSDEP_H_
/*
* Linux on i386 may pass parameters in registers. This is an option
* starting with Linux 2.6.4. Starting with Linux 2.6.20, it's done
* unconditionally. However, the HAL uses standard ABI whereas the
* parameters are passed on the stack (for maximum portability).
* "asmlinkage" forces the standard ABI for the HAL calls.
*/
#ifdef __i386__
#define __ahdecl asmlinkage
#else
#define __ahdecl
#endif
#ifndef __packed
#define __packed __attribute__((__packed__))
#endif
/* Replace void pointers from ah.h with safer specific types */
#define HAL_SOFTC struct ath_softc *
#define HAL_BUS_HANDLE void __iomem *
#define HAL_BUS_TAG struct ar531x_config *
#endif /* _ATH_AH_OSDEP_H_ */

41
ath_hal/ah_target.inc Normal file
View File

@ -0,0 +1,41 @@
# Determine HAL target based on the kernel architecture
# Make sure ARCH is defined
ifeq ($(ARCH),)
$(error ARCH must be defined)
endif
# Determine endianess. Note that it's not indicated for some CPUs at
# all, so this value is only valid for certain processors.
ifeq ($(filter-out arm%,$(ARCH)),)
ENDIAN = le
endif
ifeq ($(filter-out mips%,$(ARCH)),)
ENDIAN = be
endif
ifneq ($(CONFIG_CPU_BIG_ENDIAN)$(CONFIG_BIG_ENDIAN),)
ENDIAN = be
endif
ifneq ($(CONFIG_CPU_LITTLE_ENDIAN)$(CONFIG_LITTLE_ENDIAN),)
ENDIAN = le
endif
# Determine the target (i.e. which HAL to use).
# The default is $(ARCH)-elf
TARGET-$(CONFIG_CPU_32v4) = armv4-$(ENDIAN)-elf
TARGET-$(CONFIG_CPU_MIPS32_R1) = mips1-$(ENDIAN)-elf
TARGET-$(CONFIG_CPU_MIPS32_R2) = mips-$(ENDIAN)-elf
TARGET-$(CONFIG_CPU_R4X00) = mipsisa32-$(ENDIAN)-elf
TARGET-$(CONFIG_CPU_TX49XX) = mipsisa32-$(ENDIAN)-elf
TARGET-$(CONFIG_PPC32) = powerpc-be-elf
TARGET-$(CONFIG_CPU_SH4) = sh4-le-elf
TARGET-$(CONFIG_SPARC32) = sparc-be-elf
TARGET-$(CONFIG_SPARC64) = sparc64-be-elf
TARGET-$(CONFIG_CPU_SA110) = xscale-$(ENDIAN)-elf
TARGET-$(CONFIG_CPU_SA1100) = xscale-$(ENDIAN)-elf
TARGET-$(CONFIG_CPU_XSCALE) = xscale-$(ENDIAN)-elf
TARGET = $(if $(TARGET-y),$(TARGET-y),$(ARCH)-elf)

1
ath_hal/opt_ah.h Normal file
View File

@ -0,0 +1 @@
#include OPT_AH_H

205
ath_hal/uudecode.c Normal file
View File

@ -0,0 +1,205 @@
/*
* GPLv2
* Copyright 2003, Glenn McGrath <bug1@iinet.net.au>
* Copyright 2006, Pavel Roskin <proski@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Based on specification from
* http://www.opengroup.org/onlinepubs/007904975/utilities/uuencode.html
*
* Bugs: the spec doesn't mention anything about "`\n`\n" prior to the "end" line
*/
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
static void uudecode_usage(void)
{
printf("Usage: uudecode [-o OUTFILE] [INFILE]\n");
}
static char *get_line_from_file(FILE *file)
{
int ch;
int idx = 0;
static char linebuf[80];
while ((ch = getc(file)) != EOF) {
linebuf[idx++] = (char)ch;
if (!ch)
return linebuf;
if (ch == '\n') {
--idx;
break;
}
/* Dumb overflow protection */
if (idx >= (int)sizeof(linebuf))
idx--;
}
if (ferror(file))
return NULL;
linebuf[idx] = 0;
if (idx > 0 && linebuf[idx - 1] == '\r')
linebuf[idx - 1] = 0;
return linebuf;
}
#define char_val(n) ((line_ptr[n] - 0x20) & 0x3f)
static void read_stduu(FILE *src_stream, FILE *dst_stream)
{
char *line;
while ((line = get_line_from_file(src_stream)) != NULL) {
int length;
char *line_ptr = line;
if (strcmp(line, "end") == 0)
return;
length = char_val(0) * 4 / 3;
/* Ignore the "`\n" line, why is it even in the encode file ? */
if (length <= 0)
continue;
if (length > 60) {
fprintf(stderr, "uudecode: Line too long\n");
exit(1);
}
line_ptr++;
/* Tolerate an overly long line to accommodate an extra '`' */
if ((int)strlen(line_ptr) < length) {
fprintf(stderr, "uudecode: Short line detected\n");
exit(1);
}
while (length > 0) {
/* Merge four 6 bit chars to three 8 bit chars */
fputc(char_val(0) << 2 | char_val(1) >> 4, dst_stream);
line_ptr++;
if (--length == 0)
break;
fputc(char_val(0) << 4 | char_val(1) >> 2, dst_stream);
line_ptr++;
if (--length == 0)
break;
fputc(char_val(0) << 6 | char_val(1), dst_stream);
line_ptr += 2;
length -= 2;
}
}
fprintf(stderr, "uudecode: no `end' found\n");
exit(1);
}
int main(int argc, char **argv)
{
FILE *src_stream;
FILE *dst_stream = NULL;
char *outname = NULL;
char *line;
int mode;
char *line_ptr = NULL;
int c;
int forced_output = 0;
while ((c = getopt (argc, argv, "o:")) != -1)
switch (c) {
case 'o':
forced_output = 1;
outname = optarg;
break;
default:
uudecode_usage();
exit(1);
}
if (optind == argc) {
src_stream = stdin;
} else if (optind + 1 == argc) {
src_stream = fopen(argv[optind], "rt");
if (!src_stream) {
fprintf(stderr, "uudecode: Cannot open \"%s\": %s\n",
argv[optind], strerror(errno));
exit(1);
}
} else {
uudecode_usage();
exit(1);
}
/* Search for the start of the encoding */
while ((line = get_line_from_file(src_stream)) != NULL) {
if (strncmp(line, "begin ", 6) == 0) {
line_ptr = line + 6;
break;
}
}
if (!line_ptr) {
fprintf(stderr, "uudecode: No `begin' line\n");
exit(1);
}
mode = strtoul(line_ptr, NULL, 8);
if (outname == NULL) {
outname = strchr(line_ptr, ' ');
if ((outname == NULL) || (*outname == '\0')) {
fprintf(stderr, "uudecode: No file name specified\n");
exit(1);
}
outname++;
}
if (forced_output && (strcmp(outname, "-") == 0)) {
dst_stream = stdout;
} else {
int fd;
int flags = O_WRONLY | O_CREAT | O_TRUNC;
/* don't clobber files without an explicit "-o" */
if (!forced_output)
flags |= O_EXCL;
fd = open(outname, flags,
mode & (S_IRWXU | S_IRWXG | S_IRWXO));
if (fd != -1)
dst_stream = fdopen(fd, "wb");
if ((fd == -1) || !dst_stream) {
fprintf(stderr, "uudecode: Cannot open \"%s\": %s\n",
outname, strerror(errno));
exit(1);
}
}
read_stduu(src_stream, dst_stream);
if (src_stream != stdin)
fclose(src_stream);
if (dst_stream != stdout)
fclose(dst_stream);
return 0;
}

28
ath_rate/Makefile Normal file
View File

@ -0,0 +1,28 @@
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)/..
obj-y := amrr/ onoe/ sample/ minstrel/
include $(TOP)/Makefile.inc
modules:
ifdef LINUX24
for i in $(obj-y); do \
$(MAKE) -C $$i || exit 1; \
done
else
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
endif
install:
for i in $(obj-y); do \
$(MAKE) -C $$i install || exit 1; \
done
clean:
for i in $(obj-y); do \
$(MAKE) -C $$i clean; \
done

73
ath_rate/amrr/Makefile Normal file
View File

@ -0,0 +1,73 @@
#
# Copyright (c) 2004 Sam Leffler, Errno Consulting
# Copyright (c) 2004 Video54 Technologies, Inc.
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath_rate/amrr/Makefile#2 $
#
#
# Makefile for the Atheros Rate Control Support.
#
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)/../..
obj-m += ath_rate_amrr.o
ath_rate_amrr-objs := amrr.o
include $(TOP)/Makefile.inc
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
-include $(TOPDIR)/Rules.make
all:
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
install:
test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
install ath_rate_amrr.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
clean:
-rm -f *~ *.o *.ko *.mod.c
-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
-rm -rf .tmp_versions
ath_rate_amrr.o: $(ath_rate_amrr-objs)
$(LD) $(LDOPTS) -o ath_rate_amrr.$(KMODSUF) -r $(ath_rate_amrr-objs)

View File

@ -0,0 +1,37 @@
#
# Makefile for AMRR (Adaptive Multi Rate Retry) control algorithm.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath_rate/amrr/Makefile.kernel#1 $
#
src ?= .
srctree ?= .
TOP = $(srctree)/$(src)/../..
include $(TOP)/BuildCaps.inc
include $(TOP)/ath_hal/ah_target.inc
ATH= $(TOP)/ath
ATH_HAL=$(TOP)/ath_hal
COMPAT= $(TOP)/include
HAL= $(TOP)/hal
INCS = -include $(COMPAT)/compat.h -I$(COMPAT)
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS += $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
ifneq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) += ath_rate_amrr.o
ath_rate_amrr-objs := amrr.o
endif
ifeq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) := amrr.o
export-objs := amrr.o
list-multi := ath_rate_amrr.o
O_TARGET := ath_rate.o
include $(TOPDIR)/Rules.make
endif

600
ath_rate/amrr/amrr.c Normal file
View File

@ -0,0 +1,600 @@
/*-
* Copyright (c) 2004 INRIA
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
/*
* AMRR rate control. See:
* http://www-sop.inria.fr/rapports/sophia/RR-5208.html
* "IEEE 802.11 Rate Adaptation: A Practical Approach" by
* Mathieu Lacage, Hossein Manshaei, Thierry Turletti
*/
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/random.h>
#include <linux/delay.h>
#include <linux/cache.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/if_arp.h>
#include <asm/uaccess.h>
#include <net80211/if_media.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_rate.h>
#include "if_athvar.h"
#include "if_ath_hal.h"
#include "ah_desc.h"
#include "amrr.h"
#define AMRR_DEBUG
#ifdef AMRR_DEBUG
#define DPRINTF(sc, _fmt, ...) do { \
if (sc->sc_debug & 0x10) \
printk(_fmt, __VA_ARGS__); \
} while (0)
#else
#define DPRINTF(sc, _fmt, ...)
#endif
static int ath_rateinterval = 1000; /* rate ctl interval (ms) */
static int ath_rate_max_success_threshold = 10;
static int ath_rate_min_success_threshold = 1;
static void ath_ratectl(unsigned long);
static void ath_rate_update(struct ath_softc *, struct ieee80211_node *, int);
static void ath_rate_ctl_start(struct ath_softc *, struct ieee80211_node *);
static void ath_rate_ctl(void *, struct ieee80211_node *);
static void
ath_rate_node_init(struct ath_softc *sc, struct ath_node *an)
{
/* NB: assumed to be zero'd by caller */
ath_rate_update(sc, &an->an_node, 0);
}
static void
ath_rate_node_cleanup(struct ath_softc *sc, struct ath_node *an)
{
}
static void
ath_rate_findrate(struct ath_softc *sc, struct ath_node *an,
int shortPreamble, size_t frameLen,
u_int8_t *rix, unsigned int *try0, u_int8_t *txrate)
{
struct amrr_node *amn = ATH_NODE_AMRR(an);
*rix = amn->amn_tx_rix0;
*try0 = amn->amn_tx_try0;
if (shortPreamble)
*txrate = amn->amn_tx_rate0sp;
else
*txrate = amn->amn_tx_rate0;
}
static void
ath_rate_get_mrr(struct ath_softc *sc, struct ath_node *an, int shortPreamble,
size_t frame_size, u_int8_t rix, struct ieee80211_mrr *mrr)
{
struct amrr_node *amn = ATH_NODE_AMRR(an);
mrr->rate1 = amn->amn_tx_rate1sp;
mrr->retries1 = amn->amn_tx_try1;
mrr->rate2 = amn->amn_tx_rate2sp;
mrr->retries2 = amn->amn_tx_try2;
mrr->rate3 = amn->amn_tx_rate3sp;
mrr->retries3 = amn->amn_tx_try3;
}
static void
ath_rate_tx_complete(struct ath_softc *sc,
struct ath_node *an, const struct ath_buf *bf)
{
struct amrr_node *amn = ATH_NODE_AMRR(an);
const struct ath_tx_status *ts = &bf->bf_dsstatus.ds_txstat;
int sr = ts->ts_shortretry;
int lr = ts->ts_longretry;
int retry_count = sr + lr;
amn->amn_tx_try0_cnt++;
if (retry_count == 1) {
amn->amn_tx_try1_cnt++;
} else if (retry_count == 2) {
amn->amn_tx_try1_cnt++;
amn->amn_tx_try2_cnt++;
} else if (retry_count == 3) {
amn->amn_tx_try1_cnt++;
amn->amn_tx_try2_cnt++;
amn->amn_tx_try3_cnt++;
} else if (retry_count > 3) {
amn->amn_tx_try1_cnt++;
amn->amn_tx_try2_cnt++;
amn->amn_tx_try3_cnt++;
amn->amn_tx_failure_cnt++;
}
}
static void
ath_rate_newassoc(struct ath_softc *sc, struct ath_node *an, int isnew)
{
if (isnew)
ath_rate_ctl_start(sc, &an->an_node);
}
static void
node_reset (struct amrr_node *amn)
{
amn->amn_tx_try0_cnt = 0;
amn->amn_tx_try1_cnt = 0;
amn->amn_tx_try2_cnt = 0;
amn->amn_tx_try3_cnt = 0;
amn->amn_tx_failure_cnt = 0;
amn->amn_success = 0;
amn->amn_recovery = 0;
amn->amn_success_threshold = ath_rate_min_success_threshold;
}
/**
* The code below assumes that we are dealing with hardware multi rate retry
* I have no idea what will happen if you try to use this module with another
* type of hardware. Your machine might catch fire or it might work with
* horrible performance...
*/
static void
ath_rate_update(struct ath_softc *sc, struct ieee80211_node *ni, int rate)
{
struct ath_node *an = ATH_NODE(ni);
struct amrr_node *amn = ATH_NODE_AMRR(an);
const HAL_RATE_TABLE *rt = sc->sc_currates;
u_int8_t rix;
KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
DPRINTF(sc, "%s: set xmit rate for %s to %dM\n",
__func__, ether_sprintf(ni->ni_macaddr),
ni->ni_rates.rs_nrates > 0 ?
(ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
ni->ni_txrate = rate;
/*
* Before associating a node has no rate set setup
* so we can't calculate any transmit codes to use.
* This is ok since we should never be sending anything
* but management frames and those always go at the
* lowest hardware rate.
*/
if (ni->ni_rates.rs_nrates > 0) {
amn->amn_tx_rix0 =
sc->sc_rixmap[ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL];
amn->amn_tx_rate0 = rt->info[amn->amn_tx_rix0].rateCode;
amn->amn_tx_rate0sp = amn->amn_tx_rate0 |
rt->info[amn->amn_tx_rix0].shortPreamble;
if (sc->sc_mrretry) {
amn->amn_tx_try0 = 1;
amn->amn_tx_try1 = 1;
amn->amn_tx_try2 = 1;
amn->amn_tx_try3 = 1;
if (--rate >= 0) {
rix = sc->sc_rixmap[ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
amn->amn_tx_rate1 = rt->info[rix].rateCode;
amn->amn_tx_rate1sp = amn->amn_tx_rate1 |
rt->info[rix].shortPreamble;
} else {
amn->amn_tx_rate1 = amn->amn_tx_rate1sp = 0;
}
if (--rate >= 0) {
rix = sc->sc_rixmap[ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
amn->amn_tx_rate2 = rt->info[rix].rateCode;
amn->amn_tx_rate2sp = amn->amn_tx_rate2 |
rt->info[rix].shortPreamble;
} else {
amn->amn_tx_rate2 = amn->amn_tx_rate2sp = 0;
}
if (rate > 0) {
/* NB: only do this if we didn't already do it above */
amn->amn_tx_rate3 = rt->info[0].rateCode;
amn->amn_tx_rate3sp = amn->amn_tx_rate3 |
rt->info[0].shortPreamble;
} else {
amn->amn_tx_rate3 = amn->amn_tx_rate3sp = 0;
}
} else {
amn->amn_tx_try0 = ATH_TXMAXTRY;
/* theorically, these statements are useless because
* the code which uses them tests for an_tx_try0 == ATH_TXMAXTRY
*/
amn->amn_tx_try1 = 0;
amn->amn_tx_try2 = 0;
amn->amn_tx_try3 = 0;
amn->amn_tx_rate1 = amn->amn_tx_rate1sp = 0;
amn->amn_tx_rate2 = amn->amn_tx_rate2sp = 0;
amn->amn_tx_rate3 = amn->amn_tx_rate3sp = 0;
}
}
node_reset(amn);
}
/*
* Set the starting transmit rate for a node.
*/
static void
ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni)
{
#define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
struct ieee80211vap *vap = ni->ni_vap;
int srate;
KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates"));
if (vap->iv_fixed_rate == IEEE80211_FIXED_RATE_NONE) {
/*
* No fixed rate is requested. For 11b start with
* the highest negotiated rate; otherwise, for 11g
* and 11a, we start "in the middle" at 24Mb or 36Mb.
*/
srate = ni->ni_rates.rs_nrates - 1;
if (sc->sc_curmode != IEEE80211_MODE_11B) {
/*
* Scan the negotiated rate set to find the
* closest rate.
*/
/* NB: the rate set is assumed sorted */
for (; srate >= 0 && RATE(srate) > 72; srate--);
KASSERT(srate >= 0, ("bogus rate set"));
}
} else {
/*
* A fixed rate is to be used; ic_fixed_rate is an
* index into the supported rate set. Convert this
* to the index into the negotiated rate set for
* the node. We know the rate is there because the
* rate set is checked when the station associates.
*/
srate = ni->ni_rates.rs_nrates - 1;
for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
KASSERT(srate >= 0,
("fixed rate %d not in rate set", vap->iv_fixed_rate));
}
ath_rate_update(sc, ni, srate);
#undef RATE
}
static void
ath_rate_cb(void *arg, struct ieee80211_node *ni)
{
ath_rate_update(ni->ni_ic->ic_dev->priv, ni, (long) arg);
}
/*
* Reset the rate control state for each 802.11 state transition.
*/
static void
ath_rate_newstate(struct ieee80211vap *vap, enum ieee80211_state state)
{
struct ieee80211com *ic = vap->iv_ic;
struct ath_softc *sc = ic->ic_dev->priv;
struct amrr_softc *asc = (struct amrr_softc *) sc->sc_rc;
struct ieee80211_node *ni;
if (state == IEEE80211_S_INIT) {
del_timer(&asc->timer);
return;
}
if (ic->ic_opmode == IEEE80211_M_STA) {
/*
* Reset local xmit state; this is really only
* meaningful when operating in station mode.
*/
ni = vap->iv_bss;
if (state == IEEE80211_S_RUN)
ath_rate_ctl_start(sc, ni);
else
ath_rate_update(sc, ni, 0);
} else {
/*
* When operating as a station the node table holds
* the APs that were discovered during scanning.
* For any other operating mode we want to reset the
* tx rate state of each node.
*/
ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_cb, NULL);
ath_rate_update(sc, vap->iv_bss, 0);
}
if ((vap->iv_fixed_rate == IEEE80211_FIXED_RATE_NONE) && (state == IEEE80211_S_RUN)) {
int interval;
/*
* Start the background rate control thread if we
* are not configured to use a fixed xmit rate.
*/
interval = ath_rateinterval;
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
mod_timer(&asc->timer, jiffies + ((HZ * interval) / 1000));
}
}
/*
* Examine and potentially adjust the transmit rate.
*/
static void
ath_rate_ctl(void *arg, struct ieee80211_node *ni)
{
struct ath_softc *sc = arg;
struct amrr_node *amn = ATH_NODE_AMRR(ATH_NODE (ni));
int old_rate;
#define is_success(amn) (amn->amn_tx_try1_cnt < (amn->amn_tx_try0_cnt / 10))
#define is_enough(amn) (amn->amn_tx_try0_cnt > 10)
#define is_failure(amn) (amn->amn_tx_try1_cnt > (amn->amn_tx_try0_cnt / 3))
#define is_max_rate(ni) ((ni->ni_txrate + 1) >= ni->ni_rates.rs_nrates)
#define is_min_rate(ni) (ni->ni_txrate == 0)
old_rate = ni->ni_txrate;
DPRINTF (sc, "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d\n",
amn->amn_tx_try0_cnt,
amn->amn_tx_try1_cnt,
amn->amn_tx_try2_cnt,
amn->amn_tx_try3_cnt,
amn->amn_success_threshold);
if (is_success(amn) && is_enough(amn)) {
amn->amn_success++;
if (amn->amn_success == amn->amn_success_threshold &&
!is_max_rate(ni)) {
amn->amn_recovery = 1;
amn->amn_success = 0;
ni->ni_txrate++;
DPRINTF(sc, "increase rate to %d\n", ni->ni_txrate);
} else
amn->amn_recovery = 0;
} else if (is_failure(amn)) {
amn->amn_success = 0;
if (!is_min_rate(ni)) {
if (amn->amn_recovery) {
/* recovery failure. */
amn->amn_success_threshold *= 2;
amn->amn_success_threshold = min(amn->amn_success_threshold,
(u_int)ath_rate_max_success_threshold);
DPRINTF(sc, "decrease rate recovery thr: %d\n",
amn->amn_success_threshold);
} else {
/* simple failure. */
amn->amn_success_threshold = ath_rate_min_success_threshold;
DPRINTF(sc, "decrease rate normal thr: %d\n",
amn->amn_success_threshold);
}
amn->amn_recovery = 0;
ni->ni_txrate--;
} else
amn->amn_recovery = 0;
}
if (is_enough(amn) || old_rate != ni->ni_txrate) {
/* reset counters. */
amn->amn_tx_try0_cnt = 0;
amn->amn_tx_try1_cnt = 0;
amn->amn_tx_try2_cnt = 0;
amn->amn_tx_try3_cnt = 0;
amn->amn_tx_failure_cnt = 0;
}
if (old_rate != ni->ni_txrate)
ath_rate_update(sc, ni, ni->ni_txrate);
}
static void
ath_ratectl(unsigned long data)
{
struct net_device *dev = (struct net_device *)data;
struct ath_softc *sc = dev->priv;
struct amrr_softc *asc = (struct amrr_softc *)sc->sc_rc;
struct ieee80211com *ic = &sc->sc_ic;
int interval;
if (dev->flags & IFF_RUNNING) {
sc->sc_stats.ast_rate_calls++;
if (ic->ic_opmode == IEEE80211_M_STA) {
struct ieee80211vap *tmpvap;
TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
ath_rate_ctl(sc, tmpvap->iv_bss); /* NB: no reference */
}
} else
ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_ctl, sc);
}
interval = ath_rateinterval;
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
asc->timer.expires = jiffies + ((HZ * interval) / 1000);
add_timer(&asc->timer);
}
static struct ath_ratectrl *
ath_rate_attach(struct ath_softc *sc)
{
struct amrr_softc *asc;
_MOD_INC_USE(THIS_MODULE, return NULL);
asc = kmalloc(sizeof(struct amrr_softc), GFP_ATOMIC);
if (asc == NULL) {
_MOD_DEC_USE(THIS_MODULE);
return NULL;
}
asc->arc.arc_space = sizeof(struct amrr_node);
asc->arc.arc_vap_space = 0;
init_timer(&asc->timer);
asc->timer.data = (unsigned long) sc->sc_dev;
asc->timer.function = ath_ratectl;
return &asc->arc;
}
static void
ath_rate_detach(struct ath_ratectrl *arc)
{
struct amrr_softc *asc = (struct amrr_softc *) arc;
del_timer(&asc->timer);
kfree(asc);
_MOD_DEC_USE(THIS_MODULE);
}
static int minrateinterval = 500; /* 500ms */
static int maxint = 0x7fffffff; /* 32-bit big */
static int min_threshold = 1;
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
/*
* Static (i.e. global) sysctls.
*/
enum {
DEV_ATH = 9, /* XXX known by many */
};
static ctl_table ath_rate_static_sysctls[] = {
{ .ctl_name = CTL_AUTO,
.procname = "interval",
.mode = 0644,
.data = &ath_rateinterval,
.maxlen = sizeof(ath_rateinterval),
.extra1 = &minrateinterval,
.extra2 = &maxint,
.proc_handler = proc_dointvec_minmax
},
{ .ctl_name = CTL_AUTO,
.procname = "max_success_threshold",
.mode = 0644,
.data = &ath_rate_max_success_threshold,
.maxlen = sizeof(ath_rate_max_success_threshold),
.extra1 = &min_threshold,
.extra2 = &maxint,
.proc_handler = proc_dointvec_minmax
},
{ .ctl_name = CTL_AUTO,
.procname = "min_success_threshold",
.mode = 0644,
.data = &ath_rate_min_success_threshold,
.maxlen = sizeof(ath_rate_min_success_threshold),
.extra1 = &min_threshold,
.extra2 = &maxint,
.proc_handler = proc_dointvec_minmax
},
{ 0 }
};
static ctl_table ath_rate_table[] = {
{ .ctl_name = CTL_AUTO,
.procname = "rate",
.mode = 0555,
.child = ath_rate_static_sysctls
}, { 0 }
};
static ctl_table ath_ath_table[] = {
{ .ctl_name = DEV_ATH,
.procname = "ath",
.mode = 0555,
.child = ath_rate_table
}, { 0 }
};
static ctl_table ath_root_table[] = {
{ .ctl_name = CTL_DEV,
.procname = "dev",
.mode = 0555,
.child = ath_ath_table
}, { 0 }
};
static struct ctl_table_header *ath_sysctl_header;
static struct ieee80211_rate_ops ath_rate_ops = {
.ratectl_id = IEEE80211_RATE_AMRR,
.node_init = ath_rate_node_init,
.node_cleanup = ath_rate_node_cleanup,
.findrate = ath_rate_findrate,
.get_mrr = ath_rate_get_mrr,
.tx_complete = ath_rate_tx_complete,
.newassoc = ath_rate_newassoc,
.newstate = ath_rate_newstate,
.attach = ath_rate_attach,
.detach = ath_rate_detach,
};
#include "release.h"
static char *version = "0.1 (" RELEASE_VERSION ")";
static char *dev_info = "ath_rate_amrr";
MODULE_AUTHOR("INRIA, Mathieu Lacage");
MODULE_DESCRIPTION("AMRR Rate control algorithm");
#ifdef MODULE_VERSION
MODULE_VERSION(RELEASE_VERSION);
#endif
#ifdef MODULE_LICENSE
MODULE_LICENSE("Dual BSD/GPL");
#endif
static int __init
init_ath_rate_amrr(void)
{
int ret;
printk(KERN_INFO "%s: %s\n", dev_info, version);
ret = ieee80211_rate_register(&ath_rate_ops);
if (ret)
return ret;
ath_sysctl_header = ATH_REGISTER_SYSCTL_TABLE(ath_root_table);
return (0);
}
module_init(init_ath_rate_amrr);
static void __exit
exit_ath_rate_amrr(void)
{
if (ath_sysctl_header != NULL)
unregister_sysctl_table(ath_sysctl_header);
ieee80211_rate_unregister(&ath_rate_ops);
printk(KERN_INFO "%s: unloaded\n", dev_info);
}
module_exit(exit_ath_rate_amrr);

77
ath_rate/amrr/amrr.h Normal file
View File

@ -0,0 +1,77 @@
/*-
* Copyright (c) 2004 INRIA
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
#ifndef _DEV_ATH_RATE_AMRR_H
#define _DEV_ATH_RATE_AMRR_H
/* per-device state */
struct amrr_softc {
struct ath_ratectrl arc; /* base state */
struct timer_list timer; /* periodic timer */
};
/* per-node state */
struct amrr_node {
/* AMRR statistics for this node */
u_int amn_tx_try0_cnt;
u_int amn_tx_try1_cnt;
u_int amn_tx_try2_cnt;
u_int amn_tx_try3_cnt;
u_int amn_tx_failure_cnt;
/* AMRR algorithm state for this node */
u_int amn_success_threshold;
u_int amn_success;
u_int amn_recovery;
/* rate index et al. */
u_int8_t amn_tx_rix0; /* series 0 rate index */
u_int8_t amn_tx_rate0; /* series 0 h/w rate */
u_int8_t amn_tx_rate1; /* series 1 h/w rate */
u_int8_t amn_tx_rate2; /* series 2 h/w rate */
u_int8_t amn_tx_rate3; /* series 3 h/w rate */
u_int8_t amn_tx_rate0sp; /* series 0 short preamble h/w rate */
u_int8_t amn_tx_rate1sp; /* series 1 short preamble h/w rate */
u_int8_t amn_tx_rate2sp; /* series 2 short preamble h/w rate */
u_int8_t amn_tx_rate3sp; /* series 3 short preamble h/w rate */
u_int8_t amn_tx_try0; /* series 0 try count */
u_int amn_tx_try1; /* series 1 try count */
u_int amn_tx_try2; /* series 2 try count */
u_int amn_tx_try3; /* series 3 try count */
};
#define ATH_NODE_AMRR(an) ((struct amrr_node *)&an[1])
#endif /* _DEV_ATH_RATE_AMRR_H */

View File

@ -0,0 +1,71 @@
#
# Copyright (c) 2004 Sam Leffler, Errno Consulting
# Copyright (c) 2004 Video54 Technologies, Inc.
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
#
# Makefile for the Atheros Rate Control Support.
#
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)/../..
obj-m += ath_rate_minstrel.o
ath_rate_minstrel-objs := minstrel.o
include $(TOP)/Makefile.inc
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
-include $(TOPDIR)/Rules.make
all:
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
install:
test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
install ath_rate_minstrel.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
clean:
-rm -f *~ *.o *.ko *.mod.c
-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
-rm -rf .tmp_versions
ath_rate_minstrel.o: $(ath_rate_minstrel-objs)
$(LD) $(LDOPTS) -o ath_rate_minstrel.$(KMODSUF) -r $(ath_rate_minstrel-objs)

View File

@ -0,0 +1,37 @@
#
# Makefile for the Minstrel rate control algorithm.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath_rate/minstrel/Makefile.kernel#1 $
#
src ?= .
srctree ?= .
TOP = $(srctree)/$(src)/../..
include $(TOP)/BuildCaps.inc
include $(TOP)/ath_hal/ah_target.inc
ATH= $(TOP)/ath
ATH_HAL=$(TOP)/ath_hal
COMPAT= $(TOP)/include
HAL= $(TOP)/hal
INCS = -include $(COMPAT)/compat.h -I$(COMPAT)
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS += $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
ifneq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) += ath_rate_minstrel.o
ath_rate_minstrel-objs := minstrel.o
endif
ifeq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) := minstrel.o
export-objs := minstrel.o
list-multi := ath_rate_minstrel.o
O_TARGET := ath_rate.o
include $(TOPDIR)/Rules.make
endif

1091
ath_rate/minstrel/minstrel.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,232 @@
/*-
* And then Indranet Technologies Ltd sponsored Derek Smithies to work
* on this code. Derek Smithies (derek@indranet.co.nz) took parts of the
* adm module and pasted it into this code base.
*
* This version of John Bicket's code takes the experimental approach one
* step further.
* When in auto rate mode, packets are sent at the selected rate.
* The Hal asks for what alternative rate to use if the selected rate fails.
* We provide the alternative rate from a random selection of 1.. max rate.
* Given the probability of success, multiplied with the transmission time,
* we can determine the rate which maximises packet throughput.
*
* Different rates are used for every remote node - some nodes will work
* better on different rates.
* Every second, a timer fires, to assess the throughput at each rate with
* each remote node.
* This timer will then determine the optimum rate for each remote node, based
* on the performance figures.
*
* This code is called minstrel, because we have taken a wandering minstrel
* apporoch. Wander aimlessly around the different rates, singing wherever
* you can. And then, look at the performacnce, and make a choice.
*
* Enjoy. Derek Smithies.
*
***********************************************************************
* Copyright (c) 2005 John Bicket
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id: minstrel.h 1441 2006-02-06 16:03:21Z mrenzmann $
*/
/*
* Defintions for the Atheros Wireless LAN controller driver.
*/
#ifndef _DEV_ATH_RATE_MINSTREL_H
#define _DEV_ATH_RATE_MINSTREL_H
#define MINSTREL_COLUMNS 10
/* per-device state */
struct minstrel_softc {
struct ath_ratectrl arc; /* base state */
#ifdef CONFIG_SYSCTL
struct ctl_table_header *sysctl_header;
struct ctl_table *sysctls;
#endif
struct ath_softc *sc;
struct net_device *sc_dev;
struct timer_list timer; /* periodic timer */
int close_timer_now;
};
#define ATH_SOFTC_MINSTREL(sc) ((struct minstrel_softc *)sc->sc_rc)
struct rate_info {
int rate;
int rix;
int rateCode;
int shortPreambleRateCode;
};
/* per-node state */
struct minstrel_node {
int static_rate_ndx; /*User has bypassed dynamic selection. Fix on one rate */
int num_rates;
struct rate_info rates[IEEE80211_RATE_MAXSIZE];
unsigned perfect_tx_time[IEEE80211_RATE_MAXSIZE]; /* transmit time for 0 retries */
unsigned retry_count[IEEE80211_RATE_MAXSIZE]; /*The number of retrys permitted for this particular rate */
unsigned retry_adjusted_count[IEEE80211_RATE_MAXSIZE]; /*retry_count, but altered, depending on if this is a very poor (or very good) link */
int current_rate;
u_int32_t rs_rateattempts[IEEE80211_RATE_MAXSIZE];
u_int32_t rs_thisprob [IEEE80211_RATE_MAXSIZE];
u_int32_t rs_ratesuccess [IEEE80211_RATE_MAXSIZE];
u_int32_t rs_lastrateattempts[IEEE80211_RATE_MAXSIZE];
u_int32_t rs_lastratesuccess [IEEE80211_RATE_MAXSIZE];
u_int32_t rs_probability [IEEE80211_RATE_MAXSIZE]; /* units of parts per thousand */
u_int64_t rs_succ_hist [IEEE80211_RATE_MAXSIZE];
u_int64_t rs_att_hist [IEEE80211_RATE_MAXSIZE];
u_int32_t rs_this_tp [IEEE80211_RATE_MAXSIZE]; /*Throughput, each rate */
/**This flag on indicates to try other than the optimal rate,
to see what we find */
int is_sampling;
/**The current minstrel sample rate - which could be anything
from 1..11 - assuming there are 12 possible rates. Note that
we never ever sample at the base rate of 0.*/
int rs_sample_rate;
/**Flag to indicate that the sample rate is slower than the
current maximum throughput rate. This determines the order
of the retry chain. */
int rs_sample_rate_slower;
/** These four parameters are indexes into the current rate
table, and are calculated in ath_rate_statistics(), which
happens every time the timer for rate adjustment fires */
int max_tp_rate; /* Has the current highest recorded throughput */
int max_tp_rate2; /* Has the second highest recorded throughput */
int max_prob_rate; /* This rate has the highest chance of success. */
/**These two variables are used to keep track of what
percentage of packets have been used to do sample on.
Thus,if ath_lookaround_rate is set to 10%, we can expect that
sample_count
------------ = 0.1
sample_count + packet_count */
int packet_count; /* The number of times we have
sent a packet to this node. */
int sample_count; /* The number of times we have
sent a sample packet to this node */
/**The table that holds the sequence of rates that we use. In
each column in the table, the rates we sample are provided
in some "random" order. Each rate we sample occurs once in
each column. There are several columns, so we sample the
different rates in a different order each time. */
u_int8_t rs_sampleTable[IEEE80211_RATE_MAXSIZE][MINSTREL_COLUMNS];
int rs_sampleColumn;
int rs_sampleIndex;
/**Random number generator is
Rn+1 = (A*Rn) + B.
This Random number generator determines when we send a minstrel
packet, or a packet at an optimal rate.*/
int random_n;
int a, b; /**Coefficients of the random thing */
};
#define ATH_NODE_MINSTREL(an) ((struct minstrel_node *)&an[1])
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#if 0
#define WIFI_CW_MIN 31
#define WIFI_CW_MAX 1023
#else
#define WIFI_CW_MIN 3
#define WIFI_CW_MAX 10
#endif
/*
* Definitions for pulling the rate and trie counts from
* a 5212 h/w descriptor. These Don't belong here; the
* driver should record this information so the rate control
* code doesn't go groveling around in the descriptor bits.
*/
#define ds_ctl2 ds_hw[0]
#define ds_ctl3 ds_hw[1]
/* TX ds_ctl3 */
#define AR_XmitDataTries0 0x000f0000 /* series 0 max attempts */
#define AR_XmitDataTries0_S 16
#define AR_XmitDataTries1 0x00f00000 /* series 1 max attempts */
#define AR_XmitDataTries1_S 20
#define AR_XmitDataTries2 0x0f000000 /* series 2 max attempts */
#define AR_XmitDataTries2_S 24
#define AR_XmitDataTries3 0xf0000000 /* series 3 max attempts */
#define AR_XmitDataTries3_S 28
/* TX ds_ctl3 */
#define AR_XmitRate0 0x0000001f /* series 0 tx rate */
#define AR_XmitRate0_S 0
#define AR_XmitRate1 0x000003e0 /* series 1 tx rate */
#define AR_XmitRate1_S 5
#define AR_XmitRate2 0x00007c00 /* series 2 tx rate */
#define AR_XmitRate2_S 10
#define AR_XmitRate3 0x000f8000 /* series 3 tx rate */
#define AR_XmitRate3_S 15
#define MS(_v, _f) (((_v) & (_f)) >> _f##_S)
#endif /* _DEV_ATH_RATE_MINSTEL_H */
/* The comment below is magic for those who use emacs to edit this file. */
/* With the comment below, the tab key does auto indent to 8 spaces. */
/*
* Local Variables:
* mode:c
* c-file-style:"linux"
* c-basic-offset:8
* End:
*/

View File

@ -0,0 +1,356 @@
Minstrel
Introduction
==================================================================
This code is called minstrel, because we have taken a wandering minstrel
approach. Wander around the different rates, singing wherever you
can. And then, look at the performance, and make a choice. Note that the
wandering minstrel will always wander in directions where he/she feels he/she
will get paid the best for his/her work.
The Minstrel autorate selection algorithm is an EWMA based algorithm and is
derived from
1)An initial rate module we released in 2005,
http://sourceforge.net/mailarchive/forum.php?forum_id=33966&max_rows=25&style=flat&viewmonth=200501&viewday=5
2)the "sample" module in the madwifi-ng source tree.
The code released in 2005 had some algorithmic and implementation
flaws (one of which was that it was based on the old madwifi codebase)
and was shown to be unstable. Performance of the sample module is poor
(http://www.madwifi.org/ticket/989), and we have observed similar
issues.
We noted:
1)The rate chosen by sample did not alter to match changes in the radio
environment.
2)Higher throughput (between two nodes) could often be achieved by fixing the
bitrate of both nodes to some value.
3)After a long period of operation, "sample" appeared to be stuck in a low
data rate, and would not move to a higher data rate.
We examined the code in sample, and decided the best approach was a
rewrite based on sample and the module we released in January 2005.
Theory of operation
==================================================================
We defined the measure of successfulness (of packet transmission) as
mega-bits-transmitted
Prob_success_transmission * ----------------------
elapsed time
This measure of successfulness will therefore adjust the transmission speed to
get the maximum number of data bits through the radio interface. Further, it
means that the 1mb/sec rate (which has a very high probability of successful
transmission) will not be used in preference to the 11mb/sec rate.
We decided that the module should record the successfulness of all packets
that are transmitted. From this data, the module has sufficient information to
decide which packets are more successful than others. However, a variability
element was required. We had to force the module to examine bit rates other
than optimal. Consequently, some percent of the packets have to be sent at
rates regarded as non optimal.
10 times a second (this frequency is alterable by changing the driver code)
a timer fires, which evaluates the statistics table. EWMA calculations
(described below) are used to process the success history of each rate. On
completion of the calculation, a decision is made as to the rate which has the
best throughput, second best throughput, and highest probability of success.
This data is used for populating the retry chain during the next 100 ms.
As stated above, the minstrel algorithm collects statistics from all packet
attempts. Minstrel spends a particular percentage of frames, doing "look
around" i.e. randomly trying other rates, to gather statistics. The
percentage of "look around" frames, is set at boot time via the module
parameter "ath_lookaround_rate" and defaults to 10%. The distribution of
lookaround frames is also randomised somewhat to avoid any potential
"strobing" of lookaround between similar nodes.
TCP theory tells us that each packet sent must be delivered in under 26ms. Any
longer duration, and the TCP network layers will start to back off. A delay of
26ms implies that there is congestion in the network, and that fewer packets
should be injected to the device. Our conclusion was to adjust the retry chain
of each packet so the retry chain was guaranteed to be finished in under 26ms.
Retry Chain
==================================================================
The HAL provides a multirate retry chain - which consists of four
segments. Each segment is an advisement to the HAL to try to send the current
packet at some rate, with a fixed number of retry attempts. Once the packet is
successfully transmitted, the remainder of the retry chain is
ignored. Selection of the number of retry attempts was based on the desire to
get the packet out in under 26ms, or fail. We provided a module parameter,
ath_segment_size, which has units of microseconds, and specifies the maximum
duration one segment in the retry chain can last. This module parameter has a
default of 6000. Our view is that a segment size of between 4000 and 6000
seems to fit most situations.
There is some room for movement here - if the traffic is UDP then the limit of
26ms for the retry chain length is "meaningless". However, one may argue that
if the packet was not transmitted after some time period, it should
fail. Further, one does expect UDP packets to fail in transmission. We leave
it as an area for future improvement.
The (re)try segment chain is calculated in two possible manners. If this
packet is a normal tranmission packet (90% of packets are this) then the retry
count is best throughput, next best throughput, best probability, lowest
baserate. If it is a sample packet (10% of packets are this), then the retry
chain is random lookaround, best throughput, best probability, lowest base
rate. In tabular format:
Try | Lookaround rate | Normal rate
------------------------------------------------
1 | Random lookaround | Best throughput
2 | Best throughput | Next best throughput
3 | Best probability | Best probability
4 | Lowest Baserate | Lowest Baserate
The retry count is adjusted so that the transmission time for that section of
the retry chain is less than 26 ms.
After some discussion, we have adjusted the code so that the lowest rate is
never used for the lookaround packet. Our view is that since this rate is used
for management packets, this rate must be working. - Alternatively, the link
is set up with management packets, data packets are acknowledged with
management packets. Should the lowest rate stop working, the link is going to
die reasonably soon.
Analysis of information in the /proc/net/madwifi/athX/rate_info file
showed that the system was sampling too hard at some rates. For those
rates that never work (54mb, 500m range) there is no point in sending
10 sample packets (<6ms time). Consequently, for the very very low
probability rates, we sample at most twice.
The retry chain above does "work", but performance is suboptimal. The
key problem being that when the link is good, too much time is spent
sampling the slower rates. Thus, for two nodes adjacent to each other,
the throughput between them was several megabits/sec below using a
fixed rate. The view was that minstrel should not sample at the slower
rates if the link is doing well. However, if the link deteriorates,
minstrel should immediately sample at the lower rates.
Some time later, we realised that the only way to code this reliably
was to use the retry chain as the method of determining if the slower
rates are sampled. The retry chain was modified as:
Try | Lookaround rate | Normal rate
| random < best | random > best |
--------------------------------------------------------------
1 | Best throughput | Random rate | Best throughput
2 | Random rate | Best throughput | Next best throughput
3 | Best probability | Best probability | Best probability
4 | Lowest Baserate | Lowest baserate | Lowest baserate
With this retry chain, if the randomly selected rate is slower than the
current best throughput, the randomly selected rate is placed second in the
chain. If the link is not good, then there will be data collected at the
randomly selected rate. Thus, if the best throughput rate is currently 54mbs,
the only time slower rates are sampled is when a packet fails in
transmission. Consequently, if the link is ideal, all packets will be sent at
the full rate of 54mbs. Which is good.
EWMA
==================================================================
The EWMA calculation is carried out 10 times a second, and is run for each
rate. This calculation has a smoothing effect, so that new results have
a reasonable (but not large) influence on the selected rate. However, with
time, a series of new results in some particular direction will predominate.
Given this smoothing, we can use words like inertia to describe the EWMA.
By "new results", we mean the results collected in the just completed 100ms
interval. Old results are the EWMA scaling values from before the just
completed 100ms interval.
EWMA scaling is set by the module parameter ath_ewma_level, and defaults to
75%. A value of 0% means use only the new results, ignore the old results.
A value of 99% means use the old results, with a tiny influence from the new
results.
The calculation (performed for each rate, at each timer interrupt) of the
probability of success is:
Psucces_this_time_interval * (100 - ath_ewma_level) + (Pold * ath_ewma_level)
Pnew = ------------------------------------------------------------------------------
100
number_packets_sent_successfully_this_rate_time_interval
Psuccess_this_time_interval=--------------------------------------------------------
number_packets_sent_this_rate_time_interval
If no packets have been sent for a particular rate in a time interval, no
calculation is carried out. The Psuccess value for this rate is not changed.
If the new time interval is the first time interval (the module has just been
inserted), then Pnew is calculated from above with Pold set to 0.
The appropriate update interval was selected on the basis of choosing a compromise
between
*collecting enough success/failure information to be meaningful
*minimising the amount of cpu time spent do the updates
*providing a means to recover quickly enough from a bad rate selection.
The first two points are self explanatory. When there is a sudden change in the radio
environment, an update interval of 100ms will mean that the rates marked as optimal are
very quickly marked as poor. Consequently, the sudden change in radio environment will
mean that minstrel will very quickly switch to a better rate.
A sudden change in the transmission probabilities will happen when the
node has not transmitted any data for a while, and during that time
the environment has changed. On starting to transmit, the probability
of success at each rate will be quite different. The driver must adapt
as quickly as possible, so as to not upset the higher TCP network
layers.
Module Parameters
====================================================
The module has three parameters:
name default value purpose
ath_ewma_level 75% rate of response to new data. A value of 100 is VERY responsive.
ath_lookaround_rate 10% percent of packets sent at non optimal speed.
ath_segment_size 6000 maximum duration of a retry segment (microseconds)
Test Network
====================================================
We used three computers in our test network. The first two, equipped with
atheros cards running in adhoc mode. We used a program that sends a fixed
number of TCP packets between computers, and reports on the data rate. The
application reports on the data rate - at an application layer level, which is
considerably lower than the level used in transmitting the packets.
The third computer had an atheros card also, but was running network monitor
mode with ethereal. The monitor computer was used to see what data rates were
used on the air. This computer was a form of "logging of the connection"
without introducing any additional load on the first two computers.
It was from monitoring the results on the third computer that we started to
get some confidence in the correctness of the code. We observed TCP
backoffs (described above) on this box. There was much celebration when the
throughput increased simply because the retry chain was finished in under 26
ms.
Our view was that throughput between the two computers should be as
close as possible (or better than) what can be achieved by setting
both ends to fixed rates. Thus, if setting the both ends to fixed
rates significantly increases the throughput, a reasonable conclusion
is that a fault exists in the adaptive rate rate.
We recorded throughputs (with minstrel) that are within 10% of what is
achieved with the experimentally determined optimum fixed rate.
Notes on Timing
====================================================
As noted above, Minstrel calculates the throughput for each rate. This
calculation (using a packet of size 1200 bytes) determines the
transmission time on the radio medium. In these calculations, we assume a
contention window min and max value of 4 and 10 microseconds respectively.
Further, calculation of the transmission time is required so that we can
guarantee a packet is transmitted (or dropped) in a minimum time period.
The transmission time is used in determining how many times a packet
is transmitted in each segment of the retry chain.
Indeed, the card will supply the cwmin/cwmax values directly
iwpriv if_name get_cwmin <0|1|2|3> <0|1>
We have not made direct calls to determine cwmin/cwmax - this is an area
for future work. Indeed, the cwmin/cwmax determination code could check to
see if the user has altered these values with the appropriate iwpriv.
The contention window size does vary with traffic class. For example,
video and voice have a contention window min of 3 and 2 microseconds
respectively. Currently, minstrel does not check traffic class.
Calculating the throughputs based on traffic class and bit rate and
variable packet size will significantly complicate the code and require
many more sample packets. More sample packets will lower the throughput
achieved. Thus, our view is that for this release, we should take a simple
(but reasonable) approach that works stably and gives good throughputs.
Values of cwin/cwmax of 4 and 10 microseconds are from
IEEE Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer
(PHY) specifications, Amendment : Medium Access Control (MAC) Enhancements for
Quality of Service (QoS) P802.11e/D12.0, November 2004.
Internal variable reporting
====================================================
The minstrel algorithm reports to the proc file system its internal
statistics, which can be viewed as text. A sample output is below:
cat /proc/net/madwifi/ath0/rate_info
rate data for node:: 00:02:6f:43:8c:7a
rate throughput ewma prob this prob this succ/attempt success attempts
1 0.0 0.0 0.0 0( 0) 0 0
2 1.6 92.4 100.0 0( 0) 11 11
5.5 3.9 89.9 100.0 0( 0) 11 11
11 6.5 86.6 100.0 0( 0) 10 11
6 4.8 92.4 100.0 0( 0) 11 11
9 6.9 92.4 100.0 0( 0) 11 11
12 9.0 92.4 100.0 0( 0) 11 11
18 12.1 89.9 100.0 0( 0) 11 11
24 15.5 92.4 100.0 0( 0) 11 11
36 20.6 92.4 100.0 0( 0) 11 11
t 48 23.6 89.9 100.0 0( 0) 12 12
T P 54 27.1 96.2 96.2 0( 0) 996 1029
Total packet count:: ideal 2344 lookaround 261
There is a separate table for each node in the neighbor table, which will
appear similar to above.
The possible datarates for this node are listed in the column at the left. The
calculated throughput and "ewma prob" are listed next, from which the rates
used in retry chain are selected. The rates with the maximum throughput,
second maximum throughput and maximum probability are indicated by the letters
T, t, and P respectively.
The statistics gathered in the last 100ms time period are displayed in the
"this prob" and "this succ/attempt" columns.
Finally, the number of packets transmitted at each rate, since module loading
are listed in the last two columns. When interpreting the last four columns,
note that we use the words "succ" or "success" to mean packets successfully
sent from this node to the remote node. The driver determines success by
analysing reports from the hal. The word "attempt" or "attempts" means the
count of packets that we transmitted. Thus, the number in the success column
will always be lower than the number in the attempts column.
When the two nodes are brought closer together, the statistics start changing,
and you see more successful attempts at the higher rates. The ewma prob at the
higher rates increases and then most packets are conveyed at the higher rates.
When the rate is not on auto, but fixed, this table is still
available, and will report the throughput etc for the current bit
rate. Changing the rate from auto to fixed to auto will completely
reset this table, and the operation of the minstrel module.

73
ath_rate/onoe/Makefile Normal file
View File

@ -0,0 +1,73 @@
#
# Copyright (c) 2004 Sam Leffler, Errno Consulting
# Copyright (c) 2004 Video54 Technologies, Inc.
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath_rate/onoe/Makefile $
#
#
# Makefile for the Atheros Rate Control Support.
#
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)/../..
obj-m += ath_rate_onoe.o
ath_rate_onoe-objs := onoe.o
include $(TOP)/Makefile.inc
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
-include $(TOPDIR)/Rules.make
all:
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
install:
test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
install ath_rate_onoe.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
clean:
-rm -f *~ *.o *.ko *.mod.c
-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
-rm -rf .tmp_versions
ath_rate_onoe.o: $(ath_rate_onoe-objs)
$(LD) $(LDOPTS) -o ath_rate_onoe.$(KMODSUF) -r $(ath_rate_onoe-objs)

View File

@ -0,0 +1,37 @@
#
# Makefile for Atsushi Onoe's rate control algorithm.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath_rate/onoe/Makefile.kernel#1 $
#
src ?= .
srctree ?= .
TOP = $(srctree)/$(src)/../..
include $(TOP)/BuildCaps.inc
include $(TOP)/ath_hal/ah_target.inc
ATH= $(TOP)/ath
ATH_HAL=$(TOP)/ath_hal
COMPAT= $(TOP)/include
HAL= $(TOP)/hal
INCS = -include $(COMPAT)/compat.h -I$(COMPAT)
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS += $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
ifneq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) += ath_rate_onoe.o
ath_rate_onoe-objs := onoe.o
endif
ifeq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) := onoe.o
export-objs := onoe.o
list-multi := ath_rate_onoe.o
O_TARGET := ath_rate.o
include $(TOPDIR)/Rules.make
endif

547
ath_rate/onoe/onoe.c Normal file
View File

@ -0,0 +1,547 @@
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
/*
* Atsushi Onoe's rate control algorithm.
*/
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
#include <linux/version.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/random.h>
#include <linux/delay.h>
#include <linux/cache.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/if_arp.h>
#include <asm/uaccess.h>
#include <net80211/if_media.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_rate.h>
#include "if_athvar.h"
#include "if_ath_hal.h"
#include "ah_desc.h"
#include "onoe.h"
#define ONOE_DEBUG
#ifdef ONOE_DEBUG
enum {
ATH_DEBUG_RATE = 0x00000010, /* rate control */
};
#define DPRINTF(sc, _fmt, ...) do { \
if (sc->sc_debug & ATH_DEBUG_RATE) \
printk(_fmt, __VA_ARGS__); \
} while (0)
#else
#define DPRINTF(sc, _fmt, ...)
#endif
/*
* Default parameters for the rate control algorithm. These are
* all tunable with sysctls. The rate controller runs periodically
* (each ath_rateinterval ms) analyzing transmit statistics for each
* neighbor/station (when operating in station mode this is only the AP).
* If transmits look to be working well over a sampling period then
* it gives a "raise rate credit". If transmits look to not be working
* well than it deducts a credit. If the credits cross a threshold then
* the transmit rate is raised. Various error conditions force the
* the transmit rate to be dropped.
*
* The decision to issue/deduct a credit is based on the errors and
* retries accumulated over the sampling period. ath_rate_raise defines
* the percent of retransmits for which a credit is issued/deducted.
* ath_rate_raise_threshold defines the threshold on credits at which
* the transmit rate is increased.
*
* XXX this algorithm is flawed.
*/
static int ath_rateinterval = 1000; /* rate ctl interval (ms) */
static int ath_rate_raise = 10; /* add credit threshold */
static int ath_rate_raise_threshold = 10; /* rate ctl raise threshold */
static void ath_rate_update(struct ath_softc *, struct ieee80211_node *, int);
static void ath_rate_ctl_start(struct ath_softc *, struct ieee80211_node *);
static void ath_rate_ctl(void *, struct ieee80211_node *);
static void
ath_rate_node_init(struct ath_softc *sc, struct ath_node *an)
{
/* NB: assumed to be zero'd by caller */
ath_rate_update(sc, &an->an_node, 0);
}
static void
ath_rate_node_cleanup(struct ath_softc *sc, struct ath_node *an)
{
}
static void
ath_rate_findrate(struct ath_softc *sc, struct ath_node *an,
int shortPreamble, size_t frameLen,
u_int8_t *rix, unsigned int *try0, u_int8_t *txrate)
{
struct onoe_node *on = ATH_NODE_ONOE(an);
*rix = on->on_tx_rix0;
*try0 = on->on_tx_try0;
if (shortPreamble)
*txrate = on->on_tx_rate0sp;
else
*txrate = on->on_tx_rate0;
}
static void
ath_rate_get_mrr(struct ath_softc *sc, struct ath_node *an, int shortPreamble,
size_t frame_size, u_int8_t rix, struct ieee80211_mrr *mrr)
{
struct onoe_node *on = ATH_NODE_ONOE(an);
mrr->rate1 = on->on_tx_rate1sp;
mrr->retries1 = 2;
mrr->rate2 = on->on_tx_rate2sp;
mrr->retries2 = 2;
mrr->rate3 = on->on_tx_rate3sp;
mrr->retries3 = 2;
}
static void
ath_rate_tx_complete(struct ath_softc *sc,
struct ath_node *an, const struct ath_buf *bf)
{
struct onoe_node *on = ATH_NODE_ONOE(an);
const struct ath_tx_status *ts = &bf->bf_dsstatus.ds_txstat;
if (ts->ts_status == 0)
on->on_tx_ok++;
else
on->on_tx_err++;
on->on_tx_retr += ts->ts_shortretry
+ ts->ts_longretry;
if (jiffies >= on->on_nextcheck) {
ath_rate_ctl(sc, &an->an_node);
/* XXX halve rate for station mode */
on->on_nextcheck = jiffies + (ath_rateinterval * HZ) / 1000;
}
}
static void
ath_rate_newassoc(struct ath_softc *sc, struct ath_node *an, int isnew)
{
if (isnew)
ath_rate_ctl_start(sc, &an->an_node);
}
static void
ath_rate_update(struct ath_softc *sc, struct ieee80211_node *ni, int rate)
{
struct ath_node *an = ATH_NODE(ni);
struct onoe_node *on = ATH_NODE_ONOE(an);
const HAL_RATE_TABLE *rt = sc->sc_currates;
u_int8_t rix;
KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
DPRINTF(sc, "%s: set xmit rate for %s to %dM\n",
__func__, ether_sprintf(ni->ni_macaddr),
ni->ni_rates.rs_nrates > 0 ?
(ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
ni->ni_txrate = rate;
/*
* Before associating a node has no rate set setup
* so we can't calculate any transmit codes to use.
* This is ok since we should never be sending anything
* but management frames and those always go at the
* lowest hardware rate.
*/
if (ni->ni_rates.rs_nrates == 0)
goto done;
on->on_tx_rix0 = sc->sc_rixmap[ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL];
on->on_tx_rate0 = rt->info[on->on_tx_rix0].rateCode;
on->on_tx_rate0sp = on->on_tx_rate0 |
rt->info[on->on_tx_rix0].shortPreamble;
if (sc->sc_mrretry) {
/*
* Hardware supports multi-rate retry; setup two
* step-down retry rates and make the lowest rate
* be the ``last chance''. We use 4, 2, 2, 2 tries
* respectively (4 is set here, the rest are fixed
* in the xmit routine).
*/
on->on_tx_try0 = 1 + 3; /* 4 tries at rate 0 */
if (--rate >= 0) {
rix = sc->sc_rixmap[ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL];
on->on_tx_rate1 = rt->info[rix].rateCode;
on->on_tx_rate1sp = on->on_tx_rate1 |
rt->info[rix].shortPreamble;
} else
on->on_tx_rate1 = on->on_tx_rate1sp = 0;
if (--rate >= 0) {
rix = sc->sc_rixmap[ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL];
on->on_tx_rate2 = rt->info[rix].rateCode;
on->on_tx_rate2sp = on->on_tx_rate2 |
rt->info[rix].shortPreamble;
} else
on->on_tx_rate2 = on->on_tx_rate2sp = 0;
if (rate > 0) {
/* NB: only do this if we didn't already do it above */
on->on_tx_rate3 = rt->info[0].rateCode;
on->on_tx_rate3sp =
on->on_tx_rate3 | rt->info[0].shortPreamble;
} else
on->on_tx_rate3 = on->on_tx_rate3sp = 0;
} else {
on->on_tx_try0 = ATH_TXMAXTRY; /* max tries at rate 0 */
on->on_tx_rate1 = on->on_tx_rate1sp = 0;
on->on_tx_rate2 = on->on_tx_rate2sp = 0;
on->on_tx_rate3 = on->on_tx_rate3sp = 0;
}
done:
on->on_tx_ok = on->on_tx_err = on->on_tx_retr = on->on_tx_upper = 0;
}
/*
* Set the starting transmit rate for a node.
*/
static void
ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni)
{
#define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
struct ieee80211vap *vap = ni->ni_vap;
int srate;
KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates"));
if (vap->iv_fixed_rate == IEEE80211_FIXED_RATE_NONE) {
/*
* No fixed rate is requested. For 11b start with
* the highest negotiated rate; otherwise, for 11g
* and 11a, we start "in the middle" at 24Mb or 36Mb.
*/
srate = ni->ni_rates.rs_nrates - 1;
if (sc->sc_curmode != IEEE80211_MODE_11B) {
/*
* Scan the negotiated rate set to find the
* closest rate.
*/
/* NB: the rate set is assumed sorted */
for (; srate >= 0 && RATE(srate) > 72; srate--);
KASSERT(srate >= 0, ("bogus rate set"));
}
} else {
/*
* A fixed rate is to be used; iv_fixed_rate is the
* 802.11 rate code. Convert this to the index into
* the negotiated rate set for the node. We know the
* rate is there because the rate set is checked when
* the station associates.
*/
/* NB: the rate set is assumed sorted */
srate = ni->ni_rates.rs_nrates - 1;
for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
KASSERT(srate >= 0,
("fixed rate %d not in rate set", vap->iv_fixed_rate));
}
ath_rate_update(sc, ni, srate);
#undef RATE
}
static void
ath_rate_cb(void *arg, struct ieee80211_node *ni)
{
ath_rate_update(ni->ni_ic->ic_dev->priv, ni, (long) arg);
}
/*
* Reset the rate control state for each 802.11 state transition.
*/
static void
ath_rate_newstate(struct ieee80211vap *vap, enum ieee80211_state state)
{
struct ieee80211com *ic = vap->iv_ic;
struct ath_softc *sc = ic->ic_dev->priv;
struct ieee80211_node *ni;
if (state == IEEE80211_S_INIT)
return;
if (vap->iv_opmode == IEEE80211_M_STA) {
/*
* Reset local xmit state; this is really only
* meaningful when operating in station mode.
*/
ni = vap->iv_bss;
if (state == IEEE80211_S_RUN) {
ath_rate_ctl_start(sc, ni);
} else {
ath_rate_update(sc, ni, 0);
}
} else {
/*
* When operating as a station the node table holds
* the APs that were discovered during scanning.
* For any other operating mode we want to reset the
* tx rate state of each node.
*/
ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_cb, NULL);
ath_rate_update(sc, vap->iv_bss, 0);
}
}
/*
* Examine and potentially adjust the transmit rate.
*/
static void
ath_rate_ctl(void *arg, struct ieee80211_node *ni)
{
struct ath_softc *sc = arg;
struct onoe_node *on = ATH_NODE_ONOE(ATH_NODE(ni));
struct ieee80211_rateset *rs = &ni->ni_rates;
int dir = 0, nrate, enough;
sc->sc_stats.ast_rate_calls++;
/*
* Rate control
* XXX: very primitive version.
*/
enough = (on->on_tx_ok + on->on_tx_err >= 10);
/* no packet reached -> down */
if (on->on_tx_err > 0 && on->on_tx_ok == 0)
dir = -1;
/* all packets needs retry in average -> down */
if (enough && on->on_tx_ok < on->on_tx_retr)
dir = -1;
/* no error and less than rate_raise% of packets need retry -> up */
if (enough && on->on_tx_err == 0 &&
on->on_tx_retr < (on->on_tx_ok * ath_rate_raise) / 100)
dir = 1;
DPRINTF(sc, "%s: ok %d err %d retr %d upper %d dir %d\n",
ether_sprintf(ni->ni_macaddr),
on->on_tx_ok, on->on_tx_err, on->on_tx_retr,
on->on_tx_upper, dir);
nrate = ni->ni_txrate;
switch (dir) {
case 0:
if (enough && on->on_tx_upper > 0)
on->on_tx_upper--;
break;
case -1:
if (nrate > 0) {
nrate--;
sc->sc_stats.ast_rate_drop++;
}
on->on_tx_upper = 0;
break;
case 1:
/* raise rate if we hit rate_raise_threshold */
if (++on->on_tx_upper < ath_rate_raise_threshold)
break;
on->on_tx_upper = 0;
if (nrate + 1 < rs->rs_nrates) {
nrate++;
sc->sc_stats.ast_rate_raise++;
}
break;
}
if (nrate != ni->ni_txrate) {
DPRINTF(sc, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
__func__,
(rs->rs_rates[ni->ni_txrate] & IEEE80211_RATE_VAL) / 2,
(rs->rs_rates[nrate] & IEEE80211_RATE_VAL) / 2,
on->on_tx_ok, on->on_tx_err, on->on_tx_retr);
ath_rate_update(sc, ni, nrate);
} else if (enough)
on->on_tx_ok = on->on_tx_err = on->on_tx_retr = 0;
}
static struct ath_ratectrl *
ath_rate_attach(struct ath_softc *sc)
{
struct onoe_softc *osc;
_MOD_INC_USE(THIS_MODULE, return NULL);
osc = kmalloc(sizeof(struct onoe_softc), GFP_ATOMIC);
if (osc == NULL) {
_MOD_DEC_USE(THIS_MODULE);
return NULL;
}
osc->arc.arc_space = sizeof(struct onoe_node);
osc->arc.arc_vap_space = 0;
return &osc->arc;
}
static void
ath_rate_detach(struct ath_ratectrl *arc)
{
struct onoe_softc *osc = (struct onoe_softc *) arc;
kfree(osc);
_MOD_DEC_USE(THIS_MODULE);
}
static int minrateinterval = 500; /* 500ms */
static int maxpercent = 100; /* 100% */
static int minpercent = 0; /* 0% */
static int maxint = 0x7fffffff; /* 32-bit big */
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
/*
* Static (i.e. global) sysctls.
*/
enum {
DEV_ATH = 9, /* XXX known by many */
};
static ctl_table ath_rate_static_sysctls[] = {
{ .ctl_name = CTL_AUTO,
.procname = "interval",
.mode = 0644,
.data = &ath_rateinterval,
.maxlen = sizeof(ath_rateinterval),
.extra1 = &minrateinterval,
.extra2 = &maxint,
.proc_handler = proc_dointvec_minmax
},
{ .ctl_name = CTL_AUTO,
.procname = "raise",
.mode = 0644,
.data = &ath_rate_raise,
.maxlen = sizeof(ath_rate_raise),
.extra1 = &minpercent,
.extra2 = &maxpercent,
.proc_handler = proc_dointvec_minmax
},
{ .ctl_name = CTL_AUTO,
.procname = "raise_threshold",
.mode = 0644,
.data = &ath_rate_raise_threshold,
.maxlen = sizeof(ath_rate_raise_threshold),
.proc_handler = proc_dointvec
},
{ 0 }
};
static ctl_table ath_rate_table[] = {
{ .ctl_name = CTL_AUTO,
.procname = "rate",
.mode = 0555,
.child = ath_rate_static_sysctls
}, { 0 }
};
static ctl_table ath_ath_table[] = {
{ .ctl_name = DEV_ATH,
.procname = "ath",
.mode = 0555,
.child = ath_rate_table
}, { 0 }
};
static ctl_table ath_root_table[] = {
{ .ctl_name = CTL_DEV,
.procname = "dev",
.mode = 0555,
.child = ath_ath_table
}, { 0 }
};
static struct ctl_table_header *ath_sysctl_header;
static struct ieee80211_rate_ops ath_rate_ops = {
.ratectl_id = IEEE80211_RATE_ONOE,
.node_init = ath_rate_node_init,
.node_cleanup = ath_rate_node_cleanup,
.findrate = ath_rate_findrate,
.get_mrr = ath_rate_get_mrr,
.tx_complete = ath_rate_tx_complete,
.newassoc = ath_rate_newassoc,
.newstate = ath_rate_newstate,
.attach = ath_rate_attach,
.detach = ath_rate_detach,
};
#include "release.h"
static char *version = "1.0 (" RELEASE_VERSION ")";
static char *dev_info = "ath_rate_onoe";
MODULE_AUTHOR("Errno Consulting, Sam Leffler");
MODULE_DESCRIPTION("Atsushi Onoe's rate control algorithm for Atheros devices");
#ifdef MODULE_VERSION
MODULE_VERSION(RELEASE_VERSION);
#endif
#ifdef MODULE_LICENSE
MODULE_LICENSE("Dual BSD/GPL");
#endif
static int __init
init_ath_rate_onoe(void)
{
int ret;
printk(KERN_INFO "%s: %s\n", dev_info, version);
ret = ieee80211_rate_register(&ath_rate_ops);
if (ret)
return ret;
ath_sysctl_header = ATH_REGISTER_SYSCTL_TABLE(ath_root_table);
return (0);
}
module_init(init_ath_rate_onoe);
static void __exit
exit_ath_rate_onoe(void)
{
if (ath_sysctl_header != NULL)
unregister_sysctl_table(ath_sysctl_header);
ieee80211_rate_unregister(&ath_rate_ops);
printk(KERN_INFO "%s: unloaded\n", dev_info);
}
module_exit(exit_ath_rate_onoe);

69
ath_rate/onoe/onoe.h Normal file
View File

@ -0,0 +1,69 @@
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* 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,
without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
/*
* Defintions for the Atheros Wireless LAN controller driver.
*/
#ifndef _DEV_ATH_RATE_ONOE_H
#define _DEV_ATH_RATE_ONOE_H
/* per-device state */
struct onoe_softc {
struct ath_ratectrl arc; /* base state */
};
/* per-node state */
struct onoe_node {
u_int on_tx_ok; /* tx ok pkt */
u_int on_tx_err; /* tx !ok pkt */
u_int on_tx_retr; /* tx retry count */
int on_tx_upper; /* tx upper rate req cnt */
u_int8_t on_tx_rix0; /* series 0 rate index */
u_int8_t on_tx_try0; /* series 0 try count */
u_int8_t on_tx_rate0; /* series 0 h/w rate */
u_int8_t on_tx_rate1; /* series 1 h/w rate */
u_int8_t on_tx_rate2; /* series 2 h/w rate */
u_int8_t on_tx_rate3; /* series 3 h/w rate */
u_int8_t on_tx_rate0sp; /* series 0 short preamble h/w rate */
u_int8_t on_tx_rate1sp; /* series 1 short preamble h/w rate */
u_int8_t on_tx_rate2sp; /* series 2 short preamble h/w rate */
u_int8_t on_tx_rate3sp; /* series 3 short preamble h/w rate */
int on_nextcheck; /* time of next check for rate drop */
};
#define ATH_NODE_ONOE(an) ((struct onoe_node *)&an[1])
#endif /* _DEV_ATH_RATE_ONOE_H */

71
ath_rate/sample/Makefile Normal file
View File

@ -0,0 +1,71 @@
#
# Copyright (c) 2004 Sam Leffler, Errno Consulting
# Copyright (c) 2004 Video54 Technologies, Inc.
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
#
# Makefile for the Atheros Rate Control Support.
#
ifeq ($(obj),)
obj= .
endif
TOP = $(obj)/../..
obj-m += ath_rate_sample.o
ath_rate_sample-objs := sample.o
include $(TOP)/Makefile.inc
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
-include $(TOPDIR)/Rules.make
all:
$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
install:
test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
install ath_rate_sample.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
clean:
-rm -f *~ *.o *.ko *.mod.c
-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
-rm -rf .tmp_versions
ath_rate_sample.o: $(ath_rate_sample-objs)
$(LD) $(LDOPTS) -o ath_rate_sample.$(KMODSUF) -r $(ath_rate_sample-objs)

View File

@ -0,0 +1,37 @@
#
# Makefile for John Bicket's SampleRate control algorithm.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/ath_rate/sample/Makefile.kernel#1 $
#
src ?= .
srctree ?= .
TOP = $(srctree)/$(src)/../..
include $(TOP)/BuildCaps.inc
include $(TOP)/ath_hal/ah_target.inc
ATH= $(TOP)/ath
ATH_HAL=$(TOP)/ath_hal
COMPAT= $(TOP)/include
HAL= $(TOP)/hal
INCS = -include $(COMPAT)/compat.h -I$(COMPAT)
INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -I$(HAL)
EXTRA_CFLAGS += $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
ifneq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) += ath_rate_sample.o
ath_rate_sample-objs := sample.o
endif
ifeq ($(VERSION).$(PATCHLEVEL),2.4)
obj-$(CONFIG_ATHEROS) := sample.o
export-objs := sample.o
list-multi := ath_rate_sample.o
O_TARGET := ath_rate.o
include $(TOPDIR)/Rules.make
endif

1152
ath_rate/sample/sample.c Normal file

File diff suppressed because it is too large Load Diff

143
ath_rate/sample/sample.h Normal file
View File

@ -0,0 +1,143 @@
/*-
* Copyright (c) 2005 John Bicket
* 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,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
*
* $Id$
*/
/*
* Defintions for the Atheros Wireless LAN controller driver.
*/
#ifndef _DEV_ATH_RATE_SAMPLE_H
#define _DEV_ATH_RATE_SAMPLE_H
/* per-device state */
struct sample_softc {
struct ath_ratectrl arc; /* base state */
int ath_smoothing_rate; /* ewma percentage (out of 100) */
int ath_sample_rate; /* send a different bit-rate 1/X packets */
};
#define ATH_SOFTC_SAMPLE(sc) ((struct sample_softc *)sc->sc_rc)
struct rate_info {
int rate;
int rix;
int rateCode;
int shortPreambleRateCode;
};
struct rate_stats {
unsigned average_tx_time;
int successive_failures;
int tries;
int total_packets;
int packets_acked;
unsigned perfect_tx_time; /* transmit time for 0 retries */
int last_tx;
};
/*
* for now, we track performance for three different packet
* size buckets
*/
#define NUM_PACKET_SIZE_BINS 3
static int packet_size_bins[NUM_PACKET_SIZE_BINS] = {250, 1600, 3000};
/* per-node state */
struct sample_node {
int static_rate_ndx;
int num_rates;
struct rate_info rates[IEEE80211_RATE_MAXSIZE];
struct rate_stats stats[NUM_PACKET_SIZE_BINS][IEEE80211_RATE_MAXSIZE];
int last_sample_ndx[NUM_PACKET_SIZE_BINS];
int current_sample_ndx[NUM_PACKET_SIZE_BINS];
int packets_sent[NUM_PACKET_SIZE_BINS];
int current_rate[NUM_PACKET_SIZE_BINS];
int packets_since_switch[NUM_PACKET_SIZE_BINS];
unsigned jiffies_since_switch[NUM_PACKET_SIZE_BINS];
int packets_since_sample[NUM_PACKET_SIZE_BINS];
unsigned sample_tt[NUM_PACKET_SIZE_BINS];
};
#define ATH_NODE_SAMPLE(an) ((struct sample_node *)&an[1])
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#define WIFI_CW_MIN 31
#define WIFI_CW_MAX 1023
/*
* Definitions for pulling the rate and trie counts from
* a 5212 h/w descriptor. These Don't belong here; the
* driver should record this information so the rate control
* code doesn't go groveling around in the descriptor bits.
*/
#define ds_ctl2 ds_hw[0]
#define ds_ctl3 ds_hw[1]
/* TX ds_ctl3 */
#define AR_XmitDataTries0 0x000f0000 /* series 0 max attempts */
#define AR_XmitDataTries0_S 16
#define AR_XmitDataTries1 0x00f00000 /* series 1 max attempts */
#define AR_XmitDataTries1_S 20
#define AR_XmitDataTries2 0x0f000000 /* series 2 max attempts */
#define AR_XmitDataTries2_S 24
#define AR_XmitDataTries3 0xf0000000 /* series 3 max attempts */
#define AR_XmitDataTries3_S 28
/* TX ds_ctl3 */
#define AR_XmitRate0 0x0000001f /* series 0 tx rate */
#define AR_XmitRate0_S 0
#define AR_XmitRate1 0x000003e0 /* series 1 tx rate */
#define AR_XmitRate1_S 5
#define AR_XmitRate2 0x00007c00 /* series 2 tx rate */
#define AR_XmitRate2_S 10
#define AR_XmitRate3 0x000f8000 /* series 3 tx rate */
#define AR_XmitRate3_S 15
#define MS(_v, _f) (((_v) & (_f)) >> _f##_S)
#endif /* _DEV_ATH_RATE_SAMPLE_H */

168
contrib/madwifi.spec.in Normal file
View File

@ -0,0 +1,168 @@
#
#Gen the last kernel-devel available on the machine.
###%{!?kernel: %{expand: %%define kernel %(rpm -q kernel-devel --qf %%{version}-%%{release}\\n | sort | tail -1)}}
%{!?kernel: %{expand: %%define kernel %(rpm -q kernel-devel --last | head -1 | awk '{print $1}' | sed s/kernel-devel-// )}}
%if %(echo %{kernel} | grep -c smp)
%{expand:%%define myksmp -smp}
%endif
#
%define mykversion %(echo %{kernel} | sed -e s/smp// -)
%define mykrelver %(echo %{mykversion} | tr -s '-' '_')
# Define based on the tar ball extract.
# Those two variable will be instanced during the tarball generation
%define revision @@SVNREL@@
%define snapshot @@DDAY@@
# branch is not used yet.
%define branch @@BRANCH@@
Summary: A linux device driver for Atheros chipsets (ar5210, ar5211, ar5212).
Name: madwifi
Version: 0.%{revision}.%{snapshot}
Release: 6
License: GPL2
Group: System Environment/Kernel
URL: http://madwifi.org
#Source0: http://snapshots.madwifi.org/%{name}-%{branch}-r%{revision}-%{snapshot}.tar.gz
# Changes accordingly to the new rule : madwifi-ng-r<revision>-<generation date>.tar.gz
Source0: http://snapshots.madwifi.org/madwifi-ng/%{name}-ng-r%{revision}-%{snapshot}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires: /sbin/depmod
Requires: %{name}-module >= %{version}
BuildRequires: /sbin/depmod
BuildRequires: /lib/modules/%{mykversion}/build/Makefile
%description
This software contains a Linux kernel driver for Atheros-based
Wireless LAN devices. The driver supports station, AP, ad-hoc, and
monitor modes of operation. The Atheros driver depends on a
device-independent implementation of the 802.11 protocols that
originated in the BSD community (NetBSD in particular).
The driver functions as a normal network device and uses the Wireless
Extensions API. As such normal Linux tools can and should be used
with it. Where the wireless extensions are lacking private ioctls
have been added.
There is only one driver included here; it supports PCI, miniPCI
and Cardbus devices - USB devices are currently not supported by
this driver! The driver can be built as a module or linked
directly into the kernel. Note however that the net80211 layer is
device-independent; there is no reason it cannot be used with any
802.11 device (in fact on BSD systems this is the case).
There are currently 3 "programming generations" of Atheros 802.11
wireless devices (some of these have multiple hardware implementations
but otherwise appear identical to users):
5210 supports 11a only
5211 supports both 11a and 11b
5212 supports 11a, 11b, and 11g
%package module
Summary: A linux device driver for Atheros chipsets (ar5210, ar5211, ar5212).
Group: System Environment/Kernel
Requires: kernel = %{mykversion}
Release: 6_%{mykrelver}
%description module
This software is broken into multiple modules. The Atheros-specific
device support is found in the ath_pci module; it should be loaded
when an Atheros wireless device is recognized. The ath_pci module
requires an additional device specific module, ath_hal, which is
described more below. In addition the driver requires the wlan
module which contains the 802.11 state machine, protocol support,
and other device-independent support needed by any 802.11 device.
This code is derived from work that first appeared in NetBSD and
then FreeBSD. The wlan module may also force the loading of
additional modules for crypto support (wlan_wep, wlan_tkip, wlan_ccmp,
etc.), for MAC-based ACL support (wlan_acl), and for 802.1x
authenticator support (wlan_auth, wlan_radius)). The latter modules
are only used when operating as an AP. The crypto modules are
loaded when keys of that type are created.
%prep
#%setup -q
#%setup -q -n %{name}-%{branch}-r%{revision}-%{snapshot}
%setup -q -n %{name}-ng-r%{revision}-%{snapshot}
find . -name Makefile\* | xargs perl -pi -e's,/sbin/depmod,: /sbin/depmod,'
%build
export KERNELRELEASE=%{mykversion}
export KERNELPATH=/lib/modules/%{mykversion}/build
export KERNELCONF=/lib/modules/%{mykversion}/build/.config
export KMODPATH=/lib/modules/%{mykversion}/net
export COPTS="-I /lib/modules/%{mykversion}/build/include/ $COPTS"
# export ATH_RATE=ath_rate/onoe
make
# cd tools ; make all ; cd ..
%install
export KERNELRELEASE=%{mykversion}
export KERNELPATH=/lib/modules/%{mykversion}/build
export KERNELCONF=/lib/modules/%{mykversion}/build/.config
export KMODPATH=/lib/modules/%{mykversion}/net
rm -rf %{buildroot}
# make info
mkdir -p %{buildroot}/usr/local/bin
mkdir -p %{buildroot}/$KMODPATH
mkdir -p %{buildroot}/usr/share/madwifi
make install DESTDIR=%{buildroot} KERNELPATH=/lib/modules/%{mykversion}/build
# cd tools ; make install DESTDIR=%{buildroot} KERNELPATH=/lib/modules/%{mykversion}/build BINDIR=/usr/local/bin ; cd ..
%post module
/sbin/depmod -ae %{mykversion}
%postun module
/sbin/depmod -ae %{mykversion}
%clean
rm -rf %{buildroot}
%files
%doc COPYRIGHT README INSTALL THANKS
%attr(0755,root,root) /usr/local/bin/*
%attr(0644,root,root) /usr/local/man/*
%files module
%defattr(-,root,root,-)
/lib/modules/%{mykversion}/net/*.*o
#
%changelog
* Wed Dec 14 2005 Patrick Pichon <Patrick.Pichon@laposte.net>
- Update accordingly to the new file name rule: madwifi-ng-r<revision>-<generation date>.tar.gz
- 'branch' tag is not use yet. 'ng' is hardcoded as part of the file name
- Change the computation to target the latest kernel-devel env.
* Thu Nov 3 2005 Patrick Pichon <Patrick.Pichon@laposte.net>
- Incorporate the changes made on the Makefile
- Cleaning on the Description fields
- Changing the URL to the new madwifi.org's one.
- Install under /usr/share/doc/madwifi-release the INSTALL and THANKS files
- Install under /usr/share/doc/madwifi-release the docs files.
* Sun Oct 30 2005 Patrick Pichon <Patrick.Pichon@laposte.net>
- Add Man pages
* Mon Oct 24 2005 Lyonel Vincent <>
- Fix the --rebuild option.
* Mon Oct 3 2005 Lyonel Vincent <>
- Build by default on latest kernel installed
* Wed Jul 20 2005 Patrick Pichon <Patrick.Pichon@laposte.net
- target particular kernel
* Mon Oct 27 2004 Patrick Pichon <Patrick.Pichon@laposte.net>
- Handle 2.4 kernel
* Mon Sep 21 2004 Lyonel Vincent <>
- change the naming of the kernel module part.
* Mon Aug 23 2004 Patrick Pichon <Patrick.Pichon@laposte.net>
- Update WPA has been merged into HEAD
* Mon Jul 27 2004 Patrick Pichon <Patrick.Pichon@laposte.net>
- Update to handle WPA branch.
* Tue Jul 08 2004 Patrick Pichon <Patrick.Pichon@laposte.net>
- Initial Release

42
hal/COPYRIGHT Normal file
View File

@ -0,0 +1,42 @@
All files contained in this distribution are covered by the following
copyright unless explicitly identified otherwise. Note that this
copyright does _NOT_ contain a "or GPL" clause and does _NOT_ permit
redistribution with changes.
/*-
* Copyright (c) 2002-2006 Sam Leffler, Errno Consulting, Atheros
* Communications, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the following conditions are met:
* 1. The materials contained herein are unmodified and are used
* unmodified.
* 2. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following NO
* ''WARRANTY'' disclaimer below (''Disclaimer''), without
* modification.
* 3. Redistributions in binary form must reproduce at minimum a
* disclaimer similar to the Disclaimer below and any redistribution
* must be conditioned upon including a substantially similar
* Disclaimer requirement for further binary redistribution.
* 4. Neither the names of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote
* product derived from this software without specific prior written
* permission.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
* FOR 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 DAMAGES.
*
* $Id: //depot/sw/branches/sam_hal/COPYRIGHT#1 $
*/

73
hal/README Normal file
View File

@ -0,0 +1,73 @@
$Id: //depot/sw/branches/sam_hal/README#2 $
Atheros Hardware Access Layer (HAL)
===================================
* Copyright (c) 2002-2006 Sam Leffler.
* Copyright (c) 2002-2006 Atheros Communications, Inc.
* All rights reserved.
Read the file COPYRIGHT for the complete copyright.
This code manages much of the chip-specific operation of the Atheros
driver. The HAL is provided in a binary-only form in order to
comply with local regulatory agency rules. In the United States
the FCC requires that a radio transmitter only be operated at power
levels and on frequency channels for which it is approved. The FCC
requires that a software-defined radio cannot be configured by a
user to operate outside the approved power levels and frequency
channels. This makes it difficult to open-source code that enforces
limits on the power levels, frequency channels and other parameters
of the radio transmitter. See
http://ftp.fcc.gov/Bureaus/Engineering_Technology/Orders/2001/fcc01264.pdf
for the specific FCC regulation. Because the module is provided
in a binary-only form it is marked "Proprietary" on Linux; this
means when you load it you will see messages that your system is
now "tainted".
If you wish to use this driver on a platform for which an ath_hal
module is not already provided please contact the author. Note that
this is only necessary for new _architectures_; the HAL is not tied to
any specific version of your operating system.
Atheros Hardware
================
There are many generations of Atheros 802.11 wireless devices that
are typically referred to by their programming model:
5210 supports 11a only
5211 supports both 11a and 11b
5212 supports 11a, 11b, and 11g
These parts have been incorporated in a variety of retail products
including cardbus cards and mini-pci cards. In addition many laptop
vendors use Atheros mini-pci cards for their builtin wireless
support.
The Atheors PCI vendor id is 0x168c. The file ah_devid.h lists most
known PCI device id's but is not exhaustive. Some vendors program
their own vendor and/or device id's to aid in BIOS-locking mini-pci
cards in laptops.
Atheros SoC Hardware
====================
In addition to the cardbus/pci devices Atheros makes System on Chip
(SoC) parts that integrate a MIPS cpu core and one or more MAC and
radio parts. Binary support for these parts is necessarily built
for the embedded MIPS processor where the code is to be run.
Caveats
=======
The binary hal builds provided here include no floating point and
are operating system-independent. However due to toolchain
peculiarities the .o files may be wrongly rejected by development
tools. If that happens it may be possible to patch the file header
so that the native toolchain will accept the files. In particular
this has been observed for various Linux MIPS installations for the
SoC parts. If you have issues consult the associated .inc file in
the public directory; it explains exactly how the binary file was
created (e.g. toolchain and compilation options).

941
hal/ah.h Normal file
View File

@ -0,0 +1,941 @@
/*-
* Copyright (c) 2002-2006 Sam Leffler, Errno Consulting, Atheros
* Communications, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the following conditions are met:
* 1. The materials contained herein are unmodified and are used
* unmodified.
* 2. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following NO
* ''WARRANTY'' disclaimer below (''Disclaimer''), without
* modification.
* 3. Redistributions in binary form must reproduce at minimum a
* disclaimer similar to the Disclaimer below and any redistribution
* must be conditioned upon including a substantially similar
* Disclaimer requirement for further binary redistribution.
* 4. Neither the names of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote
* product derived from this software without specific prior written
* permission.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
* FOR 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 DAMAGES.
*
* $Id$
*/
#ifndef _ATH_AH_H_
#define _ATH_AH_H_
/*
* Atheros Hardware Access Layer
*
* Clients of the HAL call ath_hal_attach to obtain a reference to an ath_hal
* structure for use with the device. Hardware-related operations that
* follow must call back into the HAL through interface, supplying the
* reference as the first parameter.
*/
/*
* Bus i/o type definitions. We define a platform-independent
* set of types that are mapped to platform-dependent data for
* register read/write operations. We use types that are large
* enough to hold a pointer; smaller data should fit and only
* require type coercion to work. Larger data can be stored
* elsewhere and a reference passed for the bus tag and/or handle.
*/
typedef void* HAL_SOFTC; /* pointer to driver/OS state */
typedef void* HAL_BUS_TAG; /* opaque bus i/o id tag */
typedef void* HAL_BUS_HANDLE; /* opaque bus i/o handle */
#include "ah_osdep.h"
/*
* __ahdecl is analogous to _cdecl; it defines the calling
* convention used within the HAL. For most systems this
* can just default to be empty and the compiler will (should)
* use _cdecl. For systems where _cdecl is not compatible this
* must be defined. See linux/ah_osdep.h for an example.
*/
#ifndef __ahdecl
#define __ahdecl
#endif
/*
* Status codes that may be returned by the HAL. Note that
* interfaces that return a status code set it only when an
* error occurs--i.e. you cannot check it for success.
*/
typedef enum {
HAL_OK = 0, /* No error */
HAL_ENXIO = 1, /* No hardware present */
HAL_ENOMEM = 2, /* Memory allocation failed */
HAL_EIO = 3, /* Hardware didn't respond as expected */
HAL_EEMAGIC = 4, /* EEPROM magic number invalid */
HAL_EEVERSION = 5, /* EEPROM version invalid */
HAL_EELOCKED = 6, /* EEPROM unreadable */
HAL_EEBADSUM = 7, /* EEPROM checksum invalid */
HAL_EEREAD = 8, /* EEPROM read problem */
HAL_EEBADMAC = 9, /* EEPROM mac address invalid */
HAL_EESIZE = 10, /* EEPROM size not supported */
HAL_EEWRITE = 11, /* Attempt to change write-locked EEPROM */
HAL_EINVAL = 12, /* Invalid parameter to function */
HAL_ENOTSUPP = 13, /* Hardware revision not supported */
HAL_ESELFTEST = 14, /* Hardware self-test failed */
HAL_EINPROGRESS = 15, /* Operation incomplete */
} HAL_STATUS;
typedef enum {
AH_FALSE = 0, /* NB: lots of code assumes false is zero */
AH_TRUE = 1,
} HAL_BOOL;
typedef enum {
HAL_CAP_REG_DMN = 0, /* current regulatory domain */
HAL_CAP_CIPHER = 1, /* hardware supports cipher */
HAL_CAP_TKIP_MIC = 2, /* handle TKIP MIC in hardware */
HAL_CAP_TKIP_SPLIT = 3, /* hardware TKIP uses split keys */
HAL_CAP_PHYCOUNTERS = 4, /* hardware PHY error counters */
HAL_CAP_DIVERSITY = 5, /* hardware supports fast diversity */
HAL_CAP_KEYCACHE_SIZE = 6, /* number of entries in key cache */
HAL_CAP_NUM_TXQUEUES = 7, /* number of hardware xmit queues */
HAL_CAP_VEOL = 9, /* hardware supports virtual EOL */
HAL_CAP_PSPOLL = 10, /* hardware has working PS-Poll support */
HAL_CAP_DIAG = 11, /* hardware diagnostic support */
HAL_CAP_COMPRESSION = 12, /* hardware supports compression */
HAL_CAP_BURST = 13, /* hardware supports packet bursting */
HAL_CAP_FASTFRAME = 14, /* hardware supoprts fast frames */
HAL_CAP_TXPOW = 15, /* global tx power limit */
HAL_CAP_TPC = 16, /* per-packet tx power control */
HAL_CAP_PHYDIAG = 17, /* hardware phy error diagnostic */
HAL_CAP_BSSIDMASK = 18, /* hardware supports bssid mask */
HAL_CAP_MCAST_KEYSRCH = 19, /* hardware has multicast key search */
HAL_CAP_TSF_ADJUST = 20, /* hardware has beacon tsf adjust */
HAL_CAP_XR = 21, /* hardware has XR support */
HAL_CAP_WME_TKIPMIC = 22, /* hardware can support TKIP MIC when WMM is turned on */
HAL_CAP_CHAN_HALFRATE = 23, /* hardware can support half rate channels */
HAL_CAP_CHAN_QUARTERRATE = 24, /* hardware can support quarter rate channels */
HAL_CAP_RFSILENT = 25, /* hardware has rfsilent support */
HAL_CAP_TPC_ACK = 26, /* ack txpower with per-packet tpc */
HAL_CAP_TPC_CTS = 27, /* cts txpower with per-packet tpc */
HAL_CAP_11D = 28, /* 11d beacon support for changing cc */
HAL_CAP_INTMIT = 29, /* interference mitigation */
HAL_CAP_RXORN_FATAL = 30, /* HAL_INT_RXORN treated as fatal */
HAL_CAP_HT = 31, /* hardware can support HT */
HAL_CAP_NUMTXCHAIN = 32, /* # TX chains supported */
HAL_CAP_NUMRXCHAIN = 33, /* # RX chains supported */
HAL_CAP_RXTSTAMP_PREC = 34, /* rx desc tstamp precision (bits) */
} HAL_CAPABILITY_TYPE;
/*
* "States" for setting the LED. These correspond to
* the possible 802.11 operational states and there may
* be a many-to-one mapping between these states and the
* actual hardware state for the LED's (i.e. the hardware
* may have fewer states).
*/
typedef enum {
HAL_LED_INIT = 0,
HAL_LED_SCAN = 1,
HAL_LED_AUTH = 2,
HAL_LED_ASSOC = 3,
HAL_LED_RUN = 4
} HAL_LED_STATE;
/*
* Transmit queue types/numbers. These are used to tag
* each transmit queue in the hardware and to identify a set
* of transmit queues for operations such as start/stop dma.
*/
typedef enum {
HAL_TX_QUEUE_INACTIVE = 0, /* queue is inactive/unused */
HAL_TX_QUEUE_DATA = 1, /* data xmit q's */
HAL_TX_QUEUE_BEACON = 2, /* beacon xmit q */
HAL_TX_QUEUE_CAB = 3, /* "crap after beacon" xmit q */
HAL_TX_QUEUE_UAPSD = 4, /* u-apsd power save xmit q */
} HAL_TX_QUEUE;
#define HAL_NUM_TX_QUEUES 10 /* max possible # of queues */
/*
* Transmit queue subtype. These map directly to
* WME Access Categories (except for UPSD). Refer
* to Table 5 of the WME spec.
*/
typedef enum {
HAL_WME_AC_BK = 0, /* background access category */
HAL_WME_AC_BE = 1, /* best effort access category*/
HAL_WME_AC_VI = 2, /* video access category */
HAL_WME_AC_VO = 3, /* voice access category */
HAL_WME_UPSD = 4, /* uplink power save */
HAL_XR_DATA = 5, /* uplink power save */
} HAL_TX_QUEUE_SUBTYPE;
/*
* Transmit queue flags that control various
* operational parameters.
*/
typedef enum {
/*
* Per queue interrupt enables. When set the associated
* interrupt may be delivered for packets sent through
* the queue. Without these enabled no interrupts will
* be delivered for transmits through the queue.
*/
HAL_TXQ_TXOKINT_ENABLE = 0x0001, /* enable TXOK interrupt */
HAL_TXQ_TXERRINT_ENABLE = 0x0001, /* enable TXERR interrupt */
HAL_TXQ_TXDESCINT_ENABLE = 0x0002, /* enable TXDESC interrupt */
HAL_TXQ_TXEOLINT_ENABLE = 0x0004, /* enable TXEOL interrupt */
HAL_TXQ_TXURNINT_ENABLE = 0x0008, /* enable TXURN interrupt */
/*
* Enable hardware compression for packets sent through
* the queue. The compression buffer must be setup and
* packets must have a key entry marked in the tx descriptor.
*/
HAL_TXQ_COMPRESSION_ENABLE = 0x0010, /* enable h/w compression */
/*
* Disable queue when veol is hit or ready time expires.
* By default the queue is disabled only on reaching the
* physical end of queue (i.e. a null link ptr in the
* descriptor chain).
*/
HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE = 0x0020,
/*
* Schedule frames on delivery of a DBA (DMA Beacon Alert)
* event. Frames will be transmitted only when this timer
* fires, e.g to transmit a beacon in ap or adhoc modes.
*/
HAL_TXQ_DBA_GATED = 0x0040, /* schedule based on DBA */
/*
* Each transmit queue has a counter that is incremented
* each time the queue is enabled and decremented when
* the list of frames to transmit is traversed (or when
* the ready time for the queue expires). This counter
* must be non-zero for frames to be scheduled for
* transmission. The following controls disable bumping
* this counter under certain conditions. Typically this
* is used to gate frames based on the contents of another
* queue (e.g. CAB traffic may only follow a beacon frame).
* These are meaningful only when frames are scheduled
* with a non-ASAP policy (e.g. DBA-gated).
*/
HAL_TXQ_CBR_DIS_QEMPTY = 0x0080, /* disable on this q empty */
HAL_TXQ_CBR_DIS_BEMPTY = 0x0100, /* disable on beacon q empty */
/*
* Fragment burst backoff policy. Normally the no backoff
* is done after a successful transmission, the next fragment
* is sent at SIFS. If this flag is set backoff is done
* after each fragment, regardless whether it was ack'd or
* not, after the backoff count reaches zero a normal channel
* access procedure is done before the next transmit (i.e.
* wait AIFS instead of SIFS).
*/
HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE = 0x00800000,
/*
* Disable post-tx backoff following each frame.
*/
HAL_TXQ_BACKOFF_DISABLE = 0x00010000, /* disable post backoff */
/*
* DCU arbiter lockout control. This controls how
* lower priority tx queues are handled with respect to
* to a specific queue when multiple queues have frames
* to send. No lockout means lower priority queues arbitrate
* concurrently with this queue. Intra-frame lockout
* means lower priority queues are locked out until the
* current frame transmits (e.g. including backoffs and bursting).
* Global lockout means nothing lower can arbitrary so
* long as there is traffic activity on this queue (frames,
* backoff, etc).
*/
HAL_TXQ_ARB_LOCKOUT_INTRA = 0x00020000, /* intra-frame lockout */
HAL_TXQ_ARB_LOCKOUT_GLOBAL = 0x00040000, /* full lockout s */
HAL_TXQ_IGNORE_VIRTCOL = 0x00080000, /* ignore virt collisions */
HAL_TXQ_SEQNUM_INC_DIS = 0x00100000, /* disable seqnum increment */
} HAL_TX_QUEUE_FLAGS;
typedef struct {
u_int32_t tqi_ver; /* hal TXQ version */
HAL_TX_QUEUE_SUBTYPE tqi_subtype; /* subtype if applicable */
HAL_TX_QUEUE_FLAGS tqi_qflags; /* flags (see above) */
u_int32_t tqi_priority; /* (not used) */
u_int32_t tqi_aifs; /* aifs */
u_int32_t tqi_cwmin; /* cwMin */
u_int32_t tqi_cwmax; /* cwMax */
u_int16_t tqi_shretry; /* rts retry limit */
u_int16_t tqi_lgretry; /* long retry limit (not used)*/
u_int32_t tqi_cbrPeriod; /* CBR period (us) */
u_int32_t tqi_cbrOverflowLimit; /* threshold for CBROVF int */
u_int32_t tqi_burstTime; /* max burst duration (us) */
u_int32_t tqi_readyTime; /* frame schedule time (us) */
u_int32_t tqi_compBuf; /* comp buffer phys addr */
} HAL_TXQ_INFO;
#define HAL_TQI_NONVAL 0xffff
/* token to use for aifs, cwmin, cwmax */
#define HAL_TXQ_USEDEFAULT ((u_int32_t) -1)
/* compression definitions */
#define HAL_COMP_BUF_MAX_SIZE 9216 /* 9K */
#define HAL_COMP_BUF_ALIGN_SIZE 512
/*
* Transmit packet types. This belongs in ah_desc.h, but
* is here so we can give a proper type to various parameters
* (and not require everyone include the file).
*
* NB: These values are intentionally assigned for
* direct use when setting up h/w descriptors.
*/
typedef enum {
HAL_PKT_TYPE_NORMAL = 0,
HAL_PKT_TYPE_ATIM = 1,
HAL_PKT_TYPE_PSPOLL = 2,
HAL_PKT_TYPE_BEACON = 3,
HAL_PKT_TYPE_PROBE_RESP = 4,
HAL_PKT_TYPE_CHIRP = 5,
HAL_PKT_TYPE_GRP_POLL = 6,
HAL_PKT_TYPE_AMPDU = 7,
} HAL_PKT_TYPE;
/* Rx Filter Frame Types */
typedef enum {
HAL_RX_FILTER_UCAST = 0x00000001, /* Allow unicast frames */
HAL_RX_FILTER_MCAST = 0x00000002, /* Allow multicast frames */
HAL_RX_FILTER_BCAST = 0x00000004, /* Allow broadcast frames */
HAL_RX_FILTER_CONTROL = 0x00000008, /* Allow control frames */
HAL_RX_FILTER_BEACON = 0x00000010, /* Allow beacon frames */
HAL_RX_FILTER_PROM = 0x00000020, /* Promiscuous mode */
HAL_RX_FILTER_XRPOLL = 0x00000040, /* Allow XR poll frmae */
HAL_RX_FILTER_PROBEREQ = 0x00000080, /* Allow probe request frames */
HAL_RX_FILTER_PHYERR = 0x00000100, /* Allow phy errors */
HAL_RX_FILTER_PHYRADAR = 0x00000200, /* Allow phy radar errors*/
} HAL_RX_FILTER;
typedef enum {
HAL_PM_AWAKE = 0,
HAL_PM_FULL_SLEEP = 1,
HAL_PM_NETWORK_SLEEP = 2,
HAL_PM_UNDEFINED = 3
} HAL_POWER_MODE;
/*
* NOTE WELL:
* These are mapped to take advantage of the common locations for many of
* the bits on all of the currently supported MAC chips. This is to make
* the ISR as efficient as possible, while still abstracting HW differences.
* When new hardware breaks this commonality this enumerated type, as well
* as the HAL functions using it, must be modified. All values are directly
* mapped unless commented otherwise.
*/
typedef enum {
HAL_INT_RX = 0x00000001, /* Non-common mapping */
HAL_INT_RXDESC = 0x00000002,
HAL_INT_RXNOFRM = 0x00000008,
HAL_INT_RXEOL = 0x00000010,
HAL_INT_RXORN = 0x00000020,
HAL_INT_TX = 0x00000040, /* Non-common mapping */
HAL_INT_TXDESC = 0x00000080,
HAL_INT_TXURN = 0x00000800,
HAL_INT_MIB = 0x00001000,
HAL_INT_RXPHY = 0x00004000,
HAL_INT_RXKCM = 0x00008000,
HAL_INT_SWBA = 0x00010000,
HAL_INT_BMISS = 0x00040000,
HAL_INT_BNR = 0x00100000, /* Non-common mapping */
HAL_INT_TIM = 0x00200000, /* Non-common mapping */
HAL_INT_DTIM = 0x00400000, /* Non-common mapping */
HAL_INT_DTIMSYNC= 0x00800000, /* Non-common mapping */
HAL_INT_GPIO = 0x01000000,
HAL_INT_CABEND = 0x02000000, /* Non-common mapping */
HAL_INT_CST = 0x10000000, /* Non-common mapping */
HAL_INT_GTT = 0x20000000, /* Non-common mapping */
HAL_INT_FATAL = 0x40000000, /* Non-common mapping */
#define HAL_INT_GLOBAL 0x80000000 /* Set/clear IER */
HAL_INT_BMISC = HAL_INT_TIM
| HAL_INT_DTIM
| HAL_INT_DTIMSYNC
| HAL_INT_CABEND,
/* Interrupt bits that map directly to ISR/IMR bits */
HAL_INT_COMMON = HAL_INT_RXNOFRM
| HAL_INT_RXDESC
| HAL_INT_RXEOL
| HAL_INT_RXORN
| HAL_INT_TXURN
| HAL_INT_TXDESC
| HAL_INT_MIB
| HAL_INT_RXPHY
| HAL_INT_RXKCM
| HAL_INT_SWBA
| HAL_INT_BMISS
| HAL_INT_GPIO,
} HAL_INT;
typedef enum {
HAL_RFGAIN_INACTIVE = 0,
HAL_RFGAIN_READ_REQUESTED = 1,
HAL_RFGAIN_NEED_CHANGE = 2
} HAL_RFGAIN;
/*
* Channels are specified by frequency.
*/
typedef struct {
u_int32_t channelFlags; /* see below */
u_int16_t channel; /* setting in Mhz */
u_int8_t privFlags;
int8_t maxRegTxPower; /* max regulatory tx power in dBm */
int8_t maxTxPower; /* max true tx power in 0.5 dBm */
int8_t minTxPower; /* min true tx power in 0.5 dBm */
} HAL_CHANNEL;
/* channelFlags */
#define CHANNEL_CW_INT 0x00002 /* CW interference detected on channel */
#define CHANNEL_TURBO 0x00010 /* Turbo Channel */
#define CHANNEL_CCK 0x00020 /* CCK channel */
#define CHANNEL_OFDM 0x00040 /* OFDM channel */
#define CHANNEL_2GHZ 0x00080 /* 2 GHz spectrum channel */
#define CHANNEL_5GHZ 0x00100 /* 5 GHz spectrum channel */
#define CHANNEL_PASSIVE 0x00200 /* Only passive scan allowed in the channel */
#define CHANNEL_DYN 0x00400 /* dynamic CCK-OFDM channel */
#define CHANNEL_XR 0x00800 /* XR channel */
#define CHANNEL_STURBO 0x02000 /* Static turbo, no 11a-only usage */
#define CHANNEL_HALF 0x04000 /* Half rate channel */
#define CHANNEL_QUARTER 0x08000 /* Quarter rate channel */
#define CHANNEL_HT20 0x10000 /* 11n 20MHZ channel */
#define CHANNEL_HT40PLUS 0x20000 /* 11n 40MHZ channel w/ ext chan above */
#define CHANNEL_HT40MINUS 0x40000 /* 11n 40MHZ channel w/ ext chan below */
/* privFlags */
#define CHANNEL_INTERFERENCE 0x01 /* Software use: channel interference
used for as AR as well as RADAR
interference detection */
#define CHANNEL_DFS 0x02 /* DFS required on channel */
#define CHANNEL_4MS_LIMIT 0x04 /* 4msec packet limit on this channel */
#define CHANNEL_DFS_CLEAR 0x08 /* if channel has been checked for DFS */
#define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM)
#define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK)
#define CHANNEL_PUREG (CHANNEL_2GHZ|CHANNEL_OFDM)
#ifdef notdef
#define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_DYN)
#else
#define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM)
#endif
#define CHANNEL_T (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_TURBO)
#define CHANNEL_ST (CHANNEL_T|CHANNEL_STURBO)
#define CHANNEL_108G (CHANNEL_2GHZ|CHANNEL_OFDM|CHANNEL_TURBO)
#define CHANNEL_108A CHANNEL_T
#define CHANNEL_X (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_XR)
#define CHANNEL_G_HT20 (CHANNEL_2GHZ|CHANNEL_OFDM | CHANNEL_HT20)
#define CHANNEL_A_HT20 (CHANNEL_5GHZ|CHANNEL_OFDM | CHANNEL_HT20)
#define CHANNEL_G_HT40PLUS (CHANNEL_G_HT20|CHANNEL_HT40PLUS)
#define CHANNEL_G_HT40MINUS (CHANNEL_G_HT20|CHANNEL_HT40MINUS)
#define CHANNEL_A_HT40PLUS (CHANNEL_A_HT20|CHANNEL_HT40PLUS)
#define CHANNEL_A_HT40MINUS (CHANNEL_A_HT20|CHANNEL_HT40MINUS)
#define CHANNEL_ALL \
(CHANNEL_OFDM | CHANNEL_CCK| CHANNEL_2GHZ | CHANNEL_5GHZ | \
CHANNEL_TURBO | CHANNEL_HT20 | CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)
#define CHANNEL_ALL_NOTURBO (CHANNEL_ALL &~ CHANNEL_TURBO)
#define HAL_ANTENNA_MIN_MODE 0
#define HAL_ANTENNA_FIXED_A 1
#define HAL_ANTENNA_FIXED_B 2
#define HAL_ANTENNA_MAX_MODE 3
typedef struct {
u_int32_t ackrcv_bad;
u_int32_t rts_bad;
u_int32_t rts_good;
u_int32_t fcs_bad;
u_int32_t beacons;
} HAL_MIB_STATS;
typedef u_int16_t HAL_CTRY_CODE; /* country code */
typedef u_int16_t HAL_REG_DOMAIN; /* regulatory domain code */
enum {
CTRY_DEBUG = 0x1ff, /* debug country code */
CTRY_DEFAULT = 0 /* default country code */
};
enum {
HAL_MODE_11A = 0x001, /* 11a channels */
HAL_MODE_TURBO = 0x002, /* 11a turbo-only channels */
HAL_MODE_11B = 0x004, /* 11b channels */
HAL_MODE_PUREG = 0x008, /* 11g channels (OFDM only) */
#ifdef notdef
HAL_MODE_11G = 0x010, /* 11g channels (OFDM/CCK) */
#else
HAL_MODE_11G = 0x008, /* XXX historical */
#endif
HAL_MODE_108G = 0x020, /* 11a+Turbo channels */
HAL_MODE_108A = 0x040, /* 11g+Turbo channels */
HAL_MODE_XR = 0x100, /* XR channels */
HAL_MODE_11A_HALF_RATE = 0x200, /* 11A half rate channels */
HAL_MODE_11A_QUARTER_RATE = 0x400, /* 11A quarter rate channels */
HAL_MODE_11NG_HT20 = 0x8000,
HAL_MODE_11NA_HT20 = 0x10000,
HAL_MODE_11NG_HT40PLUS = 0x20000,
HAL_MODE_11NG_HT40MINUS = 0x40000,
HAL_MODE_11NA_HT40PLUS = 0x80000,
HAL_MODE_11NA_HT40MINUS = 0x100000,
HAL_MODE_ALL = 0xfff
};
typedef struct {
int rateCount; /* NB: for proper padding */
u_int8_t rateCodeToIndex[32]; /* back mapping */
struct {
u_int8_t valid; /* valid for rate control use */
u_int8_t phy; /* CCK/OFDM/XR */
u_int32_t rateKbps; /* transfer rate in kbs */
u_int8_t rateCode; /* rate for h/w descriptors */
u_int8_t shortPreamble; /* mask for enabling short
* preamble in CCK rate code */
u_int8_t dot11Rate; /* value for supported rates
* info element of MLME */
u_int8_t controlRate; /* index of next lower basic
* rate; used for dur. calcs */
u_int16_t lpAckDuration; /* long preamble ACK duration */
u_int16_t spAckDuration; /* short preamble ACK duration*/
} info[32];
} HAL_RATE_TABLE;
typedef struct {
u_int rs_count; /* number of valid entries */
u_int8_t rs_rates[32]; /* rates */
} HAL_RATE_SET;
/*
* 802.11n specific structures and enums
*/
typedef enum {
HAL_CHAINTYPE_TX = 1, /* Tx chain type */
HAL_CHAINTYPE_RX = 2, /* RX chain type */
} HAL_CHAIN_TYPE;
typedef struct {
u_int Tries;
u_int Rate;
u_int PktDuration;
u_int ChSel;
u_int RateFlags;
#define HAL_RATESERIES_RTS_CTS 0x0001 /* use rts/cts w/this series */
#define HAL_RATESERIES_2040 0x0002 /* use ext channel for series */
#define HAL_RATESERIES_HALFGI 0x0004 /* use half-gi for series */
} HAL_11N_RATE_SERIES;
typedef enum {
HAL_HT_MACMODE_20 = 0, /* 20 MHz operation */
HAL_HT_MACMODE_2040 = 1, /* 20/40 MHz operation */
} HAL_HT_MACMODE;
typedef enum {
HAL_HT_PHYMODE_20 = 0, /* 20 MHz operation */
HAL_HT_PHYMODE_2040 = 1, /* 20/40 MHz operation */
} HAL_HT_PHYMODE;
typedef enum {
HAL_HT_EXTPROTSPACING_20 = 0, /* 20 MHz spacing */
HAL_HT_EXTPROTSPACING_25 = 1, /* 25 MHz spacing */
} HAL_HT_EXTPROTSPACING;
typedef enum {
HAL_RX_CLEAR_CTL_LOW = 0x1, /* force control channel to appear busy */
HAL_RX_CLEAR_EXT_LOW = 0x2, /* force extension channel to appear busy */
} HAL_HT_RXCLEAR;
/*
* Antenna switch control. By default antenna selection
* enables multiple (2) antenna use. To force use of the
* A or B antenna only specify a fixed setting. Fixing
* the antenna will also disable any diversity support.
*/
typedef enum {
HAL_ANT_VARIABLE = 0, /* variable by programming */
HAL_ANT_FIXED_A = 1, /* fixed antenna A */
HAL_ANT_FIXED_B = 2, /* fixed antenna B */
} HAL_ANT_SETTING;
typedef enum {
HAL_M_STA = 1, /* infrastructure station */
HAL_M_IBSS = 0, /* IBSS (adhoc) station */
HAL_M_HOSTAP = 6, /* Software Access Point */
HAL_M_MONITOR = 8 /* Monitor mode */
} HAL_OPMODE;
typedef struct {
u_int8_t kv_type; /* one of HAL_CIPHER */
u_int8_t kv_pad;
u_int16_t kv_len; /* length in bits */
u_int8_t kv_val[16]; /* enough for 128-bit keys */
u_int8_t kv_mic[8]; /* TKIP MIC key */
u_int8_t kv_txmic[8]; /* TKIP TX MIC key (optional) */
} HAL_KEYVAL;
typedef enum {
HAL_CIPHER_WEP = 0,
HAL_CIPHER_AES_OCB = 1,
HAL_CIPHER_AES_CCM = 2,
HAL_CIPHER_CKIP = 3,
HAL_CIPHER_TKIP = 4,
HAL_CIPHER_CLR = 5, /* no encryption */
HAL_CIPHER_MIC = 127 /* TKIP-MIC, not a cipher */
} HAL_CIPHER;
enum {
HAL_SLOT_TIME_6 = 6, /* NB: for turbo mode */
HAL_SLOT_TIME_9 = 9,
HAL_SLOT_TIME_20 = 20,
};
/*
* Per-station beacon timer state. Note that the specified
* beacon interval (given in TU's) can also include flags
* to force a TSF reset and to enable the beacon xmit logic.
* If bs_cfpmaxduration is non-zero the hardware is setup to
* coexist with a PCF-capable AP.
*/
typedef struct {
u_int32_t bs_nexttbtt; /* next beacon in TU */
u_int32_t bs_nextdtim; /* next DTIM in TU */
u_int32_t bs_intval; /* beacon interval+flags */
#define HAL_BEACON_PERIOD 0x0000ffff /* beacon interval period */
#define HAL_BEACON_ENA 0x00800000 /* beacon xmit enable */
#define HAL_BEACON_RESET_TSF 0x01000000 /* clear TSF */
u_int32_t bs_dtimperiod;
u_int16_t bs_cfpperiod; /* CFP period in TU */
u_int16_t bs_cfpmaxduration; /* max CFP duration in TU */
u_int32_t bs_cfpnext; /* next CFP in TU */
u_int16_t bs_timoffset; /* byte offset to TIM bitmap */
u_int16_t bs_bmissthreshold; /* beacon miss threshold */
u_int32_t bs_sleepduration; /* max sleep duration */
} HAL_BEACON_STATE;
/*
* Like HAL_BEACON_STATE but for non-station mode setup.
* NB: see above flag definitions for bt_intval.
*/
typedef struct {
u_int32_t bt_intval; /* beacon interval+flags */
u_int32_t bt_nexttbtt; /* next beacon in TU */
u_int32_t bt_nextatim; /* next ATIM in TU */
u_int32_t bt_nextdba; /* next DBA in 1/8th TU */
u_int32_t bt_nextswba; /* next SWBA in 1/8th TU */
u_int32_t bt_flags; /* timer enables */
#define HAL_BEACON_TBTT_EN 0x00000001
#define HAL_BEACON_DBA_EN 0x00000002
#define HAL_BEACON_SWBA_EN 0x00000004
} HAL_BEACON_TIMERS;
/*
* Per-node statistics maintained by the driver for use in
* optimizing signal quality and other operational aspects.
*/
typedef struct {
u_int32_t ns_avgbrssi; /* average beacon rssi */
u_int32_t ns_avgrssi; /* average data rssi */
u_int32_t ns_avgtxrssi; /* average tx rssi */
} HAL_NODE_STATS;
#define HAL_RSSI_EP_MULTIPLIER (1<<7) /* pow2 to optimize out * and / */
struct ath_desc;
struct ath_tx_status;
struct ath_rx_status;
/*
* Hardware Access Layer (HAL) API.
*
* Clients of the HAL call ath_hal_attach to obtain a reference to an
* ath_hal structure for use with the device. Hardware-related operations
* that follow must call back into the HAL through interface, supplying
* the reference as the first parameter. Note that before using the
* reference returned by ath_hal_attach the caller should verify the
* ABI version number.
*/
struct ath_hal {
u_int32_t ah_magic; /* consistency check magic number */
u_int32_t ah_abi; /* HAL ABI version */
#define HAL_ABI_VERSION 0x07013100 /* YYMMDDnn */
u_int16_t ah_devid; /* PCI device ID */
u_int16_t ah_subvendorid; /* PCI subvendor ID */
HAL_SOFTC ah_sc; /* back pointer to driver/os state */
HAL_BUS_TAG ah_st; /* params for register r+w */
HAL_BUS_HANDLE ah_sh;
HAL_CTRY_CODE ah_countryCode;
u_int32_t ah_macVersion; /* MAC version id */
u_int16_t ah_macRev; /* MAC revision */
u_int16_t ah_phyRev; /* PHY revision */
/* NB: when only one radio is present the rev is in 5Ghz */
u_int16_t ah_analog5GhzRev;/* 5GHz radio revision */
u_int16_t ah_analog2GhzRev;/* 2GHz radio revision */
const HAL_RATE_TABLE *__ahdecl(*ah_getRateTable)(struct ath_hal *,
u_int mode);
void __ahdecl(*ah_detach)(struct ath_hal*);
/* Reset functions */
HAL_BOOL __ahdecl(*ah_reset)(struct ath_hal *, HAL_OPMODE,
HAL_CHANNEL *, HAL_BOOL bChannelChange,
HAL_STATUS *status);
HAL_BOOL __ahdecl(*ah_phyDisable)(struct ath_hal *);
HAL_BOOL __ahdecl(*ah_disable)(struct ath_hal *);
void __ahdecl(*ah_setPCUConfig)(struct ath_hal *);
HAL_BOOL __ahdecl(*ah_perCalibration)(struct ath_hal*, HAL_CHANNEL *, HAL_BOOL *);
HAL_BOOL __ahdecl(*ah_setTxPowerLimit)(struct ath_hal *, u_int32_t);
/* DFS support */
HAL_BOOL __ahdecl(*ah_radarWait)(struct ath_hal *, HAL_CHANNEL *);
/* Transmit functions */
HAL_BOOL __ahdecl(*ah_updateTxTrigLevel)(struct ath_hal*,
HAL_BOOL incTrigLevel);
int __ahdecl(*ah_setupTxQueue)(struct ath_hal *, HAL_TX_QUEUE,
const HAL_TXQ_INFO *qInfo);
HAL_BOOL __ahdecl(*ah_setTxQueueProps)(struct ath_hal *, int q,
const HAL_TXQ_INFO *qInfo);
HAL_BOOL __ahdecl(*ah_getTxQueueProps)(struct ath_hal *, int q,
HAL_TXQ_INFO *qInfo);
HAL_BOOL __ahdecl(*ah_releaseTxQueue)(struct ath_hal *ah, u_int q);
HAL_BOOL __ahdecl(*ah_resetTxQueue)(struct ath_hal *ah, u_int q);
u_int32_t __ahdecl(*ah_getTxDP)(struct ath_hal*, u_int);
HAL_BOOL __ahdecl(*ah_setTxDP)(struct ath_hal*, u_int, u_int32_t txdp);
u_int32_t __ahdecl(*ah_numTxPending)(struct ath_hal *, u_int q);
HAL_BOOL __ahdecl(*ah_startTxDma)(struct ath_hal*, u_int);
HAL_BOOL __ahdecl(*ah_stopTxDma)(struct ath_hal*, u_int);
HAL_BOOL __ahdecl(*ah_setupTxDesc)(struct ath_hal *, struct ath_desc *,
u_int pktLen, u_int hdrLen,
HAL_PKT_TYPE type, u_int txPower,
u_int txRate0, u_int txTries0,
u_int keyIx, u_int antMode, u_int flags,
u_int rtsctsRate, u_int rtsctsDuration,
u_int compicvLen, u_int compivLen,
u_int comp);
HAL_BOOL __ahdecl(*ah_setupXTxDesc)(struct ath_hal *, struct ath_desc*,
u_int txRate1, u_int txTries1,
u_int txRate2, u_int txTries2,
u_int txRate3, u_int txTries3);
HAL_BOOL __ahdecl(*ah_fillTxDesc)(struct ath_hal *, struct ath_desc *,
u_int segLen, HAL_BOOL firstSeg,
HAL_BOOL lastSeg, const struct ath_desc *);
HAL_STATUS __ahdecl(*ah_procTxDesc)(struct ath_hal *,
struct ath_desc *, struct ath_tx_status *);
void __ahdecl(*ah_getTxIntrQueue)(struct ath_hal *, u_int32_t *);
void __ahdecl(*ah_reqTxIntrDesc)(struct ath_hal *, struct ath_desc*);
/* Receive Functions */
u_int32_t __ahdecl(*ah_getRxDP)(struct ath_hal*);
void __ahdecl(*ah_setRxDP)(struct ath_hal*, u_int32_t rxdp);
void __ahdecl(*ah_enableReceive)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_stopDmaReceive)(struct ath_hal*);
void __ahdecl(*ah_startPcuReceive)(struct ath_hal*);
void __ahdecl(*ah_stopPcuReceive)(struct ath_hal*);
void __ahdecl(*ah_setMulticastFilter)(struct ath_hal*,
u_int32_t filter0, u_int32_t filter1);
HAL_BOOL __ahdecl(*ah_setMulticastFilterIndex)(struct ath_hal*,
u_int32_t index);
HAL_BOOL __ahdecl(*ah_clrMulticastFilterIndex)(struct ath_hal*,
u_int32_t index);
u_int32_t __ahdecl(*ah_getRxFilter)(struct ath_hal*);
void __ahdecl(*ah_setRxFilter)(struct ath_hal*, u_int32_t);
HAL_BOOL __ahdecl(*ah_setupRxDesc)(struct ath_hal *, struct ath_desc *,
u_int32_t size, u_int flags);
HAL_STATUS __ahdecl(*ah_procRxDesc)(struct ath_hal *,
struct ath_desc *, u_int32_t phyAddr,
struct ath_desc *next, u_int64_t tsf,
struct ath_rx_status *);
void __ahdecl(*ah_rxMonitor)(struct ath_hal *,
const HAL_NODE_STATS *, HAL_CHANNEL *);
void __ahdecl(*ah_procMibEvent)(struct ath_hal *,
const HAL_NODE_STATS *);
/* Misc Functions */
HAL_STATUS __ahdecl(*ah_getCapability)(struct ath_hal *,
HAL_CAPABILITY_TYPE, u_int32_t capability,
u_int32_t *result);
HAL_BOOL __ahdecl(*ah_setCapability)(struct ath_hal *,
HAL_CAPABILITY_TYPE, u_int32_t capability,
u_int32_t setting, HAL_STATUS *);
HAL_BOOL __ahdecl(*ah_getDiagState)(struct ath_hal *, int request,
const void *args, u_int32_t argsize,
void **result, u_int32_t *resultsize);
void __ahdecl(*ah_getMacAddress)(struct ath_hal *, u_int8_t *);
HAL_BOOL __ahdecl(*ah_setMacAddress)(struct ath_hal *, const u_int8_t*);
void __ahdecl(*ah_getBssIdMask)(struct ath_hal *, u_int8_t *);
HAL_BOOL __ahdecl(*ah_setBssIdMask)(struct ath_hal *, const u_int8_t*);
HAL_BOOL __ahdecl(*ah_setRegulatoryDomain)(struct ath_hal*,
u_int16_t, HAL_STATUS *);
void __ahdecl(*ah_setLedState)(struct ath_hal*, HAL_LED_STATE);
void __ahdecl(*ah_writeAssocid)(struct ath_hal*,
const u_int8_t *bssid, u_int16_t assocId);
HAL_BOOL __ahdecl(*ah_gpioCfgOutput)(struct ath_hal *, u_int32_t gpio);
HAL_BOOL __ahdecl(*ah_gpioCfgInput)(struct ath_hal *, u_int32_t gpio);
u_int32_t __ahdecl(*ah_gpioGet)(struct ath_hal *, u_int32_t gpio);
HAL_BOOL __ahdecl(*ah_gpioSet)(struct ath_hal *,
u_int32_t gpio, u_int32_t val);
void __ahdecl(*ah_gpioSetIntr)(struct ath_hal*, u_int, u_int32_t);
u_int32_t __ahdecl(*ah_getTsf32)(struct ath_hal*);
u_int64_t __ahdecl(*ah_getTsf64)(struct ath_hal*);
void __ahdecl(*ah_resetTsf)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_detectCardPresent)(struct ath_hal*);
void __ahdecl(*ah_updateMibCounters)(struct ath_hal*,
HAL_MIB_STATS*);
HAL_RFGAIN __ahdecl(*ah_getRfGain)(struct ath_hal*);
u_int __ahdecl(*ah_getDefAntenna)(struct ath_hal*);
void __ahdecl(*ah_setDefAntenna)(struct ath_hal*, u_int);
HAL_ANT_SETTING __ahdecl(*ah_getAntennaSwitch)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_setAntennaSwitch)(struct ath_hal*,
HAL_ANT_SETTING);
HAL_BOOL __ahdecl(*ah_setSlotTime)(struct ath_hal*, u_int);
u_int __ahdecl(*ah_getSlotTime)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_setAckTimeout)(struct ath_hal*, u_int);
u_int __ahdecl(*ah_getAckTimeout)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_setAckCTSRate)(struct ath_hal*, u_int);
u_int __ahdecl(*ah_getAckCTSRate)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_setCTSTimeout)(struct ath_hal*, u_int);
u_int __ahdecl(*ah_getCTSTimeout)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_setDecompMask)(struct ath_hal*, u_int16_t, int);
void __ahdecl(*ah_setCoverageClass)(struct ath_hal*, u_int8_t, int);
/* Key Cache Functions */
u_int32_t __ahdecl(*ah_getKeyCacheSize)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_resetKeyCacheEntry)(struct ath_hal*, u_int16_t);
HAL_BOOL __ahdecl(*ah_isKeyCacheEntryValid)(struct ath_hal *,
u_int16_t);
HAL_BOOL __ahdecl(*ah_setKeyCacheEntry)(struct ath_hal*,
u_int16_t, const HAL_KEYVAL *,
const u_int8_t *, int);
HAL_BOOL __ahdecl(*ah_setKeyCacheEntryMac)(struct ath_hal*,
u_int16_t, const u_int8_t *);
/* Power Management Functions */
HAL_BOOL __ahdecl(*ah_setPowerMode)(struct ath_hal*,
HAL_POWER_MODE mode, int setChip);
HAL_POWER_MODE __ahdecl(*ah_getPowerMode)(struct ath_hal*);
int16_t __ahdecl(*ah_getChanNoise)(struct ath_hal *, HAL_CHANNEL *);
/* Beacon Management Functions */
void __ahdecl(*ah_setBeaconTimers)(struct ath_hal*,
const HAL_BEACON_TIMERS *);
/* NB: deprecated, use ah_setBeaconTimers instead */
void __ahdecl(*ah_beaconInit)(struct ath_hal *,
u_int32_t nexttbtt, u_int32_t intval);
void __ahdecl(*ah_setStationBeaconTimers)(struct ath_hal*,
const HAL_BEACON_STATE *);
void __ahdecl(*ah_resetStationBeaconTimers)(struct ath_hal*);
/* Interrupt functions */
HAL_BOOL __ahdecl(*ah_isInterruptPending)(struct ath_hal*);
HAL_BOOL __ahdecl(*ah_getPendingInterrupts)(struct ath_hal*, HAL_INT*);
HAL_INT __ahdecl(*ah_getInterrupts)(struct ath_hal*);
HAL_INT __ahdecl(*ah_setInterrupts)(struct ath_hal*, HAL_INT);
};
/*
* Check the PCI vendor ID and device ID against Atheros' values
* and return a printable description for any Atheros hardware.
* AH_NULL is returned if the ID's do not describe Atheros hardware.
*/
extern const char *__ahdecl ath_hal_probe(u_int16_t vendorid, u_int16_t devid);
/*
* Attach the HAL for use with the specified device. The device is
* defined by the PCI device ID. The caller provides an opaque pointer
* to an upper-layer data structure (HAL_SOFTC) that is stored in the
* HAL state block for later use. Hardware register accesses are done
* using the specified bus tag and handle. On successful return a
* reference to a state block is returned that must be supplied in all
* subsequent HAL calls. Storage associated with this reference is
* dynamically allocated and must be freed by calling the ah_detach
* method when the client is done. If the attach operation fails a
* null (AH_NULL) reference will be returned and a status code will
* be returned if the status parameter is non-zero.
*/
extern struct ath_hal * __ahdecl ath_hal_attach(u_int16_t devid, HAL_SOFTC,
HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS* status);
/*
* Set the Vendor ID for Vendor SKU's which can modify the
* channel properties returned by ath_hal_init_channels.
*/
extern HAL_BOOL __ahdecl ath_hal_setvendor(struct ath_hal *, u_int32_t );
/*
* Return a list of channels available for use with the hardware.
* The list is based on what the hardware is capable of, the specified
* country code, the modeSelect mask, and whether or not outdoor
* channels are to be permitted.
*
* The channel list is returned in the supplied array. maxchans
* defines the maximum size of this array. nchans contains the actual
* number of channels returned. If a problem occurred or there were
* no channels that met the criteria then AH_FALSE is returned.
*/
extern HAL_BOOL __ahdecl ath_hal_init_channels(struct ath_hal *,
HAL_CHANNEL *chans, u_int maxchans, u_int *nchans,
u_int8_t *regclassids, u_int maxregids, u_int *nregids,
HAL_CTRY_CODE cc, u_int modeSelect,
HAL_BOOL enableOutdoor, HAL_BOOL enableExtendedChannels);
/*
* Calibrate noise floor data following a channel scan or similar.
* This must be called prior retrieving noise floor data.
*/
extern void __ahdecl ath_hal_process_noisefloor(struct ath_hal *ah);
/*
* Return bit mask of wireless modes supported by the hardware.
*/
extern u_int __ahdecl ath_hal_getwirelessmodes(struct ath_hal*, HAL_CTRY_CODE);
/*
* Calculate the transmit duration of a frame.
*/
extern u_int16_t __ahdecl ath_hal_computetxtime(struct ath_hal *,
const HAL_RATE_TABLE *rates, u_int32_t frameLen,
u_int16_t rateix, HAL_BOOL shortPreamble);
/*
* Return if device is public safety.
*/
extern HAL_BOOL __ahdecl ath_hal_ispublicsafetysku(struct ath_hal *);
/*
* Return if device is operating in 900 MHz band.
*/
extern HAL_BOOL ath_hal_isgsmsku(struct ath_hal *);
/*
* Convert between IEEE channel number and channel frequency
* using the specified channel flags; e.g. CHANNEL_2GHZ.
*/
extern int __ahdecl ath_hal_mhz2ieee(struct ath_hal *, u_int mhz, u_int flags);
/*
* Return a version string for the HAL release.
*/
extern char ath_hal_version[];
/*
* Return a NULL-terminated array of build/configuration options.
*/
extern const char* ath_hal_buildopts[];
#endif /* _ATH_AH_H_ */

238
hal/ah_desc.h Normal file
View File

@ -0,0 +1,238 @@
/*-
* Copyright (c) 2002-2006 Sam Leffler, Errno Consulting, Atheros
* Communications, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the following conditions are met:
* 1. The materials contained herein are unmodified and are used
* unmodified.
* 2. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following NO
* ''WARRANTY'' disclaimer below (''Disclaimer''), without
* modification.
* 3. Redistributions in binary form must reproduce at minimum a
* disclaimer similar to the Disclaimer below and any redistribution
* must be conditioned upon including a substantially similar
* Disclaimer requirement for further binary redistribution.
* 4. Neither the names of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote
* product derived from this software without specific prior written
* permission.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
* FOR 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 DAMAGES.
*
* $Id$
*/
#ifndef _DEV_ATH_DESC_H
#define _DEV_ATH_DESC_H
#include "opt_ah.h" /* NB: required for AH_SUPPORT_AR5416 */
/*
* Transmit descriptor status. This structure is filled
* in only after the tx descriptor process method finds a
* ``done'' descriptor; at which point it returns something
* other than HAL_EINPROGRESS.
*
* Note that ts_antenna may not be valid for all h/w. It
* should be used only if non-zero.
*/
struct ath_tx_status {
u_int16_t ts_seqnum; /* h/w assigned sequence number */
u_int16_t ts_tstamp; /* h/w assigned timestamp */
u_int8_t ts_status; /* frame status, 0 => xmit ok */
u_int8_t ts_rate; /* h/w transmit rate index */
#define HAL_TXSTAT_ALTRATE 0x80 /* alternate xmit rate used */
int8_t ts_rssi; /* tx ack RSSI */
u_int8_t ts_shortretry; /* # short retries */
u_int8_t ts_longretry; /* # long retries */
u_int8_t ts_virtcol; /* virtual collision count */
u_int8_t ts_antenna; /* antenna information */
u_int8_t ts_finaltsi; /* final transmit series index */
#ifdef AH_SUPPORT_AR5416
/* 802.11n status */
u_int8_t ts_flags; /* misc flags */
int8_t ts_rssi_ctl[3]; /* tx ack RSSI [ctl, chain 0-2] */
int8_t ts_rssi_ext[3]; /* tx ack RSSI [ext, chain 0-2] */
/* #define ts_rssi ts_rssi_combined */
u_int32_t ts_ba_low; /* blockack bitmap low */
u_int32_t ts_ba_high; /* blockack bitmap high */
u_int32_t ts_evm0; /* evm bytes */
u_int32_t ts_evm1;
u_int32_t ts_evm2;
#endif /* AH_SUPPORT_AR5416 */
};
/* bits found in ts_status */
#define HAL_TXERR_XRETRY 0x01 /* excessive retries */
#define HAL_TXERR_FILT 0x02 /* blocked by tx filtering */
#define HAL_TXERR_FIFO 0x04 /* fifo underrun */
#define HAL_TXERR_XTXOP 0x08 /* txop exceeded */
#define HAL_TXERR_DESC_CFG_ERR 0x10 /* Error in 20/40 desc config */
#define HAL_TXERR_DATA_UNDERRUN 0x20 /* Tx buffer underrun */
#define HAL_TXERR_DELIM_UNDERRUN 0x40 /* Tx delimiter underrun */
/* bits found in ts_flags */
#define HAL_TX_BA 0x01 /* Block Ack seen */
#define HAL_TX_AGGR 0x02 /* Aggregate */
/*
* Receive descriptor status. This structure is filled
* in only after the rx descriptor process method finds a
* ``done'' descriptor; at which point it returns something
* other than HAL_EINPROGRESS.
*
* If rx_status is zero, then the frame was received ok;
* otherwise the error information is indicated and rs_phyerr
* contains a phy error code if HAL_RXERR_PHY is set. In general
* the frame contents is undefined when an error occurred thought
* for some errors (e.g. a decryption error), it may be meaningful.
*
* Note that the receive timestamp is expanded using the TSF to
* at least 15 bits (regardless of what the h/w provides directly).
* Newer hardware supports a full 32-bits; use HAL_CAP_32TSTAMP to
* find out if the hardware is capable.
*
* rx_rssi is in units of dbm above the noise floor. This value
* is measured during the preamble and PLCP; i.e. with the initial
* 4us of detection. The noise floor is typically a consistent
* -96dBm absolute power in a 20MHz channel.
*/
struct ath_rx_status {
u_int16_t rs_datalen; /* rx frame length */
u_int8_t rs_status; /* rx status, 0 => recv ok */
u_int8_t rs_phyerr; /* phy error code */
int8_t rs_rssi; /* rx frame RSSI (combined for 11n) */
u_int8_t rs_keyix; /* key cache index */
u_int8_t rs_rate; /* h/w receive rate index */
u_int8_t rs_more; /* more descriptors follow */
u_int32_t rs_tstamp; /* h/w assigned timestamp */
u_int32_t rs_antenna; /* antenna information */
#ifdef AH_SUPPORT_AR5416
/* 802.11n status */
int8_t rs_rssi_ctl[3]; /* rx frame RSSI [ctl, chain 0-2] */
int8_t rs_rssi_ext[3]; /* rx frame RSSI [ext, chain 0-2] */
u_int8_t rs_isaggr; /* is part of the aggregate */
u_int8_t rs_moreaggr; /* more frames in aggr to follow */
u_int8_t rs_num_delims; /* number of delims in aggr */
u_int8_t rs_flags; /* misc flags */
u_int32_t rs_evm0; /* evm bytes */
u_int32_t rs_evm1;
u_int32_t rs_evm2;
#endif /* AH_SUPPORT_AR5416 */
};
/* bits found in rs_status */
#define HAL_RXERR_CRC 0x01 /* CRC error on frame */
#define HAL_RXERR_PHY 0x02 /* PHY error, rs_phyerr is valid */
#define HAL_RXERR_FIFO 0x04 /* fifo overrun */
#define HAL_RXERR_DECRYPT 0x08 /* non-Michael decrypt error */
#define HAL_RXERR_MIC 0x10 /* Michael MIC decrypt error */
/* bits found in rs_flags */
#define HAL_RX_MORE 0x01 /* more descriptors follow */
#define HAL_RX_MORE_AGGR 0x02 /* more frames in aggr */
#define HAL_RX_GI 0x04 /* full gi */
#define HAL_RX_2040 0x08 /* 40 Mhz */
#define HAL_RX_DELIM_CRC_PRE 0x10 /* crc error in delimiter pre */
#define HAL_RX_DELIM_CRC_POST 0x20 /* crc error in delim after */
#define HAL_RX_DECRYPT_BUSY 0x40 /* decrypt was too slow */
#define HAL_RX_DUP_FRAME 0x80 /* Dup frame rx'd on control channel */
enum {
HAL_PHYERR_UNDERRUN = 0, /* Transmit underrun */
HAL_PHYERR_TIMING = 1, /* Timing error */
HAL_PHYERR_PARITY = 2, /* Illegal parity */
HAL_PHYERR_RATE = 3, /* Illegal rate */
HAL_PHYERR_LENGTH = 4, /* Illegal length */
HAL_PHYERR_RADAR = 5, /* Radar detect */
HAL_PHYERR_SERVICE = 6, /* Illegal service */
HAL_PHYERR_TOR = 7, /* Transmit override receive */
/* NB: these are specific to the 5212 */
HAL_PHYERR_OFDM_TIMING = 17, /* */
HAL_PHYERR_OFDM_SIGNAL_PARITY = 18, /* */
HAL_PHYERR_OFDM_RATE_ILLEGAL = 19, /* */
HAL_PHYERR_OFDM_LENGTH_ILLEGAL = 20, /* */
HAL_PHYERR_OFDM_POWER_DROP = 21, /* */
HAL_PHYERR_OFDM_SERVICE = 22, /* */
HAL_PHYERR_OFDM_RESTART = 23, /* */
HAL_PHYERR_CCK_TIMING = 25, /* */
HAL_PHYERR_CCK_HEADER_CRC = 26, /* */
HAL_PHYERR_CCK_RATE_ILLEGAL = 27, /* */
HAL_PHYERR_CCK_SERVICE = 30, /* */
HAL_PHYERR_CCK_RESTART = 31, /* */
};
/* value found in rs_keyix to mark invalid entries */
#define HAL_RXKEYIX_INVALID ((u_int8_t) -1)
/* value used to specify no encryption key for xmit */
#define HAL_TXKEYIX_INVALID ((u_int) -1)
/* XXX rs_antenna definitions */
/*
* Definitions for the software frame/packet descriptors used by
* the Atheros HAL. This definition obscures hardware-specific
* details from the driver. Drivers are expected to fillin the
* portions of a descriptor that are not opaque then use HAL calls
* to complete the work. Status for completed frames is returned
* in a device-independent format.
*/
#ifdef AH_SUPPORT_AR5416
#define HAL_DESC_HW_SIZE 20
#else
#define HAL_DESC_HW_SIZE 4
#endif /* AH_SUPPORT_AR5416 */
struct ath_desc {
/*
* The following definitions are passed directly
* the hardware and managed by the HAL. Drivers
* should not touch those elements marked opaque.
*/
u_int32_t ds_link; /* phys address of next descriptor */
u_int32_t ds_data; /* phys address of data buffer */
u_int32_t ds_ctl0; /* opaque DMA control 0 */
u_int32_t ds_ctl1; /* opaque DMA control 1 */
u_int32_t ds_hw[HAL_DESC_HW_SIZE]; /* opaque h/w region */
};
struct ath_desc_status {
union {
struct ath_tx_status tx;/* xmit status */
struct ath_rx_status rx;/* recv status */
} ds_us;
};
#define ds_txstat ds_us.tx
#define ds_rxstat ds_us.rx
/* flags passed to tx descriptor setup methods */
#define HAL_TXDESC_CLRDMASK 0x0001 /* clear destination filter mask */
#define HAL_TXDESC_NOACK 0x0002 /* don't wait for ACK */
#define HAL_TXDESC_RTSENA 0x0004 /* enable RTS */
#define HAL_TXDESC_CTSENA 0x0008 /* enable CTS */
#define HAL_TXDESC_INTREQ 0x0010 /* enable per-descriptor interrupt */
#define HAL_TXDESC_VEOL 0x0020 /* mark virtual EOL */
/* NB: this only affects frame, not any RTS/CTS */
#define HAL_TXDESC_DURENA 0x0040 /* enable h/w write of duration field */
#define HAL_TXDESC_EXT_ONLY 0x0080 /* send on ext channel only (11n) */
#define HAL_TXDESC_EXT_AND_CTL 0x0100 /* send on ext + ctl channels (11n) */
#define HAL_TXDESC_VMF 0x0200 /* virtual more frag */
/* flags passed to rx descriptor setup methods */
#define HAL_RXDESC_INTREQ 0x0020 /* enable per-descriptor interrupt */
#endif /* _DEV_ATH_DESC_H */

99
hal/ah_devid.h Normal file
View File

@ -0,0 +1,99 @@
/*-
* Copyright (c) 2002-2006 Sam Leffler, Errno Consulting, Atheros
* Communications, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the following conditions are met:
* 1. The materials contained herein are unmodified and are used
* unmodified.
* 2. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following NO
* ''WARRANTY'' disclaimer below (''Disclaimer''), without
* modification.
* 3. Redistributions in binary form must reproduce at minimum a
* disclaimer similar to the Disclaimer below and any redistribution
* must be conditioned upon including a substantially similar
* Disclaimer requirement for further binary redistribution.
* 4. Neither the names of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote
* product derived from this software without specific prior written
* permission.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
* FOR 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 DAMAGES.
*
* $Id$
*/
#ifndef _DEV_ATH_DEVID_H_
#define _DEV_ATH_DEVID_H_
#define ATHEROS_VENDOR_ID 0x168c /* Atheros PCI vendor ID */
/*
* NB: all Atheros-based devices should have a PCI vendor ID
* of 0x168c, but some vendors, in their infinite wisdom
* do not follow this so we must handle them specially.
*/
#define ATHEROS_3COM_VENDOR_ID 0xa727 /* 3Com 3CRPAG175 vendor ID */
#define ATHEROS_3COM2_VENDOR_ID 0x10b7 /* 3Com 3CRDAG675 vendor ID */
/* AR5210 (for reference) */
#define AR5210_DEFAULT 0x1107 /* No eeprom HW default */
#define AR5210_PROD 0x0007 /* Final device ID */
#define AR5210_AP 0x0207 /* Early AP11s */
/* AR5211 */
#define AR5211_DEFAULT 0x1112 /* No eeprom HW default */
#define AR5311_DEVID 0x0011 /* Final ar5311 devid */
#define AR5211_DEVID 0x0012 /* Final ar5211 devid */
#define AR5211_LEGACY 0xff12 /* Original emulation board */
#define AR5211_FPGA11B 0xf11b /* 11b emulation board */
/* AR5212 */
#define AR5212_DEFAULT 0x1113 /* No eeprom HW default */
#define AR5212_DEVID 0x0013 /* Final ar5212 devid */
#define AR5212_FPGA 0xf013 /* Emulation board */
#define AR5212_DEVID_IBM 0x1014 /* IBM minipci ID */
#define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
#define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
#define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
#define AR5212_AR2315_REV6 0x0086 /* AR2315 WMAC (AP51-Light) */
#define AR5212_AR2315_REV7 0x0087 /* AR2315 WMAC (AP51-Full) */
#define AR5212_AR2317_REV1 0x0091 /* AR2317 WMAC (AP61) */
/* AR5212 compatible devid's also attach to 5212 */
#define AR5212_DEVID_0014 0x0014
#define AR5212_DEVID_0015 0x0015
#define AR5212_DEVID_0016 0x0016
#define AR5212_DEVID_0017 0x0017
#define AR5212_DEVID_0018 0x0018
#define AR5212_DEVID_0019 0x0019
#define AR5212_AR2413 0x001a /* AR2413 aka Griffin-lite */
#define AR5212_AR5413 0x001b /* Eagle */
#define AR5212_AR5424 0x001c /* Condor (PCI express) */
#define AR5212_DEVID_FF19 0xff19 /* XXX PCI express */
/* AR5213 */
#define AR5213_SREV_1_0 0x0055
#define AR5213_SREV_REG 0x4020
/* AR5416 */
#define AR5416_DEVID_EMU_PCI 0xff1d /* PCI Owl Emulation*/
#define AR5416_DEVID_EMU_PCIE 0xff1c /* PCIe Owl Emulation*/
#define AR5416_DEVID 0x0023 /* PCI (MB/CB) */
#define AR5418_DEVID 0x0024 /* PCI Express (XB) */
#define AR_SUBVENDOR_ID_NOG 0x0e11 /* No 11G subvendor ID */
#define AR_SUBVENDOR_ID_NEW_A 0x7065 /* Update device to new RD */
#endif /* _DEV_ATH_DEVID_H */

110
hal/ah_soc.h Normal file
View File

@ -0,0 +1,110 @@
/*-
* Copyright (c) 2006 Sam Leffler, Errno Consulting, Atheros
* Communications, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the following conditions are met:
* 1. The materials contained herein are unmodified and are used
* unmodified.
* 2. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following NO
* ''WARRANTY'' disclaimer below (''Disclaimer''), without
* modification.
* 3. Redistributions in binary form must reproduce at minimum a
* disclaimer similar to the Disclaimer below and any redistribution
* must be conditioned upon including a substantially similar
* Disclaimer requirement for further binary redistribution.
* 4. Neither the names of the above-listed copyright holders nor the
* names of any contributors may be used to endorse or promote
* product derived from this software without specific prior written
* permission.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
* FOR 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 DAMAGES.
*
* $Id: //depot/sw/branches/sam_hal/ah_soc.h#3 $
*/
#ifndef _ATH_AH_SOC_H_
#define _ATH_AH_SOC_H_
/*
* Atheros System on Chip (SoC) public definitions.
*/
/*
* This is board-specific data that is stored in a "known"
* location in flash. To find the start of this data search
* back from the (aliased) end of flash by 0x1000 bytes at a
* time until you find the string "5311", which marks the
* start of Board Configuration. Typically one gives up if
* more than 500KB is searched.
*/
struct ar531x_boarddata {
u_int32_t magic; /* board data is valid */
#define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
u_int16_t cksum; /* checksum (starting with BD_REV 2) */
u_int16_t rev; /* revision of this struct */
#define BD_REV 4
char boardName[64]; /* Name of board */
u_int16_t major; /* Board major number */
u_int16_t minor; /* Board minor number */
u_int32_t config; /* Board configuration */
#define BD_ENET0 0x00000001 /* ENET0 is stuffed */
#define BD_ENET1 0x00000002 /* ENET1 is stuffed */
#define BD_UART1 0x00000004 /* UART1 is stuffed */
#define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
#define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
#define BD_SYSLED 0x00000020 /* System LED stuffed */
#define BD_EXTUARTCLK 0x00000040 /* External UART clock */
#define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
#define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
#define BD_WLAN0 0x00000200 /* Enable WLAN0 */
#define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
#define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
#define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
#define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
#define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
#define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
#define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
#define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
u_int16_t resetConfigGpio; /* Reset factory GPIO pin */
u_int16_t sysLedGpio; /* System LED GPIO pin */
u_int32_t cpuFreq; /* CPU core frequency in Hz */
u_int32_t sysFreq; /* System frequency in Hz */
u_int32_t cntFreq; /* Calculated C0_COUNT frequency */
u_int8_t wlan0Mac[6];
u_int8_t enet0Mac[6];
u_int8_t enet1Mac[6];
u_int16_t pciId; /* Pseudo PCIID for common code */
u_int16_t memCap; /* cap bank1 in MB */
/* version 3 */
u_int8_t wlan1Mac[6]; /* (ar5212) */
};
/*
* Board support data. The driver is required to locate
* and fill-in this information before passing a reference to
* this structure as the HAL_BUS_TAG parameter supplied to
* ath_hal_attach.
*/
struct ar531x_config {
const struct ar531x_boarddata *board; /* board config data */
const char *radio; /* radio config data */
int unit; /* unit number [0, 1] */
void *tag; /* bus space tag */
};
#endif /* _ATH_AH_SOC_H_ */

12542
hal/public/alpha-elf.hal.o.uu Normal file

File diff suppressed because it is too large Load Diff

76
hal/public/alpha-elf.inc Normal file
View File

@ -0,0 +1,76 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/linuxsrc/src/802_11/madwifi/hal/main/public/x86_64-elf.inc#19 $
#
#
# Compilation configuration for building big-endian Alpha w/ elf.
#
# Built with GNU cross-devel tools:
#
# PREFIX=/pub/gnu
# BINUTILS=binutils-2.14
# GCC=gcc-3.3.2
# target=alpha-elf-linux
#
# ${BINUTILS}/configure --target=$target --prefix=${PREFIX}
# ${GCC}/configure --target=$target --prefix=${PREFIX} \
# --enable-languages=c --with-gnu-as --with-gnu-ld \
# --with-newlib --with-gxx-include-dir=${PREFIX}/$target/include
#
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/alpha-elf-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
COPTS+= -DAH_BYTE_ORDER=AH_LITTLE_ENDIAN
#
# NB: this should come from inttypes.h but can't until we cleanp
# the definition of va_list on linux
#
COPTS+= -DAH_WORDSIZE=64

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

3711
hal/public/ap30.hal.o.uu Normal file

File diff suppressed because it is too large Load Diff

69
hal/public/ap30.inc Normal file
View File

@ -0,0 +1,69 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mipsisa32-be-elf.inc#1 $
#
#
# Configuration for building big-endian MIPS2 for the AP30 SoC
# using the 5.01 linux-mips.org toolchain (manually moved to
# /pub/gnu from /pub/gnu/local where rpm --prefix=/pub/gnu
# bogusly installs them).
#
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
LDOPTS= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -G 0 -EB -mno-abicalls -fno-pic -mips32 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

5
hal/public/ap30.opt_ah.h Normal file
View File

@ -0,0 +1,5 @@
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5312 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_NEED_DESC_SWAP 1

3697
hal/public/ap43.hal.o.uu Normal file

File diff suppressed because it is too large Load Diff

69
hal/public/ap43.inc Normal file
View File

@ -0,0 +1,69 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mipsisa32-be-elf.inc#1 $
#
#
# Configuration for building big-endian MIPS2 for the AP43/AP48 SoC
# using the 5.01 linux-mips.org toolchain (manually moved to
# /pub/gnu from /pub/gnu/local where rpm --prefix=/pub/gnu
# bogusly installs them).
#
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
LDOPTS= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -G 0 -EB -mno-abicalls -fno-pic -mips32 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

4
hal/public/ap43.opt_ah.h Normal file
View File

@ -0,0 +1,4 @@
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5312 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1

3456
hal/public/ap51.hal.o.uu Normal file

File diff suppressed because it is too large Load Diff

69
hal/public/ap51.inc Normal file
View File

@ -0,0 +1,69 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mipsisa32-be-elf.inc#1 $
#
#
# Configuration for building big-endian MIPS2 for the AP51 SoC
# using the 5.01 linux-mips.org toolchain (manually moved to
# /pub/gnu from /pub/gnu/local where rpm --prefix=/pub/gnu
# bogusly installs them).
#
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
LDOPTS= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -G 0 -EB -mno-abicalls -fno-pic -mips32 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

4
hal/public/ap51.opt_ah.h Normal file
View File

@ -0,0 +1,4 @@
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5312 1
#define AH_SUPPORT_2316 1
#define AH_NEED_DESC_SWAP 1

3433
hal/public/ap61.hal.o.uu Normal file

File diff suppressed because it is too large Load Diff

69
hal/public/ap61.inc Normal file
View File

@ -0,0 +1,69 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mipsisa32-be-elf.inc#1 $
#
#
# Configuration for building big-endian MIPS2 for the AP61 SoC
# using the 5.01 linux-mips.org toolchain (manually moved to
# /pub/gnu from /pub/gnu/local where rpm --prefix=/pub/gnu
# bogusly installs them).
#
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
LDOPTS= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -G 0 -EB -mno-abicalls -fno-pic -mips32 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

3
hal/public/ap61.opt_ah.h Normal file
View File

@ -0,0 +1,3 @@
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5312 1
#define AH_SUPPORT_2317 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,78 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/arm9-le-thumb-elf.inc#3 $
#
#
# Compilation configuration for building little-endian ARM9/arm-elf.
#
# Known to work on:
# Arm940T
#
# Force register read/write operations to go through a function so
# ARM users can implement a windowing scheme to access registers in
# the PCI address space.
#
AH_REGOPS_FUNC=1
#
# Built with GNU cross-devel tools:
#
# PREFIX=/pub/gnu
# BINUTILS=binutils-2.14
# GCC=gcc-3.3.2
# target=arm-elf
#
# ${BINUTILS}/configure --target=$target --prefix=${PREFIX}
# ${GCC}/configure --target=$target --prefix=${PREFIX} \
# --enable-languages=c --with-gnu-as --with-gnu-ld \
# --with-newlib --with-gxx-include-dir=${PREFIX}/$target/include
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/arm-elf-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
LDOPTS= -EL
COPTS+= -DAH_BYTE_ORDER=AH_LITTLE_ENDIAN
COPTS+= -mthumb -mlittle-endian -mcpu=arm9 \
-ffunction-sections -fdata-sections

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/armv4-be-elf.inc#4 $
#
#
# Compilation configuration for building big-endian ARMv4.
#
#
# Built with GNU cross-devel tools:
#
# PREFIX=/pub/gnu
# BINUTILS=binutils-2.14
# GCC=gcc-3.3.2
# target=arm-elf
#
# ${BINUTILS}/configure --target=$target --prefix=${PREFIX}
# ${GCC}/configure --target=$target --prefix=${PREFIX} \
# --enable-languages=c --with-gnu-as --with-gnu-ld \
# --with-newlib --with-gxx-include-dir=${PREFIX}/$target/include
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/arm-elf-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -march=armv4 -mbig-endian \
-fno-strict-aliasing -fno-common

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/armv4-le-elf.inc#4 $
#
#
# Compilation configuration for building little-endian ARMv4.
#
#
# Built with GNU cross-devel tools:
#
# PREFIX=/pub/gnu
# BINUTILS=binutils-2.14
# GCC=gcc-3.3.2
# target=arm-elf
#
# ${BINUTILS}/configure --target=$target --prefix=${PREFIX}
# ${GCC}/configure --target=$target --prefix=${PREFIX} \
# --enable-languages=c --with-gnu-as --with-gnu-ld \
# --with-newlib --with-gxx-include-dir=${PREFIX}/$target/include
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/arm-elf-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS= -EL
COPTS+= -DAH_BYTE_ORDER=AH_LITTLE_ENDIAN
COPTS+= -march=armv4 -mlittle-endian \
-fno-strict-aliasing -fno-common

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

5383
hal/public/i386-elf.hal.o.uu Normal file

File diff suppressed because it is too large Load Diff

58
hal/public/i386-elf.inc Normal file
View File

@ -0,0 +1,58 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/i386-elf.inc#1 $
#
#
# Compilation configuration for building i386-elf.
# This assumes the build platform is also i386-elf.
#
#
ifndef TOOLPREFIX
TOOLPREFIX=
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
COPTS+= -DAH_BYTE_ORDER=AH_LITTLE_ENDIAN
ifndef CONFIG_FRAME_POINTER
COPTS+= -fomit-frame-pointer
endif

View File

@ -0,0 +1,10 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mips-be-elf.inc#2 $
#
#
# Configuration for building big-endian MIPS2 using the 5.01
# linux-mips.org toolchain (manually moved to /pub/gnu from
# /pub/gnu/local where rpm --prefix=/pub/gnu bogusly installs them).
#
# Known to work on:
# AMD Au1500
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -G 0 -EB -mno-abicalls -fno-pic -mips2 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mips-le-elf.inc#2 $
#
#
# Configuration for building little-endian MIPS2 using the 5.01
# linux-mips.org toolchain (manually moved to /pub/gnu from
# /pub/gnu/local where rpm --prefix=/pub/gnu bogusly installs them).
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS= -EL
COPTS+= -DAH_BYTE_ORDER=AH_LITTLE_ENDIAN
COPTS+= -G 0 -EL -mno-abicalls -fno-pic -mips2 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mips1-be-elf.inc#2 $
#
#
# Configuration for building big-endian MIPS1 using the 5.01
# linux-mips.org toolchain (manually moved to /pub/gnu from
# /pub/gnu/local where rpm --prefix=/pub/gnu bogusly installs them).
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -G 0 -EB -mno-abicalls -fno-pic -mips1 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mips1-le-elf.inc#2 $
#
#
# Configuration for building little-endian MIPS1 using the 5.01
# linux-mips.org toolchain (manually moved to /pub/gnu from
# /pub/gnu/local where rpm --prefix=/pub/gnu bogusly installs them).
#
# http://www.linux-mips.org/toolchain.html
#
# /pub/gnu/bin/mips-linux-gcc -v
# Reading specs from /pub/gnu/bin/../lib/gcc-lib/mips-linux/2.96-mips3264-000710/specs
# gcc version 2.96-mips3264-000710
# /pub/gnu/bin/mips-linux-as -v
# GNU assembler version 2.12.90.0.7 (mips-linux) using BFD version 2.12.90.0.7 20020423
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mips-linux-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS= -EL
COPTS+= -DAH_BYTE_ORDER=AH_LITTLE_ENDIAN
COPTS+= -G 0 -EL -mno-abicalls -fno-pic -mips1 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mipsisa32-be-elf.inc#2 $
#
#
# Compilation configuration for building big-endian mipsisa32-elf.
#
#
# Built with GNU cross-devel tools:
#
# PREFIX=/pub/gnu
# BINUTILS=binutils-2.14
# GCC=gcc-3.3.2
# target=mipsisa32-elf
#
# ${BINUTILS}/configure --target=$target --prefix=${PREFIX}
# ${GCC}/configure --target=$target --prefix=${PREFIX} \
# --enable-languages=c --with-gnu-as --with-gnu-ld \
# --with-newlib --with-gxx-include-dir=${PREFIX}/$target/include
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mipsisa32-elf-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS+= -EB
COPTS+= -DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -G 0 -mno-abicalls -fno-pic -march=r4600 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls \
-isystem ${KERNELPATH}/include

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
#
# Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
# 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,
# without modification.
# 2. Redistributions in binary form must reproduce at minimum a disclaimer
# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
# redistribution must be conditioned upon including a substantially
# similar Disclaimer requirement for further binary redistribution.
# 3. Neither the names of the above-listed copyright holders nor the names
# of any contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# NO WARRANTY
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
#
# $Id: //depot/sw/branches/sam_hal/public/mipsisa32-le-elf.inc#2 $
#
#
# Compilation configuration for building little-endian mipsisa32-elf.
#
#
# Built with GNU cross-devel tools:
#
# PREFIX=/pub/gnu
# BINUTILS=binutils-2.14
# GCC=gcc-3.3.2
# target=mipsisa32-elf
#
# ${BINUTILS}/configure --target=$target --prefix=${PREFIX}
# ${GCC}/configure --target=$target --prefix=${PREFIX} \
# --enable-languages=c --with-gnu-as --with-gnu-ld \
# --with-newlib --with-gxx-include-dir=${PREFIX}/$target/include
#
ifndef TOOLPREFIX
TOOLPREFIX= /pub/gnu/bin/mipsisa32-elf-
endif
#
CC= ${TOOLPREFIX}gcc
LD= ${TOOLPREFIX}ld
STRIP= ${TOOLPREFIX}strip
OBJCOPY=${TOOLPREFIX}objcopy
NM= ${TOOLPREFIX}nm
#
# Force register read/write operations to go through a function.
#
AH_REGOPS_FUNC=1
LDOPTS= -EL
COPTS+= -DAH_BYTE_ORDER=AH_LITTLE_ENDIAN
COPTS+= -G 0 -EL -mno-abicalls -fno-pic -march=r4600 -Wa,--trap \
-fno-strict-aliasing -fno-common -fomit-frame-pointer -mlong-calls

View File

@ -0,0 +1,11 @@
#define AH_SUPPORT_AR5210 1
#define AH_SUPPORT_AR5211 1
#define AH_SUPPORT_AR5212 1
#define AH_SUPPORT_AR5416 1
#define AH_SUPPORT_5111 1
#define AH_SUPPORT_5112 1
#define AH_SUPPORT_2413 1
#define AH_SUPPORT_5413 1
#define AH_SUPPORT_2133 1
#define AH_REGOPS_FUNC 1
#define AH_ENABLE_FORCEBIAS 1

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More