cfg80211: few updates prior to quiesce and exporting DFS regions
Subsystems (2)
cover cfg80211: few updates prior to quiesce and exporting DFS regions
Here's a few simple updates for cfg80211 regulatory to help with the next patches I'll post as RFC's. Nothing major here.
Luis R. Rodriguez (5):
cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere
cfg80211: intersection dfs regions when intersecting regdomains
cfg80211: distinguish unset DFS region from unknown
cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper
cfg80211: add reg_get_dfs_region()
include/net/regulatory.h | 4 +-- net/wireless/nl80211.c | 2 +- net/wireless/reg.c | 85 +++++++++++++++++++++++++++++++++++------------- net/wireless/reg.h | 3 +- 4 files changed, 67 insertions(+), 27 deletions(-)
Signature · 1 line
1.8.4.rc3
PATCH 1/5 cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere
u8 was used in some other places, just stick to the enum, this forces us to express the values that are expected.
--- include/net/regulatory.h | 4 ++-- net/wireless/nl80211.c | 2 +- net/wireless/reg.c | 4 ++-- net/wireless/reg.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
include/net/regulatory.h +2 -2
@@ -79,7 +79,7 @@ struct regulatory_request {enum nl80211_reg_initiator initiator;enum nl80211_user_reg_hint_type user_reg_hint_type;char alpha2[2 ]; -u8 dfs_region; +enum nl80211_dfs_regions dfs_region;bool intersect;bool processed;enum environment_cap country_ie_env;
@@ -157,7 +157,7 @@ struct ieee80211_regdomain {struct rcu_head rcu_head;u32 n_reg_rules;char alpha2[2 ]; -u8 dfs_region; +enum nl80211_dfs_regions dfs_region;struct ieee80211_reg_rule reg_rules[]; };
net/wireless/nl80211.c +1 -1
@@ -5079,7 +5079,7 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)char *alpha2 =NULL ;int rem_reg_rules =0 , r =0 ;u32 num_rules =0 , rule_idx =0 , size_of_regd; -u8 dfs_region =0 ; +enum nl80211_dfs_regions dfs_region =NL80211_DFS_UNSET ;struct ieee80211_regdomain *rd =NULL ;if (!info->attrs[NL80211_ATTR_REG_ALPHA2 ])
net/wireless/reg.c +2 -2
@@ -2115,7 +2115,7 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd) } } -bool reg_supported_dfs_region (u8 dfs_region) +bool reg_supported_dfs_region (enum nl80211_dfs_regions dfs_region) {switch (dfs_region) {case NL80211_DFS_UNSET :
@@ -2130,7 +2130,7 @@ bool reg_supported_dfs_region(u8 dfs_region) } } -static void print_dfs_region (u8 dfs_region) +static void print_dfs_region (enum nl80211_dfs_regions dfs_region) {if (!dfs_region)return ;
net/wireless/reg.h +1 -1
@@ -20,7 +20,7 @@ extern const struct ieee80211_regdomain __rcu *cfg80211_regdomain;bool reg_is_valid_request (const char *alpha2);bool is_world_regdom (const char *alpha2); -bool reg_supported_dfs_region (u8 dfs_region); +bool reg_supported_dfs_region (enum nl80211_dfs_regions dfs_region);int regulatory_hint_user (const char *alpha2,enum nl80211_user_reg_hint_type user_reg_hint_type);
Signature · 1 line
1.8.4.rc3
PATCH 2/5 cfg80211: intersection dfs regions when intersecting regdomains
In reply to Luis R. RodriguezOnly allow DFS to be set if the DFS regions agree.
--- net/wireless/reg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/wireless/reg.c +16 -0
@@ -571,6 +571,20 @@ static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range, }/* +* Later on we can perhaps use the more restrictive DFS +* region but we don't have information for that yet so +* for now simply disallow conflicts. +*/ +static enum nl80211_dfs_regions +reg_intersect_dfs_region (const enum nl80211_dfs_regions dfs_region1, +const enum nl80211_dfs_regions dfs_region2) +{ +if (dfs_region1 != dfs_region2) +return NL80211_DFS_UNSET ; +return dfs_region1; +} + +/* * Helper for regdom_intersect(), this does the real * mathematical intersection fun */
@@ -701,6 +715,8 @@ regdom_intersect(const struct ieee80211_regdomain *rd1, rd->n_reg_rules = num_rules; rd->alpha2[0 ] ='9' ; rd->alpha2[1 ] ='8' ; + rd->dfs_region =reg_intersect_dfs_region (rd1->dfs_region, + rd2->dfs_region);return rd; }
Signature · 1 line
1.8.4.rc3
PATCH 3/5 cfg80211: distinguish unset DFS region from unknown
In reply to Luis R. Rodriguez--- net/wireless/reg.c | 3 +++ 1 file changed, 3 insertions(+)
net/wireless/reg.c +3 -0
@@ -2152,6 +2152,9 @@ static void print_dfs_region(enum nl80211_dfs_regions dfs_region)return ;switch (dfs_region) { +case NL80211_DFS_UNSET : +pr_info (" DFS Master region unset" ); +break ;case NL80211_DFS_FCC :pr_info (" DFS Master region FCC" );break ;
Signature · 1 line
1.8.4.rc3
PATCH 4/5 cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper
In reply to Luis R. RodriguezThis lets us later reuse the more generic reg_dfs_region_str().
--- net/wireless/reg.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-)
net/wireless/reg.c +16 -25
@@ -120,6 +120,21 @@ static const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy)return rtnl_dereference (wiphy->regd); } +static const char *reg_dfs_region_str (enum nl80211_dfs_regions dfs_region) +{ +switch (dfs_region) { +case NL80211_DFS_UNSET : +return "unset" ; +case NL80211_DFS_FCC : +return "FCC" ; +case NL80211_DFS_ETSI : +return "ETSI" ; +case NL80211_DFS_JP : +return "JP" ; + } +return "Unknown" ; +} +static void rcu_free_regdom (const struct ieee80211_regdomain *r) {if (!r)
@@ -2146,30 +2161,6 @@ bool reg_supported_dfs_region(enum nl80211_dfs_regions dfs_region) } } -static void print_dfs_region (enum nl80211_dfs_regions dfs_region) -{ -if (!dfs_region) -return ; - -switch (dfs_region) { -case NL80211_DFS_UNSET : -pr_info (" DFS Master region unset" ); -break ; -case NL80211_DFS_FCC : -pr_info (" DFS Master region FCC" ); -break ; -case NL80211_DFS_ETSI : -pr_info (" DFS Master region ETSI" ); -break ; -case NL80211_DFS_JP : -pr_info (" DFS Master region JP" ); -break ; -default : -pr_info (" DFS Master region Unknown" ); -break ; - } -} -static void print_regdomain (const struct ieee80211_regdomain *rd) {struct regulatory_request *lr =get_last_request ();
@@ -2201,7 +2192,7 @@ static void print_regdomain(const struct ieee80211_regdomain *rd) } } -print_dfs_region (rd->dfs_region); +pr_info (" DFS Master region: %s" ,reg_dfs_region_str (rd->dfs_region));print_rd_rules (rd); }
Signature · 1 line
1.8.4.rc3
PATCH 5/5 cfg80211: add reg_get_dfs_region()
In reply to Luis R. RodriguezThis can be used outside of the regulatory context for any checks on the DFS region. The central cfg80211 dfs_region is always used and if it does not match with the wiphy a debug print is issued.
--- net/wireless/reg.c | 29 +++++++++++++++++++++++++++++ net/wireless/reg.h | 1 + 2 files changed, 30 insertions(+)
net/wireless/reg.c +29 -0
@@ -135,6 +135,35 @@ static const char *reg_dfs_region_str(enum nl80211_dfs_regions dfs_region)return "Unknown" ; } +enum nl80211_dfs_regions reg_get_dfs_region (struct wiphy *wiphy) +{ +const struct ieee80211_regdomain *regd =NULL ; +const struct ieee80211_regdomain *wiphy_regd =NULL ; + +ASSERT_RTNL (); + + regd =get_cfg80211_regdom (); +if (!wiphy) + goto out; + + wiphy_regd =get_wiphy_regdom (wiphy); +if (!wiphy_regd) + goto out; + +if (wiphy_regd->dfs_region == regd->dfs_region) + goto out; + +REG_DBG_PRINT ("%s: device specific dfs_region " +"(%s) disagrees with cfg80211's " +"central dfs_region (%s)\n" , +dev_name (&wiphy->dev), +reg_dfs_region_str (wiphy_regd->dfs_region), +reg_dfs_region_str (regd->dfs_region)); + +out: +return regd->dfs_region; +} +static void rcu_free_regdom (const struct ieee80211_regdomain *r) {if (!r)
net/wireless/reg.h +1 -0
@@ -21,6 +21,7 @@ extern const struct ieee80211_regdomain __rcu *cfg80211_regdomain;bool reg_is_valid_request (const char *alpha2);bool is_world_regdom (const char *alpha2);bool reg_supported_dfs_region (enum nl80211_dfs_regions dfs_region); +enum nl80211_dfs_regions reg_get_dfs_region (struct wiphy *wiphy);int regulatory_hint_user (const char *alpha2,enum nl80211_user_reg_hint_type user_reg_hint_type);
Signature · 1 line
1.8.4.rc3
Johannes Berg
maintainerRe: [PATCH 5/5] cfg80211: add reg_get_dfs_region()
Quoted 3 lines · Luis R. Rodriguez
This can be used outside of the regulatory context for any checks on the DFS region. The central cfg80211
dfs_regionis always used and if it does not match with the wiphy a debug print is issued.
I'll leave this until we have a user.
johannes
Johannes Berg
maintainerQuoted 2 lines · Luis R. Rodriguez
Here's a few simple updates for cfg80211 regulatory to help with the next patches I'll post as RFC's. Nothing major here.
Applied 1-4.
johannes