summaryrefslogtreecommitdiffstats
path: root/net/mac80211/chan.c
diff options
context:
space:
mode:
authorMichal Kazior <michal.kazior@tieto.com>2012-06-26 14:37:22 +0200
committerJohannes Berg <johannes.berg@intel.com>2012-10-16 20:22:44 +0200
commite89a96f5cc4c39c268c771f52d675e15e3ba8123 (patch)
tree170ea6f86a7f04ad8035a90c53c967f4b02cf633 /net/mac80211/chan.c
parent35f2fce9a4376f89f2ebac705a2742ffc058f988 (diff)
downloadop-kernel-dev-e89a96f5cc4c39c268c771f52d675e15e3ba8123.zip
op-kernel-dev-e89a96f5cc4c39c268c771f52d675e15e3ba8123.tar.gz
mac80211: reuse channels for channel contexts
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>
Diffstat (limited to 'net/mac80211/chan.c')
-rw-r--r--net/mac80211/chan.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index ff3b29e..1a8dee4 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_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_CHANNEL_TYPE);
}
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;
}
@@ -260,6 +277,43 @@ static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
return 0;
}
+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 (rcu_access_pointer(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)
{
@@ -271,6 +325,9 @@ static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
rcu_assign_pointer(sdata->vif.chanctx_conf, NULL);
drv_unassign_vif_chanctx(local, sdata, ctx);
+
+ if (ctx->refcount > 0)
+ ieee80211_recalc_chanctx_chantype(sdata->local, ctx);
}
static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
OpenPOWER on IntegriCloud