linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bernhard Schmidt <bernhard.schmidt@saxnet.de>
To: linux-wireless@vger.kernel.org
Cc: lrodriguez@atheros.com, nbd@openwrt.org, dubowoj@neratec.com,
	zefir.kurtisi@neratec.com, simon.wunderlich@saxnet.de
Subject: [PATCH 9/9] [cfg80211] interference reporting
Date: Mon, 28 Feb 2011 17:51:46 +0100	[thread overview]
Message-ID: <201102281751.47250.bernhard.schmidt@saxnet.de> (raw)
In-Reply-To: <201102281740.37036.bernhard.schmidt@saxnet.de>

Enable drivers to report interference. Same functionality is
available through debugfs for testing purposes.

Signed-off-by: Bernhard Schmidt <bernhard.schmidt@saxnet.de>
---
 include/net/cfg80211.h |    6 +++++
 net/wireless/core.c    |    2 +
 net/wireless/radar.c   |   51 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5636c0a..909bae3 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2723,6 +2723,12 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
 void cfg80211_cqm_pktloss_notify(struct net_device *dev,
 				 const u8 *peer, u32 num_packets, gfp_t gfp);
 
+/**
+ * cfg80211_radar_interference - report radar interference.
+ * @freq: the affected channel frequency
+ */
+int cfg80211_radar_interference(u16 freq);
+
 /* Logging, debugging and troubleshooting/diagnostic helpers. */
 
 /* wiphy_printk helpers, similar to dev_printk */
diff --git a/net/wireless/core.c b/net/wireless/core.c
index eb517a2..e14fab4 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -491,6 +491,8 @@ int wiphy_register(struct wiphy *wiphy)
 	/* set up regulatory info */
 	wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE);
 
+	radar_set_interference_flag(rdev);
+
 	list_add_rcu(&rdev->list, &cfg80211_rdev_list);
 	cfg80211_rdev_list_generation++;
 
diff --git a/net/wireless/radar.c b/net/wireless/radar.c
index d8911d3..88080de 100644
--- a/net/wireless/radar.c
+++ b/net/wireless/radar.c
@@ -284,6 +284,21 @@ static void radar_nol(struct work_struct *work)
 }
 static DECLARE_WORK(nol_work, radar_nol);
 
+int cfg80211_radar_interference(u16 freq)
+{
+	int error;
+
+	error = nol_add_chan(freq);
+	if (error)
+		return error;
+	mod_timer(&radar.timer, jiffies + msecs_to_jiffies(100));
+	error = cc_add_chan(freq);
+	if (error)
+		return error;
+	return 0;
+}
+EXPORT_SYMBOL(cfg80211_radar_interference);
+
 void radar_set_interference_flag(struct cfg80211_registered_device *rdev)
 {
 	struct radar_nol_list *nol;
@@ -463,6 +478,41 @@ static const struct file_operations nol_ops = {
 	.llseek = default_llseek,
 };
 
+static ssize_t radar_debugfs_bang(struct file *file,
+				  const char __user *user_buf,
+				  size_t count, loff_t *ppos)
+{
+	struct cfg80211_registered_device *rdev;
+	struct ieee80211_channel *chan = NULL;
+	unsigned long long freq;
+	char buf[100];
+	size_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EFAULT;
+	buf[len] = '\0';
+
+	freq = simple_strtoul(buf, NULL, 0);
+
+	list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
+		chan = ieee80211_get_channel(&rdev->wiphy, freq);
+		if (chan != NULL)
+			break;
+	}
+
+	if (chan != NULL)
+		cfg80211_radar_interference(freq);
+
+	return count;
+}
+
+static const struct file_operations bang_ops = {
+	.write = radar_debugfs_bang,
+	.open = radar_open_file_generic,
+	.llseek = default_llseek,
+};
+
 static struct dentry *radar_debugfs_dir;
 
 #define DEBUGFS_ADD(name)						\
@@ -474,6 +524,7 @@ void radar_debugfs_add(struct dentry *ieee80211_debugfs_dir)
 	radar_debugfs_dir = debugfs_create_dir("radar", ieee80211_debugfs_dir);
 	DEBUGFS_ADD(cac);
 	DEBUGFS_ADD(nol);
+	DEBUGFS_ADD(bang);
 }
 
 void radar_debugfs_remove()
-- 
1.7.2.3

  parent reply	other threads:[~2011-02-28 16:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 16:40 [RFC 0/9 v2] DFS/radar state/userspace handling Bernhard Schmidt
2011-02-28 16:46 ` [PATCH 1/9] [mac80211] add method to access oper chan Bernhard Schmidt
2011-03-01 12:11   ` Johannes Berg
2011-02-28 16:47 ` [PATCH 2/9] [{mac|nl}80211] Add 2 new radar channel flags Bernhard Schmidt
2011-03-01 21:54   ` Luis R. Rodriguez
2011-03-02  8:25     ` Johannes Berg
2011-03-02  9:37     ` Bernhard Schmidt
2011-02-28 16:47 ` [PATCH 3/9] [mac80211] enable radar detection Bernhard Schmidt
2011-03-01 21:56   ` Luis R. Rodriguez
2011-02-28 16:48 ` [PATCH 4/9] [cfg80211] add preliminary radar processing code Bernhard Schmidt
2011-03-01 12:17   ` Johannes Berg
2011-03-01 21:58   ` Luis R. Rodriguez
2011-03-02  7:32     ` Bernhard Schmidt
2011-03-02 16:26       ` Luis R. Rodriguez
2011-02-28 16:49 ` [PATCH 5/9] [cfg80211] channel availability check (CAC) support Bernhard Schmidt
2011-02-28 16:49 ` [PATCH 6/9] [cfg80211] no operation list (NOL) support Bernhard Schmidt
2011-03-01 12:19   ` Johannes Berg
2011-02-28 16:50 ` [PATCH 7/9] [cfg80211] abide channel closing time Bernhard Schmidt
2011-02-28 16:51 ` [PATCH 8/9] [{cfg|nl}80211] announce flag changes to userspace Bernhard Schmidt
2011-02-28 16:51 ` Bernhard Schmidt [this message]
2011-03-01 12:28 ` [RFC 0/9 v2] DFS/radar state/userspace handling Johannes Berg
2011-03-01 13:07   ` Bernhard Schmidt
2011-03-01 13:15     ` Johannes Berg
2011-03-01 13:26       ` Bernhard Schmidt

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=201102281751.47250.bernhard.schmidt@saxnet.de \
    --to=bernhard.schmidt@saxnet.de \
    --cc=dubowoj@neratec.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lrodriguez@atheros.com \
    --cc=nbd@openwrt.org \
    --cc=simon.wunderlich@saxnet.de \
    --cc=zefir.kurtisi@neratec.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).