# [solved] Atheros and regulatory domain

## TheSmallOne

Hi,

I've a question which seems to be really old, but after hours of searching the net I still couldn't find a satisfiing answer.

I just bought a WiFi-card; model: 

 07:00.0 Network controller: Qualcomm Atheros AR928X Wireless Network Adapter (PCI-Express) (rev 01)

which I'd like to use here in Germany, but I have a bit of trouble with the channels.

Upon loading the drivers, I get the following log messages: 

```
cfg80211: Calling CRDA to update world regulatory domain

ath: EEPROM regdomain: 0x0

ath: EEPROM indicates default country code should be used

ath: doing EEPROM country->regdmn map search

ath: country maps to regdmn code: 0x3a

ath: Country alpha2 being used: US

ath: Regpair used: 0x3a

ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'

ieee80211 phy0: Atheros AR9280 Rev:2 mem=0xf8d00000, irq=11

cfg80211: World regulatory domain updated:

cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)

cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)

cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

cfg80211: Calling CRDA for country: US

cfg80211: Regulatory domain changed to country: US

cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)

cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm)

cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm)

cfg80211:   (5250000 KHz - 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

cfg80211:   (5490000 KHz - 5600000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

cfg80211:   (5650000 KHz - 5710000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)

cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 3000 mBm)

cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 4000 mBm)
```

Then I try to set the domain to Germany

```
# iw reg set DE

# iw reg get

country DE: DFS-UNSET

   (2400 - 2483 @ 40), (N/A, 20)

   (5150 - 5250 @ 40), (N/A, 20), NO-OUTDOOR

   (5250 - 5350 @ 40), (N/A, 20), NO-OUTDOOR, DFS

   (5470 - 5725 @ 40), (N/A, 26), DFS

   (57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
```

And get the following log messages:

```
cfg80211: Calling CRDA for country: DE

cfg80211: Regulatory domain changed to country: DE

cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)

cfg80211:   (2400000 KHz - 2483500 KHz @ 40000 KHz), (N/A, 2000 mBm)

cfg80211:   (5150000 KHz - 5250000 KHz @ 40000 KHz), (N/A, 2000 mBm)

cfg80211:   (5250000 KHz - 5350000 KHz @ 40000 KHz), (N/A, 2000 mBm)

cfg80211:   (5470000 KHz - 5725000 KHz @ 40000 KHz), (N/A, 2698 mBm)

cfg80211:   (57240000 KHz - 65880000 KHz @ 2160000 KHz), (N/A, 4000 mBm)
```

So I think the card should now be able to work according to european regulations. But when I try iw list, I get the following:

```
      Frequencies:

         * 2412 MHz [1] (20.0 dBm)

         * 2417 MHz [2] (20.0 dBm)

         * 2422 MHz [3] (20.0 dBm)

         * 2427 MHz [4] (20.0 dBm)

         * 2432 MHz [5] (20.0 dBm)

         * 2437 MHz [6] (20.0 dBm)

         * 2442 MHz [7] (20.0 dBm)

         * 2447 MHz [8] (20.0 dBm)

         * 2452 MHz [9] (20.0 dBm)

         * 2457 MHz [10] (20.0 dBm)

         * 2462 MHz [11] (20.0 dBm)

         * 2467 MHz [12] (disabled)

         * 2472 MHz [13] (disabled)

         * 2484 MHz [14] (disabled)
```

So channel 12 and 13, which should be available are still deactivated.

On my search in the net, I found a statement which was roughly the following (quote from memory): CRDA can't activate a channel that was disabled by EEPROM, you can only narrow the frequencies further.

So basically my main question is: Is this true? Is it impossible to activate channel 12+13 without tampering with the EEPROM?

And if it really is: Is there a way to flash the EEPROM with the correct county settings? It's an EEPROM, so there should be a way to change it, shouldn't it?Last edited by TheSmallOne on Sat Jan 04, 2014 10:49 am; edited 1 time in total

----------

## Fitzcarraldo

Please post the output of the following command:

```
cat /usr/src/linux/.config | grep CFG80211
```

Also, please post the udev rule you have configured to allow the kernel to communicate with userspace.

For comparison, here is how I did it on my main laptop running Gentoo ~amd64 with kernel 3.9.4-gentoo, albeit using an Intel WiFi Link 5300 controller rather than an Atheros WiFi controller: Setting the wireless regulatory domain in Linux on your laptop.

----------

## TheSmallOne

 *Fitzcarraldo wrote:*   

> Please post the output of the following command:
> 
> ```
> cat /usr/src/linux/.config | grep CFG80211
> ```
> ...

 

The kernel config is as follows:

```
CONFIG_CFG80211=m

# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set

# CONFIG_CFG80211_REG_DEBUG is not set

CONFIG_CFG80211_DEFAULT_PS=y

# CONFIG_CFG80211_INTERNAL_REGDB is not set

# CONFIG_CFG80211_WEXT is not set
```

As for the udev-rule; I didn't write a specific rule, but just use the one which was installed by gentoo when I emerged the crda package:

```
$ cat /lib/udev/rules.d/85-regulatory.rules

# Runs CRDA for kernel wireless regulatory events.

# For more information see:

# http://wireless.kernel.org/en/developers/Regulatory/CRDA

KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/sbin/crda"
```

Seeing the output of iw reg get (in the first post) it's not like the domain change fails, it's just that only the channels remain, that are allowed in both domains (the one set by CRDA and the one in the EEPROM).

----------

## Fitzcarraldo

Have you see the following post?: http://permalink.gmane.org/gmane.linux.drivers.ath9k.devel/4131

 *Quote:*   

> Due to current regulatory rules which have been clarified in certain contries (US, JP) we cannot allow simply changing the country by a user to whatever they wish. For details see:
> 
> http://wireless.kernel.org/en/developers/Regulatory/CRDA#Helping_compliance_by_allowing_to_change_regulatory_domains
> 
> We can however help compliance by letting us apply the interesection of your program's card's regulatory domain and what the user sets and that is what we support, so we can restrict the card further, but not give it new channels. This is until legislation changes.
> ...

 

Does that explain what you are experiencing?

I'll have to play around with the "iw reg  set" command on my main laptop to check if the same applies in the case of the Intel WiFi Link 5300 controller, but I had not noticed this restriction.

----------

## TheSmallOne

I'm not sure if it was exactly this post I read, but the statement was about this.

After searching the net for some more hours for a solution, I looked a bit into the kernel sources and found an ideal solution for me.

I found the file /usr/src/linux-3.10.17-gentoo/drivers/net/wireless/ath/regd.c responsible for the initial limitations of the card.

I made a change on line 569:

```
        if (reg->country_code == CTRY_DEFAULT &&

            regdmn == CTRY_DEFAULT) {

                printk(KERN_DEBUG "ath: EEPROM indicates default "

                       "country code should be used\n");

                reg->country_code = CTRY_UNITED_STATES;

        }
```

from United States to Germany:

```
reg->country_code = CTRY_GERMANY;
```

Now I'm able to use the channels 12 and 13, as wished.

----------

