All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernhard Schmidt <bernhard.schmidt@saxnet.de>
To: linux-wireless <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 4/5] mac80211: add primarily CAC support
Date: Mon, 17 Jan 2011 11:24:54 +0100	[thread overview]
Message-ID: <20110117161133.8150D2084@mx.techwires.net> (raw)
In-Reply-To: <201101171621.29863.bernhard.schmidt@saxnet.de>

---
 net/mac80211/radar.c |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++
 net/mac80211/radar.h |    4 +++
 2 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/radar.c b/net/mac80211/radar.c
index e90b8bf..afb2ae1 100644
--- a/net/mac80211/radar.c
+++ b/net/mac80211/radar.c
@@ -15,6 +15,66 @@
 #include "driver-ops.h"
 #include "radar.h"
 
+static void cac_timer(unsigned long data)
+{
+	struct ieee80211_local *local = (void *) data;
+	struct ieee80211_radar *radar = &local->radar;
+	struct ieee80211_channel *chan;
+
+	printk(KERN_INFO "CAC done\n");
+
+	chan = local->oper_channel;
+	mutex_lock(&radar->mtx);
+	if ((chan->flags & IEEE80211_CHAN_RADAR_INTERFERENCE) == 0) {
+		chan->flags |= IEEE80211_CHAN_RADAR_CLEAR;
+	}
+	radar->cac = 0;
+	mutex_unlock(&radar->mtx);
+}
+
+int ieee80211_radar_cac(struct wiphy *wiphy, int enable)
+{
+	struct ieee80211_local *local = wiphy_priv(wiphy);
+	struct ieee80211_radar *radar = &local->radar;
+	struct ieee80211_channel *chan = local->oper_channel;
+	int ret;
+
+	ret = ieee80211_radar_detection_enable(local, chan);
+	if (ret != 0)
+		return ret;
+
+	if (!enable && !radar->cac)
+		return -EINVAL;
+	if (!enable && radar->cac) {
+		printk(KERN_INFO "stopping CAC\n");
+
+		del_timer_sync(&radar->cac_timer);
+		mutex_lock(&radar->mtx);
+		radar->cac = 0;
+		mutex_unlock(&radar->mtx);
+		return 0;
+	}
+	if (enable) {
+		if ((chan->flags & IEEE80211_CHAN_RADAR_INTERFERENCE))
+			return -EINVAL;
+
+		printk(KERN_INFO "starting CAC\n");
+
+		del_timer_sync(&radar->cac_timer);
+		mutex_lock(&radar->mtx);
+		if ((chan->flags & IEEE80211_CHAN_RADAR) &&
+		    (chan->flags & IEEE80211_CHAN_RADAR_CLEAR)) {
+			chan->flags &= ~IEEE80211_CHAN_RADAR_CLEAR;
+		}
+		radar->cac = 1;
+		mutex_unlock(&radar->mtx);
+		mod_timer(&radar->cac_timer, jiffies +
+			  msecs_to_jiffies(radar->params->cac_period * 1000));
+	}
+
+	return 0;
+}
+
 static void nol_timer(unsigned long data)
 {
 	struct ieee80211_local *local = (void *) data;
@@ -136,6 +196,9 @@ void ieee80211_radar_init(struct ieee80211_local *local)
 
 	mutex_init(&radar->mtx);
 
+	radar->cac = 0;
+	setup_timer(&radar->cac_timer, cac_timer, (unsigned long)local);
+
 	INIT_LIST_HEAD(&radar->nol_list);
 	setup_timer(&radar->nol_timer, nol_timer, (unsigned long)local);
 	mod_timer(&radar->nol_timer, jiffies + msecs_to_jiffies(1000));
@@ -146,6 +209,8 @@ void ieee80211_radar_deinit(struct ieee80211_local *local)
 	struct ieee80211_radar *radar = &local->radar;
 	struct ieee80211_radar_nol_list *nol, *tmp;
 
+	del_timer_sync(&radar->cac_timer);
+
 	del_timer_sync(&radar->nol_timer);
 	mutex_lock(&radar->mtx);
 	list_for_each_entry_safe(nol, tmp, &radar->nol_list, list) {
diff --git a/net/mac80211/radar.h b/net/mac80211/radar.h
index 79684b5..6e8bc36 100644
--- a/net/mac80211/radar.h
+++ b/net/mac80211/radar.h
@@ -31,10 +31,14 @@ struct ieee80211_radar {
 	struct mutex mtx;
 	struct ieee80211_radar_parameters *params;
 
+	int cac;
+	struct timer_list cac_timer;
+
 	struct timer_list nol_timer;
 	struct list_head nol_list;
 };
 
+int ieee80211_radar_cac(struct wiphy *wiphy, int enable);
 int ieee80211_radar_detection_enable(struct ieee80211_local *local,
 				     struct ieee80211_channel *chan);
 int ieee80211_radar_detection_disable(struct ieee80211_local *local,
-- 
1.5.6.5


  parent reply	other threads:[~2011-01-17 16:20 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17 15:21 [RFC 0/13] DFS/radar state/userspace handling Bernhard Schmidt
2011-01-17  8:31 ` [PATCH 1/5] mac80211: add DFS related channel flags Bernhard Schmidt
2011-01-18 10:40   ` Johannes Berg
2011-01-18 11:59     ` Bernhard Schmidt
2011-01-18 12:16       ` Johannes Berg
2011-01-18 12:27         ` Bernhard Schmidt
2011-01-18 14:29           ` Zefir Kurtisi
2011-01-18 10:40   ` Johannes Berg
2011-01-17  9:16 ` [PATCH 2/5] mac80211: initialize radar params + add driver API Bernhard Schmidt
2011-01-18 10:43   ` Johannes Berg
2011-01-18 12:00     ` Bernhard Schmidt
2011-01-18 10:44   ` Johannes Berg
2011-01-17 10:05 ` [PATCH 3/5] mac80211: add NOL functionality Bernhard Schmidt
2011-01-18 10:43   ` Johannes Berg
2011-01-18 12:01     ` Bernhard Schmidt
2011-01-18 12:13       ` Johannes Berg
2011-01-18 12:28         ` Bernhard Schmidt
2011-01-17 10:24 ` Bernhard Schmidt [this message]
2011-01-18 10:45   ` [PATCH 4/5] mac80211: add primarily CAC support Johannes Berg
2011-01-18 12:01     ` Bernhard Schmidt
2011-01-18 12:12       ` Johannes Berg
2011-01-18 12:28         ` Bernhard Schmidt
2011-01-18 10:48   ` Johannes Berg
2011-01-18 12:00     ` Bernhard Schmidt
2011-01-17 11:49 ` [PATCH 5/5] cfg80211: userspace commands/notifications Bernhard Schmidt
2011-01-17 12:55 ` [PATCH 1/8] hostap: make hostapd_parse_rates generic Bernhard Schmidt
2011-01-17 12:56 ` [PATCH 2/8] hostap: add channel_list config parameter Bernhard Schmidt
2011-01-17 13:00 ` [PATCH 3/8] hostapd: select random channel of the list Bernhard Schmidt
2011-01-17 13:07 ` [PATCH 4/8] hostap: sync nl80211_copy.h Bernhard Schmidt
2011-01-17 13:14 ` [PATCH 5/8] hostap: pull in additional chan flags Bernhard Schmidt
2011-01-17 13:23 ` [PATCH 6/8] hostap: request CAC before using a radar channel Bernhard Schmidt
2011-01-17 13:26 ` [PATCH 7/8] hostap: handle interference on current channel Bernhard Schmidt
2011-01-17 13:27 ` [PATCH 8/8] hostap: do not disable radar channels 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=20110117161133.8150D2084@mx.techwires.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.