Skip to contentSkip to conversation

dt-bindings: document common IEEE 802.11 frequency properties

PATCH Superseded Rafał Miłecki 6 participants 20 messages Dec 28, 2016 – Jan 4, 2017 15 messages not in the archive

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: document common IEEE 802.11 frequency properties

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +16 -0
new file mode 100644
index 0000000..c762769
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.
+
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
+
+pcie@0,0 {
+	reg = <0x0000 0 0 0 0>;
+	ieee80211-min-center-freq = <2437000>;
+	ieee80211-max-center-freq = <2457000>;
+};
Signature · 6 lines
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20161228155955.25518-1-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 2/2 cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +34 -0
index 5dbac37..35ba5c7 100644
@@ -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;
+
+	return true;
+}
+
 static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd,
 					  const struct ieee80211_reg_rule *reg_rule,
 					  const struct ieee80211_channel *chan)
@@ -1209,6 +1229,13 @@ static void handle_channel(struct wiphy *wiphy,
 		return;
 	}
 
+	if (!reg_center_freq_of_valid(wiphy, chan)) {
+		pr_debug("Disabling freq %d MHz as it's out of OF limits\n",
+			 chan->center_freq);
+		chan->flags |= IEEE80211_CHAN_DISABLED;
+		return;
+	}
+
 	regd = reg_get_regdomain(wiphy);
 
 	power_rule = &reg_rule->power_rule;
@@ -1741,6 +1768,13 @@ static void handle_channel_custom(struct wiphy *wiphy,
 		return;
 	}
 
+	if (!reg_center_freq_of_valid(wiphy, chan)) {
+		pr_debug("Disabling freq %d MHz as it's out of OF limits\n",
+			 chan->center_freq);
+		chan->flags |= IEEE80211_CHAN_DISABLED;
+		return;
+	}
+
 	power_rule = &reg_rule->power_rule;
 	bw_flags = reg_rule_to_chan_bw_flags(regd, reg_rule, chan);
 
Signature · 1 line
2.10.1

A message that is not in the archive (sent off-list or not yet received): 20161228155955.25518-2-zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

Quoted 27 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +6 -0
index 5dbac37..35ba5c7 100644
@@ -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;
+

net/wireless/reg.c const char *reg_initiator_name(enum nl80211_reg_initiator initiator) · line 1141

Quoted 10 lines
net/wireless/reg.c +10 -0
+	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.

Regards,
Arend

A message that is not in the archive (sent off-list or not yet received): 491a5af2-449d-4b2a-c4ed-af0e89b2ca78-dY08KVG/lbpWk0Htik3J/[email protected]

#6 lore raw

Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

Quoted 33 lines · Arend van Spriel
Quoted 32 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +11 -0
index 5dbac37..35ba5c7 100644
@@ -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))
Quoted 8 lines

net/wireless/reg.c const char *reg_initiator_name(enum nl80211_reg_initiator initiator) · line 1141

Quoted 5 lines
net/wireless/reg.c +5 -0
+             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?

Signature · 1 line
Rafał

A message that is not in the archive (sent off-list or not yet received): CACna6rwKLr-makRauYQf51330p96QrSNEhtNqu927yHT_Xm7Wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw

Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

Quoted 44 lines · Rafał Miłecki
Quoted 33 lines · Arend van Spriel
Quoted 32 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +11 -0
index 5dbac37..35ba5c7 100644
@@ -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))
Quoted 8 lines

net/wireless/reg.c const char *reg_initiator_name(enum nl80211_reg_initiator initiator) · line 1141

Quoted 5 lines
net/wireless/reg.c +5 -0
+             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.

Quoted 5 lines

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).

Signature · 1 line
Rafał

A message that is not in the archive (sent off-list or not yet received): CACna6rzJV-UdydKrXTquEzrkCfNXXKsHBrsZGjTJ8F=BSRyUjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw

Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

Quoted 48 lines · Rafał Miłecki
Quoted 47 lines · Rafał Miłecki
Quoted 33 lines · Arend van Spriel
Quoted 32 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +11 -0
index 5dbac37..35ba5c7 100644
@@ -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))
Quoted 8 lines

net/wireless/reg.c const char *reg_initiator_name(enum nl80211_reg_initiator initiator) · line 1141

Quoted 5 lines
net/wireless/reg.c +5 -0
+             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

Quoted 6 lines
Quoted 2 lines

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;

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.

Regards,
Arend

A message that is not in the archive (sent off-list or not yet received): 46007537-835c-90db-a44f-c45c8e2ecaed-dY08KVG/lbpWk0Htik3J/[email protected]

#12 lore raw

Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

Quoted 56 lines · Arend van Spriel
Quoted 48 lines · Rafał Miłecki
Quoted 47 lines · Rafał Miłecki
Quoted 33 lines · Arend van Spriel
Quoted 32 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +11 -0
index 5dbac37..35ba5c7 100644
@@ -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))
Quoted 8 lines

net/wireless/reg.c const char *reg_initiator_name(enum nl80211_reg_initiator initiator) · line 1141

Quoted 5 lines
net/wireless/reg.c +5 -0
+             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

Quoted 6 lines
Quoted 2 lines

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).

Quoted 7 lines

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
Quoted 5 lines

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)
Signature · 5 lines
Rafał
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CACna6rwaUWEjpBdfXS6uJSxKXH_mCP7YMGd1KaJropNQgVS7PA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#14 lore raw

Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

Quoted 63 lines · Rafał Miłecki
Quoted 61 lines · Arend van Spriel
Quoted 48 lines · Rafał Miłecki
Quoted 47 lines · Rafał Miłecki
Quoted 33 lines · Arend van Spriel
Quoted 32 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +11 -0
index 5dbac37..35ba5c7 100644
@@ -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))
Quoted 8 lines

net/wireless/reg.c const char *reg_initiator_name(enum nl80211_reg_initiator initiator) · line 1141

Quoted 5 lines
net/wireless/reg.c +5 -0
+             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

Quoted 6 lines
Quoted 2 lines

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:

Quoted 5 lines
Quoted 2 lines

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.

I am on vacation right now so not having much more than email and web browser to use as review reference.

Quoted 6 lines

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:

No need to convince me. I made a mistake reviewing the code. Thanks for clarifying it.

Quoted 17 lines
$ 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
Quoted 5 lines

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.

Quoted 3 lines

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.

But you probably do not have a mapping table for mapping country code received in notifier to firmware regulatory code/revision. Only if you have that, brcmfmac will update the channels in the bands.

Giving this some more consideration I am not sure if this is the proper place to handle this. ieee80211-(min|max)-center-freq is platform specific configuration allowing multiple cards to be used in different (sub)bands. This has nothing to do with regulatory. So probably better to move it to core.c or chan.c.

Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 86a22b00-1a04-25e7-9d31-2c1fd9d04e48-dY08KVG/lbpWk0Htik3J/[email protected]

#16 lore raw

Re: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties

Quoted 100 lines · Arend van Spriel
Quoted 63 lines · Rafał Miłecki
Quoted 61 lines · Arend van Spriel
Quoted 48 lines · Rafał Miłecki
Quoted 47 lines · Rafał Miłecki
Quoted 33 lines · Arend van Spriel
Quoted 32 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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.

---
 net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
net/wireless/reg.c +11 -0
index 5dbac37..35ba5c7 100644
@@ -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))
Quoted 8 lines

net/wireless/reg.c const char *reg_initiator_name(enum nl80211_reg_initiator initiator) · line 1141

Quoted 5 lines
net/wireless/reg.c +5 -0
+             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

Quoted 6 lines
Quoted 2 lines

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:

Quoted 5 lines
Quoted 2 lines

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.

I am on vacation right now so not having much more than email and web browser to use as review reference.

Quoted 6 lines

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:

No need to convince me. I made a mistake reviewing the code. Thanks for clarifying it.

Quoted 17 lines
$ 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
Quoted 5 lines

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.

Quoted 7 lines
Quoted 3 lines

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.

But you probably do not have a mapping table for mapping country code received in notifier to firmware regulatory code/revision. Only if you have that, brcmfmac will update the channels in the bands.

Thanks, I'll redo my tests.

Quoted 5 lines

Giving this some more consideration I am not sure if this is the proper place to handle this. ieee80211-(min|max)-center-freq is platform specific configuration allowing multiple cards to be used in different (sub)bands. This has nothing to do with regulatory. So probably better to move it to core.c or chan.c.

I can see point in this, I'll see if I can put this code in a more proper place. Thanks for your comment!

Signature · 5 lines
Rafał
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw
In reply to a message not in the archive
Quoted 17 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +0 -0
new file mode 100644
index 0000000..c762769

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +4 -0
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.

Please do not make any assumptions on how DT properties are handled nor by what. Just state that these properties apply to all wireless devices and are applicable to device specific bindings.

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 16

Quoted 11 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +11 -0
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
+
+pcie@0,0 {
+	reg = <0x0000 0 0 0 0>;
+	ieee80211-min-center-freq = <2437000>;
+	ieee80211-max-center-freq = <2457000>;
+};

Is this the proper level to define it. I was expecting a child node of the pci(e) controller. Maybe I am misreading the example.

Regards,

A message that is not in the archive (sent off-list or not yet received): f387d897-a1e9-c932-8317-41246be245b0-dY08KVG/lbpWk0Htik3J/[email protected]

#19 lore raw
Quoted 12 lines · Arend van Spriel
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Quoted 14 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +4 -0
new file mode 100644
index 0000000..c762769
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.

Please do not make any assumptions on how DT properties are handled nor by what. Just state that these properties apply to all wireless devices and are applicable to device specific bindings.

OK, I'll try to improve this description.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +6 -0
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
+
Quoted 8 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 16

Quoted 5 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +5 -0
+pcie@0,0 {
+     reg = <0x0000 0 0 0 0>;
+     ieee80211-min-center-freq = <2437000>;
+     ieee80211-max-center-freq = <2457000>;
+};

Is this the proper level to define it. I was expecting a child node of the pci(e) controller. Maybe I am misreading the example.

This is device node, not a controller node (and yes, it's complete node). You just need to add such a node inside the controller one.

It doesn't seem to be clearly documented, but you can see it in examples in:
Documentation/devicetree/bindings/pci/mvebu-pci.txt Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt

The assignment is done in
pci_scan_device -> pci_set_of_node -> of_pci_find_child_device (so this isn't controller specific thing).

Signature · 5 lines
Rafał
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CACna6rwhC=28fCHDzXok8Ka08g3yhcD2VNgQrfUZUCQRGqksOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#21 lore raw
Quoted 47 lines · Rafał Miłecki
Quoted 12 lines · Arend van Spriel
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Quoted 14 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +4 -0
new file mode 100644
index 0000000..c762769
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.

Please do not make any assumptions on how DT properties are handled nor by what. Just state that these properties apply to all wireless devices and are applicable to device specific bindings.

OK, I'll try to improve this description.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +6 -0
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
+
Quoted 8 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 16

Quoted 5 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +5 -0
+pcie@0,0 {
+     reg = <0x0000 0 0 0 0>;
+     ieee80211-min-center-freq = <2437000>;
+     ieee80211-max-center-freq = <2457000>;
+};

Is this the proper level to define it. I was expecting a child node of the pci(e) controller. Maybe I am misreading the example.

Quoted 2 lines

This is device node, not a controller node (and yes, it's complete node). You just need to add such a node inside the controller one.

you should name the node wifi@0,0 instead. I revised my ath9k OF binding documentation due to similar concerns (and after seeing the result I must admit that they were right). you can have a look at the result here: [0]

apart from that: thanks for the patch, I will try this as soon as possible!

Regards,
Martin

[0] https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/net/wireless/qca%2Cath9k.txt

A message that is not in the archive (sent off-list or not yet received): CAFBinCBNXdM-xVH9SaPZdFr3X0=k+py9aZ6Qj4ng=v1L-EvS7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#23 lore raw
Quoted 48 lines · Martin Blumenstingl
Quoted 47 lines · Rafał Miłecki
Quoted 12 lines · Arend van Spriel
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Quoted 14 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +4 -0
new file mode 100644
index 0000000..c762769
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.

Please do not make any assumptions on how DT properties are handled nor by what. Just state that these properties apply to all wireless devices and are applicable to device specific bindings.

OK, I'll try to improve this description.

Quoted 14 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 15

Quoted 11 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +11 -0
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
+
+pcie@0,0 {
+     reg = <0x0000 0 0 0 0>;
+     ieee80211-min-center-freq = <2437000>;
+     ieee80211-max-center-freq = <2457000>;
+};

Is this the proper level to define it. I was expecting a child node of the pci(e) controller. Maybe I am misreading the example.

Quoted 6 lines
Quoted 2 lines

This is device node, not a controller node (and yes, it's complete node). You just need to add such a node inside the controller one.

you should name the node wifi@0,0 instead. I revised my ath9k OF binding documentation due to similar concerns (and after seeing the result I must admit that they were right). you can have a look at the result here: [0]

Thanks for your comment, I'm far from considering myself DT expert, so I often need help with such things, I'll change this in V2.

Signature · 1 line
Rafał
#24 lore raw
In reply to a message not in the archive
Quoted 22 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +5 -0
new file mode 100644
index 0000000..c762769
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.
+

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 15

Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +10 -0
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
+
+pcie@0,0 {
+	reg = <0x0000 0 0 0 0>;
+	ieee80211-min-center-freq = <2437000>;
+	ieee80211-max-center-freq = <2457000>;

I'm not sure that's the best way to deal with enabling/disabling bands. If we get more bands in the future, there might be unsupported ones in the middle, which min/max won't cover.

- Felix

A message that is not in the archive (sent off-list or not yet received): ddd1bb11-eb4d-7a53-c3ea-5ff5e59ae100-Vt+b4OUoWG0@public.gmane.org

#26 lore raw
Quoted 28 lines · Felix Fietkau
Quoted 27 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +10 -0
new file mode 100644
index 0000000..c762769
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.
+
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
Quoted 8 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 15

Quoted 5 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +5 -0
+
+pcie@0,0 {
+     reg = <0x0000 0 0 0 0>;
+     ieee80211-min-center-freq = <2437000>;
+     ieee80211-max-center-freq = <2457000>;

I'm not sure that's the best way to deal with enabling/disabling bands. If we get more bands in the future, there might be unsupported ones in the middle, which min/max won't cover.

Maybe we could try specifying list of ranges? E.g. ieee80211-center-frequencies = <2412000 2422000

    2442000 2452>;
or
ieee80211-center-frequencies = <2412000 2422000>,
    <2442000 2452>;

for device supporting channels 1, 2, 3, 7, 8, 9?

Signature · 5 lines
Rafał
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#27 lore raw
In reply to a message not in the archive
Quoted 4 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

Why is this needed? Where would this data normally come from?

Quoted 12 lines
---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +0 -0
new file mode 100644
index 0000000..c762769

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +4 -0
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.

Not relavent to a binding. Bindings describe h/w.

Quoted 19 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +12 -0
+
+Optional properties:
+ - ieee80211-min-center-freq : minimal supported frequency in KHz
+ - ieee80211-max-center-freq : maximal supported frequency in KHz
+
+Example:
+
+pcie@0,0 {
+	reg = <0x0000 0 0 0 0>;
+	ieee80211-min-center-freq = <2437000>;
+	ieee80211-max-center-freq = <2457000>;
+};
Signature · 6 lines
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#28 lore raw
Quoted 7 lines · Rob Herring
Quoted 4 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

Why is this needed? Where would this data normally come from?

Vendors limit choice of channels at their web user interface level. I want to do better and report proper channels directly at kernel level instead of masking them in every possible configuration tool.

Quoted 6 lines
Quoted 6 lines
---
 .../devicetree/bindings/net/wireless/ieee80211.txt       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/ieee80211.txt
Quoted 12 lines

Documentation/devicetree/bindings/net/wireless/ieee80211.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/ieee80211.txt new file +4 -0
new file mode 100644
index 0000000..c762769
@@ -0,0 +1,16 @@
+Common IEEE 802.11 properties
+
+This provides documentation of common properties that are handled by a proper
+net layer and don't require extra driver code.

Not relavent to a binding. Bindings describe h/w.

Yes, Arend pointed it to me and I improved this Documentation file in further versions. Could you review V4, please?
https://patchwork.kernel.org/patch/9494713/

Signature · 1 line
Rafał

A message that is not in the archive (sent off-list or not yet received): CACna6rxmgN2zz-Fc1-Uu02oqMQreNkMJt0jGjLOMrXM=6iujFw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#30 lore raw
Quoted 4 lines · Rafał Miłecki
Quoted 3 lines · Rob Herring
Quoted 2 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This new file should be used for properties handled at higher level and so usable with all drivers.

Why is this needed? Where would this data normally come from?

Vendors limit choice of channels at their web user interface level. I want to do better and report proper channels directly at kernel level instead of masking them in every possible configuration tool.

Why do vendors limit the channels? Is it because of a hardware limitation (antenna does not support, or not calibrated, for a certain band etc) or something else?

Signature · 1 line
Kalle Valo

A message that is not in the archive (sent off-list or not yet received): [email protected]

#32 lore raw
Quoted 11 lines · Kalle Valo
Quoted 9 lines · Rafał Miłecki
Quoted 7 lines · Rob Herring
Quoted 4 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

Why is this needed? Where would this data normally come from?

Quoted 7 lines
Quoted 3 lines

Vendors limit choice of channels at their web user interface level. I want to do better and report proper channels directly at kernel level instead of masking them in every possible configuration tool.

Why do vendors limit the channels? Is it because of a hardware limitation (antenna does not support, or not calibrated, for a certain band etc) or something else?

Please review & comment on the latest version, currently V5:
https://patchwork.kernel.org/patch/9495795/
"This can be used to specify extra hardware limitations caused by e.g. used antennas or power amplifiers."

Signature · 1 line
Rafał

A message that is not in the archive (sent off-list or not yet received): CACna6rxx-8499ZQKekdORF0UWQQazwGu2On1aq-fwA4oCX7pgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#34 lore raw
Quoted 16 lines · Rafał Miłecki
Quoted 15 lines · Kalle Valo
Quoted 12 lines · Rafał Miłecki
Quoted 7 lines · Rob Herring
Quoted 4 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This new file should be used for properties handled at higher level and so usable with all drivers.

Why is this needed? Where would this data normally come from?

Vendors limit choice of channels at their web user interface level. I want to do better and report proper channels directly at kernel level instead of masking them in every possible configuration tool.

Quoted 8 lines
Quoted 3 lines

Why do vendors limit the channels? Is it because of a hardware limitation (antenna does not support, or not calibrated, for a certain band etc) or something else?

Please review & comment on the latest version, currently V5:
https://patchwork.kernel.org/patch/9495795/
"This can be used to specify extra hardware limitations caused by e.g. used antennas or power amplifiers."

Just to be clear, it is does not need to be a hardware limitation, but simply a way to assure that multiple wlan radios are not interfering with each other and crank up the total bandwidth that vendors can put on their box.

Regards,
Arend