A few days ago I installed kernel 2.6.29 from backports.org on my new Debian Lenny machine in order to get Intel 5100 AGN wireless driver support.
While trying to convince the driver that I am not, in fact, an American, I discovered that Linux’s wireless support is moving toward a new framework for handling the regulatory domain information. Drivers use this to enable the correct (and legal) channels, RF power limits and other behavior for the country you’re in…
The first thing I tried was to create a file (/etc/modprobe.d/cfg80211) containing the string:
options cfg80211 ieee80211_regdom=ZA
This was a step in the right direction, but it turns out that only US, EU and JP regulatory information is hard-coded into the kernel. If one of those won’t work for you, you need the new Wireless Central Regulatory Domain Agent user-space utility. This little program is called by the cfg80211 module through udev and provides the missing regulatory info. So I grabbed and installed the wireless-crda package from Ubuntu, and put the following in /etc/udev/rules.d/regulatory.rules:
KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/sbin/crda"
Reloading all the wireless-related modules I observed CRDA doing it’s magic:
charlie kernel: [ 4801.596578] cfg80211: Using static regulatory domain info
charlie kernel: [ 4801.596581] cfg80211: Regulatory domain: US
charlie kernel: [ 4801.596583] (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
charlie kernel: [ 4801.596585] (2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2700 mBm)
charlie kernel: [ 4801.596587] (5170000 KHz - 5190000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
charlie kernel: [ 4801.596589] (5190000 KHz - 5210000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
charlie kernel: [ 4801.596591] (5210000 KHz - 5230000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
charlie kernel: [ 4801.596593] (5230000 KHz - 5330000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
charlie kernel: [ 4801.596595] (5735000 KHz - 5835000 KHz @ 40000 KHz), (600 mBi, 3000 mBm)
charlie kernel: [ 4801.596597] cfg80211: Calling CRDA for country: ZA
charlie kernel: [ 4801.617628] iwlagn: Intel(R) Wireless WiFi Link AGN driver for Linux, 1.3.27ks
charlie kernel: [ 4801.617631] iwlagn: Copyright(c) 2003-2008 Intel Corporation
charlie kernel: [ 4801.617706] iwlagn 0000:03:00.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
charlie kernel: [ 4801.617734] iwlagn 0000:03:00.0: setting latency timer to 64
charlie kernel: [ 4801.617908] iwlagn: Detected Intel Wireless WiFi Link 5100AGN REV=0x54
charlie kernel: [ 4801.639541] iwlagn: Tunable channels: 13 802.11bg, 24 802.11a channels
charlie kernel: [ 4801.640028] wmaster0 (iwlagn): not using net_device_ops yet
charlie kernel: [ 4801.640575] phy0: Selected rate control algorithm 'iwl-agn-rs'
charlie kernel: [ 4801.640591] wlan0 (iwlagn): not using net_device_ops yet
charlie kernel: [ 4801.644881] cfg80211: Regulatory domain changed to country: ZA
charlie kernel: [ 4801.644883] (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
charlie kernel: [ 4801.644885] (2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm)
charlie kernel: [ 4801.644888] (5170000 KHz - 5250000 KHz @ 20000 KHz), (300 mBi, 1700 mBm)
charlie kernel: [ 4801.644890] (5250000 KHz - 5330000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
charlie kernel: [ 4801.644892] (5490000 KHz - 5710000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
charlie kernel: [ 4801.644894] (5735000 KHz - 5835000 KHz @ 20000 KHz), (300 mBi, 3000 mBm)
Notice that cfg80211 loads with the US regulatiory domain, then calls CRDA, and while it’s waiting, iwlagn initializes the wireless device. Finally, cfg80211 switches to ZA, using the info obtained from user-space.
Unfortunately at this point iw dev wlan0 info showed the card was still using US channels. I discovered through experimentation that ZA channels were enabled if cfg80211 had enough time to switch from US to ZA before the iwlagn driver is loaded.
I filed a bug report and Luis Rodriguez promptly responded with a patch deleting 3 lines from net/wireless/reg.c, fixing the problem.
Update:
The patch seems to have been merged into kernel 2.6.30. I’ve upgraded to 2.6.30 from backports.org and now the CRDA magic Just Works (TM).

Post a Comment