2014-04-02 13:32:10

by Rostislav Lisovy

[permalink] [raw]
Subject: [PATCH 0/4 v2] cfg80211: The very first steps to support 5/10MHz channels in 5.9Ghz band

The IEEE 802.11p amendment specifies usage of 5 and 10 MHz wide
channels in 5.9GHz band for vehicular environment. This patch-set
adds new channel attributes holding the information about the
prohibited bandwidths. This is meant to be used mainly with
channels in 5.9GHz band in future implementation of 802.11p.

Changes since v1:
* Rebased to 3.14
* Squashed patches 1+2
* All patches have long commit message


Rostislav Lisovy (4):
cfg80211: Add attributes describing prohibited channel bandwidth
cfg80211: Take the BW restrictions into account when checking the
channel
cfg80211: Use 5MHz bandwidth by default when checking usable channels
mac80211: Update conf_is_ht() to work properly with 5/10MHz channels

include/net/cfg80211.h | 6 ++++++
include/net/mac80211.h | 4 +++-
include/uapi/linux/nl80211.h | 6 ++++++
net/wireless/chan.c | 2 ++
net/wireless/nl80211.c | 13 +++++++++++++
net/wireless/reg.c | 22 +++++++++++++++-------
6 files changed, 45 insertions(+), 8 deletions(-)

--
1.9.1


2014-04-02 13:32:16

by Rostislav Lisovy

[permalink] [raw]
Subject: [PATCH 4/4] mac80211: Update conf_is_ht() to work properly with 5/10MHz channels

The channels with 5/10MHz bandwidth are not HT. We have to
reflect this in conf_is_ht() function which returns whether the
particular channel is HT or not.

Signed-off-by: Rostislav Lisovy <[email protected]>
---
include/net/mac80211.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index f4ab2fb..f56e45b 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4585,7 +4585,9 @@ conf_is_ht40(struct ieee80211_conf *conf)
static inline bool
conf_is_ht(struct ieee80211_conf *conf)
{
- return conf->chandef.width != NL80211_CHAN_WIDTH_20_NOHT;
+ return (conf->chandef.width != NL80211_CHAN_WIDTH_5) &&
+ (conf->chandef.width != NL80211_CHAN_WIDTH_10) &&
+ (conf->chandef.width != NL80211_CHAN_WIDTH_20_NOHT);
}

static inline enum nl80211_iftype
--
1.9.1

2014-04-02 13:32:53

by Rostislav Lisovy

[permalink] [raw]
Subject: [PATCH 3/4] cfg80211: Use 5MHz bandwidth by default when checking usable channels

Current code checks if the 20MHz bandwidth is allowed for
particular channel -- if it is not, the channel is disabled.
Since we need to use 5/10 MHz channels, this code is modified in
the way that the default bandwidth to check is 5MHz. If the
maximum bandwidth allowed by the channel is smaller than 5MHz,
the channel is disabled. Otherwise the channel is used and the
flags are set according to the bandwidth allowed by the channel.

Signed-off-by: Rostislav Lisovy <[email protected]>
---
net/wireless/reg.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index f054137..5f0dd26 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -805,7 +805,7 @@ freq_reg_info_regd(struct wiphy *wiphy, u32 center_freq,
if (!band_rule_found)
band_rule_found = freq_in_rule_band(fr, center_freq);

- bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(20));
+ bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(5));

if (band_rule_found && bw_fits)
return rr;
@@ -888,10 +888,10 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
}
#endif

-/*
- * Note that right now we assume the desired channel bandwidth
- * is always 20 MHz for each individual channel (HT40 uses 20 MHz
- * per channel, the primary and the extension channel).
+/* Find an ieee80211_reg_rule such that a 5MHz channel with frequency
+ * @chan->center_freq fits there.
+ * If there is no such reg_rule, disable the channel, otherwise set the
+ * flags corresponding to the bandwidths allowed in the particular reg_rule
*/
static void handle_channel(struct wiphy *wiphy,
enum nl80211_reg_initiator initiator,
@@ -944,8 +944,12 @@ static void handle_channel(struct wiphy *wiphy,
power_rule = &reg_rule->power_rule;
freq_range = &reg_rule->freq_range;

+ if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(10))
+ bw_flags = IEEE80211_CHAN_NO_10MHZ;
+ if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(20))
+ bw_flags |= IEEE80211_CHAN_NO_20MHZ;
if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(40))
- bw_flags = IEEE80211_CHAN_NO_HT40;
+ bw_flags |= IEEE80211_CHAN_NO_HT40;
if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(80))
bw_flags |= IEEE80211_CHAN_NO_80MHZ;
if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(160))
@@ -1351,8 +1355,12 @@ static void handle_channel_custom(struct wiphy *wiphy,
power_rule = &reg_rule->power_rule;
freq_range = &reg_rule->freq_range;

+ if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(10))
+ bw_flags = IEEE80211_CHAN_NO_10MHZ;
+ if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(20))
+ bw_flags |= IEEE80211_CHAN_NO_20MHZ;
if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(40))
- bw_flags = IEEE80211_CHAN_NO_HT40;
+ bw_flags |= IEEE80211_CHAN_NO_HT40;
if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(80))
bw_flags |= IEEE80211_CHAN_NO_80MHZ;
if (freq_range->max_bandwidth_khz < MHZ_TO_KHZ(160))
--
1.9.1

2014-04-02 13:32:08

by Rostislav Lisovy

[permalink] [raw]
Subject: [PATCH 1/4] cfg80211: Add attributes describing prohibited channel bandwidth

Since there are frequency bands (e.g. 5.9GHz) allowing channels
with only 10 or 5 MHz bandwidth, this patch adds attributes that
allow keeping track about this information.

When channel attributes are reported to user-space, make sure to
not break old tools, i.e. if the 'split wiphy dump' is enabled,
report the extra attributes (if present) describing the bandwidth
restrictions. If the 'split wiphy dump' is not enabled,
completely omit those channels that have flags set to either
IEEE80211_CHAN_NO_10MHZ or IEEE80211_CHAN_NO_20MHZ.

Signed-off-by: Rostislav Lisovy <[email protected]>
---
include/net/cfg80211.h | 6 ++++++
include/uapi/linux/nl80211.h | 6 ++++++
net/wireless/nl80211.c | 13 +++++++++++++
3 files changed, 25 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b1f84b0..f5ecd6c 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -109,6 +109,10 @@ enum ieee80211_band {
* channel as the control or any of the secondary channels.
* This may be due to the driver or due to regulatory bandwidth
* restrictions.
+ * @IEEE80211_CHAN_NO_20MHZ: 20 MHz bandwidth is not permitted
+ * on this channel.
+ * @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
+ * on this channel.
*/
enum ieee80211_channel_flags {
IEEE80211_CHAN_DISABLED = 1<<0,
@@ -120,6 +124,8 @@ enum ieee80211_channel_flags {
IEEE80211_CHAN_NO_OFDM = 1<<6,
IEEE80211_CHAN_NO_80MHZ = 1<<7,
IEEE80211_CHAN_NO_160MHZ = 1<<8,
+ IEEE80211_CHAN_NO_20MHZ = 1<<9,
+ IEEE80211_CHAN_NO_10MHZ = 1<<10,
};

#define IEEE80211_CHAN_NO_HT40 \
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 91054fd..0748026 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2304,6 +2304,10 @@ enum nl80211_band_attr {
* @NL80211_FREQUENCY_ATTR_NO_160MHZ: any 160 MHz (but not 80+80) channel
* using this channel as the primary or any of the secondary channels
* isn't possible
+ * @NL80211_FREQUENCY_ATTR_NO_20MHZ: 20 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_10MHZ: 10 MHz operation is not allowed
+ * on this channel in current regulatory domain.
* @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
* currently defined
* @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
@@ -2322,6 +2326,8 @@ enum nl80211_frequency_attr {
NL80211_FREQUENCY_ATTR_NO_HT40_PLUS,
NL80211_FREQUENCY_ATTR_NO_80MHZ,
NL80211_FREQUENCY_ATTR_NO_160MHZ,
+ NL80211_FREQUENCY_ATTR_NO_20MHZ,
+ NL80211_FREQUENCY_ATTR_NO_10MHZ,

/* keep last */
__NL80211_FREQUENCY_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4fe2e6e..c62c572 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -563,6 +563,13 @@ static int nl80211_msg_put_channel(struct sk_buff *msg,
struct ieee80211_channel *chan,
bool large)
{
+ /* Some channels must be completely excluded from the
+ * list to protect old user-space tools from breaking
+ */
+ if (!large && chan->flags &
+ (IEEE80211_CHAN_NO_10MHZ | IEEE80211_CHAN_NO_20MHZ))
+ return 0;
+
if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_FREQ,
chan->center_freq))
goto nla_put_failure;
@@ -606,6 +613,12 @@ static int nl80211_msg_put_channel(struct sk_buff *msg,
if ((chan->flags & IEEE80211_CHAN_NO_160MHZ) &&
nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_160MHZ))
goto nla_put_failure;
+ if ((chan->flags & IEEE80211_CHAN_NO_20MHZ) &&
+ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_20MHZ))
+ goto nla_put_failure;
+ if ((chan->flags & IEEE80211_CHAN_NO_10MHZ) &&
+ nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_10MHZ))
+ goto nla_put_failure;
}

if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
--
1.9.1

2014-04-02 13:33:40

by Rostislav Lisovy

[permalink] [raw]
Subject: [PATCH 2/4] cfg80211: Take the BW restrictions into account when checking the channel

Since there are frequency bands restricting maximum channel
bandwidth to 5MHz or 10MHz, check the particular bandwidth
flags in cfg80211_chandef_usable() to comply with the restrictions.

Signed-off-by: Rostislav Lisovy <[email protected]>
---
net/wireless/chan.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 78559b5..87e1576 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -531,12 +531,14 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
width = 5;
break;
case NL80211_CHAN_WIDTH_10:
+ prohibited_flags |= IEEE80211_CHAN_NO_10MHZ;
width = 10;
break;
case NL80211_CHAN_WIDTH_20:
if (!ht_cap->ht_supported)
return false;
case NL80211_CHAN_WIDTH_20_NOHT:
+ prohibited_flags |= IEEE80211_CHAN_NO_20MHZ;
width = 20;
break;
case NL80211_CHAN_WIDTH_40:
--
1.9.1

2014-04-08 09:50:39

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 4/4] mac80211: Update conf_is_ht() to work properly with 5/10MHz channels

On Wed, 2014-04-02 at 15:31 +0200, Rostislav Lisovy wrote:
> The channels with 5/10MHz bandwidth are not HT. We have to
> reflect this in conf_is_ht() function which returns whether the
> particular channel is HT or not.

Applied.

johannes

2014-04-08 09:54:50

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/4] cfg80211: Add attributes describing prohibited channel bandwidth

On Wed, 2014-04-02 at 15:31 +0200, Rostislav Lisovy wrote:
> Since there are frequency bands (e.g. 5.9GHz) allowing channels
> with only 10 or 5 MHz bandwidth, this patch adds attributes that
> allow keeping track about this information.
>
> When channel attributes are reported to user-space, make sure to
> not break old tools, i.e. if the 'split wiphy dump' is enabled,
> report the extra attributes (if present) describing the bandwidth
> restrictions. If the 'split wiphy dump' is not enabled,
> completely omit those channels that have flags set to either
> IEEE80211_CHAN_NO_10MHZ or IEEE80211_CHAN_NO_20MHZ.

I think you should probably squash patches 1 and 2, since otherwise you
could use the new channels?

Anyway, the patches don't seem to apply on mac80211-next, please rebase.

johannes