From: "Rafał Miłecki" <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Arend van Spriel
<arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Cc: "Kalle Valo" <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
"linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Martin Blumenstingl"
<martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>,
"Felix Fietkau" <nbd-Vt+b4OUoWG0@public.gmane.org>,
"Arnd Bergmann" <arnd-r2nGTMty4D4@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Rafał Miłecki" <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
Subject: Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties
Date: Thu, 29 Dec 2016 10:43:22 +0100 [thread overview]
Message-ID: <CACna6rwaUWEjpBdfXS6uJSxKXH_mCP7YMGd1KaJropNQgVS7PA@mail.gmail.com> (raw)
In-Reply-To: <46007537-835c-90db-a44f-c45c8e2ecaed-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
On 29 December 2016 at 09:57, Arend van Spriel
<arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org> wrote:
> On 28-12-16 22:30, Rafał Miłecki wrote:
>> On 28 December 2016 at 22:28, Rafał Miłecki <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>> On 28 December 2016 at 22:07, Arend van Spriel
>>> <arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org> wrote:
>>>> On 28-12-16 16:59, Rafał Miłecki wrote:
>>>>> From: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
>>>>>
>>>>> They allow specifying hardware limitations of supported channels. This
>>>>> may be useful for specifying single band devices or devices that support
>>>>> only some part of the whole band.
>>>>> E.g. some tri-band routers have separated radios for lower and higher
>>>>> part of 5 GHz band.
>>>>>
>>>>> Signed-off-by: Rafał Miłecki <rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org>
>>>>> ---
>>>>> net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
>>>>> 1 file changed, 34 insertions(+)
>>>>>
>>>>> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
>>>>> index 5dbac37..35ba5c7 100644
>>>>> --- a/net/wireless/reg.c
>>>>> +++ b/net/wireless/reg.c
>>>>> @@ -1123,6 +1123,26 @@ const char *reg_initiator_name(enum nl80211_reg_initiator initiator)
>>>>> }
>>>>> EXPORT_SYMBOL(reg_initiator_name);
>>>>>
>>>>> +static bool reg_center_freq_of_valid(struct wiphy *wiphy,
>>>>> + struct ieee80211_channel *chan)
>>>>> +{
>>>>> + struct device_node *np = wiphy_dev(wiphy)->of_node;
>>>>> + u32 val;
>>>>> +
>>>>> + if (!np)
>>>>> + return true;
>>>>> +
>>>>> + if (!of_property_read_u32(np, "ieee80211-min-center-freq", &val) &&
>>>>> + chan->center_freq < KHZ_TO_MHZ(val))
>>>>> + return false;
>>>>> +
>>>>> + if (!of_property_read_u32(np, "ieee80211-max-center-freq", &val) &&
>>>>> + chan->center_freq > KHZ_TO_MHZ(val))
>>>>> + return false;
>>>>
>>>> I suspect these functions rely on CONFIG_OF. So might not build for
>>>> !CONFIG_OF.
>>>
>>> I compiled it with
>>> # CONFIG_OF is not set
>>>
>>> Can you test it and provide a non-working config if you see a
>>> compilation error, please?
>>
>> include/linux/of.h provides a lot of dummy static inline functions if
>> CONFIG_OF is not used (they also allow compiler to drop most of the
>> code).
>
> of_propeirty_read_u32 is static inline in of.h calling
> of_property_read_u32_array, which has a dummy variant in of.h returning
> -ENOSYS so -38. Pretty sure that is not what you want. At least it does
> not allow the compiler to drop any code so probably better to do:
>
> if (!IS_ENABLED(CONFIG_OF) || !np)
> return true;
Please verify that using a compiler. If there is a problem I'll be
happy to work on it, but I need a proof it exists.
If compilers sees a:
if (!-ENOSYS && chan->center_freq < KHZ_TO_MHZ(val))
condition, it's pretty clear it can be dropped. With both conditional
blocks dropped function always returns "true" and... can be dropped.
Let me see if I can convince you with the following test:
$ grep -m 1 CONFIG_OF .config
# CONFIG_OF is not set
$ objdump --syms net/wireless/reg.o | grep -c reg_center_freq_of_valid
0
$ grep -m 1 CONFIG_OF .config
CONFIG_OF=y
$ objdump --syms net/wireless/reg.o | grep -c reg_center_freq_of_valid
1
> So with this patch you change the channel to DISABLED. I am not very
> familiar with reg.c so do you know if this is done before or after
> calling regulatory notifier in the driver. brcmfmac will enable channels
> querying the device upon regulatory notifier call, which may undo the
> behavior introduced by your patch.
I'm not regulatory export, so I hope someone will review this patch.
So far I can say it works for me after trying it on SR400ac with
BCM43602.
ieee80211-min-center-freq = <2437000>;
[ 11.986941] cfg80211: Disabling freq 2412 MHz as it's out of OF limits
[ 12.000466] cfg80211: Disabling freq 2417 MHz as it's out of OF limits
[ 12.013984] cfg80211: Disabling freq 2422 MHz as it's out of OF limits
[ 12.027497] cfg80211: Disabling freq 2427 MHz as it's out of OF limits
[ 12.041012] cfg80211: Disabling freq 2432 MHz as it's out of OF limits
root@lede:/# iw phy phy0 channels
Band 1:
* 2412 MHz [1] (disabled)
* 2417 MHz [2] (disabled)
* 2422 MHz [3] (disabled)
* 2427 MHz [4] (disabled)
* 2432 MHz [5] (disabled)
* 2437 MHz [6]
Maximum TX power: 20.0 dBm
Channel widths: 20MHz HT40- HT40+
* 2442 MHz [7]
Maximum TX power: 20.0 dBm
Channel widths: 20MHz HT40- HT40+
* 2447 MHz [8]
Maximum TX power: 20.0 dBm
Channel widths: 20MHz HT40-
* 2452 MHz [9]
Maximum TX power: 20.0 dBm
Channel widths: 20MHz HT40-
* 2457 MHz [10]
Maximum TX power: 20.0 dBm
Channel widths: 20MHz HT40-
* 2462 MHz [11]
Maximum TX power: 20.0 dBm
Channel widths: 20MHz HT40-
* 2467 MHz [12] (disabled)
* 2472 MHz [13] (disabled)
* 2484 MHz [14] (disabled)
--
Rafał
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-12-29 9:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 15:59 [PATCH 1/2] dt-bindings: document common IEEE 802.11 frequency properties Rafał Miłecki
[not found] ` <20161228155955.25518-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-28 15:59 ` [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties Rafał Miłecki
[not found] ` <20161228155955.25518-2-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-28 21:07 ` Arend van Spriel
[not found] ` <491a5af2-449d-4b2a-c4ed-af0e89b2ca78-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-28 21:28 ` Rafał Miłecki
[not found] ` <CACna6rwKLr-makRauYQf51330p96QrSNEhtNqu927yHT_Xm7Wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-28 21:30 ` Rafał Miłecki
[not found] ` <CACna6rzJV-UdydKrXTquEzrkCfNXXKsHBrsZGjTJ8F=BSRyUjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-29 8:57 ` Arend van Spriel
[not found] ` <46007537-835c-90db-a44f-c45c8e2ecaed-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-29 9:43 ` Rafał Miłecki [this message]
[not found] ` <CACna6rwaUWEjpBdfXS6uJSxKXH_mCP7YMGd1KaJropNQgVS7PA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-30 20:20 ` Arend van Spriel
[not found] ` <86a22b00-1a04-25e7-9d31-2c1fd9d04e48-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-30 21:37 ` Rafał Miłecki
2016-12-28 20:05 ` [PATCH 1/2] dt-bindings: document common IEEE 802.11 frequency properties Arend van Spriel
[not found] ` <f387d897-a1e9-c932-8317-41246be245b0-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2016-12-28 20:32 ` Rafał Miłecki
[not found] ` <CACna6rwhC=28fCHDzXok8Ka08g3yhcD2VNgQrfUZUCQRGqksOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-28 20:39 ` Martin Blumenstingl
[not found] ` <CAFBinCBNXdM-xVH9SaPZdFr3X0=k+py9aZ6Qj4ng=v1L-EvS7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-28 20:43 ` Rafał Miłecki
2016-12-28 21:35 ` Felix Fietkau
[not found] ` <ddd1bb11-eb4d-7a53-c3ea-5ff5e59ae100-Vt+b4OUoWG0@public.gmane.org>
2016-12-28 22:22 ` Rafał Miłecki
2017-01-03 19:55 ` Rob Herring
2017-01-03 20:20 ` Rafał Miłecki
[not found] ` <CACna6rxmgN2zz-Fc1-Uu02oqMQreNkMJt0jGjLOMrXM=6iujFw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-04 14:32 ` Kalle Valo
[not found] ` <874m1ej3oz.fsf-HodKDYzPHsUD5k0oWYwrnHL1okKdlPRT@public.gmane.org>
2017-01-04 14:53 ` Rafał Miłecki
[not found] ` <CACna6rxx-8499ZQKekdORF0UWQQazwGu2On1aq-fwA4oCX7pgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-04 19:53 ` Arend Van Spriel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACna6rwaUWEjpBdfXS6uJSxKXH_mCP7YMGd1KaJropNQgVS7PA@mail.gmail.com \
--to=zajec5-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org \
--cc=nbd-Vt+b4OUoWG0@public.gmane.org \
--cc=rafal-g1n6cQUeyibVItvQsEIGlw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).