aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2010-05-05 09:25:02 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-05-07 14:55:50 -0400
commitf444de05d20e27cdd960c13fcbcfca3099f03143 (patch)
treea7fbef60420d88dda5840e06094be21ee3eb1dc0 /net/mac80211
parentac8dd506e40ee2c7fcc61654a44c32555a0a8d6c (diff)
cfg80211/mac80211: better channel handling
Currently (all tested with hwsim) you can do stupid things like setting up an AP on a certain channel, then adding another virtual interface and making that associate on another channel -- this will make the beaconing to move channel but obviously without the necessary IEs data update. In order to improve this situation, first make the configuration APIs (cfg80211 and nl80211) aware of multi-channel operation -- we'll eventually need that in the future anyway. There's one userland API change and one API addition. The API change is that now SET_WIPHY must be called with virtual interface index rather than only wiphy index in order to take effect for that interface -- luckily all current users (hostapd) do that. For monitor interfaces, the old setting is preserved, but monitors are always slaved to other devices anyway so no guarantees. The second userland API change is the introduction of a per virtual interface SET_CHANNEL command, that hostapd should use going forward to make it easier to understand what's going on (it can automatically detect a kernel with this command). Other than mac80211, no existing cfg80211 drivers are affected by this change because they only allow a single virtual interface. mac80211, however, now needs to be aware that the channel settings are per interface now, and needs to disallow (for now) real multi-channel operation, which is another important part of this patch. One of the immediate benefits is that you can now start hostapd to operate on a hardware that already has a connection on another virtual interface, as long as you specify the same channel. Note that two things are left unhandled (this is an improvement -- not a complete fix): * different HT/no-HT modes currently you could start an HT AP and then connect to a non-HT network on the same channel which would configure the hardware for no HT; that can be fixed fairly easily * CSA An AP we're connected to on a virtual interface might indicate switching channels, and in that case we would follow it, regardless of how many other interfaces are operating; this requires more effort to fix but is pretty rare after all Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/Makefile3
-rw-r--r--net/mac80211/cfg.c41
-rw-r--r--net/mac80211/chan.c57
-rw-r--r--net/mac80211/ieee80211_i.h11
4 files changed, 111 insertions, 1 deletions
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
index 04420291e7ad..84b48ba8a77e 100644
--- a/net/mac80211/Makefile
+++ b/net/mac80211/Makefile
@@ -23,7 +23,8 @@ mac80211-y := \
23 key.o \ 23 key.o \
24 util.o \ 24 util.o \
25 wme.o \ 25 wme.o \
26 event.o 26 event.o \
27 chan.o
27 28
28mac80211-$(CONFIG_MAC80211_LEDS) += led.o 29mac80211-$(CONFIG_MAC80211_LEDS) += led.o
29mac80211-$(CONFIG_MAC80211_DEBUGFS) += \ 30mac80211-$(CONFIG_MAC80211_DEBUGFS) += \
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index b575a5066219..414b7dd7d7fd 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1161,11 +1161,24 @@ static int ieee80211_set_txq_params(struct wiphy *wiphy,
1161} 1161}
1162 1162
1163static int ieee80211_set_channel(struct wiphy *wiphy, 1163static int ieee80211_set_channel(struct wiphy *wiphy,
1164 struct net_device *netdev,
1164 struct ieee80211_channel *chan, 1165 struct ieee80211_channel *chan,
1165 enum nl80211_channel_type channel_type) 1166 enum nl80211_channel_type channel_type)
1166{ 1167{
1167 struct ieee80211_local *local = wiphy_priv(wiphy); 1168 struct ieee80211_local *local = wiphy_priv(wiphy);
1168 1169
1170 switch (ieee80211_get_channel_mode(local, NULL)) {
1171 case CHAN_MODE_HOPPING:
1172 return -EBUSY;
1173 case CHAN_MODE_FIXED:
1174 if (local->oper_channel == chan &&
1175 local->oper_channel_type == channel_type)
1176 return 0;
1177 return -EBUSY;
1178 case CHAN_MODE_UNDEFINED:
1179 break;
1180 }
1181
1169 local->oper_channel = chan; 1182 local->oper_channel = chan;
1170 local->oper_channel_type = channel_type; 1183 local->oper_channel_type = channel_type;
1171 1184
@@ -1213,6 +1226,20 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1213static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, 1226static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1214 struct cfg80211_assoc_request *req) 1227 struct cfg80211_assoc_request *req)
1215{ 1228{
1229 struct ieee80211_local *local = wiphy_priv(wiphy);
1230 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1231
1232 switch (ieee80211_get_channel_mode(local, sdata)) {
1233 case CHAN_MODE_HOPPING:
1234 return -EBUSY;
1235 case CHAN_MODE_FIXED:
1236 if (local->oper_channel == req->bss->channel)
1237 break;
1238 return -EBUSY;
1239 case CHAN_MODE_UNDEFINED:
1240 break;
1241 }
1242
1216 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); 1243 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
1217} 1244}
1218 1245
@@ -1235,8 +1262,22 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1235static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, 1262static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1236 struct cfg80211_ibss_params *params) 1263 struct cfg80211_ibss_params *params)
1237{ 1264{
1265 struct ieee80211_local *local = wiphy_priv(wiphy);
1238 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1266 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1239 1267
1268 switch (ieee80211_get_channel_mode(local, sdata)) {
1269 case CHAN_MODE_HOPPING:
1270 return -EBUSY;
1271 case CHAN_MODE_FIXED:
1272 if (!params->channel_fixed)
1273 return -EBUSY;
1274 if (local->oper_channel == params->channel)
1275 break;
1276 return -EBUSY;
1277 case CHAN_MODE_UNDEFINED:
1278 break;
1279 }
1280
1240 return ieee80211_ibss_join(sdata, params); 1281 return ieee80211_ibss_join(sdata, params);
1241} 1282}
1242 1283
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
new file mode 100644
index 000000000000..08f3832661a5
--- /dev/null
+++ b/net/mac80211/chan.c
@@ -0,0 +1,57 @@
1/*
2 * mac80211 - channel management
3 */
4
5#include "ieee80211_i.h"
6
7enum ieee80211_chan_mode
8__ieee80211_get_channel_mode(struct ieee80211_local *local,
9 struct ieee80211_sub_if_data *ignore)
10{
11 struct ieee80211_sub_if_data *sdata;
12
13 WARN_ON(!mutex_is_locked(&local->iflist_mtx));
14
15 list_for_each_entry(sdata, &local->interfaces, list) {
16 if (sdata == ignore)
17 continue;
18
19 if (!ieee80211_sdata_running(sdata))
20 continue;
21
22 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
23 continue;
24
25 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
26 !sdata->u.mgd.associated)
27 continue;
28
29 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
30 if (!sdata->u.ibss.ssid_len)
31 continue;
32 if (!sdata->u.ibss.fixed_channel)
33 return CHAN_MODE_HOPPING;
34 }
35
36 if (sdata->vif.type == NL80211_IFTYPE_AP &&
37 !sdata->u.ap.beacon)
38 continue;
39
40 return CHAN_MODE_FIXED;
41 }
42
43 return CHAN_MODE_UNDEFINED;
44}
45
46enum ieee80211_chan_mode
47ieee80211_get_channel_mode(struct ieee80211_local *local,
48 struct ieee80211_sub_if_data *ignore)
49{
50 enum ieee80211_chan_mode mode;
51
52 mutex_lock(&local->iflist_mtx);
53 mode = __ieee80211_get_channel_mode(local, ignore);
54 mutex_unlock(&local->iflist_mtx);
55
56 return mode;
57}
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index c8077a3647c6..359edff31471 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1229,6 +1229,17 @@ int ieee80211_wk_remain_on_channel(struct ieee80211_sub_if_data *sdata,
1229int ieee80211_wk_cancel_remain_on_channel( 1229int ieee80211_wk_cancel_remain_on_channel(
1230 struct ieee80211_sub_if_data *sdata, u64 cookie); 1230 struct ieee80211_sub_if_data *sdata, u64 cookie);
1231 1231
1232/* channel management */
1233enum ieee80211_chan_mode {
1234 CHAN_MODE_UNDEFINED,
1235 CHAN_MODE_HOPPING,
1236 CHAN_MODE_FIXED,
1237};
1238
1239enum ieee80211_chan_mode
1240ieee80211_get_channel_mode(struct ieee80211_local *local,
1241 struct ieee80211_sub_if_data *ignore);
1242
1232#ifdef CONFIG_MAC80211_NOINLINE 1243#ifdef CONFIG_MAC80211_NOINLINE
1233#define debug_noinline noinline 1244#define debug_noinline noinline
1234#else 1245#else