MADWIFI: Multimode Atheros Driver for WiFi on Linux
================================================================

* Copyright (c) 2002-2005 Sam Leffler.  All rights reserved.


Requirements
============

o sharutils (especially uudecode tool)
o kernel sources of running kernel
o Wireless Extensions support (14 or later, 17 preferred)
o Sysctl support
o Crypto API support (AES support is used if present, otherwise the
  AES-CCMP cipher module falls back to a private implementation)
o gcc in same version as the compiled kernel, or you get problems 
  during module load (Invalid module format)
  
Kernels 2.4.2x - 2.6.10 should work without problems. Other
kernel versions may require modifications; e.g. for crypto support 
and/or updated wireless extensions.


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 and configuration must be
available as well as the build scripts.  If you built your kernel
from source then this will be present.  Otherwise you may need to
install some materials from your distribution.

Most people can just type:

trouble% make

at the top level to build all the modules for the system where you
are building.  If you installed your kernel sources as the super-user
then this may fail because of permission problems.  In that case
you either need to change the permission/ownership of the kernel
sources or build the driver as the super-user.
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 this does not work or if you want to cross-compile
the code for a different system then you will need to explicitly
specify the location where the kernel sources are located, e.g.:

trouble% make KERNELPATH=/usr/src/linux-2.6.3

Note that you can also specify this path by setting an environment
variable; e.g.

trouble% KERNELPATH=/usr/src/linux-2.6.3
trouble% make

You can also just specify a kernel version using the KERNELRELEASE
variable which is required for distributions which install kernels
with names like '2.6.10-4-686' but the kernel-source is only called
2.6.10 for example. Without specifying KERNELRELEASE you will get
problems during module load time in that case. The kernel sources are 
automatically searched for in /lib/modules/$KERNELRELEASE/build.

If you want to build for a machine different of i386 you will have
to specifiy the Target. A complete example for building on a AMD 
Athlon64 (x86_64) machine could look like:

trouble% make TARGET="x86_64-elf" TOOLPREFIX="" LINUX_DIR=/usr/src/linux


Madwifi currently provides three different rate control algorithms,
ONOE, AMRR and SAMPLE. SAMPLE is the most advanced one and is used
by default. In order to make madwifi use AMRR instead, you have to 
specify that via the ATH_RATE environment variable; e.g.

trouble% export ATH_RATE=ath_rate/amrr
trouble% make

Note:
Changing the rate control is only required (and recomended) for users 
which want to setup an accesspoint using madwifi in difficult 
(e.g. lossy) environments and if he knows what he is 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:

trouble% ls hal/linux/*.inc
hal/linux/Makefile.inc          hal/linux/mips1-le-elf.inc
hal/linux/arm9-le-thumb-elf.inc hal/linux/mipsisa32-be-elf.inc
hal/linux/armv4-be-elf.inc      hal/linux/mipsisa32-le-elf.inc
hal/linux/armv4-le-elf.inc      hal/linux/powerpc-be-eabi.inc
hal/linux/i386-elf.inc          hal/linux/powerpc-le-eabi.inc
hal/linux/mips-be-elf.inc       hal/linux/sh4-le-elf.inc
hal/linux/mips-le-elf.inc       hal/linux/xscale-be-elf.inc
hal/linux/mips1-be-elf.inc

A target specifies the CPU architecture, byte order, and the ABI/file
format.  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; many target platforms require that
the HAL and driver be built with the same toolchain (i.e. compiler,
assembler, and loader).  If you want to override the default toolchain
specified in the .inc file you can do that by editing the .inc file
or by specifying environment variables.

For example, the file for xscale-be-elf is:

#
# Compilation configuration for building big-endian XScale/arm-elf.
#

#
# 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=	-EB
COPTS+=	-DAH_BYTE_ORDER=AH_BIG_ENDIAN
COPTS+= -march=armv4 -mbig-endian -fno-strict-aliasing -fno-common -mapcs-32 \
	-mtune=xscale  -mshort-load-bytes -msoft-float

The first set of definitions specify the location and name of the
programs used to build the software.  The rest of the file defines
the compilation options for the target platform.  The latter should
usually not be changed because they were the options used to build
the binary HAL module, but TOOLPREFIX is unlikely to be right for
your system and you will want to change it; e.g

trouble% export TOOLPREFIX=/usr/local/bin/arm-elf-

to use programs installed in /usr/local/bin.  Note that mixing different
versions of the GNU tools may not work.  The .inc file for each target
platform specifies the exact toolchains used, including where they
were obtained (if pre-built).

The build system is designed to support cross-building without any
modification to the distribution files.  If you cannot do what you
need by setting environment variables please send patches to show
where things failed to do the right thing.


Building the software will generate numerous loadable modules:

Linux 2.6
    ath/ath_pci.ko (Atheros driver for PCI/Cardbus devices),
    ath_hal/ath_hal.ko (Atheros HAL), and
    net80211/wlan.ko (802.11 support layer)
    net80211/wlan_wep.ko (WEP cipher support)
    net80211/wlan_tkip.ko (TKIP cipher support)
    net80211/wlan_ccmp.ko (AES-CCMP cipher support)
    net80211/wlan_xauth.ko (external authenticator)
    net80211/wlan_auth.ko (802.1x authenticator)
    net80211/wlan_radius.ko (RADIUS client for 802.1x authenticator)
    net80211/wlan_acl.ko (MAC ACL support for AP operation)

    and, depending on the rate control algorithm you choose (see above), 
    one of these:

    ath_rate/onoe/ath_rate_onoe.ko (ONOE rate control)
    ath_rate/amrr/ath_rate_amrr.ko (AMRR rate control)
    ath_rate/amrr/ath_rate_sample.ko (SAMPLE rate control)
    

Linux 2.4
    ath/ath_pci.o (Atheros driver for PCI/Cardbus devices),
    ath_hal/ath_hal.o (Atheros HAL), and
    net80211/wlan.o (802.11 support layer)
    net80211/wlan_wep.o (WEP cipher support)
    net80211/wlan_tkip.o (TKIP cipher support)
    net80211/wlan_ccmp.o (AES-CCMP cipher support)
    net80211/wlan_xauth.o (external authenticator)
    net80211/wlan_auth.o (802.1x authenticator)
    net80211/wlan_radius.o (RADIUS client for 802.1x authenticator)
    net80211/wlan_acl.o (MAC ACL support for AP operation)

    and, depending on the rate control algorithm you choose (see above), 
    one of these:

    ath_rate/onoe/ath_rate_onoe.o (ONOE rate control)
    ath_rate/amrr/ath_rate_amrr.o (AMRR rate control)
    ath_rate/amrr/ath_rate_sample.o (SAMPLE rate control)


The first three files must be loaded either manually or by the
system, e.g. through the hotplug or card manager support.  The
remaining modules are loaded by the wlan module as needed.  Typically
modules are automatically loaded via dependencies, so after doing a
make install you only need to do:

    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 cards eeprom does not contain the 
correct one for your location. See http://www.unicode.org/onlinedat/countries.html
to find your code. To active German frequencies you would specify:

    modprobe ath_pci countrycode=276

To see available parameters type:

    modinfo ath_pci

