linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: johannes@sipsolutions.net
Cc: janusz.dziedzic@tieto.com, j@w1.fi, sunitb@qca.qualcomm.com,
	rsunki@qca.qualcomm.com, linux-wireless@vger.kernel.org,
	"Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Subject: [RFC 3/5] cfg80211: add regulatory quiescing support
Date: Wed, 13 Nov 2013 19:12:57 +0100	[thread overview]
Message-ID: <1384366379-25301-4-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1384366379-25301-1-git-send-email-mcgrof@do-not-panic.com>

This quiesces devices when appropriate to ensure that
regulatory domain updates take effect and avoid having
devices initiate radiation when they should not.

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

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index e5935c2..3036093 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1287,12 +1287,65 @@ static void reg_call_notifier(struct wiphy *wiphy,
 		wiphy->reg_notifier(wiphy, request);
 }
 
+static void wiphy_regulatory_quiesce_all(struct wiphy *wiphy)
+{
+	struct cfg80211_registered_device *rdev;
+
+	rdev = wiphy_to_dev(wiphy);
+	if (!rdev)
+		return;
+
+	cfg80211_leave_all(rdev);
+}
+
+static void wiphy_regulatory_quiesce_skip_wdev(struct wiphy *wiphy,
+					       struct regulatory_request *lr)
+{
+	struct cfg80211_registered_device *rdev;
+	struct wiphy *last_wiphy = NULL;
+	struct wireless_dev *wdev;
+
+	rdev = wiphy_to_dev(wiphy);
+	if (!rdev)
+		return;
+
+	last_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx);
+	if (last_wiphy != wiphy) {
+		cfg80211_leave_all(rdev);
+		return;
+	}
+
+	list_for_each_entry(wdev, &rdev->wdev_list, list)
+		if (lr->wdev != wdev)
+			cfg80211_leave(rdev, wdev);
+}
+
+static void wiphy_regulatory_quiesce(struct wiphy *wiphy,
+				     struct regulatory_request *lr)
+{
+	switch (lr->initiator) {
+	case NL80211_REGDOM_SET_BY_CORE:
+		return;
+	case NL80211_REGDOM_SET_BY_USER:
+		wiphy_regulatory_quiesce_all(wiphy);
+		return;
+	case NL80211_REGDOM_SET_BY_DRIVER:
+		wiphy_regulatory_quiesce_all(wiphy);
+		return;
+	case NL80211_REGDOM_SET_BY_COUNTRY_IE:
+		wiphy_regulatory_quiesce_skip_wdev(wiphy, lr);
+		return;
+	}
+}
+
 static void wiphy_update_regulatory(struct wiphy *wiphy,
 				    enum nl80211_reg_initiator initiator)
 {
 	enum ieee80211_band band;
 	struct regulatory_request *lr = get_last_request();
 
+	wiphy_regulatory_quiesce(wiphy, lr);
+
 	if (ignore_reg_update(wiphy, initiator)) {
 		/*
 		 * Regulatory updates set by CORE are ignored for custom
-- 
1.8.4.rc3


  parent reply	other threads:[~2013-11-13 18:13 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13 18:12 [RFC 0/5] cfg80211: regulatory quiescing and exporting DFS regions Luis R. Rodriguez
2013-11-13 18:12 ` [RFC 1/5] cfg80211: pass the wdev on the country IE regulatory hint Luis R. Rodriguez
2013-11-13 21:20   ` Johannes Berg
2013-11-14 14:05     ` Luis R. Rodriguez
2013-11-14 14:02       ` Johannes Berg
2013-11-14 15:12         ` Luis R. Rodriguez
2013-11-14 15:05           ` Johannes Berg
2013-11-14 15:21             ` Luis R. Rodriguez
2013-11-15 16:28               ` Luis R. Rodriguez
2013-11-13 18:12 ` [RFC 2/5] cfg80211: make cfg80211_leave_all() available outside of sysfs Luis R. Rodriguez
2013-11-13 18:12 ` Luis R. Rodriguez [this message]
2013-11-13 21:22   ` [RFC 3/5] cfg80211: add regulatory quiescing support Johannes Berg
2013-11-14 14:11     ` Luis R. Rodriguez
2013-11-14 14:44       ` Johannes Berg
2013-11-14 15:18         ` Luis R. Rodriguez
2013-11-25 15:59           ` Johannes Berg
2014-01-24 23:35             ` Luis R. Rodriguez
2014-01-24 23:37               ` Johannes Berg
2013-11-25 15:59           ` Johannes Berg
2013-11-13 18:12 ` [RFC 4/5] cfg80211: add DFS region capability support Luis R. Rodriguez
2013-11-13 21:28   ` Johannes Berg
2013-11-14 14:31     ` Luis R. Rodriguez
2013-11-14 14:48       ` Johannes Berg
2013-11-14 15:33         ` Luis R. Rodriguez
2013-11-14 15:29           ` Johannes Berg
2013-11-14 15:34             ` Luis R. Rodriguez
2013-11-14 16:13               ` Simon Wunderlich
2013-11-15 12:05                 ` Luis R. Rodriguez
2013-11-13 18:12 ` [RFC 5/5] cfg80211: DFS check dfs_region before usage Luis R. Rodriguez
2013-11-13 21:29   ` Johannes Berg
2013-11-14 10:15     ` Janusz Dziedzic
2013-11-14 11:52       ` Janusz Dziedzic
2013-11-14 14:46         ` Luis R. Rodriguez
2013-11-15  9:37           ` Janusz Dziedzic
2013-11-15 12:01             ` Luis R. Rodriguez
2013-11-14 14:35       ` Luis R. Rodriguez
2013-11-14 14:33     ` Luis R. Rodriguez
2013-11-13 18:48 ` [RFC 0/5] cfg80211: regulatory quiescing and exporting DFS regions Johannes Berg
2013-11-13 18:57   ` Luis R. Rodriguez
2013-11-13 19:12     ` Johannes Berg
2013-11-13 19:13     ` Johannes Berg
2013-11-14 14:49       ` Luis R. Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384366379-25301-4-git-send-email-mcgrof@do-not-panic.com \
    --to=mcgrof@do-not-panic.com \
    --cc=j@w1.fi \
    --cc=janusz.dziedzic@tieto.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rsunki@qca.qualcomm.com \
    --cc=sunitb@qca.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).