This patchset adds new channel types -- 5MHz and 10MHz. Channels
with such bandwidth are used in IEEE 802.11p with frequencies
ranging from 5850 to 5925 MHz. Since OCB mode defined in 802.11p
does not use beacons, the channel frequencies including the
bandwidth should be set by all STAs before joining the network.
This patchset adds the possibility of setting the channel
bandwidth via netlink (i.e. from userspace).
Potential issues:
CRDA reports to the kernel the information about the maximum
channel bandwidth allowed for some particular range of channels/
frequencies. In case the maximum BW is usual 20 or 40 MHz, e.g.
(2400 - 2483.5 @ 40), it is possible to configure a channel with
5MHz or 10MHz in that range. Is this behavior acceptable or
should it be prevented?
Rostislav Lisovy (8):
nl80211: Add new channel types -- 5MHz and 10MHz
nl80211: Add attributes describing channel bandwidth
cfg80211: Add attributes describing channel bandwidth
cfg80211: Modify chandef related functions to work with 5/10MHz
channels
nl80211: Modify chandef related functions to work with 5/10MHz
channels
nl80211: Support for 5/10 MHz channels when reporting BW restrictions
cfg80211: Use 5MHz bandwidth when checking usable channels
mac80211: Update conf_is_ht() to work properly with 5/10MHz channels
include/net/cfg80211.h | 10 ++++++++++
include/net/mac80211.h | 4 +++-
include/uapi/linux/nl80211.h | 14 +++++++++++++-
net/wireless/chan.c | 10 ++++++++++
net/wireless/nl80211.c | 10 ++++++++++
net/wireless/reg.c | 22 +++++++++++++++-------
6 files changed, 61 insertions(+), 9 deletions(-)
--
1.8.5.1
Signed-off-by: Rostislav Lisovy <[email protected]>
---
net/wireless/nl80211.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 48040cd..8b40a3a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -606,6 +606,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.8.5.1
On Fri, 2014-03-07 at 18:31 +0100, Rostislav Lisovy wrote:
> On Fri, 2014-03-07 at 15:29 +0100, Johannes Berg wrote:
> > This is the part of the code that I was referring to before, you
> > should
> > skip these channels if (!large) to not break older tools with too much
> > data.
>
> The whole channel (not only these attributes) should be excluded if the
> 'split wiphy info' is not supported? I thought that reporting these
> attributes only 'if (large)' is a safe solution (except the userspace
> will be lacking some information).
The issue is that if all those channels are included, the data is
guaranteed to become too large, and nothing will be shown in those older
tools at all. So it's safer to just skip those channels that the old
tools won't be able to use anyway.
johannes
On Fri, 2014-03-07 at 15:29 +0100, Johannes Berg wrote:
> This is the part of the code that I was referring to before, you
> should
> skip these channels if (!large) to not break older tools with too much
> data.
The whole channel (not only these attributes) should be excluded if the
'split wiphy info' is not supported? I thought that reporting these
attributes only 'if (large)' is a safe solution (except the userspace
will be lacking some information).
Thanks;
Rostislav
Signed-off-by: Rostislav Lisovy <[email protected]>
---
include/net/cfg80211.h | 4 ++++
net/wireless/chan.c | 10 ++++++++++
2 files changed, 14 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index f5ecd6c..16f19e0 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -367,6 +367,10 @@ static inline enum nl80211_channel_type
cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
{
switch (chandef->width) {
+ case NL80211_CHAN_WIDTH_5:
+ return NL80211_CHAN_5MHZ;
+ case NL80211_CHAN_WIDTH_10:
+ return NL80211_CHAN_10MHZ;
case NL80211_CHAN_WIDTH_20_NOHT:
return NL80211_CHAN_NO_HT;
case NL80211_CHAN_WIDTH_20:
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 78559b5..0bcdd27 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -22,6 +22,14 @@ void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
chandef->center_freq2 = 0;
switch (chan_type) {
+ case NL80211_CHAN_5MHZ:
+ chandef->width = NL80211_CHAN_WIDTH_5;
+ chandef->center_freq1 = chan->center_freq;
+ break;
+ case NL80211_CHAN_10MHZ:
+ chandef->width = NL80211_CHAN_WIDTH_10;
+ chandef->center_freq1 = chan->center_freq;
+ break;
case NL80211_CHAN_NO_HT:
chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
chandef->center_freq1 = chan->center_freq;
@@ -531,12 +539,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.8.5.1
On Fri, 2014-03-07 at 14:37 +0100, Rostislav Lisovy wrote:
> Signed-off-by: Rostislav Lisovy <[email protected]>
> ---
> include/net/cfg80211.h | 4 ++++
> net/wireless/chan.c | 10 ++++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index f5ecd6c..16f19e0 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -367,6 +367,10 @@ static inline enum nl80211_channel_type
> cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
> {
> switch (chandef->width) {
> + case NL80211_CHAN_WIDTH_5:
> + return NL80211_CHAN_5MHZ;
NACK, this isn't needed, just fix the code to not use channel_type.
johannes
These attributes are used to report back to userspace
the information about the bandwidth allowed in
a particular channel
Signed-off-by: Rostislav Lisovy <[email protected]>
---
include/uapi/linux/nl80211.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 8d0e319..b5b5600 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2304,6 +2304,12 @@ 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.
+ * - this still allows 10 MHz and 5 MHz operation
+ * @NL80211_FREQUENCY_ATTR_NO_10MHZ: 10 MHz operation is not allowed
+ * on this channel in current regulatory domain.
+ * - this still allows 20 MHz and 5 MHz operation
* @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
* currently defined
* @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
@@ -2322,6 +2328,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,
--
1.8.5.1
Ditto here, no new channel_type please.
johannes
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.8.5.1
Since channels with frequencies ranging from 5850 to 5925
are used with 5/10 MHz channels according to IEEE 802.11p,
we need a way how to keep the information about the forbidden
bandwidths.
Signed-off-by: Rostislav Lisovy <[email protected]>
---
include/net/cfg80211.h | 6 ++++++
1 file changed, 6 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 \
--
1.8.5.1
Current code checks if the 20MHz BW 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 BW to check is 5MHz. If 5MHz is greater than
the maximum bandwidth supported by the channel, the channel is
disabled. If it is smaller than the maximum BW, the channel is
used and the flags are set according to the BW supported 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 9b897fc..582e623 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 = ®_rule->power_rule;
freq_range = ®_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 = ®_rule->power_rule;
freq_range = ®_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.8.5.1
Signed-off-by: Rostislav Lisovy <[email protected]>
---
net/wireless/nl80211.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4fe2e6e..48040cd 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1843,6 +1843,8 @@ static int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
switch (chantype) {
+ case NL80211_CHAN_5MHZ:
+ case NL80211_CHAN_10MHZ:
case NL80211_CHAN_NO_HT:
case NL80211_CHAN_HT20:
case NL80211_CHAN_HT40PLUS:
@@ -2213,6 +2215,8 @@ static int nl80211_send_chandef(struct sk_buff *msg,
chandef->chan->center_freq))
return -ENOBUFS;
switch (chandef->width) {
+ case NL80211_CHAN_WIDTH_5:
+ case NL80211_CHAN_WIDTH_10:
case NL80211_CHAN_WIDTH_20_NOHT:
case NL80211_CHAN_WIDTH_20:
case NL80211_CHAN_WIDTH_40:
--
1.8.5.1
On Fri, 2014-03-07 at 14:37 +0100, Rostislav Lisovy wrote:
> These attributes are used to report back to userspace
> the information about the bandwidth allowed in
> a particular channel
> + NL80211_FREQUENCY_ATTR_NO_20MHZ,
> + NL80211_FREQUENCY_ATTR_NO_10MHZ,
This makes some sense, but I think such channels should be excluded by
default from the channel list in nl80211.c because they will break old
tools - you should include them only in the 'split wiphy info' case.
johannes
These attributes are necessary to provide a way how to
set a channel type of '5MHz' or '10MHz' from userspace.
This is necessary for future 802.11p implementation.
Signed-off-by: Rostislav Lisovy <[email protected]>
---
include/uapi/linux/nl80211.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 91054fd..8d0e319 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2891,12 +2891,16 @@ enum nl80211_ac {
* below the control channel
* @NL80211_CHAN_HT40PLUS: HT40 channel, secondary channel
* above the control channel
+ * @NL80211_CHAN_5MHZ: normal, 5 MHz bandwidth
+ * @NL80211_CHAN_10MHZ: normal, 10 MHz bandwidth
*/
enum nl80211_channel_type {
NL80211_CHAN_NO_HT,
NL80211_CHAN_HT20,
NL80211_CHAN_HT40MINUS,
- NL80211_CHAN_HT40PLUS
+ NL80211_CHAN_HT40PLUS,
+ NL80211_CHAN_5MHZ,
+ NL80211_CHAN_10MHZ,
};
/**
--
1.8.5.1
On Fri, 2014-03-07 at 14:37 +0100, Rostislav Lisovy wrote:
> Since channels with frequencies ranging from 5850 to 5925
> are used with 5/10 MHz channels according to IEEE 802.11p,
> we need a way how to keep the information about the forbidden
> bandwidths.
I see no reason to have this as a separate patch with the previous one.
johannes
On Fri, 2014-03-07 at 14:37 +0100, Rostislav Lisovy wrote:
> These attributes are necessary to provide a way how to
> set a channel type of '5MHz' or '10MHz' from userspace.
> This is necessary for future 802.11p implementation.
> enum nl80211_channel_type {
> NL80211_CHAN_NO_HT,
> NL80211_CHAN_HT20,
> NL80211_CHAN_HT40MINUS,
> - NL80211_CHAN_HT40PLUS
> + NL80211_CHAN_HT40PLUS,
> + NL80211_CHAN_5MHZ,
> + NL80211_CHAN_10MHZ,
I think that this is completely unnecessary since all APIs that take
channel types also take channel width with the new chandef framework.
johannes
On Fri, 2014-03-07 at 14:37 +0100, Rostislav Lisovy wrote:
> + 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;
This is the part of the code that I was referring to before, you should
skip these channels if (!large) to not break older tools with too much
data.
johannes