Skip to contentSkip to conversation

cfg80211: few updates prior to quiesce and exporting DFS regions

PATCH In review Luis R. Rodriguez 2 participants 8 messages Nov 13, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 7e49cf6..ab0bee0 100644
@@ -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
index 3f8c364..c33b374 100644
@@ -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
index 067c1f6..2796b62 100644
@@ -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
index b4076ba..cc4c2c0 100644
@@ -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
#2 lore raw

PATCH 2/5 cfg80211: intersection dfs regions when intersecting regdomains

In reply to Luis R. Rodriguez

Only 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
index 2796b62..068cb40 100644
@@ -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
#3 lore raw

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
index 068cb40..740eccb 100644
@@ -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
#4 lore raw

PATCH 4/5 cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper

In reply to Luis R. Rodriguez

This 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
index 740eccb..ec54e1a 100644
@@ -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
#5 lore raw

PATCH 5/5 cfg80211: add reg_get_dfs_region()

In reply to Luis R. Rodriguez

This 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
index ec54e1a..4bfbeaa 100644
@@ -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
index cc4c2c0..02bd8f4 100644
@@ -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
maintainer
#6 lore raw

Re: [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_region is 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

maintainer
#7 lore raw
In reply to Luis R. Rodriguez
Quoted 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