Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Monday, October 8, 2012

WiFi regulatory compliance, and how to fix it

Troubleshooting and Recovery
Wireless Regulatory Issues?
Unless you are American, BOTH 2.4GHz and 5GHz will likely not be fully available on OpenWrt 10.03 Backfire (you will experience loss of channels 12, 13 and 14 if these are available where you are, as well as potentially incorrect 5GHz channel availability. Power output levels may be incorrect for your country as well).
To sum up the background for this:
  • Netgear ships the WNDR3700 with EEPROM chip stating that the router should restrict to US settings. Outside America, they ship software that ignores this chip. This is a bad thing as it means that your OpenWrt can't work properly for the next two reasons.
  • In the USA, it is illegal to ship router firmware that can (through incorrect settings) bypass radio regulations.
  • Atheros (the wireless chip maker in the WNDR3700) asks open source folks not to ship compiled builds that bypass radio restrictions, even though their hardware vendors do this. This means if you bought hardware from one of the manufacturers (and you're one of the 95% of the world's population that doesn't live in the USA) that doesn't set the value in the EEPROM correctly, you're kinda screwed if you want to use OpenWrt…
Personally, I think this is a ridiculous situation, but there seem to be issues with fixing it. You can do the job yourself as follows:
You may partially fix this by compiling a custom image with CONFIG_ATH_USER_REGD set in the Ath9k driver. This will, however, take a significant time to compile and result in a restriction to 20dBm max power output across all channels (this is apparently due to a bug according to my reading, but it's not fixed yet as far as I can tell). A much better option that will allow you to use the full legal power output in your country would be to follow the instructions here:

The wherefore and the why. And the how.

No channel 13. Wut? I found this informative mailing list post detailing what’s happening here. Basically, the kernel first loads the rules for the ‘world’ domain. On planet Earth, no countries exist that allow you to go beyond these frequencies (for domestic wifi). But many countries have additional restrictions. In Japan, you can use channel 14, in Europe you can’t. You can use 12 and 13 though, which in the US you can’t.
The kernel (well, the “ath” driver) then proceeds to look for any hints from the hardware. In my case the value burned into the hardware EEPROM is 0×0. That’s a value, which, per the Atheros specs, should map to the US. The kernel calls a userspace program crda to get the list of allowed frequencies and signal strenghts for the US.
After this has been done, you can do iw reg set FOO until you drop but you wont be able to go beyond the limits set previously.
The weird thing with radio hardware is that not only the users are subject to regulation, the sellers are too. You can’t sell non-compliant radio hardware. Now, the wifi chip manufacturers do not physically limit a chip intended for sale in the US to channels 1-11. Rather, they mass produce chips and then the equipment manufacturers are supposed to configure the chip in compliance with its target market. (As if you’d never take your equipment to Japan).
As I understand it, TP-Link messed up here.
Compare the above setup with what happens on my laptop’s Atheros chip:
ath: EEPROM regdomain: 0x65
ath: EEPROM indicates we should expect a direct regpair map
ath: Country alpha2 being used: 00
ath: Regpair used: 0x65
Looking at the Linux 2.6.35 sourcecode in drivers/net/wireless/ath/regd_common.h you’ll see that 0×65 maps to WOR5_ETSIC, which holds rules for compliance with EU regulation. Which I suppose is right since I’ve bought that laptop in the EU. But my TP-link comes out as FCC3_FCCA ­— that’s FCC-land, the US.

Fixing it

No comments: