linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] cfg80211: DFS check dfs_region before CAC
@ 2013-11-08 10:41 Janusz Dziedzic
  2013-11-08 10:41 ` [PATCH 2/3] cfg80211/mac80211: DFS pass CAC time as a parameter Janusz Dziedzic
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Janusz Dziedzic @ 2013-11-08 10:41 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, mcgrof, Janusz Dziedzic

Before we will start radar detection check
if we have correct DFS region. Fail in case
we don't know DFS region (don't know CAC/NOP
timing and how to configure DFS pattern detector).

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 net/wireless/nl80211.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 076ed55..635842b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5628,8 +5628,21 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
 	struct net_device *dev = info->user_ptr[1];
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
 	struct cfg80211_chan_def chandef;
+	const struct ieee80211_regdomain *regdom;
+	u8 dfs_region;
 	int err;
 
+	if (!cfg80211_regdomain)
+		return -EINVAL;
+
+	rcu_read_lock();
+	regdom = rcu_dereference(cfg80211_regdomain);
+	dfs_region = regdom->dfs_region;
+	rcu_read_unlock();
+
+	if (dfs_region == NL80211_DFS_UNSET)
+		return -EINVAL;
+
 	err = nl80211_parse_chandef(rdev, info, &chandef);
 	if (err)
 		return err;
-- 
1.7.9.5


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

* [PATCH 2/3] cfg80211/mac80211: DFS pass CAC time as a parameter
  2013-11-08 10:41 [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Janusz Dziedzic
@ 2013-11-08 10:41 ` Janusz Dziedzic
  2013-11-08 10:41 ` [PATCH 3/3] cfg80211: DFS use 10 minutes CAC when weather channels Janusz Dziedzic
  2013-11-11 14:03 ` [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Johannes Berg
  2 siblings, 0 replies; 5+ messages in thread
From: Janusz Dziedzic @ 2013-11-08 10:41 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, mcgrof, Janusz Dziedzic

Send Channel Availability Check time as a parameter
of start_radar_detection() callback.
We could have different CAC time configuration for
Off-channel CAC and for weather channels.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 include/net/cfg80211.h |    3 ++-
 net/mac80211/cfg.c     |    8 ++++----
 net/wireless/nl80211.c |    3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 968f2ad..d43fa0a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2412,7 +2412,8 @@ struct cfg80211_ops {
 
 	int	(*start_radar_detection)(struct wiphy *wiphy,
 					 struct net_device *dev,
-					 struct cfg80211_chan_def *chandef);
+					 struct cfg80211_chan_def *chandef,
+					 u32 cac_time_ms);
 	int	(*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
 				 struct cfg80211_update_ft_ies_params *ftie);
 	int	(*crit_proto_start)(struct wiphy *wiphy,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index fcdc357..7daea55 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2874,11 +2874,11 @@ static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
 
 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
 					   struct net_device *dev,
-					   struct cfg80211_chan_def *chandef)
+					   struct cfg80211_chan_def *chandef,
+					   u32 cac_time_ms)
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	struct ieee80211_local *local = sdata->local;
-	unsigned long timeout;
 	int err;
 
 	if (!list_empty(&local->roc_list) || local->scanning)
@@ -2896,9 +2896,9 @@ static int ieee80211_start_radar_detection(struct wiphy *wiphy,
 	if (err)
 		return err;
 
-	timeout = msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS);
 	ieee80211_queue_delayed_work(&sdata->local->hw,
-				     &sdata->dfs_cac_timer_work, timeout);
+				     &sdata->dfs_cac_timer_work,
+				     msecs_to_jiffies(cac_time_ms));
 
 	return 0;
 }
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 635842b..689a335 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5672,7 +5672,8 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
 	if (err)
 		return err;
 
-	err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef);
+	err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef,
+					       IEEE80211_DFS_MIN_CAC_TIME_MS);
 	if (!err) {
 		wdev->channel = chandef.chan;
 		wdev->cac_started = true;
-- 
1.7.9.5


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

* [PATCH 3/3] cfg80211: DFS use 10 minutes CAC when weather channels
  2013-11-08 10:41 [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Janusz Dziedzic
  2013-11-08 10:41 ` [PATCH 2/3] cfg80211/mac80211: DFS pass CAC time as a parameter Janusz Dziedzic
@ 2013-11-08 10:41 ` Janusz Dziedzic
  2013-11-11 14:03 ` [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Johannes Berg
  2 siblings, 0 replies; 5+ messages in thread
From: Janusz Dziedzic @ 2013-11-08 10:41 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, mcgrof, Janusz Dziedzic

When nominal bandwidth falls completely or partly
within the band 5600MHz to 5650MHz the CAC time shall
be 10 minutes.
This is ETSI requirement. FCC forbids weather channels usage.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 include/net/cfg80211.h |    5 +++-
 net/wireless/chan.c    |   73 ++++++++++++++++++++++++++++++++++++++++++++++++
 net/wireless/core.h    |    4 +++
 net/wireless/nl80211.c |    6 +++-
 4 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index d43fa0a..c40847e 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -125,9 +125,12 @@ enum ieee80211_channel_flags {
 #define IEEE80211_CHAN_NO_HT40 \
 	(IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
 
-#define IEEE80211_DFS_MIN_CAC_TIME_MS		60000
+#define IEEE80211_DFS_MIN_CAC_TIME_MS		(60 * 1000)
 #define IEEE80211_DFS_MIN_NOP_TIME_MS		(30 * 60 * 1000)
 
+/* ETSI EN 301 893 V1.7.0 - Table D.1 */
+#define IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS	(10 * 60 * 1000)
+
 /**
  * struct ieee80211_channel - channel definition
  *
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 78559b5..aa691d3 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -490,6 +490,79 @@ static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy,
 	return r;
 }
 
+static int cfg80211_get_chans_dfs_is_weather(struct wiphy *wiphy,
+					     u32 center_freq,
+					     u32 bandwidth)
+{
+	u32 start_freq, end_freq;
+
+	start_freq = cfg80211_get_start_freq(center_freq, bandwidth) - 10;
+	end_freq = cfg80211_get_end_freq(center_freq, bandwidth) + 10;
+
+	/*
+	 * ETSI EN 301 893 V1.7.0 Table D.1
+	 * TODO In the future we can get this from regdb eg. channel flag
+	 * IEEE80211_CHAN_TDWR.
+	 */
+	if ((start_freq >= 5600 && start_freq < 5650) ||
+	    (end_freq > 5600 && end_freq <= 5650))
+		return 1;
+
+	return 0;
+}
+
+static int
+cfg80211_chandef_dfs_is_weather(struct wiphy *wiphy,
+				const struct cfg80211_chan_def *chandef)
+{
+	int width;
+	int r;
+
+	if (WARN_ON(!cfg80211_chandef_valid(chandef)))
+		return -EINVAL;
+
+	width = cfg80211_chandef_get_width(chandef);
+	if (width < 0)
+		return -EINVAL;
+
+	r = cfg80211_get_chans_dfs_is_weather(wiphy,
+					      chandef->center_freq1,
+					      width);
+
+	if (r)
+		return r;
+
+	if (!chandef->center_freq2)
+		return 0;
+
+	return cfg80211_get_chans_dfs_is_weather(wiphy,
+						 chandef->center_freq2,
+						 width);
+}
+
+unsigned int
+cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy,
+			      const struct cfg80211_chan_def *chandef,
+			      u8 dfs_region)
+{
+	unsigned int timeout_ms = IEEE80211_DFS_MIN_CAC_TIME_MS;
+
+	switch (dfs_region) {
+	case NL80211_DFS_ETSI:
+		if (cfg80211_chandef_dfs_is_weather(wiphy, chandef))
+			timeout_ms = IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS;
+		break;
+	/* TODO check JP CAC time */
+	case NL80211_DFS_JP:
+		break;
+	/* FCC don't allow weather channels */
+	case NL80211_DFS_FCC:
+	default:
+		break;
+	}
+
+	return timeout_ms;
+}
 
 static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
 					u32 center_freq, u32 bandwidth,
diff --git a/net/wireless/core.h b/net/wireless/core.h
index 5390aeb..67d70c1 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -401,6 +401,10 @@ void cfg80211_set_dfs_state(struct wiphy *wiphy,
 
 void cfg80211_dfs_channels_update_work(struct work_struct *work);
 
+unsigned int
+cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy,
+			      const struct cfg80211_chan_def *chandef,
+			      u8 dfs_region);
 
 static inline int
 cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 689a335..9421bc7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5629,6 +5629,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
 	struct cfg80211_chan_def chandef;
 	const struct ieee80211_regdomain *regdom;
+	unsigned int cac_time_ms;
 	u8 dfs_region;
 	int err;
 
@@ -5672,8 +5673,11 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
 	if (err)
 		return err;
 
+	cac_time_ms = cfg80211_chandef_dfs_cac_time(&rdev->wiphy, &chandef,
+						    dfs_region);
+
 	err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef,
-					       IEEE80211_DFS_MIN_CAC_TIME_MS);
+					       cac_time_ms);
 	if (!err) {
 		wdev->channel = chandef.chan;
 		wdev->cac_started = true;
-- 
1.7.9.5


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

* Re: [PATCH 1/3] cfg80211: DFS check dfs_region before CAC
  2013-11-08 10:41 [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Janusz Dziedzic
  2013-11-08 10:41 ` [PATCH 2/3] cfg80211/mac80211: DFS pass CAC time as a parameter Janusz Dziedzic
  2013-11-08 10:41 ` [PATCH 3/3] cfg80211: DFS use 10 minutes CAC when weather channels Janusz Dziedzic
@ 2013-11-11 14:03 ` Johannes Berg
  2013-11-11 17:12   ` Luis R. Rodriguez
  2 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2013-11-11 14:03 UTC (permalink / raw)
  To: Janusz Dziedzic; +Cc: linux-wireless, mcgrof

On Fri, 2013-11-08 at 11:41 +0100, Janusz Dziedzic wrote:

> +	rcu_read_lock();
> +	regdom = rcu_dereference(cfg80211_regdomain);
> +	dfs_region = regdom->dfs_region;
> +	rcu_read_unlock();

Isn't all of this valid to dereference under RTNL anyway? See
get_cfg80211_regdom()

johannes


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

* Re: [PATCH 1/3] cfg80211: DFS check dfs_region before CAC
  2013-11-11 14:03 ` [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Johannes Berg
@ 2013-11-11 17:12   ` Luis R. Rodriguez
  0 siblings, 0 replies; 5+ messages in thread
From: Luis R. Rodriguez @ 2013-11-11 17:12 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Janusz Dziedzic, linux-wireless

On Mon, Nov 11, 2013 at 3:03 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Fri, 2013-11-08 at 11:41 +0100, Janusz Dziedzic wrote:
>
>> +     rcu_read_lock();
>> +     regdom = rcu_dereference(cfg80211_regdomain);
>> +     dfs_region = regdom->dfs_region;
>> +     rcu_read_unlock();
>
> Isn't all of this valid to dereference under RTNL anyway? See
> get_cfg80211_regdom()

Also note that we have wiphy->regd too, so that should be considered,
if present that should be used.

  Luis

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

end of thread, other threads:[~2013-11-11 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-08 10:41 [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Janusz Dziedzic
2013-11-08 10:41 ` [PATCH 2/3] cfg80211/mac80211: DFS pass CAC time as a parameter Janusz Dziedzic
2013-11-08 10:41 ` [PATCH 3/3] cfg80211: DFS use 10 minutes CAC when weather channels Janusz Dziedzic
2013-11-11 14:03 ` [PATCH 1/3] cfg80211: DFS check dfs_region before CAC Johannes Berg
2013-11-11 17:12   ` Luis R. Rodriguez

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