From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 12/14] mac80211: add ieee80211_vif_change_bandwidth
Date: Mon, 11 Feb 2013 13:38:16 +0100 [thread overview]
Message-ID: <1360586298-15028-13-git-send-email-johannes@sipsolutions.net> (raw)
In-Reply-To: <1360586298-15028-1-git-send-email-johannes@sipsolutions.net>
From: Johannes Berg <johannes.berg@intel.com>
For HT and VHT the current bandwidth can change,
add the function ieee80211_vif_change_bandwidth()
to take care of this. It returns a failure if the
new bandwidth isn't compatible with the existing
channel context, the caller has to handle that.
When it happens, also inform the driver that the
bandwidth changed for this virtual interface (no
drivers would actually care today though.)
Changing to/from HT/VHT isn't allowed though.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/mac80211.h | 4 ++++
net/mac80211/chan.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
net/mac80211/ieee80211_i.h | 4 ++++
3 files changed, 57 insertions(+)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index a3a0bdf..db5330a 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -210,6 +210,9 @@ struct ieee80211_chanctx_conf {
* changed (currently only in P2P client mode, GO mode will be later)
* @BSS_CHANGED_DTIM_PERIOD: the DTIM period value was changed (set when
* it becomes valid, managed mode only)
+ * @BSS_CHANGED_BANDWIDTH: The bandwidth used by this interface changed,
+ * note that this is only called when it changes after the channel
+ * context had been assigned.
*/
enum ieee80211_bss_change {
BSS_CHANGED_ASSOC = 1<<0,
@@ -233,6 +236,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_TXPOWER = 1<<18,
BSS_CHANGED_P2P_PS = 1<<19,
BSS_CHANGED_DTIM_PERIOD = 1<<20,
+ BSS_CHANGED_BANDWIDTH = 1<<21,
/* when adding here, make sure to change ieee80211_reconfig */
};
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 8fc56e4..2ad6c4d 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -336,6 +336,55 @@ int ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
return ret;
}
+int ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
+ const struct cfg80211_chan_def *chandef,
+ u32 *changed)
+{
+ struct ieee80211_local *local = sdata->local;
+ struct ieee80211_chanctx_conf *conf;
+ struct ieee80211_chanctx *ctx;
+ int ret;
+
+ if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
+ IEEE80211_CHAN_DISABLED))
+ return -EINVAL;
+
+ mutex_lock(&local->chanctx_mtx);
+ if (cfg80211_chandef_identical(chandef, &sdata->vif.bss_conf.chandef)) {
+ ret = 0;
+ goto out;
+ }
+
+ if (chandef->width == NL80211_CHAN_WIDTH_20_NOHT ||
+ sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
+ lockdep_is_held(&local->chanctx_mtx));
+ if (!conf) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ctx = container_of(conf, struct ieee80211_chanctx, conf);
+ if (!cfg80211_chandef_compatible(&conf->def, chandef)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ sdata->vif.bss_conf.chandef = *chandef;
+
+ ieee80211_recalc_chanctx_chantype(local, ctx);
+
+ *changed |= BSS_CHANGED_BANDWIDTH;
+ ret = 0;
+ out:
+ mutex_unlock(&local->chanctx_mtx);
+ return ret;
+}
+
void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
{
WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index c1bb491..a66f52f 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1602,6 +1602,10 @@ int __must_check
ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
const struct cfg80211_chan_def *chandef,
enum ieee80211_chanctx_mode mode);
+int __must_check
+ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
+ const struct cfg80211_chan_def *chandef,
+ u32 *changed);
void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata);
void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
--
1.8.0
next prev parent reply other threads:[~2013-02-11 12:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH 00/14] mac80211: HT/VHT handling>
2013-02-11 12:38 ` Johannes Berg
2013-02-11 12:38 ` [PATCH 01/14] mac80211: pass station to ieee80211_vht_cap_ie_to_sta_vht_cap Johannes Berg
2013-02-11 12:38 ` [PATCH 02/14] mac80211: stop toggling IEEE80211_HT_CAP_SUP_WIDTH_20_40 Johannes Berg
2013-02-11 12:38 ` [PATCH 03/14] wireless: define operating mode action frame Johannes Berg
2013-02-11 12:38 ` [PATCH 04/14] mac80211: track number of spatial streams Johannes Berg
2013-02-11 12:38 ` [PATCH 05/14] mac80211: handle VHT operating mode notification Johannes Berg
2013-02-11 12:38 ` [PATCH 06/14] mac80211: init HT TX data before rate control Johannes Berg
2013-02-11 12:38 ` [PATCH 07/14] mac80211: fix HT/VHT disable flags Johannes Berg
2013-02-11 12:38 ` [PATCH 08/14] mac80211: fix ieee80211_change_chandef name Johannes Berg
2013-02-11 12:38 ` [PATCH 09/14] mac80211: handle operating mode notif in beacon/assoc response Johannes Berg
2013-02-11 12:38 ` [PATCH 10/14] mac80211: disable HT/VHT if AP has no HT/VHT capability Johannes Berg
2013-02-11 12:38 ` [PATCH 11/14] mac80211: clean up channel use in ieee80211_config_ht_tx Johannes Berg
2013-02-11 12:38 ` Johannes Berg [this message]
2013-02-11 12:38 ` [PATCH 13/14] mac80211: move ieee80211_determine_chantype function Johannes Berg
2013-02-11 12:38 ` [PATCH 14/14] mac80211: properly track HT/VHT operation changes Johannes Berg
2013-02-14 17:40 ` 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=1360586298-15028-13-git-send-email-johannes@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=johannes.berg@intel.com \
--cc=linux-wireless@vger.kernel.org \
/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.