Summer of Code 2023 work submission


Update Atheros Wi-Fi driver(s) for new Wi-Fi stack

Jeandre Kruger

Submitted NZST

View blog

Jump to code

Background and goals

NetBSD is an open-source operating system in the BSD family. The NetBSD Project has been working to adapt the latest FreeBSD Wi-Fi stack. This will result in various improvements in functionality. For example, NetBSD will support IEEE 802.11n, and one can use multiple virtual access points (VAPs) with the same physical Wi-Fi adapter (use cases include multiple access points, etc.). Consequently NetBSD's wireless drivers are being converted to work with the new stack, and this Google Summer of Code, I set out to do that for those for Atheros hardware. Originally I intended to convert athn(4) followed by ath(4), if time allowed.

What was done

I ended up first converting ath(4). I got Wi-Fi to begin to work on 6 June, and it was basically functional by 22 June (about three weeks before the midterm evaluation).

I began converting athn(4) on 27 June and by 8 July I had it in a working state. Later my mentor let me know of an existing patch that had been written for athn(4) by James Browning in 2022. In some ways it was similar; in other ways better, so I started over based on that patch (getting it to a point were it compiled and worked didn't take very long, using my existing conversion for reference).

From then I made some other fixes and changes to both ath(4) and athn(4) (e.g. rate adaption). The blog has more details on what I did, and there are emails between myself and Martin and others on NetBSD's tech-net mailing list.

On 11 August my latter patch for athn(4) based on James Browning's was merged into the wifi topic of NetBSD's Mercurial repository (but not ath yet – athn is the preferred driver for the chipsets it supports).

Initially, I didn't have any plan of converting athn(4) for USB (in addition to PCI and CardBus) since I had no hardware. But since there was still plenty of time, I did end up trying to do this, in spite of not yet being able to test it, and I have ordered an Atheros USB dongle which will arrive in a month or two.

What to do from here

When that arrives I will know if what I've done for USB works, and then I plan on getting it to work if it doesn't (which should not take long). Then the best approach for converting athn(4) at USB (with or without usbwifi) can be evaluated (which is the intention).

Since ath(4) is working, I hope to likely have the code merged into the wifi topic of NetBSD's Mercurial repository soon (after making any changes in response to feedback I receive from Martin). In the case of ath(4) there is one kludge (a constant was defined both in the Atheros HAL and the new Wi-Fi stack, so I added an #ifndef to the former) that should probably still be dealt with.

After this I expect to help convert more of the remaining Wi-Fi drivers; Martin might be able to send me more USB adapters.


GitHub repository

All code is on the GitHub repository here. It has the NetBSD source tree (from the wifi topic), with my changes (not a clone of the NetBSD mercurial repository with all its history).

These branches matter:

main Conversion of ath(4)
athn Old conversion of athn(4)
athn2 Conversion working from James Browning's patch (now the same as main)
athn-usb athn(4) USB (untested as of now, first 2 compile)

Some of the most important files (to get a better idea, look at the commit history or patches; all the following are in sys/dev/ic):

ath(4) athvar.h ath.c
athn(4) athnvar.h athn.c arn5008.c arn9003.c


ath(4) conversion Patch
athn(4) conversion Diff against code w/ James Browning's patch
Complete patch against unconverted driver (same code as above)
Patch for USB w/o usbwifi (against converted driver; untested)
Patch for USB w/ usbwifi (against converted driver; untested)