linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions
@ 2013-11-13 17:54 Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 1/5] cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere Luis R. Rodriguez
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2013-11-13 17:54 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, 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.

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(-)

-- 
1.8.4.rc3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/5] cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere
  2013-11-13 17:54 [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Luis R. Rodriguez
@ 2013-11-13 17:54 ` Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 2/5] cfg80211: intersection dfs regions when intersecting regdomains Luis R. Rodriguez
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2013-11-13 17:54 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Luis R. Rodriguez

u8 was used in some other places, just stick to the enum,
this forces us to express the values that are expected.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 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(-)

diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 7e49cf6..ab0bee0 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -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[];
 };
 
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3f8c364..c33b374 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -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])
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 067c1f6..2796b62 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -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;
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index b4076ba..cc4c2c0 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -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);
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/5] cfg80211: intersection dfs regions when intersecting regdomains
  2013-11-13 17:54 [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 1/5] cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere Luis R. Rodriguez
@ 2013-11-13 17:54 ` Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 3/5] cfg80211: distinguish unset DFS region from unknown Luis R. Rodriguez
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2013-11-13 17:54 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Luis R. Rodriguez

Only allow DFS to be set if the DFS regions agree.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 net/wireless/reg.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 2796b62..068cb40 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -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;
 }
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/5] cfg80211: distinguish unset DFS region from unknown
  2013-11-13 17:54 [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 1/5] cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 2/5] cfg80211: intersection dfs regions when intersecting regdomains Luis R. Rodriguez
@ 2013-11-13 17:54 ` Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 4/5] cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper Luis R. Rodriguez
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2013-11-13 17:54 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Luis R. Rodriguez

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 net/wireless/reg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 068cb40..740eccb 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -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;
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/5] cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper
  2013-11-13 17:54 [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Luis R. Rodriguez
                   ` (2 preceding siblings ...)
  2013-11-13 17:54 ` [PATCH 3/5] cfg80211: distinguish unset DFS region from unknown Luis R. Rodriguez
@ 2013-11-13 17:54 ` Luis R. Rodriguez
  2013-11-13 17:54 ` [PATCH 5/5] cfg80211: add reg_get_dfs_region() Luis R. Rodriguez
  2013-11-13 18:49 ` [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Johannes Berg
  5 siblings, 0 replies; 8+ messages in thread
From: Luis R. Rodriguez @ 2013-11-13 17:54 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Luis R. Rodriguez

This lets us later reuse the more generic reg_dfs_region_str().

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 net/wireless/reg.c | 41 ++++++++++++++++-------------------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 740eccb..ec54e1a 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -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);
 }
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/5] cfg80211: add reg_get_dfs_region()
  2013-11-13 17:54 [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Luis R. Rodriguez
                   ` (3 preceding siblings ...)
  2013-11-13 17:54 ` [PATCH 4/5] cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper Luis R. Rodriguez
@ 2013-11-13 17:54 ` Luis R. Rodriguez
  2013-11-13 18:49   ` Johannes Berg
  2013-11-13 18:49 ` [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Johannes Berg
  5 siblings, 1 reply; 8+ messages in thread
From: Luis R. Rodriguez @ 2013-11-13 17:54 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, 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.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 net/wireless/reg.c | 29 +++++++++++++++++++++++++++++
 net/wireless/reg.h |  1 +
 2 files changed, 30 insertions(+)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index ec54e1a..4bfbeaa 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -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)
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index cc4c2c0..02bd8f4 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -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);
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] cfg80211: add reg_get_dfs_region()
  2013-11-13 17:54 ` [PATCH 5/5] cfg80211: add reg_get_dfs_region() Luis R. Rodriguez
@ 2013-11-13 18:49   ` Johannes Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Berg @ 2013-11-13 18:49 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: linux-wireless

On Wed, 2013-11-13 at 18:54 +0100, Luis R. Rodriguez wrote:
> 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions
  2013-11-13 17:54 [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Luis R. Rodriguez
                   ` (4 preceding siblings ...)
  2013-11-13 17:54 ` [PATCH 5/5] cfg80211: add reg_get_dfs_region() Luis R. Rodriguez
@ 2013-11-13 18:49 ` Johannes Berg
  5 siblings, 0 replies; 8+ messages in thread
From: Johannes Berg @ 2013-11-13 18:49 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: linux-wireless

On Wed, 2013-11-13 at 18:54 +0100, Luis R. Rodriguez wrote:
> 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-11-13 18:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-13 17:54 [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Luis R. Rodriguez
2013-11-13 17:54 ` [PATCH 1/5] cfg80211: use enum nl80211_dfs_regions for dfs_region everywhere Luis R. Rodriguez
2013-11-13 17:54 ` [PATCH 2/5] cfg80211: intersection dfs regions when intersecting regdomains Luis R. Rodriguez
2013-11-13 17:54 ` [PATCH 3/5] cfg80211: distinguish unset DFS region from unknown Luis R. Rodriguez
2013-11-13 17:54 ` [PATCH 4/5] cfg80211: replace print_dfs_region() with reg_dfs_region_str() helper Luis R. Rodriguez
2013-11-13 17:54 ` [PATCH 5/5] cfg80211: add reg_get_dfs_region() Luis R. Rodriguez
2013-11-13 18:49   ` Johannes Berg
2013-11-13 18:49 ` [PATCH 0/5] cfg80211: few updates prior to quiesce and exporting DFS regions Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).