cfg80211: VHT regulatory
RFC 1/1 cfg80211: VHT regulatory
VHT (11ac) regulatory new design. VHT channel center freq, bandwidth and primary channel are used to decide if that channel config is permitted in current regulatory domain.
---
include/net/cfg80211.h | 36 ++++++++++++++++ net/wireless/reg.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 0 deletions(-)
include/net/cfg80211.h +36 -0
@@ -83,6 +83,25 @@ enum ieee80211_band { };/** +* enum ieee80211_chan_width - channel bandwidths +* +* @IEEE80211_CHAN_WIDTH_20MHZ_NOHT: 20 MHz chan bandwidth No HT +* @IEEE80211_CHAN_WIDTH_20MHZ: 20 MHz chan bandwidth +* @IEEE80211_CHAN_WIDTH_40MHZ: 40 MHz chan bandwidth +* @IEEE80211_CHAN_WIDTH_80MHZ: 80 MHz chan bandwidth +* @IEEE80211_CHAN_WIDTH_160MHZ: 160 MHz chan bandwidth +* @IEEE80211_CHAN_WIDTH_80P80MHZ: 80+80 MHz chan bandwidth +*/ +enum ieee80211_chan_width { +IEEE80211_CHAN_WIDTH_20MHZ_NOHT , +IEEE80211_CHAN_WIDTH_20MHZ , +IEEE80211_CHAN_WIDTH_40MHZ , +IEEE80211_CHAN_WIDTH_80MHZ , +IEEE80211_CHAN_WIDTH_160MHZ , +IEEE80211_CHAN_WIDTH_80P80MHZ +}; + +/** * enum ieee80211_channel_flags - channel flags * * Channel flags set by the regulatory control code.
@@ -144,6 +163,23 @@ struct ieee80211_channel { };/** +* struct ieee80211_channel_config - channel config definition +* +* This structure describes channel configuration +* +* @chan_width1: channel bandwidth +* @center_freq1: center frequency of 1 st frequency segment +* @center_freq2: center frequency of 2 nd frequency segment +* @prim_chan_freq: primary channel frequency +*/ +struct ieee80211_channel_config { +enum ieee80211_chan_width chan_width; +u16 center_freq1; +u16 center_freq2; +u16 prim_chan_freq; +}; + +/** * enum ieee80211_rate_flags - rate flags * * Hardware/specification flags for rates. These are structured
net/wireless/reg.c +104 -0
110 lines not on this page · raw message
Johannes Berg
maintainerQuoted 3 lines · Mahesh Palivela
include/net/cfg80211.h | 36 ++++++++++++++++ net/wireless/reg.c | 104++++++++++++++++++++++++++++++++++++++++++++++++
Even for an RFC patch it'd be nice to not mangle it :)
Quoted 8 lines
/**
+ * structieee80211_channel_config- channel config definition
+ *
+ * This structure describes channel configuration
+ *
+ * @chan_width1: channel bandwidth
+ * @center_freq1: center frequency of 1 st frequency segment
+ * @center_freq2: center frequency of 2 nd frequency segment
I'd add a note here that the 2nd is only used for 80+80
Quoted 1 line
+ * @prim_chan_freq: primary channel frequency
You said you wanted to change it to be like the standard, that's not how it works though, the standard says (copying from your email)
dot11CurrentPrimaryChannel
Denotes the location of the primary 20 MHz channel. Valid range is 1 to 200.
Quoted 10 lines
net/wireless/reg.c +10
-0+static bool reg_sec_chans_permitted (struct wiphy *wiphy, +u32 center_freq, +u32 bw_khz) +{ +struct ieee80211_channel *chan; +u32 left_end_freq, right_end_freq; + +if (center_freq ==0 || bw_khz ==0 ) +return false; +
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1146
Quoted 10 lines
net/wireless/reg.c +10
-0+/* find left and right arms of center freq */ + left_end_freq = center_freq - (bw_khz/2 ); + right_end_freq = center_freq + (bw_khz/2 ); + +/* left_end_freq and right_end_freq are edge of left and right +* channels. Get center freq of left and right channels +* by subtracting 10 MHZ from each of them. +*/ + left_end_freq -=MHZ_TO_KHZ (10 ); + right_end_freq -=MHZ_TO_KHZ (10 );
Hmm? Shouldn't you add 10 MHz to the lower end, if anything?
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1159
Quoted 12 lines
net/wireless/reg.c +12
-0+/* find out all possible secondary channels */ +while (left_end_freq < right_end_freq) { + chan =ieee80211_get_channel (wiphy, left_end_freq); +if (chan ==NULL || + chan->flags &IEEE80211_CHAN_DISABLED ) { +return false; + } + left_end_freq -=MHZ_TO_KHZ (20 ); + } + +return true; +}
Overall I'm not sure I'd go to the channel structs for this function at all though, I'd rather go to the regulatory definition, I think that would make more sense.
OTOH, this may be needed to keep the ability for the driver to disable certain channels etc.
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1168
Quoted 8 lines
net/wireless/reg.c +8
-0+bool reg_chan_use_permitted (struct wiphy *wiphy, +struct ieee80211_channel_config *chan_config, +const struct ieee80211_regdomain *regd) +{ +int r; +u32 desired_bw_khz =MHZ_TO_KHZ (20 ); +const struct ieee80211_reg_rule *reg_rule =NULL ; +const struct ieee80211_freq_range *freq_range =NULL ;
Don't initialize to values you don't need.
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1190
Quoted 12 lines
net/wireless/reg.c +10
-0+bool ret; + +assert_reg_lock (); + +// get chan BW from config +switch (chan_config->chan_width) { +case IEEE80211_CHAN_WIDTH_20MHZ_NOHT : +case IEEE80211_CHAN_WIDTH_20MHZ : +case IEEE80211_CHAN_WIDTH_80P80MHZ : + desired_bw_khz =MHZ_TO_KHZ (160 );
This is not true at all.
Review
Quoted 2 lines
(quoted diff) +2
-0+ break; + }
Missing a default case with a warning/error return?
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1205
Quoted 12 lines
net/wireless/reg.c +12
-0+ r =freq_reg_info_regd (wiphy, + chan_config->prim_chan_freq, + desired_bw_khz, + ®_rule, + regd); + +if (r) { +REG_DBG_PRINT ("Disabling freq %d MHz as custom " +"regd has no rule that fits a %d MHz " +"wide channel\n" , + chan_config->prim_chan_freq, +KHZ_TO_MHZ (desired_bw_khz));
That's not a good message in this context now. Clearly it came from the channel flag settings, but now we don't do that so ...
johannes
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Mahesh Palivela
net/wireless/reg.c | 104++++++++++++++++++++++++++++++++++++++++++++++++
Even for an RFC patch it'd be nice to not mangle it :)
My email text editor issue. wrapping more than 80 char.
Quoted 4 lines
Quoted 1 line
+ * @center_freq2: center frequency of 2 nd frequency segment
I'd add a note here that the 2nd is only used for 80+80
Sure
Quoted 9 lines
Quoted 1 line
+ * @prim_chan_freq: primary channel frequency
You said you wanted to change it to be like the standard, that's not how it works though, the standard says (copying from your email)
dot11CurrentPrimaryChannel
Denotes the location of the primary 20 MHz channel. Valid range is 1 to 200.
From that number we derive freq in kHZ. Even center freq also mentioned as number only. we need to use formula to derive freq in kHZ. Thought better hostapd convert numbers to freq value.
Quoted 5 lines
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1146
Quoted 2 lines
net/wireless/reg.c +2
-0+ left_end_freq -=MHZ_TO_KHZ (10 ); + right_end_freq -=MHZ_TO_KHZ (10 );Hmm? Shouldn't you add 10 MHz to the lower end, if anything?
Nope. For example 80 MHz BW, take channel 36, 40, 44 and 48. Center freq value is chan 42. so left end will be chan 34 and right end will be chan 50. so I am subtracting 10MHz on both ends to get chan 36 and 48 Hope I made it clear.
Quoted 8 lines
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1150
Quoted 3 lines
net/wireless/reg.c +3
-0+/* find out all possible secondary channels */ +while (left_end_freq < right_end_freq) { + chan =ieee80211_get_channel (wiphy, left_end_freq);Overall I'm not sure I'd go to the channel structs for this function at all though, I'd rather go to the regulatory definition, I think that would make more sense.
Quoted 8 lines
OTOH, this may be needed to keep the ability for the driver to disable certain channels etc.
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1168
Quoted 2 lines
net/wireless/reg.c +2
-0+const struct ieee80211_reg_rule *reg_rule =NULL ; +const struct ieee80211_freq_range *freq_range =NULL ;Don't initialize to values you don't need.
Sure, will remove inits.
Quoted 5 lines
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1190
Quoted 2 lines
net/wireless/reg.c +2
-0+case IEEE80211_CHAN_WIDTH_80P80MHZ : + desired_bw_khz =MHZ_TO_KHZ (160 );This is not true at all.
ok, will change to 80 MHz
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ break; + }Missing a default case with a warning/error return?
ok, will add default.
Quoted 7 lines
Quoted 7 lines
net/wireless/reg.c +7
-0+ r =freq_reg_info_regd (wiphy, + chan_config->prim_chan_freq, + desired_bw_khz, + ®_rule, + regd); + +if (r) {
Quoted 8 lines
net/wireless/reg.c static void reg_process_beacons(struct wiphy *wiphy) · line 1205
Quoted 5 lines
net/wireless/reg.c +5
-0+REG_DBG_PRINT ("Disabling freq %d MHz as custom " +"regd has no rule that fits a %d MHz " +"wide channel\n" , + chan_config->prim_chan_freq, +KHZ_TO_MHZ (desired_bw_khz));That's not a good message in this context now. Clearly it came from the channel flag settings, but now we don't do that so ...
OK. I will modify REG_DBG_PRINT()
Quoted 3 lines
johannes
Hi Mahesh,
Quoted 7 lines · Mahesh Palivela
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Mahesh Palivela
net/wireless/reg.c +2
-0+ left_end_freq -=MHZ_TO_KHZ (10 ); + right_end_freq -=MHZ_TO_KHZ (10 );
Quoted 6 lines
Quoted 2 lines
Hmm? Shouldn't you add 10 MHz to the lower end, if anything?
Nope. For example 80 MHz BW, take channel 36, 40, 44 and 48. Center freq value is chan 42. so left end will be chan 34 and right end will be chan 50. so I am subtracting 10MHz on both ends to get chan 36 and 48
Surely if you subtract 10MHz from chan 34, you'd end up with chan 32, right?
Thanks,
Signature · 5 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/ .Plan: http://sites.google.com/site/juliancalaby/
Quoted 4 lines · Julian Calaby
Hi Mahesh,
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Hmm? Shouldn't you add 10 MHz to the lower end, if anything?
Nope. For example 80 MHz BW, take channel 36, 40, 44 and 48. Center freq value is chan 42. so left end will be chan 34 and right end will be chan 50. so I am subtracting 10MHz on both ends to get chan 36 and 48
Surely if you subtract 10MHz from chan 34, you'd end up with chan 32, right?
Very bad. I am wrong. It should be + 10 MHz. Thanks for quick response Julian.
Quoted 3 lines
Thanks,