All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
	"Felix Fietkau" <nbd@nbd.name>,
	"Arend van Spriel" <arend@broadcom.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH V5 3/3] cfg80211: support ieee80211-freq-limit DT property
Date: Thu, 05 Jan 2017 12:50:50 +0100	[thread overview]
Message-ID: <1483617050.4394.12.camel@sipsolutions.net> (raw)
In-Reply-To: <CACna6ryzk958T0by_4F96hJxUCR5VsKJjrsjByFO96+HcfmXqg@mail.gmail.com> (sfid-20170104_171308_807288_97C21013)


> > But just setting orig_flags also won't work, since it'd be
> > overwritten again by wiphy_register(), no?
> 
> I told you I successfully tested it, didn't I? Well, I quickly
> checked wiphy_register and couldn't understand how it was possible it
> worked for me...

I guess I didn't believe it ;-)

> OK, so after some debugging I understood why I got this working. It's
> the way brcmfmac handles channels.
> 
> At the beginning all channels are disabled: see __wl_2ghz_channels &
> __wl_5ghz_channels. They have IEEE80211_CHAN_DISABLED set in "flags"
> for every channel.
> 
> In early phase brcmfmac calls wiphy_read_of_freq_limits which sets
> IEEE80211_CHAN_DISABLED in "orig_flags" for unavailable channels.
> 
> Then brcmf_construct_chaninfo kicks in. Normally it removes
> IEEE80211_CHAN_DISABLED from "flags" for most of channels, but it
> doesn't happen anymore due to my change:
> if (channel->orig_flags & IEEE80211_CHAN_DISABLED)
>         continue;
> 
> Then brcmfmac calls wiphy_apply_custom_regulatory which sets some
> bits like IEEE80211_CHAN_NO_80MHZ and IEEE80211_CHAN_NO_160MHZ in
> "flags".
> 
> Finally wiphy_register is called which copies "flags" to
> "original_flags". As brcmfmac /respected/ IEEE80211_CHAN_DISABLED set
> in orig_flags, it also left IEEE80211_CHAN_DISABLED in flags. This
> way I got IEEE80211_CHAN_DISABLED in orig_flags after overwriting
> that field inside wiphy_register.
> 
> That's quite crazy, right?

Yeah, that was pretty crazy.

> I guess you're right after all, I should set IEEE80211_CHAN_DISABLED
> in "flags" field, let wiphy_register copy that to "orig_flags" and
> sanitize brcmfmac.

Makes sense to me. That would also match the way it works when no
custom regulatory notifier is used, which makes the OF function more
widely applicable.

Thanks,
johannes

WARNING: multiple messages have this Message-ID (diff)
From: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
To: "Rafał Miłecki" <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "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>,
	"Arend van Spriel"
	<arend-dY08KVG/lbpWk0Htik3J/w@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 V5 3/3] cfg80211: support ieee80211-freq-limit DT property
Date: Thu, 05 Jan 2017 12:50:50 +0100	[thread overview]
Message-ID: <1483617050.4394.12.camel@sipsolutions.net> (raw)
In-Reply-To: <CACna6ryzk958T0by_4F96hJxUCR5VsKJjrsjByFO96+HcfmXqg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> (sfid-20170104_171308_807288_97C21013)


> > But just setting orig_flags also won't work, since it'd be
> > overwritten again by wiphy_register(), no?
> 
> I told you I successfully tested it, didn't I? Well, I quickly
> checked wiphy_register and couldn't understand how it was possible it
> worked for me...

I guess I didn't believe it ;-)

> OK, so after some debugging I understood why I got this working. It's
> the way brcmfmac handles channels.
> 
> At the beginning all channels are disabled: see __wl_2ghz_channels &
> __wl_5ghz_channels. They have IEEE80211_CHAN_DISABLED set in "flags"
> for every channel.
> 
> In early phase brcmfmac calls wiphy_read_of_freq_limits which sets
> IEEE80211_CHAN_DISABLED in "orig_flags" for unavailable channels.
> 
> Then brcmf_construct_chaninfo kicks in. Normally it removes
> IEEE80211_CHAN_DISABLED from "flags" for most of channels, but it
> doesn't happen anymore due to my change:
> if (channel->orig_flags & IEEE80211_CHAN_DISABLED)
>         continue;
> 
> Then brcmfmac calls wiphy_apply_custom_regulatory which sets some
> bits like IEEE80211_CHAN_NO_80MHZ and IEEE80211_CHAN_NO_160MHZ in
> "flags".
> 
> Finally wiphy_register is called which copies "flags" to
> "original_flags". As brcmfmac /respected/ IEEE80211_CHAN_DISABLED set
> in orig_flags, it also left IEEE80211_CHAN_DISABLED in flags. This
> way I got IEEE80211_CHAN_DISABLED in orig_flags after overwriting
> that field inside wiphy_register.
> 
> That's quite crazy, right?

Yeah, that was pretty crazy.

> I guess you're right after all, I should set IEEE80211_CHAN_DISABLED
> in "flags" field, let wiphy_register copy that to "orig_flags" and
> sanitize brcmfmac.

Makes sense to me. That would also match the way it works when no
custom regulatory notifier is used, which makes the OF function more
widely applicable.

Thanks,
johannes

  reply	other threads:[~2017-01-05 11:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03 22:57 [PATCH V5 1/3] dt-bindings: document common IEEE 802.11 frequency limit property Rafał Miłecki
2017-01-03 22:57 ` Rafał Miłecki
2017-01-03 22:57 ` [PATCH V5 2/3] cfg80211: move function checking range fit to util.c Rafał Miłecki
2017-01-03 22:57   ` Rafał Miłecki
2017-01-03 22:57 ` [PATCH V5 3/3] cfg80211: support ieee80211-freq-limit DT property Rafał Miłecki
2017-01-03 22:57   ` Rafał Miłecki
2017-01-04 13:26   ` Johannes Berg
2017-01-04 13:26     ` Johannes Berg
2017-01-04 16:13     ` Rafał Miłecki
2017-01-04 16:13       ` Rafał Miłecki
2017-01-05 11:50       ` Johannes Berg [this message]
2017-01-05 11:50         ` Johannes Berg
2017-01-03 22:57 ` [PATCH V5 4/3] brcmfmac: use wiphy_read_of_freq_limits to respect extra limits Rafał Miłecki
2017-01-03 22:57   ` Rafał Miłecki
2017-01-04 14:20   ` Rob Herring
2017-01-04 14:20     ` Rob Herring
2017-01-04  6:20 ` [PATCH V5 1/3] dt-bindings: document common IEEE 802.11 frequency limit property Rafał Miłecki
2017-01-04  6:20   ` Rafał Miłecki
2017-01-04 10:02   ` Arend Van Spriel
2017-01-04 10:02     ` 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=1483617050.4394.12.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=arend@broadcom.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=nbd@nbd.name \
    --cc=rafal@milecki.pl \
    --cc=zajec5@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.