2014-02-12 17:43:27

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH] crda: handle AUTO bw setting in db2rd

Handle AUTO bandwidth setting in db2rd.
Don't add NL80211_ATTR_FREQ_RANGE_MAX_BW attribute
in case of AUTO bw calculation.

Signed-off-by: Janusz Dziedzic <[email protected]>
---
crda.c | 3 ++-
reglib.c | 9 ++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/crda.c b/crda.c
index 0bf83a1..2fc5bce 100644
--- a/crda.c
+++ b/crda.c
@@ -127,7 +127,8 @@ static int put_reg_rule(const struct ieee80211_reg_rule *rule, struct nl_msg *ms
NLA_PUT_U32(msg, NL80211_ATTR_REG_RULE_FLAGS, rule->flags);
NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_START, freq_range->start_freq_khz);
NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_END, freq_range->end_freq_khz);
- NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_MAX_BW, freq_range->max_bandwidth_khz);
+ if (freq_range->max_bandwidth_khz)
+ NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_MAX_BW, freq_range->max_bandwidth_khz);
NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN, power_rule->max_antenna_gain);
NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_EIRP, power_rule->max_eirp);

diff --git a/reglib.c b/reglib.c
index af38fe7..bb8ce96 100644
--- a/reglib.c
+++ b/reglib.c
@@ -1116,7 +1116,7 @@ reglib_parse_rule_args_cac(char *line, struct ieee80211_reg_rule *reg_rule)
static int reglib_parse_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)
{
char line[1024];
- char *line_p;
+ char *line_p, *auto_p;
unsigned int i;
int r = 0;
struct reglib_rule_parse_list *reglib_rule_parsers;
@@ -1150,6 +1150,13 @@ static int reglib_parse_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)
return -EINVAL;
}

+ auto_p = strstr(line_p, "@ AUTO");
+ if (auto_p) {
+ /* This will be much easier instead of adding new parser! */
+ memcpy(&auto_p[0], "@ 0", 3);
+ memcpy(&auto_p[3], &auto_p[6], strlen(line_p) + 1 - (auto_p + 3 - line_p));
+ }
+
for (i = 0; i < reglib_rule_parsers->n_parsers; i++) {
r = reglib_rule_parsers->rule_parsers[i](line, reg_rule);
if (r == 0)
--
1.7.9.5



2014-02-20 07:59:18

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On Thu, 2014-02-20 at 08:57 +0100, Janusz Dziedzic wrote:

> >> Yes, seems we should send this even this is 0.
> >> Next for old kernel, all channels where BW=0 will be HT20 only.
> >
> > Is that really a good idea?
> >
> > Maybe crda should just get the logic to determine maximum bandwidth,
> > like you did in the kernel, and then we can even revert the kernel code
> > again?
> >
> Yes, this is possible to calculate this in crda (or even set this manually).

Ok. Would that help older kernels? How would we handle genregdb.awk?

johannes


2014-02-19 00:33:50

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On Wed, Feb 12, 2014 at 9:43 AM, Janusz Dziedzic
<[email protected]> wrote:
> Handle AUTO bandwidth setting in db2rd.
> Don't add NL80211_ATTR_FREQ_RANGE_MAX_BW attribute
> in case of AUTO bw calculation.
>
> Signed-off-by: Janusz Dziedzic <[email protected]>

Please elaborate more on this. Who deals with the automatic math on
the bandwidth?

Luis

2014-02-20 09:31:37

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On 20 February 2014 09:03, Janusz Dziedzic <[email protected]> wrote:
> On 20 February 2014 08:59, Johannes Berg <[email protected]> wrote:
>> On Thu, 2014-02-20 at 08:57 +0100, Janusz Dziedzic wrote:
>>
>>> >> Yes, seems we should send this even this is 0.
>>> >> Next for old kernel, all channels where BW=0 will be HT20 only.
>>> >
>>> > Is that really a good idea?
>>> >
>>> > Maybe crda should just get the logic to determine maximum bandwidth,
>>> > like you did in the kernel, and then we can even revert the kernel code
>>> > again?
>>> >
>>> Yes, this is possible to calculate this in crda (or even set this manually).
>>
>> Ok. Would that help older kernels? How would we handle genregdb.awk?
>>
> In case of older kernels we will fail (end_freq - start_freq < bw) with -EINVAL.
> So, bw=0 (cfg calculation) seems like best idea - will work with new
> and old kernels.
>
Seems cfg80211 max bandwidth calculation is best option here.

We should set BW as is in old regulatory (skip this BW=0 patches) -
will work fine with old kernels.
And in new regulatory add RULE flag NL80211_RRF_AUTO_BW, which will be
checked in newer kernels and if AUTO_BW flag we will skip (end_freq -
start_freq < bw) check and calculate maximum available bandwidth. What
you think?

BR
Janusz
-

2014-02-19 06:12:03

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

2014-02-19 1:33 GMT+01:00 Luis R. Rodriguez <[email protected]>:
> On Wed, Feb 12, 2014 at 9:43 AM, Janusz Dziedzic
> <[email protected]> wrote:
>> Handle AUTO bandwidth setting in db2rd.
>> Don't add NL80211_ATTR_FREQ_RANGE_MAX_BW attribute
>> in case of AUTO bw calculation.
>>
>> Signed-off-by: Janusz Dziedzic <[email protected]>
>
> Please elaborate more on this. Who deals with the automatic math on
> the bandwidth?
>
cfg80211,

Please check patch:
cfg80211: regulatory introduce maximum bandwidth calculation

BR
Janusz

2014-02-19 22:00:27

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On Tue, Feb 18, 2014 at 10:12 PM, Janusz Dziedzic
<[email protected]> wrote:
> 2014-02-19 1:33 GMT+01:00 Luis R. Rodriguez <[email protected]>:
>> On Wed, Feb 12, 2014 at 9:43 AM, Janusz Dziedzic
>> <[email protected]> wrote:
>>> Handle AUTO bandwidth setting in db2rd.
>>> Don't add NL80211_ATTR_FREQ_RANGE_MAX_BW attribute
>>> in case of AUTO bw calculation.
>>>
>>> Signed-off-by: Janusz Dziedzic <[email protected]>
>>
>> Please elaborate more on this. Who deals with the automatic math on
>> the bandwidth?
>>
> cfg80211,
>
> Please check patch:
> cfg80211: regulatory introduce maximum bandwidth calculation

OK, so we don't send the max bandwidth attribute now, what about
support for older kernels?

Luis

2014-02-20 08:03:09

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On 20 February 2014 08:59, Johannes Berg <[email protected]> wrote:
> On Thu, 2014-02-20 at 08:57 +0100, Janusz Dziedzic wrote:
>
>> >> Yes, seems we should send this even this is 0.
>> >> Next for old kernel, all channels where BW=0 will be HT20 only.
>> >
>> > Is that really a good idea?
>> >
>> > Maybe crda should just get the logic to determine maximum bandwidth,
>> > like you did in the kernel, and then we can even revert the kernel code
>> > again?
>> >
>> Yes, this is possible to calculate this in crda (or even set this manually).
>
> Ok. Would that help older kernels? How would we handle genregdb.awk?
>
In case of older kernels we will fail (end_freq - start_freq < bw) with -EINVAL.
So, bw=0 (cfg calculation) seems like best idea - will work with new
and old kernels.

BR
Janusz

2014-02-20 07:57:08

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On 20 February 2014 08:51, Johannes Berg <[email protected]> wrote:
> On Thu, 2014-02-20 at 08:27 +0100, Janusz Dziedzic wrote:
>> On 19 February 2014 23:00, Luis R. Rodriguez <[email protected]> wrote:
>> > On Tue, Feb 18, 2014 at 10:12 PM, Janusz Dziedzic
>> > <[email protected]> wrote:
>> >> 2014-02-19 1:33 GMT+01:00 Luis R. Rodriguez <[email protected]>:
>> >>> On Wed, Feb 12, 2014 at 9:43 AM, Janusz Dziedzic
>> >>> <[email protected]> wrote:
>> >>>> Handle AUTO bandwidth setting in db2rd.
>> >>>> Don't add NL80211_ATTR_FREQ_RANGE_MAX_BW attribute
>> >>>> in case of AUTO bw calculation.
>> >>>>
>> >>>> Signed-off-by: Janusz Dziedzic <[email protected]>
>> >>>
>> >>> Please elaborate more on this. Who deals with the automatic math on
>> >>> the bandwidth?
>> >>>
>> >> cfg80211,
>> >>
>> >> Please check patch:
>> >> cfg80211: regulatory introduce maximum bandwidth calculation
>> >
>> > OK, so we don't send the max bandwidth attribute now, what about
>> > support for older kernels?
>> >
>> Yes, seems we should send this even this is 0.
>> Next for old kernel, all channels where BW=0 will be HT20 only.
>
> Is that really a good idea?
>
> Maybe crda should just get the logic to determine maximum bandwidth,
> like you did in the kernel, and then we can even revert the kernel code
> again?
>
Yes, this is possible to calculate this in crda (or even set this manually).
In such case we have to remove this bw check in the kernel code:

is_valid_reg_rule(...)
freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;

if (freq_range->max_bandwidth_khz > freq_diff)
return false;

BR
Janusz

2014-02-20 07:27:55

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On 19 February 2014 23:00, Luis R. Rodriguez <[email protected]> wrote:
> On Tue, Feb 18, 2014 at 10:12 PM, Janusz Dziedzic
> <[email protected]> wrote:
>> 2014-02-19 1:33 GMT+01:00 Luis R. Rodriguez <[email protected]>:
>>> On Wed, Feb 12, 2014 at 9:43 AM, Janusz Dziedzic
>>> <[email protected]> wrote:
>>>> Handle AUTO bandwidth setting in db2rd.
>>>> Don't add NL80211_ATTR_FREQ_RANGE_MAX_BW attribute
>>>> in case of AUTO bw calculation.
>>>>
>>>> Signed-off-by: Janusz Dziedzic <[email protected]>
>>>
>>> Please elaborate more on this. Who deals with the automatic math on
>>> the bandwidth?
>>>
>> cfg80211,
>>
>> Please check patch:
>> cfg80211: regulatory introduce maximum bandwidth calculation
>
> OK, so we don't send the max bandwidth attribute now, what about
> support for older kernels?
>
Yes, seems we should send this even this is 0.
Next for old kernel, all channels where BW=0 will be HT20 only.

BR
Janusz

2014-02-20 07:51:41

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On Thu, 2014-02-20 at 08:27 +0100, Janusz Dziedzic wrote:
> On 19 February 2014 23:00, Luis R. Rodriguez <[email protected]> wrote:
> > On Tue, Feb 18, 2014 at 10:12 PM, Janusz Dziedzic
> > <[email protected]> wrote:
> >> 2014-02-19 1:33 GMT+01:00 Luis R. Rodriguez <[email protected]>:
> >>> On Wed, Feb 12, 2014 at 9:43 AM, Janusz Dziedzic
> >>> <[email protected]> wrote:
> >>>> Handle AUTO bandwidth setting in db2rd.
> >>>> Don't add NL80211_ATTR_FREQ_RANGE_MAX_BW attribute
> >>>> in case of AUTO bw calculation.
> >>>>
> >>>> Signed-off-by: Janusz Dziedzic <[email protected]>
> >>>
> >>> Please elaborate more on this. Who deals with the automatic math on
> >>> the bandwidth?
> >>>
> >> cfg80211,
> >>
> >> Please check patch:
> >> cfg80211: regulatory introduce maximum bandwidth calculation
> >
> > OK, so we don't send the max bandwidth attribute now, what about
> > support for older kernels?
> >
> Yes, seems we should send this even this is 0.
> Next for old kernel, all channels where BW=0 will be HT20 only.

Is that really a good idea?

Maybe crda should just get the logic to determine maximum bandwidth,
like you did in the kernel, and then we can even revert the kernel code
again?

johannes


2014-02-20 09:54:37

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] crda: handle AUTO bw setting in db2rd

On Thu, 2014-02-20 at 10:31 +0100, Janusz Dziedzic wrote:
> On 20 February 2014 09:03, Janusz Dziedzic <[email protected]> wrote:
> > On 20 February 2014 08:59, Johannes Berg <[email protected]> wrote:
> >> On Thu, 2014-02-20 at 08:57 +0100, Janusz Dziedzic wrote:
> >>
> >>> >> Yes, seems we should send this even this is 0.
> >>> >> Next for old kernel, all channels where BW=0 will be HT20 only.
> >>> >
> >>> > Is that really a good idea?
> >>> >
> >>> > Maybe crda should just get the logic to determine maximum bandwidth,
> >>> > like you did in the kernel, and then we can even revert the kernel code
> >>> > again?
> >>> >
> >>> Yes, this is possible to calculate this in crda (or even set this manually).
> >>
> >> Ok. Would that help older kernels? How would we handle genregdb.awk?
> >>
> > In case of older kernels we will fail (end_freq - start_freq < bw) with -EINVAL.
> > So, bw=0 (cfg calculation) seems like best idea - will work with new
> > and old kernels.
> >
> Seems cfg80211 max bandwidth calculation is best option here.
>
> We should set BW as is in old regulatory (skip this BW=0 patches) -
> will work fine with old kernels.
> And in new regulatory add RULE flag NL80211_RRF_AUTO_BW, which will be
> checked in newer kernels and if AUTO_BW flag we will skip (end_freq -
> start_freq < bw) check and calculate maximum available bandwidth. What
> you think?

Yeah that seems reasonable.

johannes