linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Michal Kazior <michal.kazior@tieto.com>
Subject: [RFC 07/20] mac80211: reuse channels for channel contexts
Date: Fri, 27 Jul 2012 13:16:43 +0200	[thread overview]
Message-ID: <1343387816-9414-8-git-send-email-johannes@sipsolutions.net> (raw)
In-Reply-To: <1343387816-9414-1-git-send-email-johannes@sipsolutions.net>

From: Michal Kazior <michal.kazior@tieto.com>

Reuse channels with compatible channel types. Some
channel types are compatible and can be used
concurrently.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/chan.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 90fef15..40e707c 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -167,7 +167,17 @@ bool ieee80211_set_channel_type(struct ieee80211_local *local,
 		sdata->vif.bss_conf.channel_type = chantype;
 
 	return true;
+}
+
+static void ieee80211_change_chantype(struct ieee80211_local *local,
+				      struct ieee80211_chanctx *ctx,
+				      enum nl80211_channel_type chantype)
+{
+	if (chantype == ctx->conf.channel_type)
+		return;
 
+	ctx->conf.channel_type = chantype;
+	drv_change_chantype(local, ctx);
 }
 
 static struct ieee80211_chanctx *
@@ -177,6 +187,7 @@ ieee80211_find_chanctx(struct ieee80211_local *local,
 		       enum ieee80211_chanctx_mode mode)
 {
 	struct ieee80211_chanctx *ctx;
+	enum nl80211_channel_type compat_type;
 
 	lockdep_assert_held(&local->chanctx_mtx);
 
@@ -186,13 +197,19 @@ ieee80211_find_chanctx(struct ieee80211_local *local,
 		return NULL;
 
 	list_for_each_entry(ctx, &local->chanctx_list, list) {
+		compat_type = ctx->conf.channel_type;
+
 		if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
 			continue;
 		if (ctx->conf.channel != channel)
 			continue;
-		if (ctx->conf.channel_type != channel_type)
+		if (!ieee80211_channel_types_are_compatible(ctx->conf.channel_type,
+							    channel_type,
+							    &compat_type))
 			continue;
 
+		ieee80211_change_chantype(local, ctx, compat_type);
+
 		return ctx;
 	}
 
@@ -251,6 +268,43 @@ static void ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
 	drv_assign_vif_chanctx(local, sdata, ctx);
 }
 
+static enum nl80211_channel_type
+ieee80211_calc_chantype(struct ieee80211_local *local,
+			struct ieee80211_chanctx *ctx)
+{
+	struct ieee80211_chanctx_conf *conf = &ctx->conf;
+	struct ieee80211_sub_if_data *sdata;
+	enum nl80211_channel_type result = NL80211_CHAN_NO_HT;
+
+	lockdep_assert_held(&local->chanctx_mtx);
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(sdata, &local->interfaces, list) {
+		if (!ieee80211_sdata_running(sdata))
+			continue;
+		if (sdata->vif.chanctx_conf != conf)
+			continue;
+
+		WARN_ON_ONCE(!ieee80211_channel_types_are_compatible(
+					sdata->vif.bss_conf.channel_type,
+					result, &result));
+	}
+	rcu_read_unlock();
+
+	return result;
+}
+
+static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
+					      struct ieee80211_chanctx *ctx)
+{
+	enum nl80211_channel_type chantype;
+
+	lockdep_assert_held(&local->chanctx_mtx);
+
+	chantype = ieee80211_calc_chantype(local, ctx);
+	ieee80211_change_chantype(local, ctx, chantype);
+}
+
 static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
 					   struct ieee80211_chanctx *ctx)
 {
@@ -262,6 +316,8 @@ static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
 
 	ctx->refcount--;
 	sdata->vif.chanctx_conf = NULL;
+
+	ieee80211_recalc_chanctx_chantype(sdata->local, ctx);
 }
 
 static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
-- 
1.7.10.4


  parent reply	other threads:[~2012-07-27 11:17 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27 11:16 [RFC 00/20] mac80211: multi-channel work Johannes Berg
2012-07-27 11:16 ` [RFC 01/20] mac80211: introduce channel context skeleton code Johannes Berg
2012-07-27 11:16 ` [RFC 02/20] mac80211: introduce new ieee80211_ops Johannes Berg
2012-07-27 11:16 ` [RFC 03/20] mac80211: add drv_* wrappers for channel contexts Johannes Berg
2012-07-27 18:08   ` Joe Perches
2012-07-27 21:03     ` Johannes Berg
2012-07-27 11:16 ` [RFC 04/20] mac80211: add chanctx tracing Johannes Berg
2012-07-27 11:16 ` [RFC 05/20] mac80211: use channel context notifications Johannes Berg
2012-07-27 11:16 ` [RFC 06/20] mac80211: refactor set_channel_type Johannes Berg
2012-07-29  9:03   ` Eliad Peller
2012-07-27 11:16 ` Johannes Berg [this message]
2012-07-27 11:16 ` [RFC 08/20] mac80211: mesh: don't use global channel type Johannes Berg
2012-07-27 11:16 ` [RFC 09/20] mac80211: remove almost unused local variable Johannes Berg
2012-07-27 11:16 ` [RFC 10/20] mac80211: remove freq/chantype from debugfs Johannes Berg
2012-07-27 11:16 ` [RFC 11/20] mac80211: use oper_channel in rate init Johannes Berg
2012-07-27 11:16 ` [RFC 12/20] mac80211: don't assume channel is set in tracing Johannes Berg
2012-07-27 11:16 ` [RFC 13/20] mac80211: use RX status band instead of current band Johannes Berg
2012-07-27 11:16 ` [RFC 14/20] mac80211: check operating channel in scan Johannes Berg
2012-07-27 11:16 ` [RFC 15/20] mac80211: convert ops checks to WARN_ON Johannes Berg
2012-07-27 11:16 ` [RFC 16/20] mac80211: check channel context methods Johannes Berg
2012-07-27 11:16 ` [RFC 17/20] mac80211: track whether to use channel contexts Johannes Berg
2012-07-27 11:16 ` [RFC 18/20] mac80211: allow drv_add_chanctx to fail Johannes Berg
2012-07-27 11:42   ` Michal Kazior
2012-07-27 11:42     ` Johannes Berg
2012-07-27 11:45       ` Michal Kazior
2012-07-27 11:16 ` [RFC 19/20] mac80211: return error code from ieee80211_vif_use_channel Johannes Berg
2012-07-27 11:16 ` [RFC 20/20] mac80211: use channel contexts Johannes Berg
2012-07-27 11:46   ` Michal Kazior
2012-07-27 11:55     ` Johannes Berg
2012-08-06 15:21   ` Arik Nemtsov
2012-08-06 15:26     ` Johannes Berg
2012-07-27 12:31 ` [RFC 00/20] mac80211: multi-channel work Johannes Berg
2012-08-24  9:29 ` Johannes Berg
2012-08-26  7:58   ` Eliad Peller
2012-08-26  8:10     ` Johannes Berg
2012-08-26  8:28       ` Eliad Peller
2012-08-26  8:30         ` Johannes Berg
2012-08-26  8:36           ` Eliad Peller
2012-09-05 14:03             ` Johannes Berg

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=1343387816-9414-8-git-send-email-johannes@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=michal.kazior@tieto.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).