Search Linux Wireless

[PATCH 4/5] mac80211: add primarily CAC support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux