2014-05-24 12:34:47

by John Walker

[permalink] [raw]
Subject: max_erip/tx_power not being set correctly

Hi Wireless Development

I hope you can help.A bug seems to have been introduced in 3.10.34ish
(3.10.32 is ok) linux kernel where a statically compiled regulator
db.txt file does not set max_erip /tx_power correctly.

It was first noticed that the power output of a RaspberyPi hostapd AP
was only outputting -55dBm, while previously it was at -30dbm. This
was measured with a phone app, wifi analyzer at 1 m distance.

Any post 3.10.33 & late 3.12 kernels show the following when cfg80211
is loaded. One can see that the max_erip is not set:

cfg80211: Calling CRDA to update world regulatory domain
cfg80211: World regulatory domain updated:
cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
cfg80211: (2402000 KHz - 2472000 KHz @ 0 KHz), (2000 mBi, 0 mBm)
cfg80211: (2457000 KHz - 2482000 KHz @ 0 KHz), (2000 mBi, 0 mBm)
cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (2000 mBi, 0 mBm)
cfg80211: (5170000 KHz - 5250000 KHz @ 160000 KHz), (2000 mBi, 0 mBm)
cfg80211: (5250000 KHz - 5330000 KHz @ 160000 KHz), (2000 mBi, 0 mBm)
cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz), (2000 mBi, 0 mBm)
cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (2000 mBi, 0 mBm)
cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm)
cfg80211: Calling CRDA for country: GB
cfg80211: Regulatory domain changed to country: GB
cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
cfg80211: (2402000 KHz - 2482000 KHz @ 40000 KHz), (2000 mBi, 0 mBm)
cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz), (2000 mBi, 0 mBm)
cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz), (2000 mBi, 0 mBm)
cfg80211: (5490000 KHz - 5710000 KHz @ 80000 KHz), (2700 mBi, 0 mBm)
cfg80211: (57240000 KHz - 65880000 KHz @ 2160000 KHz), (4000 mBi, 0 mBm)

iw list shows:
[snip]
Frequencies:
* 2412 MHz [1] (0.0 dBm)
* 2417 MHz [2] (0.0 dBm)
* 2422 MHz [3] (0.0 dBm)
* 2427 MHz [4] (0.0 dBm)
* 2432 MHz [5] (0.0 dBm)
* 2437 MHz [6] (0.0 dBm)
* 2442 MHz [7] (0.0 dBm)
* 2447 MHz [8] (0.0 dBm)
* 2452 MHz [9] (0.0 dBm)
* 2457 MHz [10] (0.0 dBm)
* 2462 MHz [11] (0.0 dBm)
* 2467 MHz [12] (0.0 dBm)
* 2472 MHz [13] (0.0 dBm)
* 2484 MHz [14] (disabled)

iw reg get shows:
(3.12.20)
country GB: DFS-UNSET
(2402 - 2482 @ 40), (20, 0)
(5170 - 5250 @ 80), (20, 0)
(5250 - 5330 @ 80), (20, 0)
(5490 - 5710 @ 80), (27, 0)
(57240 - 65880 @ 2160), (40, 0)

When I've returned to a 3.10.32 kernel, the tx output power is
restored to -30dBm, all the cfg80211 and iw list values are restored.
I've also tested an old db.txt file from the start of the year against
3.12.19, but it makes no difference.

iw list from 3.10.32
[snip]
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] (20.0 dBm)
* 2472 MHz [13] (20.0 dBm)
* 2484 MHz [14] (disabled)

iw reg get
country GB: DFS-UNSET
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 80), (N/A, 20)
(5250 - 5330 @ 80), (N/A, 20), DFS
(5490 - 5710 @ 80), (N/A, 27), DFS
(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR


The iw version is 3.14

I hope you can help, and many thanks

John


2014-05-25 17:55:58

by Krishna Chaitanya

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Sat, May 24, 2014 at 6:04 PM, John Walker <[email protected]> wrote:
>
> Hi Wireless Development
>
> I hope you can help.A bug seems to have been introduced in 3.10.34ish
> (3.10.32 is ok) linux kernel where a statically compiled regulator
> db.txt file does not set max_erip /tx_power correctly.
>
> It was first noticed that the power output of a RaspberyPi hostapd AP
> was only outputting -55dBm, while previously it was at -30dbm. This
> was measured with a phone app, wifi analyzer at 1 m distance.
>
> Any post 3.10.33 & late 3.12 kernels show the following when cfg80211
> is loaded. One can see that the max_erip is not set:
>
> cfg80211: Calling CRDA to update world regulatory domain
> cfg80211: World regulatory domain updated:
> cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
> cfg80211: (2402000 KHz - 2472000 KHz @ 0 KHz), (2000 mBi, 0 mBm)
> cfg80211: (2457000 KHz - 2482000 KHz @ 0 KHz), (2000 mBi, 0 mBm)
> cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (5170000 KHz - 5250000 KHz @ 160000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (5250000 KHz - 5330000 KHz @ 160000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm)
> cfg80211: Calling CRDA for country: GB
> cfg80211: Regulatory domain changed to country: GB
> cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
> cfg80211: (2402000 KHz - 2482000 KHz @ 40000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz), (2000 mBi, 0 mBm)
> cfg80211: (5490000 KHz - 5710000 KHz @ 80000 KHz), (2700 mBi, 0 mBm)
> cfg80211: (57240000 KHz - 65880000 KHz @ 2160000 KHz), (4000 mBi, 0 mBm)
>
> iw list shows:
> [snip]
> Frequencies:
> * 2412 MHz [1] (0.0 dBm)
> * 2417 MHz [2] (0.0 dBm)
> * 2422 MHz [3] (0.0 dBm)
> * 2427 MHz [4] (0.0 dBm)
> * 2432 MHz [5] (0.0 dBm)
> * 2437 MHz [6] (0.0 dBm)
> * 2442 MHz [7] (0.0 dBm)
> * 2447 MHz [8] (0.0 dBm)
> * 2452 MHz [9] (0.0 dBm)
> * 2457 MHz [10] (0.0 dBm)
> * 2462 MHz [11] (0.0 dBm)
> * 2467 MHz [12] (0.0 dBm)
> * 2472 MHz [13] (0.0 dBm)
> * 2484 MHz [14] (disabled)
>
> iw reg get shows:
> (3.12.20)
> country GB: DFS-UNSET
> (2402 - 2482 @ 40), (20, 0)
> (5170 - 5250 @ 80), (20, 0)
> (5250 - 5330 @ 80), (20, 0)
> (5490 - 5710 @ 80), (27, 0)
> (57240 - 65880 @ 2160), (40, 0)
>
> When I've returned to a 3.10.32 kernel, the tx output power is
> restored to -30dBm, all the cfg80211 and iw list values are restored.
> I've also tested an old db.txt file from the start of the year against
> 3.12.19, but it makes no difference.
>
> iw list from 3.10.32
> [snip]
> 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] (20.0 dBm)
> * 2472 MHz [13] (20.0 dBm)
> * 2484 MHz [14] (disabled)
>
> iw reg get
> country GB: DFS-UNSET
> (2402 - 2482 @ 40), (N/A, 20)
> (5170 - 5250 @ 80), (N/A, 20)
> (5250 - 5330 @ 80), (N/A, 20), DFS
> (5490 - 5710 @ 80), (N/A, 27), DFS
> (57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
>
>
> The iw version is 3.14
>
> I hope you can help, and many thanks
>


This happens when we use the latest db.txt, its format is
changed. Please use the below patch from Luis.

https://dev.openwrt.org/browser/trunk/package/kernel/mac80211/patches/005-make-genregdb.awk-skip-antenna-gain.patch?rev=40296



--
Thanks,
Regards,
Chaitanya T K.

2014-06-11 08:55:15

by Luis Chamberlain

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Tue, Jun 10, 2014 at 10:05 PM, Krishna Chaitanya
<[email protected]> wrote:
> On Wed, Jun 11, 2014 at 3:28 AM, Luis R. Rodriguez
> <[email protected]> wrote:
>> On Sun, May 25, 2014 at 10:55 AM, Krishna Chaitanya
>> <[email protected]> wrote:
>>> https://dev.openwrt.org/browser/trunk/package/kernel/mac80211/patches/005-make-genregdb.awk-skip-antenna-gain.patch?rev=40296
>>
>> This just ignores antenna gain as it was useless.
> That actually fixes the issue of setting tx power :-). In the new
> db.txt format there
> is tx power is not present, so the awk script parses the tx power as
> antenna gain.

Is this patch not upstream? Or do you mean that the db.txt format
causes an issue for 3.10 kernels which do not have this patch when the
internal regdb is used? If so that's a good corner case that I had not
considered -- the removal of the antenna gain for future releases of
db.txt obviously would have had an impact on older kernels with an awk
script expecting something different.

We need a solution for this and thanks for reporting this. Since we
have to support both for older kernels I think we will need to modify
the awk script to pick up on the differences... that's the only thing
I can think of. That or break the db.txt to not work with older
kernels, but we don't want that... Can you hack up a solution now that
I've identified the issue? Otherwise I can look at it soon.

Luis

2014-06-25 17:36:36

by Krishna Chaitanya

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Wed, Jun 25, 2014 at 10:47 PM, Luis R. Rodriguez
<[email protected]> wrote:
> On Wed, Jun 11, 2014 at 2:27 PM, Luis R. Rodriguez
> <[email protected]> wrote:
>> On Wed, Jun 11, 2014 at 6:47 AM, Krishna Chaitanya
>> <[email protected]> wrote:
>>> I plan to submit a patch for awk script which can handle both db.txt formats
>>> but could not execute it.
>>>
>>> Will try to submit a hack soon.
>>
>> OK glad to hear you will address this -- please Cc stable and specify
>> the kernels that require this too.
>
> Krishna, how's that coming along? If you don't have time I'll have to
> take a stab soon.
>
Sorry Luis, i did not even start yet. Quit busy, please go ahead.

2014-06-10 21:59:08

by Luis Chamberlain

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Sun, May 25, 2014 at 10:55 AM, Krishna Chaitanya
<[email protected]> wrote:
> https://dev.openwrt.org/browser/trunk/package/kernel/mac80211/patches/005-make-genregdb.awk-skip-antenna-gain.patch?rev=40296

This just ignores antenna gain as it was useless.

Luis

2014-06-10 21:58:39

by Luis Chamberlain

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Sat, May 24, 2014 at 5:34 AM, John Walker <[email protected]> wrote:
> I hope you can help.A bug seems to have been introduced in 3.10.34ish
> (3.10.32 is ok) linux kernel where a statically compiled regulator
> db.txt file does not set max_erip /tx_power correctly.

If using stock vanilla kernel and you noticed an issue between a
stable release, ie between 3.10.32 and 3.10.34 you should be able to
bisect. Furthermore the description of the issue you are running into
is vague. You will need to provide a bit more details with regards to
what exactly was seen before and what is new you see after. The iw
list output from both would be useful as well as the kernel logs.

Luis

2014-06-11 21:28:11

by Luis Chamberlain

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Wed, Jun 11, 2014 at 6:47 AM, Krishna Chaitanya
<[email protected]> wrote:
> I plan to submit a patch for awk script which can handle both db.txt formats
> but could not execute it.
>
> Will try to submit a hack soon.

OK glad to hear you will address this -- please Cc stable and specify
the kernels that require this too. Please also note that there is some
code on CRDA that could replace the awk script, db2rd but that just
spits out regular output right now. You will have to revert the AUTO
patches from wireless-regdb and CRDA right now though, but db2rd could
be used as base for an implementation for something that provides the
output of a general data structures just as the awk script does, that
may be more manageable than the awk script, and although the code is
under copyleft-next I'd be happy to make an exception to include code
for a C conversion tool to data structure specifically for the kernel.
Evne though C code may be better for upstream than the awk script in
the long run we do need a work around for the awk stuff for stable and
a C replacement won't fly for stable, so the best approach would be a
fix for the awk stuff for now and then we can consider a replacement.

Felix mentioned some changes to CRDA / wireless-regdb which could help
with binary compatibility on the db, perhaps this needs to be
coordinated with a replacement for the awk script to avoid issues like
this in the future.

Luis

2014-06-11 05:05:26

by Krishna Chaitanya

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Wed, Jun 11, 2014 at 3:28 AM, Luis R. Rodriguez
<[email protected]> wrote:
> On Sun, May 25, 2014 at 10:55 AM, Krishna Chaitanya
> <[email protected]> wrote:
>> https://dev.openwrt.org/browser/trunk/package/kernel/mac80211/patches/005-make-genregdb.awk-skip-antenna-gain.patch?rev=40296
>
> This just ignores antenna gain as it was useless.
That actually fixes the issue of setting tx power :-). In the new
db.txt format there
is tx power is not present, so the awk script parses the tx power as
antenna gain.

2014-06-11 13:47:42

by Krishna Chaitanya

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Wed, Jun 11, 2014 at 2:24 PM, Luis R. Rodriguez
<[email protected]> wrote:
> On Tue, Jun 10, 2014 at 10:05 PM, Krishna Chaitanya
> <[email protected]> wrote:
>> On Wed, Jun 11, 2014 at 3:28 AM, Luis R. Rodriguez
>> <[email protected]> wrote:
>>> On Sun, May 25, 2014 at 10:55 AM, Krishna Chaitanya
>>> <[email protected]> wrote:
>>>> https://dev.openwrt.org/browser/trunk/package/kernel/mac80211/patches/005-make-genregdb.awk-skip-antenna-gain.patch?rev=40296
>>>
>>> This just ignores antenna gain as it was useless.
>> That actually fixes the issue of setting tx power :-). In the new
>> db.txt format there
>> is tx power is not present, so the awk script parses the tx power as
>> antenna gain.
>
> Is this patch not upstream? Or do you mean that the db.txt format
> causes an issue for 3.10 kernels which do not have this patch when the
> internal regdb is used? If so that's a good corner case that I had not
> considered -- the removal of the antenna gain for future releases of
> db.txt obviously would have had an impact on older kernels with an awk
> script expecting something different.
>
Right, this patch is not upstream. Current kernels do not work with
new db.txt format when itnernal regdb is enabled.

> We need a solution for this and thanks for reporting this. Since we
> have to support both for older kernels I think we will need to modify
> the awk script to pick up on the differences... that's the only thing
> I can think of. That or break the db.txt to not work with older
> kernels, but we don't want that... Can you hack up a solution now that
> I've identified the issue? Otherwise I can look at it soon.

I plan to submit a patch for awk script which can handle both db.txt formats
but could not execute it.

Will try to submit a hack soon.

2014-06-11 11:05:16

by Jonas Gorski

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Wed, Jun 11, 2014 at 10:54 AM, Luis R. Rodriguez
<[email protected]> wrote:
> On Tue, Jun 10, 2014 at 10:05 PM, Krishna Chaitanya
> <[email protected]> wrote:
>> On Wed, Jun 11, 2014 at 3:28 AM, Luis R. Rodriguez
>> <[email protected]> wrote:
>>> On Sun, May 25, 2014 at 10:55 AM, Krishna Chaitanya
>>> <[email protected]> wrote:
>>>> https://dev.openwrt.org/browser/trunk/package/kernel/mac80211/patches/005-make-genregdb.awk-skip-antenna-gain.patch?rev=40296
>>>
>>> This just ignores antenna gain as it was useless.
>> That actually fixes the issue of setting tx power :-). In the new
>> db.txt format there
>> is tx power is not present, so the awk script parses the tx power as
>> antenna gain.
>
> Is this patch not upstream?

This patch is not upstream. You only posted it as an RFC, not a PATCH,
so it was likely never applied for that reason. Note that this patch
is from you ;-)

Or do you mean that the db.txt format
> causes an issue for 3.10 kernels which do not have this patch when the
> internal regdb is used? If so that's a good corner case that I had not
> considered -- the removal of the antenna gain for future releases of
> db.txt obviously would have had an impact on older kernels with an awk
> script expecting something different.

AFAICT, this has been an issue for any kernel (even current linus'
master) using the internal regdb since antenna gain was dropped from
regdb.txt.


Regards
Jonas

2014-06-25 17:17:52

by Luis Chamberlain

[permalink] [raw]
Subject: Re: max_erip/tx_power not being set correctly

On Wed, Jun 11, 2014 at 2:27 PM, Luis R. Rodriguez
<[email protected]> wrote:
> On Wed, Jun 11, 2014 at 6:47 AM, Krishna Chaitanya
> <[email protected]> wrote:
>> I plan to submit a patch for awk script which can handle both db.txt formats
>> but could not execute it.
>>
>> Will try to submit a hack soon.
>
> OK glad to hear you will address this -- please Cc stable and specify
> the kernels that require this too.

Krishna, how's that coming along? If you don't have time I'll have to
take a stab soon.

> Please also note that there is some
> code on CRDA that could replace the awk script, db2rd but that just
> spits out regular output right now. You will have to revert the AUTO
> patches from wireless-regdb and CRDA right now though, but db2rd could
> be used as base for an implementation for something that provides the
> output of a general data structures just as the awk script does, that
> may be more manageable than the awk script, and although the code is
> under copyleft-next I'd be happy to make an exception to include code
> for a C conversion tool to data structure specifically for the kernel.
> Evne though C code may be better for upstream than the awk script in
> the long run we do need a work around for the awk stuff for stable and
> a C replacement won't fly for stable, so the best approach would be a
> fix for the awk stuff for now and then we can consider a replacement.
>
> Felix mentioned some changes to CRDA / wireless-regdb which could help
> with binary compatibility on the db, perhaps this needs to be
> coordinated with a replacement for the awk script to avoid issues like
> this in the future.
>
> Luis