Subject: Preliminary work on ath(4)
To: None <current-users@netbsd.org>
From: Bruce J.A. Nourish <bjan+current-users@bjan.net>
List: current-users
Date: 08/19/2003 20:27:41
Hey everyone,

I've done some initial work on porting FreeBSD's ath(4). Note that I
say "initial": I've never done any kernel programming before, everything
I did I learned tonight. The code is probably not of a very high quality.
I'm throwing it out here because (a) I'm exhausted and (b) I've hit a
a wall.

These are the major things I've done so far:

* Ripped out all the FreeBSD mutex and taskqueue junk from ath_softc,
  and fixed header breakage in if_athvar.h. 
* Rewritten most of if_ath_pci.c, replacing FreeBSD code with NetBSD
  equivalent, fixing header breakage, and commenting out some 
  non-essential stuff. This file now compiles.
* In if_ath.c, I have kludged around the use of FreeBSD's 2-arguament 
  KASSERT, fixed header breakage, and a few other things.
* Added it to the config/Makefile system under sys/arch/i386/ath.
* Added some needed stuff to sys/net/if_ieee80211.h.

The problem I've run into is in the difference between FreeBSD and 
NetBSD's bus_dma interfaces: these are non-trivial. For instance,
bus_dma_load_mbuf uses a callback on Free - it doesn't on Net. Also,
on Free, the creation of DMA tags and DMA maps are two separate 
functions: on Net, they are wedded together. The code in if_ath.c
is designed for the FreeBSD interface, and altering it is made more
difficult by my lack of knowlege of the underlying algorithm (scatter/
gather I/O).

Anyway, the code is here:

http://bjan.net/ath.tar.gz
http://bjan.net/files.i386.diff
http://bjan.net/if_ieee80211.h

Unpack ath.tar.gz in arch/i386, apply the patches, and add a line to
your kernel conf:

ath at pci ? dev ? function ?

I hope somebody with more experience will be able to finish the job, or
give me an idea on how to go about translating those bus_dma calls.

-- 
Bruce J.A. Nourish <bjan+JUNK@bjan.net>