Make Atheros drivers ignore regulatory domain set in EEPROM

The latest version of this project (at the time of writing, Linux kernel 4.8.6) is now in my GitHub repository. The following are old information.

Why?

Because I want to create a wireless AP in the 5GHz band using a consumer wireless card (as opposed to a card specifically marketed for AP use).

Specifically, I have a half-height mini PCIe wireless card using AR9462 chipset, and I would like to use hostapd with it to create an 802.11n AP in the 5GHz band. However, the card is set to a "world" regulatory domain in EEPROM, therefore all channels in the 5GHz band have "No-IR" flag set, so they cannot be used in master mode unless the driver see another AP already broadcasting on that channel.

[    9.040245] ath: EEPROM regdomain: 0x6c
[    9.040249] ath: EEPROM indicates we should expect a direct regpair map
[    9.040254] ath: Country alpha2 being used: 00
[    9.040257] ath: Regpair used: 0x6c

http://wireless.kernel.org/en/users/Drivers/ath#EEPROM_world_regulatory_domain

http://wireless.kernel.org/en/developers/Regulatory/processing_rules

Setting the regulatory domain manually with the usual tools (iw reg set US, etc) can only impose more limitations, not lift them.

I would rather not brick my wireless card by messing up the EEPROM, so let's hack the driver instead.

How?

Thankfully, the good fellows over at OpenWRT has solved the problem already. Consult the patches on their mac80211 package:

https://dev.openwrt.org/browser/trunk/package/kernel/mac80211/patches

Quite a few among the 400- patches deal with regulatory domains. For my purpose I need these two patches: 402-ath_regd_optional.patch and 404-regd_no_assoc_hints.patch. The first one ignores regdomain set in EEPROM, and the second one disables "picking up regulatory domains" from other APs. (These filenames may change anytime due to OpenWRT development.)

I'm not writing a step-by-step guide here. If you're trying to do something similar, the rough procedure is this: grab the kernel source for your distribution, adapt the above patches to your source, compile, use the new kernel, profit.

If you use Arch Linux like me, then the files below may help you.

First grab the kernel source according to this: https://wiki.archlinux.org/index.php/Kernels/Compilation/Arch_Build_System

Then, edit PKGBUILD to patch the source. PKGBUILD.patch contains my modifications to PKGBUILD for kernel version 3.17.6; it probably won't apply to any other version.

1000-ath-Ignore-regdomain-in-eeprom.patch is the actual changes to the kernel source.

Warning!

By disabling these regulatory domain safeguards, you're taking regulatory compliance into your own hands. Try not to break the law!