aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/Kconfig28
-rw-r--r--net/mac80211/Makefile3
-rw-r--r--net/mac80211/agg-tx.c3
-rw-r--r--net/mac80211/cfg.c216
-rw-r--r--net/mac80211/debugfs.c2
-rw-r--r--net/mac80211/debugfs_netdev.c46
-rw-r--r--net/mac80211/debugfs_sta.c98
-rw-r--r--net/mac80211/driver-ops.h85
-rw-r--r--net/mac80211/driver-trace.c6
-rw-r--r--net/mac80211/driver-trace.h648
-rw-r--r--net/mac80211/event.c23
-rw-r--r--net/mac80211/ibss.c15
-rw-r--r--net/mac80211/ieee80211_i.h181
-rw-r--r--net/mac80211/iface.c81
-rw-r--r--net/mac80211/key.c28
-rw-r--r--net/mac80211/main.c125
-rw-r--r--net/mac80211/mesh.c11
-rw-r--r--net/mac80211/mesh.h3
-rw-r--r--net/mac80211/mesh_hwmp.c9
-rw-r--r--net/mac80211/mesh_pathtbl.c26
-rw-r--r--net/mac80211/mlme.c1905
-rw-r--r--net/mac80211/rate.c31
-rw-r--r--net/mac80211/rc80211_minstrel.c23
-rw-r--r--net/mac80211/rc80211_pid_algo.c12
-rw-r--r--net/mac80211/rx.c158
-rw-r--r--net/mac80211/scan.c48
-rw-r--r--net/mac80211/sta_info.h17
-rw-r--r--net/mac80211/tx.c335
-rw-r--r--net/mac80211/util.c68
-rw-r--r--net/mac80211/wep.c52
-rw-r--r--net/mac80211/wep.h7
-rw-r--r--net/mac80211/wext.c450
-rw-r--r--net/mac80211/wme.c6
-rw-r--r--net/mac80211/wme.h3
-rw-r--r--net/mac80211/wpa.c3
35 files changed, 2355 insertions, 2400 deletions
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index 7836ee928983..19a4c66e143e 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -14,22 +14,6 @@ config MAC80211
14comment "CFG80211 needs to be enabled for MAC80211" 14comment "CFG80211 needs to be enabled for MAC80211"
15 depends on CFG80211=n 15 depends on CFG80211=n
16 16
17config MAC80211_DEFAULT_PS
18 bool "enable powersave by default"
19 depends on MAC80211
20 default y
21 help
22 This option enables powersave mode by default.
23
24 If this causes your applications to misbehave you should fix your
25 applications instead -- they need to register their network
26 latency requirement, see Documentation/power/pm_qos_interface.txt.
27
28config MAC80211_DEFAULT_PS_VALUE
29 int
30 default 1 if MAC80211_DEFAULT_PS
31 default 0
32
33menu "Rate control algorithm selection" 17menu "Rate control algorithm selection"
34 depends on MAC80211 != n 18 depends on MAC80211 != n
35 19
@@ -222,3 +206,15 @@ config MAC80211_DEBUG_COUNTERS
222 and show them in debugfs. 206 and show them in debugfs.
223 207
224 If unsure, say N. 208 If unsure, say N.
209
210config MAC80211_DRIVER_API_TRACER
211 bool "Driver API tracer"
212 depends on MAC80211_DEBUG_MENU
213 depends on EVENT_TRACING
214 help
215 Say Y here to make mac80211 register with the ftrace
216 framework for the driver API -- you can see which
217 driver methods it is calling then by looking at the
218 trace.
219
220 If unsure, say N.
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
index 0e3ab88bb706..91284a74ff91 100644
--- a/net/mac80211/Makefile
+++ b/net/mac80211/Makefile
@@ -41,6 +41,9 @@ mac80211-$(CONFIG_MAC80211_MESH) += \
41 41
42mac80211-$(CONFIG_PM) += pm.o 42mac80211-$(CONFIG_PM) += pm.o
43 43
44mac80211-$(CONFIG_MAC80211_DRIVER_API_TRACER) += driver-trace.o
45CFLAGS_driver-trace.o := -I$(src)
46
44# objects for PID algorithm 47# objects for PID algorithm
45rc80211_pid-y := rc80211_pid_algo.o 48rc80211_pid-y := rc80211_pid_algo.o
46rc80211_pid-$(CONFIG_MAC80211_DEBUGFS) += rc80211_pid_debugfs.o 49rc80211_pid-$(CONFIG_MAC80211_DEBUGFS) += rc80211_pid_debugfs.o
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 9e5762ad307d..1958c7c42cd9 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -383,9 +383,6 @@ static void ieee80211_agg_splice_packets(struct ieee80211_local *local,
383 383
384 if (!skb_queue_empty(&sta->ampdu_mlme.tid_tx[tid]->pending)) { 384 if (!skb_queue_empty(&sta->ampdu_mlme.tid_tx[tid]->pending)) {
385 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 385 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
386 /* mark queue as pending, it is stopped already */
387 __set_bit(IEEE80211_QUEUE_STOP_REASON_PENDING,
388 &local->queue_stop_reasons[queue]);
389 /* copy over remaining packets */ 386 /* copy over remaining packets */
390 skb_queue_splice_tail_init( 387 skb_queue_splice_tail_init(
391 &sta->ampdu_mlme.tid_tx[tid]->pending, 388 &sta->ampdu_mlme.tid_tx[tid]->pending,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 3f47276caeb8..52928ad90570 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -74,19 +74,14 @@ static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
74 return 0; 74 return 0;
75} 75}
76 76
77static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, 77static int ieee80211_change_iface(struct wiphy *wiphy,
78 struct net_device *dev,
78 enum nl80211_iftype type, u32 *flags, 79 enum nl80211_iftype type, u32 *flags,
79 struct vif_params *params) 80 struct vif_params *params)
80{ 81{
81 struct net_device *dev;
82 struct ieee80211_sub_if_data *sdata; 82 struct ieee80211_sub_if_data *sdata;
83 int ret; 83 int ret;
84 84
85 /* we're under RTNL */
86 dev = __dev_get_by_index(&init_net, ifindex);
87 if (!dev)
88 return -ENODEV;
89
90 if (!nl80211_type_check(type)) 85 if (!nl80211_type_check(type))
91 return -EINVAL; 86 return -EINVAL;
92 87
@@ -1177,123 +1172,29 @@ static int ieee80211_scan(struct wiphy *wiphy,
1177static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, 1172static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1178 struct cfg80211_auth_request *req) 1173 struct cfg80211_auth_request *req)
1179{ 1174{
1180 struct ieee80211_sub_if_data *sdata; 1175 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
1181
1182 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1183
1184 switch (req->auth_type) {
1185 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1186 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN;
1187 break;
1188 case NL80211_AUTHTYPE_SHARED_KEY:
1189 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_SHARED_KEY;
1190 break;
1191 case NL80211_AUTHTYPE_FT:
1192 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_FT;
1193 break;
1194 case NL80211_AUTHTYPE_NETWORK_EAP:
1195 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_LEAP;
1196 break;
1197 default:
1198 return -EOPNOTSUPP;
1199 }
1200
1201 memcpy(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN);
1202 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
1203 sdata->u.mgd.flags |= IEEE80211_STA_BSSID_SET;
1204
1205 /* TODO: req->chan */
1206 sdata->u.mgd.flags |= IEEE80211_STA_AUTO_CHANNEL_SEL;
1207
1208 if (req->ssid) {
1209 sdata->u.mgd.flags |= IEEE80211_STA_SSID_SET;
1210 memcpy(sdata->u.mgd.ssid, req->ssid, req->ssid_len);
1211 sdata->u.mgd.ssid_len = req->ssid_len;
1212 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL;
1213 }
1214
1215 kfree(sdata->u.mgd.sme_auth_ie);
1216 sdata->u.mgd.sme_auth_ie = NULL;
1217 sdata->u.mgd.sme_auth_ie_len = 0;
1218 if (req->ie) {
1219 sdata->u.mgd.sme_auth_ie = kmalloc(req->ie_len, GFP_KERNEL);
1220 if (sdata->u.mgd.sme_auth_ie == NULL)
1221 return -ENOMEM;
1222 memcpy(sdata->u.mgd.sme_auth_ie, req->ie, req->ie_len);
1223 sdata->u.mgd.sme_auth_ie_len = req->ie_len;
1224 }
1225
1226 sdata->u.mgd.flags |= IEEE80211_STA_EXT_SME;
1227 sdata->u.mgd.state = IEEE80211_STA_MLME_DIRECT_PROBE;
1228 ieee80211_sta_req_auth(sdata);
1229 return 0;
1230} 1176}
1231 1177
1232static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, 1178static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1233 struct cfg80211_assoc_request *req) 1179 struct cfg80211_assoc_request *req)
1234{ 1180{
1235 struct ieee80211_sub_if_data *sdata; 1181 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
1236 int ret;
1237
1238 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1239
1240 if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 ||
1241 !(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED))
1242 return -ENOLINK; /* not authenticated */
1243
1244 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
1245 sdata->u.mgd.flags |= IEEE80211_STA_BSSID_SET;
1246
1247 /* TODO: req->chan */
1248 sdata->u.mgd.flags |= IEEE80211_STA_AUTO_CHANNEL_SEL;
1249
1250 if (req->ssid) {
1251 sdata->u.mgd.flags |= IEEE80211_STA_SSID_SET;
1252 memcpy(sdata->u.mgd.ssid, req->ssid, req->ssid_len);
1253 sdata->u.mgd.ssid_len = req->ssid_len;
1254 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL;
1255 } else
1256 sdata->u.mgd.flags |= IEEE80211_STA_AUTO_SSID_SEL;
1257
1258 ret = ieee80211_sta_set_extra_ie(sdata, req->ie, req->ie_len);
1259 if (ret && ret != -EALREADY)
1260 return ret;
1261
1262 if (req->use_mfp) {
1263 sdata->u.mgd.mfp = IEEE80211_MFP_REQUIRED;
1264 sdata->u.mgd.flags |= IEEE80211_STA_MFP_ENABLED;
1265 } else {
1266 sdata->u.mgd.mfp = IEEE80211_MFP_DISABLED;
1267 sdata->u.mgd.flags &= ~IEEE80211_STA_MFP_ENABLED;
1268 }
1269
1270 if (req->control_port)
1271 sdata->u.mgd.flags |= IEEE80211_STA_CONTROL_PORT;
1272 else
1273 sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT;
1274
1275 sdata->u.mgd.flags |= IEEE80211_STA_EXT_SME;
1276 sdata->u.mgd.state = IEEE80211_STA_MLME_ASSOCIATE;
1277 ieee80211_sta_req_auth(sdata);
1278 return 0;
1279} 1182}
1280 1183
1281static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, 1184static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
1282 struct cfg80211_deauth_request *req) 1185 struct cfg80211_deauth_request *req,
1186 void *cookie)
1283{ 1187{
1284 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1188 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev),
1285 1189 req, cookie);
1286 /* TODO: req->ie, req->peer_addr */
1287 return ieee80211_sta_deauthenticate(sdata, req->reason_code);
1288} 1190}
1289 1191
1290static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, 1192static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1291 struct cfg80211_disassoc_request *req) 1193 struct cfg80211_disassoc_request *req,
1194 void *cookie)
1292{ 1195{
1293 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1196 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev),
1294 1197 req, cookie);
1295 /* TODO: req->ie, req->peer_addr */
1296 return ieee80211_sta_disassociate(sdata, req->reason_code);
1297} 1198}
1298 1199
1299static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, 1200static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
@@ -1374,6 +1275,16 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1374 return 0; 1275 return 0;
1375} 1276}
1376 1277
1278static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
1279 u8 *addr)
1280{
1281 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1282
1283 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
1284
1285 return 0;
1286}
1287
1377static void ieee80211_rfkill_poll(struct wiphy *wiphy) 1288static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1378{ 1289{
1379 struct ieee80211_local *local = wiphy_priv(wiphy); 1290 struct ieee80211_local *local = wiphy_priv(wiphy);
@@ -1381,6 +1292,85 @@ static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1381 drv_rfkill_poll(local); 1292 drv_rfkill_poll(local);
1382} 1293}
1383 1294
1295#ifdef CONFIG_NL80211_TESTMODE
1296static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
1297{
1298 struct ieee80211_local *local = wiphy_priv(wiphy);
1299
1300 if (!local->ops->testmode_cmd)
1301 return -EOPNOTSUPP;
1302
1303 return local->ops->testmode_cmd(&local->hw, data, len);
1304}
1305#endif
1306
1307static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
1308 bool enabled, int timeout)
1309{
1310 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1311 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1312 struct ieee80211_conf *conf = &local->hw.conf;
1313
1314 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
1315 return -EOPNOTSUPP;
1316
1317 if (enabled == sdata->u.mgd.powersave &&
1318 timeout == conf->dynamic_ps_timeout)
1319 return 0;
1320
1321 sdata->u.mgd.powersave = enabled;
1322 conf->dynamic_ps_timeout = timeout;
1323
1324 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
1325 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
1326
1327 ieee80211_recalc_ps(local, -1);
1328
1329 return 0;
1330}
1331
1332static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
1333 struct net_device *dev,
1334 const u8 *addr,
1335 const struct cfg80211_bitrate_mask *mask)
1336{
1337 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1338 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1339 int i, err = -EINVAL;
1340 u32 target_rate;
1341 struct ieee80211_supported_band *sband;
1342
1343 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1344
1345 /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates
1346 * target_rate = X, rate->fixed = 1 means only rate X
1347 * target_rate = X, rate->fixed = 0 means all rates <= X */
1348 sdata->max_ratectrl_rateidx = -1;
1349 sdata->force_unicast_rateidx = -1;
1350
1351 if (mask->fixed)
1352 target_rate = mask->fixed / 100;
1353 else if (mask->maxrate)
1354 target_rate = mask->maxrate / 100;
1355 else
1356 return 0;
1357
1358 for (i=0; i< sband->n_bitrates; i++) {
1359 struct ieee80211_rate *brate = &sband->bitrates[i];
1360 int this_rate = brate->bitrate;
1361
1362 if (target_rate == this_rate) {
1363 sdata->max_ratectrl_rateidx = i;
1364 if (mask->fixed)
1365 sdata->force_unicast_rateidx = i;
1366 err = 0;
1367 break;
1368 }
1369 }
1370
1371 return err;
1372}
1373
1384struct cfg80211_ops mac80211_config_ops = { 1374struct cfg80211_ops mac80211_config_ops = {
1385 .add_virtual_intf = ieee80211_add_iface, 1375 .add_virtual_intf = ieee80211_add_iface,
1386 .del_virtual_intf = ieee80211_del_iface, 1376 .del_virtual_intf = ieee80211_del_iface,
@@ -1422,5 +1412,9 @@ struct cfg80211_ops mac80211_config_ops = {
1422 .set_wiphy_params = ieee80211_set_wiphy_params, 1412 .set_wiphy_params = ieee80211_set_wiphy_params,
1423 .set_tx_power = ieee80211_set_tx_power, 1413 .set_tx_power = ieee80211_set_tx_power,
1424 .get_tx_power = ieee80211_get_tx_power, 1414 .get_tx_power = ieee80211_get_tx_power,
1415 .set_wds_peer = ieee80211_set_wds_peer,
1425 .rfkill_poll = ieee80211_rfkill_poll, 1416 .rfkill_poll = ieee80211_rfkill_poll,
1417 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
1418 .set_power_mgmt = ieee80211_set_power_mgmt,
1419 .set_bitrate_mask = ieee80211_set_bitrate_mask,
1426}; 1420};
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 6c439cd5ccea..96991b68f048 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -175,7 +175,7 @@ static ssize_t queues_read(struct file *file, char __user *user_buf,
175 for (q = 0; q < local->hw.queues; q++) 175 for (q = 0; q < local->hw.queues; q++)
176 res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q, 176 res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q,
177 local->queue_stop_reasons[q], 177 local->queue_stop_reasons[q],
178 __netif_subqueue_stopped(local->mdev, q)); 178 skb_queue_len(&local->pending[q]));
179 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 179 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
180 180
181 return simple_read_from_buffer(user_buf, count, ppos, buf, res); 181 return simple_read_from_buffer(user_buf, count, ppos, buf, res);
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index e3420329f4e6..e9ec6cae2d39 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -95,33 +95,9 @@ IEEE80211_IF_FILE(force_unicast_rateidx, force_unicast_rateidx, DEC);
95IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC); 95IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC);
96 96
97/* STA attributes */ 97/* STA attributes */
98IEEE80211_IF_FILE(state, u.mgd.state, DEC);
99IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); 98IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC);
100IEEE80211_IF_FILE(prev_bssid, u.mgd.prev_bssid, MAC);
101IEEE80211_IF_FILE(ssid_len, u.mgd.ssid_len, SIZE);
102IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); 99IEEE80211_IF_FILE(aid, u.mgd.aid, DEC);
103IEEE80211_IF_FILE(ap_capab, u.mgd.ap_capab, HEX);
104IEEE80211_IF_FILE(capab, u.mgd.capab, HEX); 100IEEE80211_IF_FILE(capab, u.mgd.capab, HEX);
105IEEE80211_IF_FILE(extra_ie_len, u.mgd.extra_ie_len, SIZE);
106IEEE80211_IF_FILE(auth_tries, u.mgd.auth_tries, DEC);
107IEEE80211_IF_FILE(assoc_tries, u.mgd.assoc_tries, DEC);
108IEEE80211_IF_FILE(auth_algs, u.mgd.auth_algs, HEX);
109IEEE80211_IF_FILE(auth_alg, u.mgd.auth_alg, DEC);
110IEEE80211_IF_FILE(auth_transaction, u.mgd.auth_transaction, DEC);
111
112static ssize_t ieee80211_if_fmt_flags(
113 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
114{
115 return scnprintf(buf, buflen, "%s%s%s%s%s%s%s\n",
116 sdata->u.mgd.flags & IEEE80211_STA_SSID_SET ? "SSID\n" : "",
117 sdata->u.mgd.flags & IEEE80211_STA_BSSID_SET ? "BSSID\n" : "",
118 sdata->u.mgd.flags & IEEE80211_STA_PREV_BSSID_SET ? "prev BSSID\n" : "",
119 sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "",
120 sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "",
121 sdata->u.mgd.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "",
122 sdata->vif.bss_conf.use_cts_prot ? "CTS prot\n" : "");
123}
124__IEEE80211_IF_FILE(flags);
125 101
126/* AP attributes */ 102/* AP attributes */
127IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); 103IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
@@ -184,20 +160,9 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata)
184 DEBUGFS_ADD(force_unicast_rateidx, sta); 160 DEBUGFS_ADD(force_unicast_rateidx, sta);
185 DEBUGFS_ADD(max_ratectrl_rateidx, sta); 161 DEBUGFS_ADD(max_ratectrl_rateidx, sta);
186 162
187 DEBUGFS_ADD(state, sta);
188 DEBUGFS_ADD(bssid, sta); 163 DEBUGFS_ADD(bssid, sta);
189 DEBUGFS_ADD(prev_bssid, sta);
190 DEBUGFS_ADD(ssid_len, sta);
191 DEBUGFS_ADD(aid, sta); 164 DEBUGFS_ADD(aid, sta);
192 DEBUGFS_ADD(ap_capab, sta);
193 DEBUGFS_ADD(capab, sta); 165 DEBUGFS_ADD(capab, sta);
194 DEBUGFS_ADD(extra_ie_len, sta);
195 DEBUGFS_ADD(auth_tries, sta);
196 DEBUGFS_ADD(assoc_tries, sta);
197 DEBUGFS_ADD(auth_algs, sta);
198 DEBUGFS_ADD(auth_alg, sta);
199 DEBUGFS_ADD(auth_transaction, sta);
200 DEBUGFS_ADD(flags, sta);
201} 166}
202 167
203static void add_ap_files(struct ieee80211_sub_if_data *sdata) 168static void add_ap_files(struct ieee80211_sub_if_data *sdata)
@@ -317,20 +282,9 @@ static void del_sta_files(struct ieee80211_sub_if_data *sdata)
317 DEBUGFS_DEL(force_unicast_rateidx, sta); 282 DEBUGFS_DEL(force_unicast_rateidx, sta);
318 DEBUGFS_DEL(max_ratectrl_rateidx, sta); 283 DEBUGFS_DEL(max_ratectrl_rateidx, sta);
319 284
320 DEBUGFS_DEL(state, sta);
321 DEBUGFS_DEL(bssid, sta); 285 DEBUGFS_DEL(bssid, sta);
322 DEBUGFS_DEL(prev_bssid, sta);
323 DEBUGFS_DEL(ssid_len, sta);
324 DEBUGFS_DEL(aid, sta); 286 DEBUGFS_DEL(aid, sta);
325 DEBUGFS_DEL(ap_capab, sta);
326 DEBUGFS_DEL(capab, sta); 287 DEBUGFS_DEL(capab, sta);
327 DEBUGFS_DEL(extra_ie_len, sta);
328 DEBUGFS_DEL(auth_tries, sta);
329 DEBUGFS_DEL(assoc_tries, sta);
330 DEBUGFS_DEL(auth_algs, sta);
331 DEBUGFS_DEL(auth_alg, sta);
332 DEBUGFS_DEL(auth_transaction, sta);
333 DEBUGFS_DEL(flags, sta);
334} 288}
335 289
336static void del_ap_files(struct ieee80211_sub_if_data *sdata) 290static void del_ap_files(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 90230c718b5b..33a2e892115b 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -120,45 +120,38 @@ STA_OPS(last_seq_ctrl);
120static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, 120static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
121 size_t count, loff_t *ppos) 121 size_t count, loff_t *ppos)
122{ 122{
123 char buf[768], *p = buf; 123 char buf[30 + STA_TID_NUM * 70], *p = buf;
124 int i; 124 int i;
125 struct sta_info *sta = file->private_data; 125 struct sta_info *sta = file->private_data;
126 p += scnprintf(p, sizeof(buf)+buf-p, "Agg state for STA is:\n");
127 p += scnprintf(p, sizeof(buf)+buf-p, " STA next dialog_token is %d \n "
128 "TIDs info is: \n TID :",
129 (sta->ampdu_mlme.dialog_token_allocator + 1));
130 for (i = 0; i < STA_TID_NUM; i++)
131 p += scnprintf(p, sizeof(buf)+buf-p, "%5d", i);
132
133 p += scnprintf(p, sizeof(buf)+buf-p, "\n RX :");
134 for (i = 0; i < STA_TID_NUM; i++)
135 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
136 sta->ampdu_mlme.tid_state_rx[i]);
137
138 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:");
139 for (i = 0; i < STA_TID_NUM; i++)
140 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
141 sta->ampdu_mlme.tid_state_rx[i] ?
142 sta->ampdu_mlme.tid_rx[i]->dialog_token : 0);
143
144 p += scnprintf(p, sizeof(buf)+buf-p, "\n TX :");
145 for (i = 0; i < STA_TID_NUM; i++)
146 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
147 sta->ampdu_mlme.tid_state_tx[i]);
148
149 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:");
150 for (i = 0; i < STA_TID_NUM; i++)
151 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
152 sta->ampdu_mlme.tid_state_tx[i] ?
153 sta->ampdu_mlme.tid_tx[i]->dialog_token : 0);
154
155 p += scnprintf(p, sizeof(buf)+buf-p, "\n SSN :");
156 for (i = 0; i < STA_TID_NUM; i++)
157 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
158 sta->ampdu_mlme.tid_state_tx[i] ?
159 sta->ampdu_mlme.tid_tx[i]->ssn : 0);
160 126
161 p += scnprintf(p, sizeof(buf)+buf-p, "\n"); 127 spin_lock_bh(&sta->lock);
128 p += scnprintf(p, sizeof(buf)+buf-p, "next dialog_token is %#02x\n",
129 sta->ampdu_mlme.dialog_token_allocator + 1);
130 for (i = 0; i < STA_TID_NUM; i++) {
131 p += scnprintf(p, sizeof(buf)+buf-p, "TID %02d:", i);
132 p += scnprintf(p, sizeof(buf)+buf-p, " RX=%x",
133 sta->ampdu_mlme.tid_state_rx[i]);
134 p += scnprintf(p, sizeof(buf)+buf-p, "/DTKN=%#.2x",
135 sta->ampdu_mlme.tid_state_rx[i] ?
136 sta->ampdu_mlme.tid_rx[i]->dialog_token : 0);
137 p += scnprintf(p, sizeof(buf)+buf-p, "/SSN=%#.3x",
138 sta->ampdu_mlme.tid_state_rx[i] ?
139 sta->ampdu_mlme.tid_rx[i]->ssn : 0);
140
141 p += scnprintf(p, sizeof(buf)+buf-p, " TX=%x",
142 sta->ampdu_mlme.tid_state_tx[i]);
143 p += scnprintf(p, sizeof(buf)+buf-p, "/DTKN=%#.2x",
144 sta->ampdu_mlme.tid_state_tx[i] ?
145 sta->ampdu_mlme.tid_tx[i]->dialog_token : 0);
146 p += scnprintf(p, sizeof(buf)+buf-p, "/SSN=%#.3x",
147 sta->ampdu_mlme.tid_state_tx[i] ?
148 sta->ampdu_mlme.tid_tx[i]->ssn : 0);
149 p += scnprintf(p, sizeof(buf)+buf-p, "/pending=%03d",
150 sta->ampdu_mlme.tid_state_tx[i] ?
151 skb_queue_len(&sta->ampdu_mlme.tid_tx[i]->pending) : 0);
152 p += scnprintf(p, sizeof(buf)+buf-p, "\n");
153 }
154 spin_unlock_bh(&sta->lock);
162 155
163 return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); 156 return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
164} 157}
@@ -203,6 +196,22 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
203 DEBUGFS_ADD(inactive_ms); 196 DEBUGFS_ADD(inactive_ms);
204 DEBUGFS_ADD(last_seq_ctrl); 197 DEBUGFS_ADD(last_seq_ctrl);
205 DEBUGFS_ADD(agg_status); 198 DEBUGFS_ADD(agg_status);
199 DEBUGFS_ADD(dev);
200 DEBUGFS_ADD(rx_packets);
201 DEBUGFS_ADD(tx_packets);
202 DEBUGFS_ADD(rx_bytes);
203 DEBUGFS_ADD(tx_bytes);
204 DEBUGFS_ADD(rx_duplicates);
205 DEBUGFS_ADD(rx_fragments);
206 DEBUGFS_ADD(rx_dropped);
207 DEBUGFS_ADD(tx_fragments);
208 DEBUGFS_ADD(tx_filtered);
209 DEBUGFS_ADD(tx_retry_failed);
210 DEBUGFS_ADD(tx_retry_count);
211 DEBUGFS_ADD(last_signal);
212 DEBUGFS_ADD(last_qual);
213 DEBUGFS_ADD(last_noise);
214 DEBUGFS_ADD(wep_weak_iv_count);
206} 215}
207 216
208void ieee80211_sta_debugfs_remove(struct sta_info *sta) 217void ieee80211_sta_debugfs_remove(struct sta_info *sta)
@@ -212,6 +221,23 @@ void ieee80211_sta_debugfs_remove(struct sta_info *sta)
212 DEBUGFS_DEL(inactive_ms); 221 DEBUGFS_DEL(inactive_ms);
213 DEBUGFS_DEL(last_seq_ctrl); 222 DEBUGFS_DEL(last_seq_ctrl);
214 DEBUGFS_DEL(agg_status); 223 DEBUGFS_DEL(agg_status);
224 DEBUGFS_DEL(aid);
225 DEBUGFS_DEL(dev);
226 DEBUGFS_DEL(rx_packets);
227 DEBUGFS_DEL(tx_packets);
228 DEBUGFS_DEL(rx_bytes);
229 DEBUGFS_DEL(tx_bytes);
230 DEBUGFS_DEL(rx_duplicates);
231 DEBUGFS_DEL(rx_fragments);
232 DEBUGFS_DEL(rx_dropped);
233 DEBUGFS_DEL(tx_fragments);
234 DEBUGFS_DEL(tx_filtered);
235 DEBUGFS_DEL(tx_retry_failed);
236 DEBUGFS_DEL(tx_retry_count);
237 DEBUGFS_DEL(last_signal);
238 DEBUGFS_DEL(last_qual);
239 DEBUGFS_DEL(last_noise);
240 DEBUGFS_DEL(wep_weak_iv_count);
215 241
216 debugfs_remove(sta->debugfs.dir); 242 debugfs_remove(sta->debugfs.dir);
217 sta->debugfs.dir = NULL; 243 sta->debugfs.dir = NULL;
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index b13446afd48f..4100c361a99d 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -3,6 +3,7 @@
3 3
4#include <net/mac80211.h> 4#include <net/mac80211.h>
5#include "ieee80211_i.h" 5#include "ieee80211_i.h"
6#include "driver-trace.h"
6 7
7static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb) 8static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
8{ 9{
@@ -11,29 +12,37 @@ static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
11 12
12static inline int drv_start(struct ieee80211_local *local) 13static inline int drv_start(struct ieee80211_local *local)
13{ 14{
14 return local->ops->start(&local->hw); 15 int ret = local->ops->start(&local->hw);
16 trace_drv_start(local, ret);
17 return ret;
15} 18}
16 19
17static inline void drv_stop(struct ieee80211_local *local) 20static inline void drv_stop(struct ieee80211_local *local)
18{ 21{
19 local->ops->stop(&local->hw); 22 local->ops->stop(&local->hw);
23 trace_drv_stop(local);
20} 24}
21 25
22static inline int drv_add_interface(struct ieee80211_local *local, 26static inline int drv_add_interface(struct ieee80211_local *local,
23 struct ieee80211_if_init_conf *conf) 27 struct ieee80211_if_init_conf *conf)
24{ 28{
25 return local->ops->add_interface(&local->hw, conf); 29 int ret = local->ops->add_interface(&local->hw, conf);
30 trace_drv_add_interface(local, conf->mac_addr, conf->vif, ret);
31 return ret;
26} 32}
27 33
28static inline void drv_remove_interface(struct ieee80211_local *local, 34static inline void drv_remove_interface(struct ieee80211_local *local,
29 struct ieee80211_if_init_conf *conf) 35 struct ieee80211_if_init_conf *conf)
30{ 36{
31 local->ops->remove_interface(&local->hw, conf); 37 local->ops->remove_interface(&local->hw, conf);
38 trace_drv_remove_interface(local, conf->mac_addr, conf->vif);
32} 39}
33 40
34static inline int drv_config(struct ieee80211_local *local, u32 changed) 41static inline int drv_config(struct ieee80211_local *local, u32 changed)
35{ 42{
36 return local->ops->config(&local->hw, changed); 43 int ret = local->ops->config(&local->hw, changed);
44 trace_drv_config(local, changed, ret);
45 return ret;
37} 46}
38 47
39static inline void drv_bss_info_changed(struct ieee80211_local *local, 48static inline void drv_bss_info_changed(struct ieee80211_local *local,
@@ -43,6 +52,7 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
43{ 52{
44 if (local->ops->bss_info_changed) 53 if (local->ops->bss_info_changed)
45 local->ops->bss_info_changed(&local->hw, vif, info, changed); 54 local->ops->bss_info_changed(&local->hw, vif, info, changed);
55 trace_drv_bss_info_changed(local, vif, info, changed);
46} 56}
47 57
48static inline void drv_configure_filter(struct ieee80211_local *local, 58static inline void drv_configure_filter(struct ieee80211_local *local,
@@ -53,14 +63,18 @@ static inline void drv_configure_filter(struct ieee80211_local *local,
53{ 63{
54 local->ops->configure_filter(&local->hw, changed_flags, total_flags, 64 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
55 mc_count, mc_list); 65 mc_count, mc_list);
66 trace_drv_configure_filter(local, changed_flags, total_flags,
67 mc_count);
56} 68}
57 69
58static inline int drv_set_tim(struct ieee80211_local *local, 70static inline int drv_set_tim(struct ieee80211_local *local,
59 struct ieee80211_sta *sta, bool set) 71 struct ieee80211_sta *sta, bool set)
60{ 72{
73 int ret = 0;
61 if (local->ops->set_tim) 74 if (local->ops->set_tim)
62 return local->ops->set_tim(&local->hw, sta, set); 75 ret = local->ops->set_tim(&local->hw, sta, set);
63 return 0; 76 trace_drv_set_tim(local, sta, set, ret);
77 return ret;
64} 78}
65 79
66static inline int drv_set_key(struct ieee80211_local *local, 80static inline int drv_set_key(struct ieee80211_local *local,
@@ -68,7 +82,9 @@ static inline int drv_set_key(struct ieee80211_local *local,
68 struct ieee80211_sta *sta, 82 struct ieee80211_sta *sta,
69 struct ieee80211_key_conf *key) 83 struct ieee80211_key_conf *key)
70{ 84{
71 return local->ops->set_key(&local->hw, cmd, vif, sta, key); 85 int ret = local->ops->set_key(&local->hw, cmd, vif, sta, key);
86 trace_drv_set_key(local, cmd, vif, sta, key, ret);
87 return ret;
72} 88}
73 89
74static inline void drv_update_tkip_key(struct ieee80211_local *local, 90static inline void drv_update_tkip_key(struct ieee80211_local *local,
@@ -79,32 +95,41 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local,
79 if (local->ops->update_tkip_key) 95 if (local->ops->update_tkip_key)
80 local->ops->update_tkip_key(&local->hw, conf, address, 96 local->ops->update_tkip_key(&local->hw, conf, address,
81 iv32, phase1key); 97 iv32, phase1key);
98 trace_drv_update_tkip_key(local, conf, address, iv32);
82} 99}
83 100
84static inline int drv_hw_scan(struct ieee80211_local *local, 101static inline int drv_hw_scan(struct ieee80211_local *local,
85 struct cfg80211_scan_request *req) 102 struct cfg80211_scan_request *req)
86{ 103{
87 return local->ops->hw_scan(&local->hw, req); 104 int ret = local->ops->hw_scan(&local->hw, req);
105 trace_drv_hw_scan(local, req, ret);
106 return ret;
88} 107}
89 108
90static inline void drv_sw_scan_start(struct ieee80211_local *local) 109static inline void drv_sw_scan_start(struct ieee80211_local *local)
91{ 110{
92 if (local->ops->sw_scan_start) 111 if (local->ops->sw_scan_start)
93 local->ops->sw_scan_start(&local->hw); 112 local->ops->sw_scan_start(&local->hw);
113 trace_drv_sw_scan_start(local);
94} 114}
95 115
96static inline void drv_sw_scan_complete(struct ieee80211_local *local) 116static inline void drv_sw_scan_complete(struct ieee80211_local *local)
97{ 117{
98 if (local->ops->sw_scan_complete) 118 if (local->ops->sw_scan_complete)
99 local->ops->sw_scan_complete(&local->hw); 119 local->ops->sw_scan_complete(&local->hw);
120 trace_drv_sw_scan_complete(local);
100} 121}
101 122
102static inline int drv_get_stats(struct ieee80211_local *local, 123static inline int drv_get_stats(struct ieee80211_local *local,
103 struct ieee80211_low_level_stats *stats) 124 struct ieee80211_low_level_stats *stats)
104{ 125{
105 if (!local->ops->get_stats) 126 int ret = -EOPNOTSUPP;
106 return -EOPNOTSUPP; 127
107 return local->ops->get_stats(&local->hw, stats); 128 if (local->ops->get_stats)
129 ret = local->ops->get_stats(&local->hw, stats);
130 trace_drv_get_stats(local, stats, ret);
131
132 return ret;
108} 133}
109 134
110static inline void drv_get_tkip_seq(struct ieee80211_local *local, 135static inline void drv_get_tkip_seq(struct ieee80211_local *local,
@@ -112,14 +137,17 @@ static inline void drv_get_tkip_seq(struct ieee80211_local *local,
112{ 137{
113 if (local->ops->get_tkip_seq) 138 if (local->ops->get_tkip_seq)
114 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); 139 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
140 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
115} 141}
116 142
117static inline int drv_set_rts_threshold(struct ieee80211_local *local, 143static inline int drv_set_rts_threshold(struct ieee80211_local *local,
118 u32 value) 144 u32 value)
119{ 145{
146 int ret = 0;
120 if (local->ops->set_rts_threshold) 147 if (local->ops->set_rts_threshold)
121 return local->ops->set_rts_threshold(&local->hw, value); 148 ret = local->ops->set_rts_threshold(&local->hw, value);
122 return 0; 149 trace_drv_set_rts_threshold(local, value, ret);
150 return ret;
123} 151}
124 152
125static inline void drv_sta_notify(struct ieee80211_local *local, 153static inline void drv_sta_notify(struct ieee80211_local *local,
@@ -129,46 +157,57 @@ static inline void drv_sta_notify(struct ieee80211_local *local,
129{ 157{
130 if (local->ops->sta_notify) 158 if (local->ops->sta_notify)
131 local->ops->sta_notify(&local->hw, vif, cmd, sta); 159 local->ops->sta_notify(&local->hw, vif, cmd, sta);
160 trace_drv_sta_notify(local, vif, cmd, sta);
132} 161}
133 162
134static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, 163static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
135 const struct ieee80211_tx_queue_params *params) 164 const struct ieee80211_tx_queue_params *params)
136{ 165{
166 int ret = -EOPNOTSUPP;
137 if (local->ops->conf_tx) 167 if (local->ops->conf_tx)
138 return local->ops->conf_tx(&local->hw, queue, params); 168 ret = local->ops->conf_tx(&local->hw, queue, params);
139 return -EOPNOTSUPP; 169 trace_drv_conf_tx(local, queue, params, ret);
170 return ret;
140} 171}
141 172
142static inline int drv_get_tx_stats(struct ieee80211_local *local, 173static inline int drv_get_tx_stats(struct ieee80211_local *local,
143 struct ieee80211_tx_queue_stats *stats) 174 struct ieee80211_tx_queue_stats *stats)
144{ 175{
145 return local->ops->get_tx_stats(&local->hw, stats); 176 int ret = local->ops->get_tx_stats(&local->hw, stats);
177 trace_drv_get_tx_stats(local, stats, ret);
178 return ret;
146} 179}
147 180
148static inline u64 drv_get_tsf(struct ieee80211_local *local) 181static inline u64 drv_get_tsf(struct ieee80211_local *local)
149{ 182{
183 u64 ret = -1ULL;
150 if (local->ops->get_tsf) 184 if (local->ops->get_tsf)
151 return local->ops->get_tsf(&local->hw); 185 ret = local->ops->get_tsf(&local->hw);
152 return -1ULL; 186 trace_drv_get_tsf(local, ret);
187 return ret;
153} 188}
154 189
155static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) 190static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
156{ 191{
157 if (local->ops->set_tsf) 192 if (local->ops->set_tsf)
158 local->ops->set_tsf(&local->hw, tsf); 193 local->ops->set_tsf(&local->hw, tsf);
194 trace_drv_set_tsf(local, tsf);
159} 195}
160 196
161static inline void drv_reset_tsf(struct ieee80211_local *local) 197static inline void drv_reset_tsf(struct ieee80211_local *local)
162{ 198{
163 if (local->ops->reset_tsf) 199 if (local->ops->reset_tsf)
164 local->ops->reset_tsf(&local->hw); 200 local->ops->reset_tsf(&local->hw);
201 trace_drv_reset_tsf(local);
165} 202}
166 203
167static inline int drv_tx_last_beacon(struct ieee80211_local *local) 204static inline int drv_tx_last_beacon(struct ieee80211_local *local)
168{ 205{
206 int ret = 1;
169 if (local->ops->tx_last_beacon) 207 if (local->ops->tx_last_beacon)
170 return local->ops->tx_last_beacon(&local->hw); 208 ret = local->ops->tx_last_beacon(&local->hw);
171 return 1; 209 trace_drv_tx_last_beacon(local, ret);
210 return ret;
172} 211}
173 212
174static inline int drv_ampdu_action(struct ieee80211_local *local, 213static inline int drv_ampdu_action(struct ieee80211_local *local,
@@ -176,10 +215,12 @@ static inline int drv_ampdu_action(struct ieee80211_local *local,
176 struct ieee80211_sta *sta, u16 tid, 215 struct ieee80211_sta *sta, u16 tid,
177 u16 *ssn) 216 u16 *ssn)
178{ 217{
218 int ret = -EOPNOTSUPP;
179 if (local->ops->ampdu_action) 219 if (local->ops->ampdu_action)
180 return local->ops->ampdu_action(&local->hw, action, 220 ret = local->ops->ampdu_action(&local->hw, action,
181 sta, tid, ssn); 221 sta, tid, ssn);
182 return -EOPNOTSUPP; 222 trace_drv_ampdu_action(local, action, sta, tid, ssn, ret);
223 return ret;
183} 224}
184 225
185 226
diff --git a/net/mac80211/driver-trace.c b/net/mac80211/driver-trace.c
new file mode 100644
index 000000000000..6da6f79932fc
--- /dev/null
+++ b/net/mac80211/driver-trace.c
@@ -0,0 +1,6 @@
1/* bug in tracepoint.h, it should include this */
2#include <linux/module.h>
3
4#include "driver-ops.h"
5#define CREATE_TRACE_POINTS
6#include "driver-trace.h"
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h
new file mode 100644
index 000000000000..5a10da2d70fd
--- /dev/null
+++ b/net/mac80211/driver-trace.h
@@ -0,0 +1,648 @@
1#if !defined(__MAC80211_DRIVER_TRACE) || defined(TRACE_HEADER_MULTI_READ)
2#define __MAC80211_DRIVER_TRACE
3
4#include <linux/tracepoint.h>
5#include <net/mac80211.h>
6#include "ieee80211_i.h"
7
8#if !defined(CONFIG_MAC80211_DRIVER_API_TRACER) || defined(__CHECKER__)
9#undef TRACE_EVENT
10#define TRACE_EVENT(name, proto, ...) \
11static inline void trace_ ## name(proto) {}
12#endif
13
14#undef TRACE_SYSTEM
15#define TRACE_SYSTEM mac80211
16
17#define MAXNAME 32
18#define LOCAL_ENTRY __array(char, wiphy_name, 32)
19#define LOCAL_ASSIGN strlcpy(__entry->wiphy_name, wiphy_name(local->hw.wiphy), MAXNAME)
20#define LOCAL_PR_FMT "%s"
21#define LOCAL_PR_ARG __entry->wiphy_name
22
23#define STA_ENTRY __array(char, sta_addr, ETH_ALEN)
24#define STA_ASSIGN (sta ? memcpy(__entry->sta_addr, sta->addr, ETH_ALEN) : memset(__entry->sta_addr, 0, ETH_ALEN))
25#define STA_PR_FMT " sta:%pM"
26#define STA_PR_ARG __entry->sta_addr
27
28#define VIF_ENTRY __field(enum nl80211_iftype, vif_type) __field(void *, vif)
29#define VIF_ASSIGN __entry->vif_type = vif ? vif->type : 0; __entry->vif = vif
30#define VIF_PR_FMT " vif:%p(%d)"
31#define VIF_PR_ARG __entry->vif, __entry->vif_type
32
33TRACE_EVENT(drv_start,
34 TP_PROTO(struct ieee80211_local *local, int ret),
35
36 TP_ARGS(local, ret),
37
38 TP_STRUCT__entry(
39 LOCAL_ENTRY
40 __field(int, ret)
41 ),
42
43 TP_fast_assign(
44 LOCAL_ASSIGN;
45 __entry->ret = ret;
46 ),
47
48 TP_printk(
49 LOCAL_PR_FMT, LOCAL_PR_ARG
50 )
51);
52
53TRACE_EVENT(drv_stop,
54 TP_PROTO(struct ieee80211_local *local),
55
56 TP_ARGS(local),
57
58 TP_STRUCT__entry(
59 LOCAL_ENTRY
60 ),
61
62 TP_fast_assign(
63 LOCAL_ASSIGN;
64 ),
65
66 TP_printk(
67 LOCAL_PR_FMT, LOCAL_PR_ARG
68 )
69);
70
71TRACE_EVENT(drv_add_interface,
72 TP_PROTO(struct ieee80211_local *local,
73 const u8 *addr,
74 struct ieee80211_vif *vif,
75 int ret),
76
77 TP_ARGS(local, addr, vif, ret),
78
79 TP_STRUCT__entry(
80 LOCAL_ENTRY
81 VIF_ENTRY
82 __array(char, addr, 6)
83 __field(int, ret)
84 ),
85
86 TP_fast_assign(
87 LOCAL_ASSIGN;
88 VIF_ASSIGN;
89 memcpy(__entry->addr, addr, 6);
90 __entry->ret = ret;
91 ),
92
93 TP_printk(
94 LOCAL_PR_FMT VIF_PR_FMT " addr:%pM ret:%d",
95 LOCAL_PR_ARG, VIF_PR_ARG, __entry->addr, __entry->ret
96 )
97);
98
99TRACE_EVENT(drv_remove_interface,
100 TP_PROTO(struct ieee80211_local *local,
101 const u8 *addr, struct ieee80211_vif *vif),
102
103 TP_ARGS(local, addr, vif),
104
105 TP_STRUCT__entry(
106 LOCAL_ENTRY
107 VIF_ENTRY
108 __array(char, addr, 6)
109 ),
110
111 TP_fast_assign(
112 LOCAL_ASSIGN;
113 VIF_ASSIGN;
114 memcpy(__entry->addr, addr, 6);
115 ),
116
117 TP_printk(
118 LOCAL_PR_FMT VIF_PR_FMT " addr:%pM",
119 LOCAL_PR_ARG, VIF_PR_ARG, __entry->addr
120 )
121);
122
123TRACE_EVENT(drv_config,
124 TP_PROTO(struct ieee80211_local *local,
125 u32 changed,
126 int ret),
127
128 TP_ARGS(local, changed, ret),
129
130 TP_STRUCT__entry(
131 LOCAL_ENTRY
132 __field(u32, changed)
133 __field(int, ret)
134 ),
135
136 TP_fast_assign(
137 LOCAL_ASSIGN;
138 __entry->changed = changed;
139 __entry->ret = ret;
140 ),
141
142 TP_printk(
143 LOCAL_PR_FMT " ch:%#x ret:%d",
144 LOCAL_PR_ARG, __entry->changed, __entry->ret
145 )
146);
147
148TRACE_EVENT(drv_bss_info_changed,
149 TP_PROTO(struct ieee80211_local *local,
150 struct ieee80211_vif *vif,
151 struct ieee80211_bss_conf *info,
152 u32 changed),
153
154 TP_ARGS(local, vif, info, changed),
155
156 TP_STRUCT__entry(
157 LOCAL_ENTRY
158 VIF_ENTRY
159 __field(bool, assoc)
160 __field(u16, aid)
161 __field(bool, cts)
162 __field(bool, shortpre)
163 __field(bool, shortslot)
164 __field(u8, dtimper)
165 __field(u16, bcnint)
166 __field(u16, assoc_cap)
167 __field(u64, timestamp)
168 __field(u32, basic_rates)
169 __field(u32, changed)
170 ),
171
172 TP_fast_assign(
173 LOCAL_ASSIGN;
174 VIF_ASSIGN;
175 __entry->changed = changed;
176 __entry->aid = info->aid;
177 __entry->assoc = info->assoc;
178 __entry->shortpre = info->use_short_preamble;
179 __entry->cts = info->use_cts_prot;
180 __entry->shortslot = info->use_short_slot;
181 __entry->dtimper = info->dtim_period;
182 __entry->bcnint = info->beacon_int;
183 __entry->assoc_cap = info->assoc_capability;
184 __entry->timestamp = info->timestamp;
185 __entry->basic_rates = info->basic_rates;
186 ),
187
188 TP_printk(
189 LOCAL_PR_FMT VIF_PR_FMT " changed:%#x",
190 LOCAL_PR_ARG, VIF_PR_ARG, __entry->changed
191 )
192);
193
194TRACE_EVENT(drv_configure_filter,
195 TP_PROTO(struct ieee80211_local *local,
196 unsigned int changed_flags,
197 unsigned int *total_flags,
198 int mc_count),
199
200 TP_ARGS(local, changed_flags, total_flags, mc_count),
201
202 TP_STRUCT__entry(
203 LOCAL_ENTRY
204 __field(unsigned int, changed)
205 __field(unsigned int, total)
206 __field(int, mc)
207 ),
208
209 TP_fast_assign(
210 LOCAL_ASSIGN;
211 __entry->changed = changed_flags;
212 __entry->total = *total_flags;
213 __entry->mc = mc_count;
214 ),
215
216 TP_printk(
217 LOCAL_PR_FMT " changed:%#x total:%#x mc:%d",
218 LOCAL_PR_ARG, __entry->changed, __entry->total, __entry->mc
219 )
220);
221
222TRACE_EVENT(drv_set_tim,
223 TP_PROTO(struct ieee80211_local *local,
224 struct ieee80211_sta *sta, bool set, int ret),
225
226 TP_ARGS(local, sta, set, ret),
227
228 TP_STRUCT__entry(
229 LOCAL_ENTRY
230 STA_ENTRY
231 __field(bool, set)
232 __field(int, ret)
233 ),
234
235 TP_fast_assign(
236 LOCAL_ASSIGN;
237 STA_ASSIGN;
238 __entry->set = set;
239 __entry->ret = ret;
240 ),
241
242 TP_printk(
243 LOCAL_PR_FMT STA_PR_FMT " set:%d ret:%d",
244 LOCAL_PR_ARG, STA_PR_FMT, __entry->set, __entry->ret
245 )
246);
247
248TRACE_EVENT(drv_set_key,
249 TP_PROTO(struct ieee80211_local *local,
250 enum set_key_cmd cmd, struct ieee80211_vif *vif,
251 struct ieee80211_sta *sta,
252 struct ieee80211_key_conf *key, int ret),
253
254 TP_ARGS(local, cmd, vif, sta, key, ret),
255
256 TP_STRUCT__entry(
257 LOCAL_ENTRY
258 VIF_ENTRY
259 STA_ENTRY
260 __field(enum ieee80211_key_alg, alg)
261 __field(u8, hw_key_idx)
262 __field(u8, flags)
263 __field(s8, keyidx)
264 __field(int, ret)
265 ),
266
267 TP_fast_assign(
268 LOCAL_ASSIGN;
269 VIF_ASSIGN;
270 STA_ASSIGN;
271 __entry->alg = key->alg;
272 __entry->flags = key->flags;
273 __entry->keyidx = key->keyidx;
274 __entry->hw_key_idx = key->hw_key_idx;
275 __entry->ret = ret;
276 ),
277
278 TP_printk(
279 LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " ret:%d",
280 LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->ret
281 )
282);
283
284TRACE_EVENT(drv_update_tkip_key,
285 TP_PROTO(struct ieee80211_local *local,
286 struct ieee80211_key_conf *conf,
287 const u8 *address, u32 iv32),
288
289 TP_ARGS(local, conf, address, iv32),
290
291 TP_STRUCT__entry(
292 LOCAL_ENTRY
293 __array(u8, addr, 6)
294 __field(u32, iv32)
295 ),
296
297 TP_fast_assign(
298 LOCAL_ASSIGN;
299 memcpy(__entry->addr, address, 6);
300 __entry->iv32 = iv32;
301 ),
302
303 TP_printk(
304 LOCAL_PR_FMT " addr:%pM iv32:%#x",
305 LOCAL_PR_ARG, __entry->addr, __entry->iv32
306 )
307);
308
309TRACE_EVENT(drv_hw_scan,
310 TP_PROTO(struct ieee80211_local *local,
311 struct cfg80211_scan_request *req, int ret),
312
313 TP_ARGS(local, req, ret),
314
315 TP_STRUCT__entry(
316 LOCAL_ENTRY
317 __field(int, ret)
318 ),
319
320 TP_fast_assign(
321 LOCAL_ASSIGN;
322 __entry->ret = ret;
323 ),
324
325 TP_printk(
326 LOCAL_PR_FMT " ret:%d",
327 LOCAL_PR_ARG, __entry->ret
328 )
329);
330
331TRACE_EVENT(drv_sw_scan_start,
332 TP_PROTO(struct ieee80211_local *local),
333
334 TP_ARGS(local),
335
336 TP_STRUCT__entry(
337 LOCAL_ENTRY
338 ),
339
340 TP_fast_assign(
341 LOCAL_ASSIGN;
342 ),
343
344 TP_printk(
345 LOCAL_PR_FMT, LOCAL_PR_ARG
346 )
347);
348
349TRACE_EVENT(drv_sw_scan_complete,
350 TP_PROTO(struct ieee80211_local *local),
351
352 TP_ARGS(local),
353
354 TP_STRUCT__entry(
355 LOCAL_ENTRY
356 ),
357
358 TP_fast_assign(
359 LOCAL_ASSIGN;
360 ),
361
362 TP_printk(
363 LOCAL_PR_FMT, LOCAL_PR_ARG
364 )
365);
366
367TRACE_EVENT(drv_get_stats,
368 TP_PROTO(struct ieee80211_local *local,
369 struct ieee80211_low_level_stats *stats,
370 int ret),
371
372 TP_ARGS(local, stats, ret),
373
374 TP_STRUCT__entry(
375 LOCAL_ENTRY
376 __field(int, ret)
377 __field(unsigned int, ackfail)
378 __field(unsigned int, rtsfail)
379 __field(unsigned int, fcserr)
380 __field(unsigned int, rtssucc)
381 ),
382
383 TP_fast_assign(
384 LOCAL_ASSIGN;
385 __entry->ret = ret;
386 __entry->ackfail = stats->dot11ACKFailureCount;
387 __entry->rtsfail = stats->dot11RTSFailureCount;
388 __entry->fcserr = stats->dot11FCSErrorCount;
389 __entry->rtssucc = stats->dot11RTSSuccessCount;
390 ),
391
392 TP_printk(
393 LOCAL_PR_FMT " ret:%d",
394 LOCAL_PR_ARG, __entry->ret
395 )
396);
397
398TRACE_EVENT(drv_get_tkip_seq,
399 TP_PROTO(struct ieee80211_local *local,
400 u8 hw_key_idx, u32 *iv32, u16 *iv16),
401
402 TP_ARGS(local, hw_key_idx, iv32, iv16),
403
404 TP_STRUCT__entry(
405 LOCAL_ENTRY
406 __field(u8, hw_key_idx)
407 __field(u32, iv32)
408 __field(u16, iv16)
409 ),
410
411 TP_fast_assign(
412 LOCAL_ASSIGN;
413 __entry->hw_key_idx = hw_key_idx;
414 __entry->iv32 = *iv32;
415 __entry->iv16 = *iv16;
416 ),
417
418 TP_printk(
419 LOCAL_PR_FMT, LOCAL_PR_ARG
420 )
421);
422
423TRACE_EVENT(drv_set_rts_threshold,
424 TP_PROTO(struct ieee80211_local *local, u32 value, int ret),
425
426 TP_ARGS(local, value, ret),
427
428 TP_STRUCT__entry(
429 LOCAL_ENTRY
430 __field(u32, value)
431 __field(int, ret)
432 ),
433
434 TP_fast_assign(
435 LOCAL_ASSIGN;
436 __entry->ret = ret;
437 __entry->value = value;
438 ),
439
440 TP_printk(
441 LOCAL_PR_FMT " value:%d ret:%d",
442 LOCAL_PR_ARG, __entry->value, __entry->ret
443 )
444);
445
446TRACE_EVENT(drv_sta_notify,
447 TP_PROTO(struct ieee80211_local *local,
448 struct ieee80211_vif *vif,
449 enum sta_notify_cmd cmd,
450 struct ieee80211_sta *sta),
451
452 TP_ARGS(local, vif, cmd, sta),
453
454 TP_STRUCT__entry(
455 LOCAL_ENTRY
456 VIF_ENTRY
457 STA_ENTRY
458 __field(u32, cmd)
459 ),
460
461 TP_fast_assign(
462 LOCAL_ASSIGN;
463 VIF_ASSIGN;
464 STA_ASSIGN;
465 __entry->cmd = cmd;
466 ),
467
468 TP_printk(
469 LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " cmd:%d",
470 LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->cmd
471 )
472);
473
474TRACE_EVENT(drv_conf_tx,
475 TP_PROTO(struct ieee80211_local *local, u16 queue,
476 const struct ieee80211_tx_queue_params *params,
477 int ret),
478
479 TP_ARGS(local, queue, params, ret),
480
481 TP_STRUCT__entry(
482 LOCAL_ENTRY
483 __field(u16, queue)
484 __field(u16, txop)
485 __field(u16, cw_min)
486 __field(u16, cw_max)
487 __field(u8, aifs)
488 __field(int, ret)
489 ),
490
491 TP_fast_assign(
492 LOCAL_ASSIGN;
493 __entry->queue = queue;
494 __entry->ret = ret;
495 __entry->txop = params->txop;
496 __entry->cw_max = params->cw_max;
497 __entry->cw_min = params->cw_min;
498 __entry->aifs = params->aifs;
499 ),
500
501 TP_printk(
502 LOCAL_PR_FMT " queue:%d ret:%d",
503 LOCAL_PR_ARG, __entry->queue, __entry->ret
504 )
505);
506
507TRACE_EVENT(drv_get_tx_stats,
508 TP_PROTO(struct ieee80211_local *local,
509 struct ieee80211_tx_queue_stats *stats,
510 int ret),
511
512 TP_ARGS(local, stats, ret),
513
514 TP_STRUCT__entry(
515 LOCAL_ENTRY
516 __field(int, ret)
517 ),
518
519 TP_fast_assign(
520 LOCAL_ASSIGN;
521 __entry->ret = ret;
522 ),
523
524 TP_printk(
525 LOCAL_PR_FMT " ret:%d",
526 LOCAL_PR_ARG, __entry->ret
527 )
528);
529
530TRACE_EVENT(drv_get_tsf,
531 TP_PROTO(struct ieee80211_local *local, u64 ret),
532
533 TP_ARGS(local, ret),
534
535 TP_STRUCT__entry(
536 LOCAL_ENTRY
537 __field(u64, ret)
538 ),
539
540 TP_fast_assign(
541 LOCAL_ASSIGN;
542 __entry->ret = ret;
543 ),
544
545 TP_printk(
546 LOCAL_PR_FMT " ret:%llu",
547 LOCAL_PR_ARG, (unsigned long long)__entry->ret
548 )
549);
550
551TRACE_EVENT(drv_set_tsf,
552 TP_PROTO(struct ieee80211_local *local, u64 tsf),
553
554 TP_ARGS(local, tsf),
555
556 TP_STRUCT__entry(
557 LOCAL_ENTRY
558 __field(u64, tsf)
559 ),
560
561 TP_fast_assign(
562 LOCAL_ASSIGN;
563 __entry->tsf = tsf;
564 ),
565
566 TP_printk(
567 LOCAL_PR_FMT " tsf:%llu",
568 LOCAL_PR_ARG, (unsigned long long)__entry->tsf
569 )
570);
571
572TRACE_EVENT(drv_reset_tsf,
573 TP_PROTO(struct ieee80211_local *local),
574
575 TP_ARGS(local),
576
577 TP_STRUCT__entry(
578 LOCAL_ENTRY
579 ),
580
581 TP_fast_assign(
582 LOCAL_ASSIGN;
583 ),
584
585 TP_printk(
586 LOCAL_PR_FMT, LOCAL_PR_ARG
587 )
588);
589
590TRACE_EVENT(drv_tx_last_beacon,
591 TP_PROTO(struct ieee80211_local *local, int ret),
592
593 TP_ARGS(local, ret),
594
595 TP_STRUCT__entry(
596 LOCAL_ENTRY
597 __field(int, ret)
598 ),
599
600 TP_fast_assign(
601 LOCAL_ASSIGN;
602 __entry->ret = ret;
603 ),
604
605 TP_printk(
606 LOCAL_PR_FMT " ret:%d",
607 LOCAL_PR_ARG, __entry->ret
608 )
609);
610
611TRACE_EVENT(drv_ampdu_action,
612 TP_PROTO(struct ieee80211_local *local,
613 enum ieee80211_ampdu_mlme_action action,
614 struct ieee80211_sta *sta, u16 tid,
615 u16 *ssn, int ret),
616
617 TP_ARGS(local, action, sta, tid, ssn, ret),
618
619 TP_STRUCT__entry(
620 LOCAL_ENTRY
621 STA_ENTRY
622 __field(u32, action)
623 __field(u16, tid)
624 __field(u16, ssn)
625 __field(int, ret)
626 ),
627
628 TP_fast_assign(
629 LOCAL_ASSIGN;
630 STA_ASSIGN;
631 __entry->ret = ret;
632 __entry->action = action;
633 __entry->tid = tid;
634 __entry->ssn = *ssn;
635 ),
636
637 TP_printk(
638 LOCAL_PR_FMT STA_PR_FMT " action:%d tid:%d ret:%d",
639 LOCAL_PR_ARG, STA_PR_ARG, __entry->action, __entry->tid, __entry->ret
640 )
641);
642#endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
643
644#undef TRACE_INCLUDE_PATH
645#define TRACE_INCLUDE_PATH .
646#undef TRACE_INCLUDE_FILE
647#define TRACE_INCLUDE_FILE driver-trace
648#include <trace/define_trace.h>
diff --git a/net/mac80211/event.c b/net/mac80211/event.c
index f288d01a6344..01ae759518f6 100644
--- a/net/mac80211/event.c
+++ b/net/mac80211/event.c
@@ -7,8 +7,7 @@
7 * 7 *
8 * mac80211 - events 8 * mac80211 - events
9 */ 9 */
10 10#include <net/cfg80211.h>
11#include <net/iw_handler.h>
12#include "ieee80211_i.h" 11#include "ieee80211_i.h"
13 12
14/* 13/*
@@ -17,26 +16,12 @@
17 * driver or is still in the frame), it should provide that information. 16 * driver or is still in the frame), it should provide that information.
18 */ 17 */
19void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, 18void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
20 struct ieee80211_hdr *hdr, const u8 *tsc) 19 struct ieee80211_hdr *hdr, const u8 *tsc,
20 gfp_t gfp)
21{ 21{
22 union iwreq_data wrqu;
23 char *buf = kmalloc(128, GFP_ATOMIC);
24
25 if (buf) {
26 /* TODO: needed parameters: count, key type, TSC */
27 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
28 "keyid=%d %scast addr=%pM)",
29 keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
30 hdr->addr2);
31 memset(&wrqu, 0, sizeof(wrqu));
32 wrqu.data.length = strlen(buf);
33 wireless_send_event(sdata->dev, IWEVCUSTOM, &wrqu, buf);
34 kfree(buf);
35 }
36
37 cfg80211_michael_mic_failure(sdata->dev, hdr->addr2, 22 cfg80211_michael_mic_failure(sdata->dev, hdr->addr2,
38 (hdr->addr1[0] & 0x01) ? 23 (hdr->addr1[0] & 0x01) ?
39 NL80211_KEYTYPE_GROUP : 24 NL80211_KEYTYPE_GROUP :
40 NL80211_KEYTYPE_PAIRWISE, 25 NL80211_KEYTYPE_PAIRWISE,
41 keyidx, tsc); 26 keyidx, tsc, gfp);
42} 27}
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 0b30277eb366..8e2220000e5c 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -57,7 +57,7 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
57 */ 57 */
58 if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) 58 if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1)
59 ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, 59 ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0,
60 sdata->u.ibss.bssid, 0); 60 sdata->u.ibss.bssid, NULL, 0, 0);
61} 61}
62 62
63static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, 63static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
@@ -494,7 +494,7 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
494 494
495 capability = WLAN_CAPABILITY_IBSS; 495 capability = WLAN_CAPABILITY_IBSS;
496 496
497 if (sdata->default_key) 497 if (ifibss->privacy)
498 capability |= WLAN_CAPABILITY_PRIVACY; 498 capability |= WLAN_CAPABILITY_PRIVACY;
499 else 499 else
500 sdata->drop_unencrypted = 0; 500 sdata->drop_unencrypted = 0;
@@ -524,9 +524,8 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
524 return; 524 return;
525 525
526 capability = WLAN_CAPABILITY_IBSS; 526 capability = WLAN_CAPABILITY_IBSS;
527 if (sdata->default_key) 527 if (ifibss->privacy)
528 capability |= WLAN_CAPABILITY_PRIVACY; 528 capability |= WLAN_CAPABILITY_PRIVACY;
529
530 if (ifibss->fixed_bssid) 529 if (ifibss->fixed_bssid)
531 bssid = ifibss->bssid; 530 bssid = ifibss->bssid;
532 if (ifibss->fixed_channel) 531 if (ifibss->fixed_channel)
@@ -705,7 +704,7 @@ static void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
705 struct ieee80211_mgmt *mgmt; 704 struct ieee80211_mgmt *mgmt;
706 u16 fc; 705 u16 fc;
707 706
708 rx_status = (struct ieee80211_rx_status *) skb->cb; 707 rx_status = IEEE80211_SKB_RXCB(skb);
709 mgmt = (struct ieee80211_mgmt *) skb->data; 708 mgmt = (struct ieee80211_mgmt *) skb->data;
710 fc = le16_to_cpu(mgmt->frame_control); 709 fc = le16_to_cpu(mgmt->frame_control);
711 710
@@ -836,8 +835,7 @@ void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local)
836} 835}
837 836
838ieee80211_rx_result 837ieee80211_rx_result
839ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 838ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
840 struct ieee80211_rx_status *rx_status)
841{ 839{
842 struct ieee80211_local *local = sdata->local; 840 struct ieee80211_local *local = sdata->local;
843 struct ieee80211_mgmt *mgmt; 841 struct ieee80211_mgmt *mgmt;
@@ -852,7 +850,6 @@ ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
852 switch (fc & IEEE80211_FCTL_STYPE) { 850 switch (fc & IEEE80211_FCTL_STYPE) {
853 case IEEE80211_STYPE_PROBE_RESP: 851 case IEEE80211_STYPE_PROBE_RESP:
854 case IEEE80211_STYPE_BEACON: 852 case IEEE80211_STYPE_BEACON:
855 memcpy(skb->cb, rx_status, sizeof(*rx_status));
856 case IEEE80211_STYPE_PROBE_REQ: 853 case IEEE80211_STYPE_PROBE_REQ:
857 case IEEE80211_STYPE_AUTH: 854 case IEEE80211_STYPE_AUTH:
858 skb_queue_tail(&sdata->u.ibss.skb_queue, skb); 855 skb_queue_tail(&sdata->u.ibss.skb_queue, skb);
@@ -874,6 +871,8 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
874 } else 871 } else
875 sdata->u.ibss.fixed_bssid = false; 872 sdata->u.ibss.fixed_bssid = false;
876 873
874 sdata->u.ibss.privacy = params->privacy;
875
877 sdata->vif.bss_conf.beacon_int = params->beacon_interval; 876 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
878 877
879 sdata->u.ibss.channel = params->channel; 878 sdata->u.ibss.channel = params->channel;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 68eb5052179a..6a0177137dd5 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -227,86 +227,79 @@ struct mesh_preq_queue {
227 u8 flags; 227 u8 flags;
228}; 228};
229 229
230enum ieee80211_mgd_state {
231 IEEE80211_MGD_STATE_IDLE,
232 IEEE80211_MGD_STATE_PROBE,
233 IEEE80211_MGD_STATE_AUTH,
234 IEEE80211_MGD_STATE_ASSOC,
235};
236
237struct ieee80211_mgd_work {
238 struct list_head list;
239 struct ieee80211_bss *bss;
240 int ie_len;
241 u8 prev_bssid[ETH_ALEN];
242 u8 ssid[IEEE80211_MAX_SSID_LEN];
243 u8 ssid_len;
244 unsigned long timeout;
245 enum ieee80211_mgd_state state;
246 u16 auth_alg, auth_transaction;
247
248 int tries;
249
250 u8 key[WLAN_KEY_LEN_WEP104];
251 u8 key_len, key_idx;
252
253 /* must be last */
254 u8 ie[0]; /* for auth or assoc frame, not probe */
255};
256
230/* flags used in struct ieee80211_if_managed.flags */ 257/* flags used in struct ieee80211_if_managed.flags */
231#define IEEE80211_STA_SSID_SET BIT(0) 258enum ieee80211_sta_flags {
232#define IEEE80211_STA_BSSID_SET BIT(1) 259 IEEE80211_STA_BEACON_POLL = BIT(0),
233#define IEEE80211_STA_PREV_BSSID_SET BIT(2) 260 IEEE80211_STA_CONNECTION_POLL = BIT(1),
234#define IEEE80211_STA_AUTHENTICATED BIT(3) 261 IEEE80211_STA_CONTROL_PORT = BIT(2),
235#define IEEE80211_STA_ASSOCIATED BIT(4) 262 IEEE80211_STA_WMM_ENABLED = BIT(3),
236#define IEEE80211_STA_PROBEREQ_POLL BIT(5) 263 IEEE80211_STA_DISABLE_11N = BIT(4),
237#define IEEE80211_STA_CREATE_IBSS BIT(6) 264 IEEE80211_STA_CSA_RECEIVED = BIT(5),
238#define IEEE80211_STA_CONTROL_PORT BIT(7) 265 IEEE80211_STA_MFP_ENABLED = BIT(6),
239#define IEEE80211_STA_WMM_ENABLED BIT(8) 266};
240/* hole at 9, please re-use */
241#define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
242#define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
243#define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
244#define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
245#define IEEE80211_STA_TKIP_WEP_USED BIT(14)
246#define IEEE80211_STA_CSA_RECEIVED BIT(15)
247#define IEEE80211_STA_MFP_ENABLED BIT(16)
248#define IEEE80211_STA_EXT_SME BIT(17)
249/* flags for MLME request */
250#define IEEE80211_STA_REQ_SCAN 0
251#define IEEE80211_STA_REQ_AUTH 1
252#define IEEE80211_STA_REQ_RUN 2
253 267
254/* bitfield of allowed auth algs */ 268/* flags for MLME request */
255#define IEEE80211_AUTH_ALG_OPEN BIT(0) 269enum ieee80211_sta_request {
256#define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) 270 IEEE80211_STA_REQ_SCAN,
257#define IEEE80211_AUTH_ALG_LEAP BIT(2) 271};
258#define IEEE80211_AUTH_ALG_FT BIT(3)
259 272
260struct ieee80211_if_managed { 273struct ieee80211_if_managed {
261 struct timer_list timer; 274 struct timer_list timer;
275 struct timer_list conn_mon_timer;
276 struct timer_list bcn_mon_timer;
262 struct timer_list chswitch_timer; 277 struct timer_list chswitch_timer;
263 struct work_struct work; 278 struct work_struct work;
279 struct work_struct monitor_work;
264 struct work_struct chswitch_work; 280 struct work_struct chswitch_work;
265 struct work_struct beacon_loss_work; 281 struct work_struct beacon_loss_work;
266 282
267 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; 283 unsigned long probe_timeout;
268 284
269 u8 ssid[IEEE80211_MAX_SSID_LEN]; 285 struct mutex mtx;
270 size_t ssid_len; 286 struct ieee80211_bss *associated;
287 struct list_head work_list;
271 288
272 enum { 289 u8 bssid[ETH_ALEN];
273 IEEE80211_STA_MLME_DISABLED,
274 IEEE80211_STA_MLME_DIRECT_PROBE,
275 IEEE80211_STA_MLME_AUTHENTICATE,
276 IEEE80211_STA_MLME_ASSOCIATE,
277 IEEE80211_STA_MLME_ASSOCIATED,
278 } state;
279 290
280 u16 aid; 291 u16 aid;
281 u16 ap_capab, capab; 292 u16 capab;
282 u8 *extra_ie; /* to be added to the end of AssocReq */
283 size_t extra_ie_len;
284
285 /* The last AssocReq/Resp IEs */
286 u8 *assocreq_ies, *assocresp_ies;
287 size_t assocreq_ies_len, assocresp_ies_len;
288 293
289 struct sk_buff_head skb_queue; 294 struct sk_buff_head skb_queue;
290 295
291 int assoc_scan_tries; /* number of scans done pre-association */
292 int direct_probe_tries; /* retries for direct probes */
293 int auth_tries; /* retries for auth req */
294 int assoc_tries; /* retries for assoc req */
295
296 unsigned long timers_running; /* used for quiesce/restart */ 296 unsigned long timers_running; /* used for quiesce/restart */
297 bool powersave; /* powersave requested for this iface */ 297 bool powersave; /* powersave requested for this iface */
298 298
299 unsigned long request; 299 unsigned long request;
300 300
301 unsigned long last_probe;
302 unsigned long last_beacon;
303
304 unsigned int flags; 301 unsigned int flags;
305 302
306 unsigned int auth_algs; /* bitfield of allowed auth algs */
307 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
308 int auth_transaction;
309
310 u32 beacon_crc; 303 u32 beacon_crc;
311 304
312 enum { 305 enum {
@@ -316,10 +309,6 @@ struct ieee80211_if_managed {
316 } mfp; /* management frame protection */ 309 } mfp; /* management frame protection */
317 310
318 int wmm_last_param_set; 311 int wmm_last_param_set;
319
320 /* Extra IE data for management frames */
321 u8 *sme_auth_ie;
322 size_t sme_auth_ie_len;
323}; 312};
324 313
325enum ieee80211_ibss_request { 314enum ieee80211_ibss_request {
@@ -339,6 +328,7 @@ struct ieee80211_if_ibss {
339 328
340 bool fixed_bssid; 329 bool fixed_bssid;
341 bool fixed_channel; 330 bool fixed_channel;
331 bool privacy;
342 332
343 u8 bssid[ETH_ALEN]; 333 u8 bssid[ETH_ALEN];
344 u8 ssid[IEEE80211_MAX_SSID_LEN]; 334 u8 ssid[IEEE80211_MAX_SSID_LEN];
@@ -478,20 +468,9 @@ struct ieee80211_sub_if_data {
478 union { 468 union {
479 struct { 469 struct {
480 struct dentry *drop_unencrypted; 470 struct dentry *drop_unencrypted;
481 struct dentry *state;
482 struct dentry *bssid; 471 struct dentry *bssid;
483 struct dentry *prev_bssid;
484 struct dentry *ssid_len;
485 struct dentry *aid; 472 struct dentry *aid;
486 struct dentry *ap_capab;
487 struct dentry *capab; 473 struct dentry *capab;
488 struct dentry *extra_ie_len;
489 struct dentry *auth_tries;
490 struct dentry *assoc_tries;
491 struct dentry *auth_algs;
492 struct dentry *auth_alg;
493 struct dentry *auth_transaction;
494 struct dentry *flags;
495 struct dentry *force_unicast_rateidx; 474 struct dentry *force_unicast_rateidx;
496 struct dentry *max_ratectrl_rateidx; 475 struct dentry *max_ratectrl_rateidx;
497 } sta; 476 } sta;
@@ -588,14 +567,9 @@ enum queue_stop_reason {
588 IEEE80211_QUEUE_STOP_REASON_CSA, 567 IEEE80211_QUEUE_STOP_REASON_CSA,
589 IEEE80211_QUEUE_STOP_REASON_AGGREGATION, 568 IEEE80211_QUEUE_STOP_REASON_AGGREGATION,
590 IEEE80211_QUEUE_STOP_REASON_SUSPEND, 569 IEEE80211_QUEUE_STOP_REASON_SUSPEND,
591 IEEE80211_QUEUE_STOP_REASON_PENDING,
592 IEEE80211_QUEUE_STOP_REASON_SKB_ADD, 570 IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
593}; 571};
594 572
595struct ieee80211_master_priv {
596 struct ieee80211_local *local;
597};
598
599struct ieee80211_local { 573struct ieee80211_local {
600 /* embed the driver visible part. 574 /* embed the driver visible part.
601 * don't cast (use the static inlines below), but we keep 575 * don't cast (use the static inlines below), but we keep
@@ -608,13 +582,20 @@ struct ieee80211_local {
608 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ 582 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
609 spinlock_t queue_stop_reason_lock; 583 spinlock_t queue_stop_reason_lock;
610 584
611 struct net_device *mdev; /* wmaster# - "master" 802.11 device */
612 int open_count; 585 int open_count;
613 int monitors, cooked_mntrs; 586 int monitors, cooked_mntrs;
614 /* number of interfaces with corresponding FIF_ flags */ 587 /* number of interfaces with corresponding FIF_ flags */
615 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss; 588 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;
616 unsigned int filter_flags; /* FIF_* */ 589 unsigned int filter_flags; /* FIF_* */
617 struct iw_statistics wstats; 590 struct iw_statistics wstats;
591
592 /* protects the aggregated multicast list and filter calls */
593 spinlock_t filter_lock;
594
595 /* aggregated multicast list */
596 struct dev_addr_list *mc_list;
597 int mc_count;
598
618 bool tim_in_locked_section; /* see ieee80211_beacon_get() */ 599 bool tim_in_locked_section; /* see ieee80211_beacon_get() */
619 600
620 /* 601 /*
@@ -834,10 +815,6 @@ struct ieee80211_local {
834static inline struct ieee80211_sub_if_data * 815static inline struct ieee80211_sub_if_data *
835IEEE80211_DEV_TO_SUB_IF(struct net_device *dev) 816IEEE80211_DEV_TO_SUB_IF(struct net_device *dev)
836{ 817{
837 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
838
839 BUG_ON(!local || local->mdev == dev);
840
841 return netdev_priv(dev); 818 return netdev_priv(dev);
842} 819}
843 820
@@ -942,16 +919,18 @@ extern const struct iw_handler_def ieee80211_iw_handler_def;
942 919
943/* STA code */ 920/* STA code */
944void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); 921void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
922int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
923 struct cfg80211_auth_request *req);
924int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
925 struct cfg80211_assoc_request *req);
926int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
927 struct cfg80211_deauth_request *req,
928 void *cookie);
929int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
930 struct cfg80211_disassoc_request *req,
931 void *cookie);
945ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, 932ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata,
946 struct sk_buff *skb, 933 struct sk_buff *skb);
947 struct ieee80211_rx_status *rx_status);
948int ieee80211_sta_commit(struct ieee80211_sub_if_data *sdata);
949int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len);
950int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len);
951int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid);
952void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata);
953int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason);
954int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason);
955void ieee80211_send_pspoll(struct ieee80211_local *local, 934void ieee80211_send_pspoll(struct ieee80211_local *local,
956 struct ieee80211_sub_if_data *sdata); 935 struct ieee80211_sub_if_data *sdata);
957void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency); 936void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency);
@@ -967,8 +946,7 @@ void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata);
967void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local); 946void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
968void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata); 947void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata);
969ieee80211_rx_result 948ieee80211_rx_result
970ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 949ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
971 struct ieee80211_rx_status *rx_status);
972struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 950struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
973 u8 *bssid, u8 *addr, u32 supp_rates); 951 u8 *bssid, u8 *addr, u32 supp_rates);
974int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, 952int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
@@ -983,16 +961,9 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
983 const u8 *ssid, u8 ssid_len); 961 const u8 *ssid, u8 ssid_len);
984int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, 962int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
985 struct cfg80211_scan_request *req); 963 struct cfg80211_scan_request *req);
986int ieee80211_scan_results(struct ieee80211_local *local,
987 struct iw_request_info *info,
988 char *buf, size_t len);
989void ieee80211_scan_cancel(struct ieee80211_local *local); 964void ieee80211_scan_cancel(struct ieee80211_local *local);
990ieee80211_rx_result 965ieee80211_rx_result
991ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, 966ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
992 struct sk_buff *skb,
993 struct ieee80211_rx_status *rx_status);
994int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata,
995 const char *ie, size_t len);
996 967
997void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local); 968void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local);
998struct ieee80211_bss * 969struct ieee80211_bss *
@@ -1008,8 +979,6 @@ ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq,
1008 u8 *ssid, u8 ssid_len); 979 u8 *ssid, u8 ssid_len);
1009void ieee80211_rx_bss_put(struct ieee80211_local *local, 980void ieee80211_rx_bss_put(struct ieee80211_local *local,
1010 struct ieee80211_bss *bss); 981 struct ieee80211_bss *bss);
1011void ieee80211_rx_bss_remove(struct ieee80211_sub_if_data *sdata, u8 *bssid,
1012 int freq, u8 *ssid, u8 ssid_len);
1013 982
1014/* interface handling */ 983/* interface handling */
1015int ieee80211_if_add(struct ieee80211_local *local, const char *name, 984int ieee80211_if_add(struct ieee80211_local *local, const char *name,
@@ -1025,7 +994,6 @@ void ieee80211_recalc_idle(struct ieee80211_local *local);
1025/* tx handling */ 994/* tx handling */
1026void ieee80211_clear_tx_pending(struct ieee80211_local *local); 995void ieee80211_clear_tx_pending(struct ieee80211_local *local);
1027void ieee80211_tx_pending(unsigned long data); 996void ieee80211_tx_pending(unsigned long data);
1028int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
1029int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); 997int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
1030int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); 998int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
1031 999
@@ -1092,7 +1060,8 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
1092int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, 1060int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
1093 int rate, int erp, int short_preamble); 1061 int rate, int erp, int short_preamble);
1094void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, 1062void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx,
1095 struct ieee80211_hdr *hdr, const u8 *tsc); 1063 struct ieee80211_hdr *hdr, const u8 *tsc,
1064 gfp_t gfp);
1096void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata); 1065void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata);
1097void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 1066void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
1098 int encrypt); 1067 int encrypt);
@@ -1129,8 +1098,8 @@ int ieee80211_add_pending_skbs(struct ieee80211_local *local,
1129 1098
1130void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 1099void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1131 u16 transaction, u16 auth_alg, 1100 u16 transaction, u16 auth_alg,
1132 u8 *extra, size_t extra_len, 1101 u8 *extra, size_t extra_len, const u8 *bssid,
1133 const u8 *bssid, int encrypt); 1102 const u8 *key, u8 key_len, u8 key_idx);
1134int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, 1103int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1135 const u8 *ie, size_t ie_len); 1104 const u8 *ie, size_t ie_len);
1136void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 1105void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index b7c8a4484298..2f797a86ced5 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -190,10 +190,6 @@ static int ieee80211_open(struct net_device *dev)
190 ETH_ALEN); 190 ETH_ALEN);
191 } 191 }
192 192
193 if (compare_ether_addr(null_addr, local->mdev->dev_addr) == 0)
194 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr,
195 ETH_ALEN);
196
197 /* 193 /*
198 * Validate the MAC address for this device. 194 * Validate the MAC address for this device.
199 */ 195 */
@@ -229,13 +225,10 @@ static int ieee80211_open(struct net_device *dev)
229 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) 225 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
230 local->fif_other_bss++; 226 local->fif_other_bss++;
231 227
232 netif_addr_lock_bh(local->mdev); 228 spin_lock_bh(&local->filter_lock);
233 ieee80211_configure_filter(local); 229 ieee80211_configure_filter(local);
234 netif_addr_unlock_bh(local->mdev); 230 spin_unlock_bh(&local->filter_lock);
235 break; 231 break;
236 case NL80211_IFTYPE_STATION:
237 sdata->u.mgd.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
238 /* fall through */
239 default: 232 default:
240 conf.vif = &sdata->vif; 233 conf.vif = &sdata->vif;
241 conf.type = sdata->vif.type; 234 conf.type = sdata->vif.type;
@@ -246,9 +239,9 @@ static int ieee80211_open(struct net_device *dev)
246 239
247 if (ieee80211_vif_is_mesh(&sdata->vif)) { 240 if (ieee80211_vif_is_mesh(&sdata->vif)) {
248 local->fif_other_bss++; 241 local->fif_other_bss++;
249 netif_addr_lock_bh(local->mdev); 242 spin_lock_bh(&local->filter_lock);
250 ieee80211_configure_filter(local); 243 ieee80211_configure_filter(local);
251 netif_addr_unlock_bh(local->mdev); 244 spin_unlock_bh(&local->filter_lock);
252 245
253 ieee80211_start_mesh(sdata); 246 ieee80211_start_mesh(sdata);
254 } 247 }
@@ -282,10 +275,6 @@ static int ieee80211_open(struct net_device *dev)
282 } 275 }
283 276
284 if (local->open_count == 0) { 277 if (local->open_count == 0) {
285 res = dev_open(local->mdev);
286 WARN_ON(res);
287 if (res)
288 goto err_del_interface;
289 tasklet_enable(&local->tx_pending_tasklet); 278 tasklet_enable(&local->tx_pending_tasklet);
290 tasklet_enable(&local->tasklet); 279 tasklet_enable(&local->tasklet);
291 } 280 }
@@ -366,18 +355,6 @@ static int ieee80211_stop(struct net_device *dev)
366 rcu_read_unlock(); 355 rcu_read_unlock();
367 356
368 /* 357 /*
369 * Announce that we are leaving the network, in case we are a
370 * station interface type. This must be done before removing
371 * all stations associated with sta_info_flush, otherwise STA
372 * information will be gone and no announce being done.
373 */
374 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
375 if (sdata->u.mgd.state != IEEE80211_STA_MLME_DISABLED)
376 ieee80211_sta_deauthenticate(sdata,
377 WLAN_REASON_DEAUTH_LEAVING);
378 }
379
380 /*
381 * Remove all stations associated with this interface. 358 * Remove all stations associated with this interface.
382 * 359 *
383 * This must be done before calling ops->remove_interface() 360 * This must be done before calling ops->remove_interface()
@@ -408,7 +385,14 @@ static int ieee80211_stop(struct net_device *dev)
408 if (sdata->flags & IEEE80211_SDATA_PROMISC) 385 if (sdata->flags & IEEE80211_SDATA_PROMISC)
409 atomic_dec(&local->iff_promiscs); 386 atomic_dec(&local->iff_promiscs);
410 387
411 dev_mc_unsync(local->mdev, dev); 388 netif_addr_lock_bh(dev);
389 spin_lock_bh(&local->filter_lock);
390 __dev_addr_unsync(&local->mc_list, &local->mc_count,
391 &dev->mc_list, &dev->mc_count);
392 ieee80211_configure_filter(local);
393 spin_unlock_bh(&local->filter_lock);
394 netif_addr_unlock_bh(dev);
395
412 del_timer_sync(&local->dynamic_ps_timer); 396 del_timer_sync(&local->dynamic_ps_timer);
413 cancel_work_sync(&local->dynamic_ps_enable_work); 397 cancel_work_sync(&local->dynamic_ps_enable_work);
414 398
@@ -457,24 +441,25 @@ static int ieee80211_stop(struct net_device *dev)
457 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) 441 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
458 local->fif_other_bss--; 442 local->fif_other_bss--;
459 443
460 netif_addr_lock_bh(local->mdev); 444 spin_lock_bh(&local->filter_lock);
461 ieee80211_configure_filter(local); 445 ieee80211_configure_filter(local);
462 netif_addr_unlock_bh(local->mdev); 446 spin_unlock_bh(&local->filter_lock);
463 break; 447 break;
464 case NL80211_IFTYPE_STATION: 448 case NL80211_IFTYPE_STATION:
465 memset(sdata->u.mgd.bssid, 0, ETH_ALEN);
466 del_timer_sync(&sdata->u.mgd.chswitch_timer); 449 del_timer_sync(&sdata->u.mgd.chswitch_timer);
467 del_timer_sync(&sdata->u.mgd.timer); 450 del_timer_sync(&sdata->u.mgd.timer);
451 del_timer_sync(&sdata->u.mgd.conn_mon_timer);
452 del_timer_sync(&sdata->u.mgd.bcn_mon_timer);
468 /* 453 /*
469 * If the timer fired while we waited for it, it will have 454 * If any of the timers fired while we waited for it, it will
470 * requeued the work. Now the work will be running again 455 * have queued its work. Now the work will be running again
471 * but will not rearm the timer again because it checks 456 * but will not rearm the timer again because it checks
472 * whether the interface is running, which, at this point, 457 * whether the interface is running, which, at this point,
473 * it no longer is. 458 * it no longer is.
474 */ 459 */
475 cancel_work_sync(&sdata->u.mgd.work); 460 cancel_work_sync(&sdata->u.mgd.work);
476 cancel_work_sync(&sdata->u.mgd.chswitch_work); 461 cancel_work_sync(&sdata->u.mgd.chswitch_work);
477 462 cancel_work_sync(&sdata->u.mgd.monitor_work);
478 cancel_work_sync(&sdata->u.mgd.beacon_loss_work); 463 cancel_work_sync(&sdata->u.mgd.beacon_loss_work);
479 464
480 /* 465 /*
@@ -485,12 +470,6 @@ static int ieee80211_stop(struct net_device *dev)
485 */ 470 */
486 synchronize_rcu(); 471 synchronize_rcu();
487 skb_queue_purge(&sdata->u.mgd.skb_queue); 472 skb_queue_purge(&sdata->u.mgd.skb_queue);
488
489 sdata->u.mgd.flags &= ~(IEEE80211_STA_PRIVACY_INVOKED |
490 IEEE80211_STA_TKIP_WEP_USED);
491 kfree(sdata->u.mgd.extra_ie);
492 sdata->u.mgd.extra_ie = NULL;
493 sdata->u.mgd.extra_ie_len = 0;
494 /* fall through */ 473 /* fall through */
495 case NL80211_IFTYPE_ADHOC: 474 case NL80211_IFTYPE_ADHOC:
496 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 475 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
@@ -507,9 +486,9 @@ static int ieee80211_stop(struct net_device *dev)
507 local->fif_other_bss--; 486 local->fif_other_bss--;
508 atomic_dec(&local->iff_allmultis); 487 atomic_dec(&local->iff_allmultis);
509 488
510 netif_addr_lock_bh(local->mdev); 489 spin_lock_bh(&local->filter_lock);
511 ieee80211_configure_filter(local); 490 ieee80211_configure_filter(local);
512 netif_addr_unlock_bh(local->mdev); 491 spin_unlock_bh(&local->filter_lock);
513 492
514 ieee80211_stop_mesh(sdata); 493 ieee80211_stop_mesh(sdata);
515 } 494 }
@@ -555,9 +534,6 @@ static int ieee80211_stop(struct net_device *dev)
555 ieee80211_recalc_ps(local, -1); 534 ieee80211_recalc_ps(local, -1);
556 535
557 if (local->open_count == 0) { 536 if (local->open_count == 0) {
558 if (netif_running(local->mdev))
559 dev_close(local->mdev);
560
561 drv_stop(local); 537 drv_stop(local);
562 538
563 ieee80211_led_radio(local, false); 539 ieee80211_led_radio(local, false);
@@ -604,8 +580,11 @@ static void ieee80211_set_multicast_list(struct net_device *dev)
604 atomic_dec(&local->iff_promiscs); 580 atomic_dec(&local->iff_promiscs);
605 sdata->flags ^= IEEE80211_SDATA_PROMISC; 581 sdata->flags ^= IEEE80211_SDATA_PROMISC;
606 } 582 }
607 583 spin_lock_bh(&local->filter_lock);
608 dev_mc_sync(local->mdev, dev); 584 __dev_addr_sync(&local->mc_list, &local->mc_count,
585 &dev->mc_list, &dev->mc_count);
586 ieee80211_configure_filter(local);
587 spin_unlock_bh(&local->filter_lock);
609} 588}
610 589
611/* 590/*
@@ -652,11 +631,6 @@ static void ieee80211_teardown_sdata(struct net_device *dev)
652 kfree_skb(sdata->u.ibss.presp); 631 kfree_skb(sdata->u.ibss.presp);
653 break; 632 break;
654 case NL80211_IFTYPE_STATION: 633 case NL80211_IFTYPE_STATION:
655 kfree(sdata->u.mgd.extra_ie);
656 kfree(sdata->u.mgd.assocreq_ies);
657 kfree(sdata->u.mgd.assocresp_ies);
658 kfree(sdata->u.mgd.sme_auth_ie);
659 break;
660 case NL80211_IFTYPE_WDS: 634 case NL80211_IFTYPE_WDS:
661 case NL80211_IFTYPE_AP_VLAN: 635 case NL80211_IFTYPE_AP_VLAN:
662 case NL80211_IFTYPE_MONITOR: 636 case NL80211_IFTYPE_MONITOR:
@@ -939,7 +913,8 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local)
939 continue; 913 continue;
940 /* do not count disabled managed interfaces */ 914 /* do not count disabled managed interfaces */
941 if (sdata->vif.type == NL80211_IFTYPE_STATION && 915 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
942 sdata->u.mgd.state == IEEE80211_STA_MLME_DISABLED) 916 !sdata->u.mgd.associated &&
917 list_empty(&sdata->u.mgd.work_list))
943 continue; 918 continue;
944 /* do not count unused IBSS interfaces */ 919 /* do not count unused IBSS interfaces */
945 if (sdata->vif.type == NL80211_IFTYPE_ADHOC && 920 if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index ce267565e180..659a42d529e3 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -67,6 +67,8 @@ static DECLARE_WORK(todo_work, key_todo);
67 * 67 *
68 * @key: key to add to do item for 68 * @key: key to add to do item for
69 * @flag: todo flag(s) 69 * @flag: todo flag(s)
70 *
71 * Must be called with IRQs or softirqs disabled.
70 */ 72 */
71static void add_todo(struct ieee80211_key *key, u32 flag) 73static void add_todo(struct ieee80211_key *key, u32 flag)
72{ 74{
@@ -140,9 +142,9 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
140 ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf); 142 ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf);
141 143
142 if (!ret) { 144 if (!ret) {
143 spin_lock(&todo_lock); 145 spin_lock_bh(&todo_lock);
144 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; 146 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
145 spin_unlock(&todo_lock); 147 spin_unlock_bh(&todo_lock);
146 } 148 }
147 149
148 if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP) 150 if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
@@ -164,12 +166,12 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
164 if (!key || !key->local->ops->set_key) 166 if (!key || !key->local->ops->set_key)
165 return; 167 return;
166 168
167 spin_lock(&todo_lock); 169 spin_lock_bh(&todo_lock);
168 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) { 170 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
169 spin_unlock(&todo_lock); 171 spin_unlock_bh(&todo_lock);
170 return; 172 return;
171 } 173 }
172 spin_unlock(&todo_lock); 174 spin_unlock_bh(&todo_lock);
173 175
174 sta = get_sta_for_key(key); 176 sta = get_sta_for_key(key);
175 sdata = key->sdata; 177 sdata = key->sdata;
@@ -188,9 +190,9 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
188 wiphy_name(key->local->hw.wiphy), 190 wiphy_name(key->local->hw.wiphy),
189 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret); 191 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
190 192
191 spin_lock(&todo_lock); 193 spin_lock_bh(&todo_lock);
192 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 194 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
193 spin_unlock(&todo_lock); 195 spin_unlock_bh(&todo_lock);
194} 196}
195 197
196static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, 198static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
@@ -437,14 +439,14 @@ void ieee80211_key_link(struct ieee80211_key *key,
437 439
438 __ieee80211_key_replace(sdata, sta, old_key, key); 440 __ieee80211_key_replace(sdata, sta, old_key, key);
439 441
440 spin_unlock_irqrestore(&sdata->local->key_lock, flags);
441
442 /* free old key later */ 442 /* free old key later */
443 add_todo(old_key, KEY_FLAG_TODO_DELETE); 443 add_todo(old_key, KEY_FLAG_TODO_DELETE);
444 444
445 add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS); 445 add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS);
446 if (netif_running(sdata->dev)) 446 if (netif_running(sdata->dev))
447 add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD); 447 add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD);
448
449 spin_unlock_irqrestore(&sdata->local->key_lock, flags);
448} 450}
449 451
450static void __ieee80211_key_free(struct ieee80211_key *key) 452static void __ieee80211_key_free(struct ieee80211_key *key)
@@ -547,7 +549,7 @@ static void __ieee80211_key_todo(void)
547 */ 549 */
548 synchronize_rcu(); 550 synchronize_rcu();
549 551
550 spin_lock(&todo_lock); 552 spin_lock_bh(&todo_lock);
551 while (!list_empty(&todo_list)) { 553 while (!list_empty(&todo_list)) {
552 key = list_first_entry(&todo_list, struct ieee80211_key, todo); 554 key = list_first_entry(&todo_list, struct ieee80211_key, todo);
553 list_del_init(&key->todo); 555 list_del_init(&key->todo);
@@ -558,7 +560,7 @@ static void __ieee80211_key_todo(void)
558 KEY_FLAG_TODO_HWACCEL_REMOVE | 560 KEY_FLAG_TODO_HWACCEL_REMOVE |
559 KEY_FLAG_TODO_DELETE); 561 KEY_FLAG_TODO_DELETE);
560 key->flags &= ~todoflags; 562 key->flags &= ~todoflags;
561 spin_unlock(&todo_lock); 563 spin_unlock_bh(&todo_lock);
562 564
563 work_done = false; 565 work_done = false;
564 566
@@ -591,9 +593,9 @@ static void __ieee80211_key_todo(void)
591 593
592 WARN_ON(!work_done); 594 WARN_ON(!work_done);
593 595
594 spin_lock(&todo_lock); 596 spin_lock_bh(&todo_lock);
595 } 597 }
596 spin_unlock(&todo_lock); 598 spin_unlock_bh(&todo_lock);
597} 599}
598 600
599void ieee80211_key_todo(void) 601void ieee80211_key_todo(void)
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 092a017b237e..3234f3751d22 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -83,75 +83,14 @@ void ieee80211_configure_filter(struct ieee80211_local *local)
83 new_flags |= (1<<31); 83 new_flags |= (1<<31);
84 84
85 drv_configure_filter(local, changed_flags, &new_flags, 85 drv_configure_filter(local, changed_flags, &new_flags,
86 local->mdev->mc_count, 86 local->mc_count,
87 local->mdev->mc_list); 87 local->mc_list);
88 88
89 WARN_ON(new_flags & (1<<31)); 89 WARN_ON(new_flags & (1<<31));
90 90
91 local->filter_flags = new_flags & ~(1<<31); 91 local->filter_flags = new_flags & ~(1<<31);
92} 92}
93 93
94/* master interface */
95
96static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr)
97{
98 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
99 return ETH_ALEN;
100}
101
102static const struct header_ops ieee80211_header_ops = {
103 .create = eth_header,
104 .parse = header_parse_80211,
105 .rebuild = eth_rebuild_header,
106 .cache = eth_header_cache,
107 .cache_update = eth_header_cache_update,
108};
109
110static int ieee80211_master_open(struct net_device *dev)
111{
112 struct ieee80211_master_priv *mpriv = netdev_priv(dev);
113 struct ieee80211_local *local = mpriv->local;
114 struct ieee80211_sub_if_data *sdata;
115 int res = -EOPNOTSUPP;
116
117 /* we hold the RTNL here so can safely walk the list */
118 list_for_each_entry(sdata, &local->interfaces, list) {
119 if (netif_running(sdata->dev)) {
120 res = 0;
121 break;
122 }
123 }
124
125 if (res)
126 return res;
127
128 netif_tx_start_all_queues(local->mdev);
129
130 return 0;
131}
132
133static int ieee80211_master_stop(struct net_device *dev)
134{
135 struct ieee80211_master_priv *mpriv = netdev_priv(dev);
136 struct ieee80211_local *local = mpriv->local;
137 struct ieee80211_sub_if_data *sdata;
138
139 /* we hold the RTNL here so can safely walk the list */
140 list_for_each_entry(sdata, &local->interfaces, list)
141 if (netif_running(sdata->dev))
142 dev_close(sdata->dev);
143
144 return 0;
145}
146
147static void ieee80211_master_set_multicast_list(struct net_device *dev)
148{
149 struct ieee80211_master_priv *mpriv = netdev_priv(dev);
150 struct ieee80211_local *local = mpriv->local;
151
152 ieee80211_configure_filter(local);
153}
154
155int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) 94int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
156{ 95{
157 struct ieee80211_channel *chan, *scan_chan; 96 struct ieee80211_channel *chan, *scan_chan;
@@ -310,7 +249,6 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
310 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 249 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
311 int tmp; 250 int tmp;
312 251
313 skb->dev = local->mdev;
314 skb->pkt_type = IEEE80211_TX_STATUS_MSG; 252 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
315 skb_queue_tail(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS ? 253 skb_queue_tail(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS ?
316 &local->skb_queue : &local->skb_queue_unreliable, skb); 254 &local->skb_queue : &local->skb_queue_unreliable, skb);
@@ -330,19 +268,16 @@ static void ieee80211_tasklet_handler(unsigned long data)
330{ 268{
331 struct ieee80211_local *local = (struct ieee80211_local *) data; 269 struct ieee80211_local *local = (struct ieee80211_local *) data;
332 struct sk_buff *skb; 270 struct sk_buff *skb;
333 struct ieee80211_rx_status rx_status;
334 struct ieee80211_ra_tid *ra_tid; 271 struct ieee80211_ra_tid *ra_tid;
335 272
336 while ((skb = skb_dequeue(&local->skb_queue)) || 273 while ((skb = skb_dequeue(&local->skb_queue)) ||
337 (skb = skb_dequeue(&local->skb_queue_unreliable))) { 274 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
338 switch (skb->pkt_type) { 275 switch (skb->pkt_type) {
339 case IEEE80211_RX_MSG: 276 case IEEE80211_RX_MSG:
340 /* status is in skb->cb */
341 memcpy(&rx_status, skb->cb, sizeof(rx_status));
342 /* Clear skb->pkt_type in order to not confuse kernel 277 /* Clear skb->pkt_type in order to not confuse kernel
343 * netstack. */ 278 * netstack. */
344 skb->pkt_type = 0; 279 skb->pkt_type = 0;
345 __ieee80211_rx(local_to_hw(local), skb, &rx_status); 280 ieee80211_rx(local_to_hw(local), skb);
346 break; 281 break;
347 case IEEE80211_TX_STATUS_MSG: 282 case IEEE80211_TX_STATUS_MSG:
348 skb->pkt_type = 0; 283 skb->pkt_type = 0;
@@ -719,7 +654,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
719 mutex_init(&local->scan_mtx); 654 mutex_init(&local->scan_mtx);
720 655
721 spin_lock_init(&local->key_lock); 656 spin_lock_init(&local->key_lock);
722 657 spin_lock_init(&local->filter_lock);
723 spin_lock_init(&local->queue_stop_reason_lock); 658 spin_lock_init(&local->queue_stop_reason_lock);
724 659
725 INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work); 660 INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work);
@@ -755,30 +690,11 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
755} 690}
756EXPORT_SYMBOL(ieee80211_alloc_hw); 691EXPORT_SYMBOL(ieee80211_alloc_hw);
757 692
758static const struct net_device_ops ieee80211_master_ops = {
759 .ndo_start_xmit = ieee80211_master_start_xmit,
760 .ndo_open = ieee80211_master_open,
761 .ndo_stop = ieee80211_master_stop,
762 .ndo_set_multicast_list = ieee80211_master_set_multicast_list,
763 .ndo_select_queue = ieee80211_select_queue,
764};
765
766static void ieee80211_master_setup(struct net_device *mdev)
767{
768 mdev->type = ARPHRD_IEEE80211;
769 mdev->netdev_ops = &ieee80211_master_ops;
770 mdev->header_ops = &ieee80211_header_ops;
771 mdev->tx_queue_len = 1000;
772 mdev->addr_len = ETH_ALEN;
773}
774
775int ieee80211_register_hw(struct ieee80211_hw *hw) 693int ieee80211_register_hw(struct ieee80211_hw *hw)
776{ 694{
777 struct ieee80211_local *local = hw_to_local(hw); 695 struct ieee80211_local *local = hw_to_local(hw);
778 int result; 696 int result;
779 enum ieee80211_band band; 697 enum ieee80211_band band;
780 struct net_device *mdev;
781 struct ieee80211_master_priv *mpriv;
782 int channels, i, j, max_bitrates; 698 int channels, i, j, max_bitrates;
783 bool supp_ht; 699 bool supp_ht;
784 static const u32 cipher_suites[] = { 700 static const u32 cipher_suites[] = {
@@ -877,16 +793,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
877 if (hw->queues > IEEE80211_MAX_QUEUES) 793 if (hw->queues > IEEE80211_MAX_QUEUES)
878 hw->queues = IEEE80211_MAX_QUEUES; 794 hw->queues = IEEE80211_MAX_QUEUES;
879 795
880 mdev = alloc_netdev_mq(sizeof(struct ieee80211_master_priv),
881 "wmaster%d", ieee80211_master_setup,
882 hw->queues);
883 if (!mdev)
884 goto fail_mdev_alloc;
885
886 mpriv = netdev_priv(mdev);
887 mpriv->local = local;
888 local->mdev = mdev;
889
890 local->hw.workqueue = 796 local->hw.workqueue =
891 create_singlethread_workqueue(wiphy_name(local->hw.wiphy)); 797 create_singlethread_workqueue(wiphy_name(local->hw.wiphy));
892 if (!local->hw.workqueue) { 798 if (!local->hw.workqueue) {
@@ -921,17 +827,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
921 } 827 }
922 828
923 rtnl_lock(); 829 rtnl_lock();
924 result = dev_alloc_name(local->mdev, local->mdev->name);
925 if (result < 0)
926 goto fail_dev;
927
928 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
929 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
930 local->mdev->features |= NETIF_F_NETNS_LOCAL;
931
932 result = register_netdevice(local->mdev);
933 if (result < 0)
934 goto fail_dev;
935 830
936 result = ieee80211_init_rate_ctrl_alg(local, 831 result = ieee80211_init_rate_ctrl_alg(local,
937 hw->rate_control_algorithm); 832 hw->rate_control_algorithm);
@@ -984,9 +879,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
984 ieee80211_led_exit(local); 879 ieee80211_led_exit(local);
985 ieee80211_remove_interfaces(local); 880 ieee80211_remove_interfaces(local);
986 fail_rate: 881 fail_rate:
987 unregister_netdevice(local->mdev);
988 local->mdev = NULL;
989 fail_dev:
990 rtnl_unlock(); 882 rtnl_unlock();
991 ieee80211_wep_free(local); 883 ieee80211_wep_free(local);
992 fail_wep: 884 fail_wep:
@@ -995,9 +887,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
995 debugfs_hw_del(local); 887 debugfs_hw_del(local);
996 destroy_workqueue(local->hw.workqueue); 888 destroy_workqueue(local->hw.workqueue);
997 fail_workqueue: 889 fail_workqueue:
998 if (local->mdev)
999 free_netdev(local->mdev);
1000 fail_mdev_alloc:
1001 wiphy_unregister(local->hw.wiphy); 890 wiphy_unregister(local->hw.wiphy);
1002 fail_wiphy_register: 891 fail_wiphy_register:
1003 kfree(local->int_scan_req.channels); 892 kfree(local->int_scan_req.channels);
@@ -1022,13 +911,8 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1022 * because the driver cannot be handing us frames any 911 * because the driver cannot be handing us frames any
1023 * more and the tasklet is killed. 912 * more and the tasklet is killed.
1024 */ 913 */
1025
1026 /* First, we remove all virtual interfaces. */
1027 ieee80211_remove_interfaces(local); 914 ieee80211_remove_interfaces(local);
1028 915
1029 /* then, finally, remove the master interface */
1030 unregister_netdevice(local->mdev);
1031
1032 rtnl_unlock(); 916 rtnl_unlock();
1033 917
1034 ieee80211_clear_tx_pending(local); 918 ieee80211_clear_tx_pending(local);
@@ -1047,7 +931,6 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1047 wiphy_unregister(local->hw.wiphy); 931 wiphy_unregister(local->hw.wiphy);
1048 ieee80211_wep_free(local); 932 ieee80211_wep_free(local);
1049 ieee80211_led_exit(local); 933 ieee80211_led_exit(local);
1050 free_netdev(local->mdev);
1051 kfree(local->int_scan_req.channels); 934 kfree(local->int_scan_req.channels);
1052} 935}
1053EXPORT_SYMBOL(ieee80211_unregister_hw); 936EXPORT_SYMBOL(ieee80211_unregister_hw);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 11cf45bce38a..8a97b1423088 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -568,7 +568,7 @@ static void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
568 568
569 ifmsh = &sdata->u.mesh; 569 ifmsh = &sdata->u.mesh;
570 570
571 rx_status = (struct ieee80211_rx_status *) skb->cb; 571 rx_status = IEEE80211_SKB_RXCB(skb);
572 mgmt = (struct ieee80211_mgmt *) skb->data; 572 mgmt = (struct ieee80211_mgmt *) skb->data;
573 stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE; 573 stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
574 574
@@ -671,8 +671,7 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
671} 671}
672 672
673ieee80211_rx_result 673ieee80211_rx_result
674ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 674ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
675 struct ieee80211_rx_status *rx_status)
676{ 675{
677 struct ieee80211_local *local = sdata->local; 676 struct ieee80211_local *local = sdata->local;
678 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 677 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
@@ -686,10 +685,12 @@ ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
686 fc = le16_to_cpu(mgmt->frame_control); 685 fc = le16_to_cpu(mgmt->frame_control);
687 686
688 switch (fc & IEEE80211_FCTL_STYPE) { 687 switch (fc & IEEE80211_FCTL_STYPE) {
688 case IEEE80211_STYPE_ACTION:
689 if (skb->len < IEEE80211_MIN_ACTION_SIZE)
690 return RX_DROP_MONITOR;
691 /* fall through */
689 case IEEE80211_STYPE_PROBE_RESP: 692 case IEEE80211_STYPE_PROBE_RESP:
690 case IEEE80211_STYPE_BEACON: 693 case IEEE80211_STYPE_BEACON:
691 case IEEE80211_STYPE_ACTION:
692 memcpy(skb->cb, rx_status, sizeof(*rx_status));
693 skb_queue_tail(&ifmsh->skb_queue, skb); 694 skb_queue_tail(&ifmsh->skb_queue, skb);
694 queue_work(local->hw.workqueue, &ifmsh->work); 695 queue_work(local->hw.workqueue, &ifmsh->work);
695 return RX_QUEUED; 696 return RX_QUEUED;
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index c7d72819cdd2..2a2ed182cb7e 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -208,8 +208,7 @@ void ieee80211s_init(void);
208void ieee80211s_stop(void); 208void ieee80211s_stop(void);
209void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); 209void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
210ieee80211_rx_result 210ieee80211_rx_result
211ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 211ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);
212 struct ieee80211_rx_status *rx_status);
213void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); 212void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
214void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); 213void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
215 214
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index f49ef288e2e2..e93c37ef6a48 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -686,11 +686,11 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
686 u8 ttl, dst_flags; 686 u8 ttl, dst_flags;
687 u32 lifetime; 687 u32 lifetime;
688 688
689 spin_lock(&ifmsh->mesh_preq_queue_lock); 689 spin_lock_bh(&ifmsh->mesh_preq_queue_lock);
690 if (!ifmsh->preq_queue_len || 690 if (!ifmsh->preq_queue_len ||
691 time_before(jiffies, ifmsh->last_preq + 691 time_before(jiffies, ifmsh->last_preq +
692 min_preq_int_jiff(sdata))) { 692 min_preq_int_jiff(sdata))) {
693 spin_unlock(&ifmsh->mesh_preq_queue_lock); 693 spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
694 return; 694 return;
695 } 695 }
696 696
@@ -698,7 +698,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
698 struct mesh_preq_queue, list); 698 struct mesh_preq_queue, list);
699 list_del(&preq_node->list); 699 list_del(&preq_node->list);
700 --ifmsh->preq_queue_len; 700 --ifmsh->preq_queue_len;
701 spin_unlock(&ifmsh->mesh_preq_queue_lock); 701 spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
702 702
703 rcu_read_lock(); 703 rcu_read_lock();
704 mpath = mesh_path_lookup(preq_node->dst, sdata); 704 mpath = mesh_path_lookup(preq_node->dst, sdata);
@@ -784,7 +784,6 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
784 mesh_path_add(dst_addr, sdata); 784 mesh_path_add(dst_addr, sdata);
785 mpath = mesh_path_lookup(dst_addr, sdata); 785 mpath = mesh_path_lookup(dst_addr, sdata);
786 if (!mpath) { 786 if (!mpath) {
787 dev_kfree_skb(skb);
788 sdata->u.mesh.mshstats.dropped_frames_no_route++; 787 sdata->u.mesh.mshstats.dropped_frames_no_route++;
789 err = -ENOSPC; 788 err = -ENOSPC;
790 goto endlookup; 789 goto endlookup;
@@ -804,6 +803,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
804 memcpy(hdr->addr1, mpath->next_hop->sta.addr, 803 memcpy(hdr->addr1, mpath->next_hop->sta.addr,
805 ETH_ALEN); 804 ETH_ALEN);
806 } else { 805 } else {
806 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
807 if (!(mpath->flags & MESH_PATH_RESOLVING)) { 807 if (!(mpath->flags & MESH_PATH_RESOLVING)) {
808 /* Start discovery only if it is not running yet */ 808 /* Start discovery only if it is not running yet */
809 mesh_queue_preq(mpath, PREQ_Q_F_START); 809 mesh_queue_preq(mpath, PREQ_Q_F_START);
@@ -815,6 +815,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
815 skb_unlink(skb_to_free, &mpath->frame_queue); 815 skb_unlink(skb_to_free, &mpath->frame_queue);
816 } 816 }
817 817
818 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
818 skb_queue_tail(&mpath->frame_queue, skb); 819 skb_queue_tail(&mpath->frame_queue, skb);
819 if (skb_to_free) 820 if (skb_to_free)
820 mesh_path_discard_frame(skb_to_free, sdata); 821 mesh_path_discard_frame(skb_to_free, sdata);
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 479597e88583..04b9e4d61b8e 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -55,7 +55,25 @@ static DEFINE_RWLOCK(pathtbl_resize_lock);
55 */ 55 */
56void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) 56void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta)
57{ 57{
58 struct sk_buff *skb;
59 struct ieee80211_hdr *hdr;
60 struct sk_buff_head tmpq;
61 unsigned long flags;
62
58 rcu_assign_pointer(mpath->next_hop, sta); 63 rcu_assign_pointer(mpath->next_hop, sta);
64
65 __skb_queue_head_init(&tmpq);
66
67 spin_lock_irqsave(&mpath->frame_queue.lock, flags);
68
69 while ((skb = __skb_dequeue(&mpath->frame_queue)) != NULL) {
70 hdr = (struct ieee80211_hdr *) skb->data;
71 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN);
72 __skb_queue_tail(&tmpq, skb);
73 }
74
75 skb_queue_splice(&tmpq, &mpath->frame_queue);
76 spin_unlock_irqrestore(&mpath->frame_queue.lock, flags);
59} 77}
60 78
61 79
@@ -481,11 +499,9 @@ enddel:
481 */ 499 */
482void mesh_path_tx_pending(struct mesh_path *mpath) 500void mesh_path_tx_pending(struct mesh_path *mpath)
483{ 501{
484 struct sk_buff *skb; 502 if (mpath->flags & MESH_PATH_ACTIVE)
485 503 ieee80211_add_pending_skbs(mpath->sdata->local,
486 while ((skb = skb_dequeue(&mpath->frame_queue)) && 504 &mpath->frame_queue);
487 (mpath->flags & MESH_PATH_ACTIVE))
488 dev_queue_xmit(skb);
489} 505}
490 506
491/** 507/**
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 07e7e41816be..0b3551da8f43 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -27,43 +27,98 @@
27#include "rate.h" 27#include "rate.h"
28#include "led.h" 28#include "led.h"
29 29
30#define IEEE80211_ASSOC_SCANS_MAX_TRIES 2
31#define IEEE80211_AUTH_TIMEOUT (HZ / 5) 30#define IEEE80211_AUTH_TIMEOUT (HZ / 5)
32#define IEEE80211_AUTH_MAX_TRIES 3 31#define IEEE80211_AUTH_MAX_TRIES 3
33#define IEEE80211_ASSOC_TIMEOUT (HZ / 5) 32#define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
34#define IEEE80211_ASSOC_MAX_TRIES 3 33#define IEEE80211_ASSOC_MAX_TRIES 3
35#define IEEE80211_MONITORING_INTERVAL (2 * HZ) 34
36#define IEEE80211_PROBE_WAIT (HZ / 5) 35/*
37#define IEEE80211_PROBE_IDLE_TIME (60 * HZ) 36 * beacon loss detection timeout
38#define IEEE80211_RETRY_AUTH_INTERVAL (1 * HZ) 37 * XXX: should depend on beacon interval
38 */
39#define IEEE80211_BEACON_LOSS_TIME (2 * HZ)
40/*
41 * Time the connection can be idle before we probe
42 * it to see if we can still talk to the AP.
43 */
44#define IEEE80211_CONNECTION_IDLE_TIME (2 * HZ)
45/*
46 * Time we wait for a probe response after sending
47 * a probe request because of beacon loss or for
48 * checking the connection still works.
49 */
50#define IEEE80211_PROBE_WAIT (HZ / 5)
39 51
40#define TMR_RUNNING_TIMER 0 52#define TMR_RUNNING_TIMER 0
41#define TMR_RUNNING_CHANSW 1 53#define TMR_RUNNING_CHANSW 1
42 54
55/*
56 * All cfg80211 functions have to be called outside a locked
57 * section so that they can acquire a lock themselves... This
58 * is much simpler than queuing up things in cfg80211, but we
59 * do need some indirection for that here.
60 */
61enum rx_mgmt_action {
62 /* no action required */
63 RX_MGMT_NONE,
64
65 /* caller must call cfg80211_send_rx_auth() */
66 RX_MGMT_CFG80211_AUTH,
67
68 /* caller must call cfg80211_send_rx_assoc() */
69 RX_MGMT_CFG80211_ASSOC,
70
71 /* caller must call cfg80211_send_deauth() */
72 RX_MGMT_CFG80211_DEAUTH,
73
74 /* caller must call cfg80211_send_disassoc() */
75 RX_MGMT_CFG80211_DISASSOC,
76
77 /* caller must call cfg80211_auth_timeout() & free work */
78 RX_MGMT_CFG80211_AUTH_TO,
79
80 /* caller must call cfg80211_assoc_timeout() & free work */
81 RX_MGMT_CFG80211_ASSOC_TO,
82};
83
43/* utils */ 84/* utils */
44static int ecw2cw(int ecw) 85static inline void ASSERT_MGD_MTX(struct ieee80211_if_managed *ifmgd)
45{ 86{
46 return (1 << ecw) - 1; 87 WARN_ON(!mutex_is_locked(&ifmgd->mtx));
47} 88}
48 89
49static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie) 90/*
91 * We can have multiple work items (and connection probing)
92 * scheduling this timer, but we need to take care to only
93 * reschedule it when it should fire _earlier_ than it was
94 * asked for before, or if it's not pending right now. This
95 * function ensures that. Note that it then is required to
96 * run this function for all timeouts after the first one
97 * has happened -- the work that runs from this timer will
98 * do that.
99 */
100static void run_again(struct ieee80211_if_managed *ifmgd,
101 unsigned long timeout)
50{ 102{
51 u8 *end, *pos; 103 ASSERT_MGD_MTX(ifmgd);
52 104
53 pos = bss->cbss.information_elements; 105 if (!timer_pending(&ifmgd->timer) ||
54 if (pos == NULL) 106 time_before(timeout, ifmgd->timer.expires))
55 return NULL; 107 mod_timer(&ifmgd->timer, timeout);
56 end = pos + bss->cbss.len_information_elements; 108}
57 109
58 while (pos + 1 < end) { 110static void mod_beacon_timer(struct ieee80211_sub_if_data *sdata)
59 if (pos + 2 + pos[1] > end) 111{
60 break; 112 if (sdata->local->hw.flags & IEEE80211_HW_BEACON_FILTER)
61 if (pos[0] == ie) 113 return;
62 return pos; 114
63 pos += 2 + pos[1]; 115 mod_timer(&sdata->u.mgd.bcn_mon_timer,
64 } 116 round_jiffies_up(jiffies + IEEE80211_BEACON_LOSS_TIME));
117}
65 118
66 return NULL; 119static int ecw2cw(int ecw)
120{
121 return (1 << ecw) - 1;
67} 122}
68 123
69static int ieee80211_compatible_rates(struct ieee80211_bss *bss, 124static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
@@ -94,11 +149,10 @@ static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
94 */ 149 */
95static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, 150static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
96 struct ieee80211_ht_info *hti, 151 struct ieee80211_ht_info *hti,
97 u16 ap_ht_cap_flags) 152 const u8 *bssid, u16 ap_ht_cap_flags)
98{ 153{
99 struct ieee80211_local *local = sdata->local; 154 struct ieee80211_local *local = sdata->local;
100 struct ieee80211_supported_band *sband; 155 struct ieee80211_supported_band *sband;
101 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
102 struct sta_info *sta; 156 struct sta_info *sta;
103 u32 changed = 0; 157 u32 changed = 0;
104 u16 ht_opmode; 158 u16 ht_opmode;
@@ -147,12 +201,10 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
147 ieee80211_hw_config(local, 0); 201 ieee80211_hw_config(local, 0);
148 202
149 rcu_read_lock(); 203 rcu_read_lock();
150 204 sta = sta_info_get(local, bssid);
151 sta = sta_info_get(local, ifmgd->bssid);
152 if (sta) 205 if (sta)
153 rate_control_rate_update(local, sband, sta, 206 rate_control_rate_update(local, sband, sta,
154 IEEE80211_RC_HT_CHANGED); 207 IEEE80211_RC_HT_CHANGED);
155
156 rcu_read_unlock(); 208 rcu_read_unlock();
157 } 209 }
158 210
@@ -175,23 +227,24 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
175 227
176/* frame sending functions */ 228/* frame sending functions */
177 229
178static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) 230static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
231 struct ieee80211_mgd_work *wk)
179{ 232{
180 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 233 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
181 struct ieee80211_local *local = sdata->local; 234 struct ieee80211_local *local = sdata->local;
182 struct sk_buff *skb; 235 struct sk_buff *skb;
183 struct ieee80211_mgmt *mgmt; 236 struct ieee80211_mgmt *mgmt;
184 u8 *pos, *ies, *ht_ie; 237 u8 *pos;
238 const u8 *ies, *ht_ie;
185 int i, len, count, rates_len, supp_rates_len; 239 int i, len, count, rates_len, supp_rates_len;
186 u16 capab; 240 u16 capab;
187 struct ieee80211_bss *bss;
188 int wmm = 0; 241 int wmm = 0;
189 struct ieee80211_supported_band *sband; 242 struct ieee80211_supported_band *sband;
190 u32 rates = 0; 243 u32 rates = 0;
191 244
192 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 245 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
193 sizeof(*mgmt) + 200 + ifmgd->extra_ie_len + 246 sizeof(*mgmt) + 200 + wk->ie_len +
194 ifmgd->ssid_len); 247 wk->ssid_len);
195 if (!skb) { 248 if (!skb) {
196 printk(KERN_DEBUG "%s: failed to allocate buffer for assoc " 249 printk(KERN_DEBUG "%s: failed to allocate buffer for assoc "
197 "frame\n", sdata->dev->name); 250 "frame\n", sdata->dev->name);
@@ -210,45 +263,35 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
210 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; 263 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
211 } 264 }
212 265
213 bss = ieee80211_rx_bss_get(local, ifmgd->bssid, 266 if (wk->bss->cbss.capability & WLAN_CAPABILITY_PRIVACY)
214 local->hw.conf.channel->center_freq, 267 capab |= WLAN_CAPABILITY_PRIVACY;
215 ifmgd->ssid, ifmgd->ssid_len); 268 if (wk->bss->wmm_used)
216 if (bss) { 269 wmm = 1;
217 if (bss->cbss.capability & WLAN_CAPABILITY_PRIVACY)
218 capab |= WLAN_CAPABILITY_PRIVACY;
219 if (bss->wmm_used)
220 wmm = 1;
221 270
222 /* get all rates supported by the device and the AP as 271 /* get all rates supported by the device and the AP as
223 * some APs don't like getting a superset of their rates 272 * some APs don't like getting a superset of their rates
224 * in the association request (e.g. D-Link DAP 1353 in 273 * in the association request (e.g. D-Link DAP 1353 in
225 * b-only mode) */ 274 * b-only mode) */
226 rates_len = ieee80211_compatible_rates(bss, sband, &rates); 275 rates_len = ieee80211_compatible_rates(wk->bss, sband, &rates);
227 276
228 if ((bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && 277 if ((wk->bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) &&
229 (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) 278 (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT))
230 capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; 279 capab |= WLAN_CAPABILITY_SPECTRUM_MGMT;
231
232 ieee80211_rx_bss_put(local, bss);
233 } else {
234 rates = ~0;
235 rates_len = sband->n_bitrates;
236 }
237 280
238 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); 281 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
239 memset(mgmt, 0, 24); 282 memset(mgmt, 0, 24);
240 memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN); 283 memcpy(mgmt->da, wk->bss->cbss.bssid, ETH_ALEN);
241 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 284 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
242 memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN); 285 memcpy(mgmt->bssid, wk->bss->cbss.bssid, ETH_ALEN);
243 286
244 if (ifmgd->flags & IEEE80211_STA_PREV_BSSID_SET) { 287 if (!is_zero_ether_addr(wk->prev_bssid)) {
245 skb_put(skb, 10); 288 skb_put(skb, 10);
246 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 289 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
247 IEEE80211_STYPE_REASSOC_REQ); 290 IEEE80211_STYPE_REASSOC_REQ);
248 mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); 291 mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab);
249 mgmt->u.reassoc_req.listen_interval = 292 mgmt->u.reassoc_req.listen_interval =
250 cpu_to_le16(local->hw.conf.listen_interval); 293 cpu_to_le16(local->hw.conf.listen_interval);
251 memcpy(mgmt->u.reassoc_req.current_ap, ifmgd->prev_bssid, 294 memcpy(mgmt->u.reassoc_req.current_ap, wk->prev_bssid,
252 ETH_ALEN); 295 ETH_ALEN);
253 } else { 296 } else {
254 skb_put(skb, 4); 297 skb_put(skb, 4);
@@ -260,10 +303,10 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
260 } 303 }
261 304
262 /* SSID */ 305 /* SSID */
263 ies = pos = skb_put(skb, 2 + ifmgd->ssid_len); 306 ies = pos = skb_put(skb, 2 + wk->ssid_len);
264 *pos++ = WLAN_EID_SSID; 307 *pos++ = WLAN_EID_SSID;
265 *pos++ = ifmgd->ssid_len; 308 *pos++ = wk->ssid_len;
266 memcpy(pos, ifmgd->ssid, ifmgd->ssid_len); 309 memcpy(pos, wk->ssid, wk->ssid_len);
267 310
268 /* add all rates which were marked to be used above */ 311 /* add all rates which were marked to be used above */
269 supp_rates_len = rates_len; 312 supp_rates_len = rates_len;
@@ -318,9 +361,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
318 } 361 }
319 } 362 }
320 363
321 if (ifmgd->extra_ie) { 364 if (wk->ie_len && wk->ie) {
322 pos = skb_put(skb, ifmgd->extra_ie_len); 365 pos = skb_put(skb, wk->ie_len);
323 memcpy(pos, ifmgd->extra_ie, ifmgd->extra_ie_len); 366 memcpy(pos, wk->ie, wk->ie_len);
324 } 367 }
325 368
326 if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) { 369 if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) {
@@ -345,9 +388,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
345 */ 388 */
346 if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && 389 if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) &&
347 sband->ht_cap.ht_supported && 390 sband->ht_cap.ht_supported &&
348 (ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) && 391 (ht_ie = ieee80211_bss_get_ie(&wk->bss->cbss, WLAN_EID_HT_INFORMATION)) &&
349 ht_ie[1] >= sizeof(struct ieee80211_ht_info) && 392 ht_ie[1] >= sizeof(struct ieee80211_ht_info) &&
350 (!(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED))) { 393 (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N))) {
351 struct ieee80211_ht_info *ht_info = 394 struct ieee80211_ht_info *ht_info =
352 (struct ieee80211_ht_info *)(ht_ie + 2); 395 (struct ieee80211_ht_info *)(ht_ie + 2);
353 u16 cap = sband->ht_cap.cap; 396 u16 cap = sband->ht_cap.cap;
@@ -382,18 +425,13 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
382 memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); 425 memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs));
383 } 426 }
384 427
385 kfree(ifmgd->assocreq_ies);
386 ifmgd->assocreq_ies_len = (skb->data + skb->len) - ies;
387 ifmgd->assocreq_ies = kmalloc(ifmgd->assocreq_ies_len, GFP_KERNEL);
388 if (ifmgd->assocreq_ies)
389 memcpy(ifmgd->assocreq_ies, ies, ifmgd->assocreq_ies_len);
390
391 ieee80211_tx_skb(sdata, skb, 0); 428 ieee80211_tx_skb(sdata, skb, 0);
392} 429}
393 430
394 431
395static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, 432static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
396 u16 stype, u16 reason) 433 const u8 *bssid, u16 stype, u16 reason,
434 void *cookie)
397{ 435{
398 struct ieee80211_local *local = sdata->local; 436 struct ieee80211_local *local = sdata->local;
399 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 437 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
@@ -410,18 +448,18 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
410 448
411 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); 449 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
412 memset(mgmt, 0, 24); 450 memset(mgmt, 0, 24);
413 memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN); 451 memcpy(mgmt->da, bssid, ETH_ALEN);
414 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 452 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
415 memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN); 453 memcpy(mgmt->bssid, bssid, ETH_ALEN);
416 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); 454 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
417 skb_put(skb, 2); 455 skb_put(skb, 2);
418 /* u.deauth.reason_code == u.disassoc.reason_code */ 456 /* u.deauth.reason_code == u.disassoc.reason_code */
419 mgmt->u.deauth.reason_code = cpu_to_le16(reason); 457 mgmt->u.deauth.reason_code = cpu_to_le16(reason);
420 458
421 if (stype == IEEE80211_STYPE_DEAUTH) 459 if (stype == IEEE80211_STYPE_DEAUTH)
422 cfg80211_send_deauth(sdata->dev, (u8 *) mgmt, skb->len); 460 cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len, cookie);
423 else 461 else
424 cfg80211_send_disassoc(sdata->dev, (u8 *) mgmt, skb->len); 462 cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len, cookie);
425 ieee80211_tx_skb(sdata, skb, ifmgd->flags & IEEE80211_STA_MFP_ENABLED); 463 ieee80211_tx_skb(sdata, skb, ifmgd->flags & IEEE80211_STA_MFP_ENABLED);
426} 464}
427 465
@@ -494,28 +532,26 @@ static void ieee80211_chswitch_work(struct work_struct *work)
494{ 532{
495 struct ieee80211_sub_if_data *sdata = 533 struct ieee80211_sub_if_data *sdata =
496 container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); 534 container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work);
497 struct ieee80211_bss *bss;
498 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 535 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
499 536
500 if (!netif_running(sdata->dev)) 537 if (!netif_running(sdata->dev))
501 return; 538 return;
502 539
503 bss = ieee80211_rx_bss_get(sdata->local, ifmgd->bssid, 540 mutex_lock(&ifmgd->mtx);
504 sdata->local->hw.conf.channel->center_freq, 541 if (!ifmgd->associated)
505 ifmgd->ssid, ifmgd->ssid_len); 542 goto out;
506 if (!bss)
507 goto exit;
508 543
509 sdata->local->oper_channel = sdata->local->csa_channel; 544 sdata->local->oper_channel = sdata->local->csa_channel;
545 ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL);
546
510 /* XXX: shouldn't really modify cfg80211-owned data! */ 547 /* XXX: shouldn't really modify cfg80211-owned data! */
511 if (!ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL)) 548 ifmgd->associated->cbss.channel = sdata->local->oper_channel;
512 bss->cbss.channel = sdata->local->oper_channel;
513 549
514 ieee80211_rx_bss_put(sdata->local, bss);
515exit:
516 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
517 ieee80211_wake_queues_by_reason(&sdata->local->hw, 550 ieee80211_wake_queues_by_reason(&sdata->local->hw,
518 IEEE80211_QUEUE_STOP_REASON_CSA); 551 IEEE80211_QUEUE_STOP_REASON_CSA);
552 out:
553 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
554 mutex_unlock(&ifmgd->mtx);
519} 555}
520 556
521static void ieee80211_chswitch_timer(unsigned long data) 557static void ieee80211_chswitch_timer(unsigned long data)
@@ -540,7 +576,9 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
540 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 576 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
541 int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num); 577 int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num);
542 578
543 if (ifmgd->state != IEEE80211_STA_MLME_ASSOCIATED) 579 ASSERT_MGD_MTX(ifmgd);
580
581 if (!ifmgd->associated)
544 return; 582 return;
545 583
546 if (sdata->local->sw_scanning || sdata->local->hw_scanning) 584 if (sdata->local->sw_scanning || sdata->local->hw_scanning)
@@ -651,8 +689,9 @@ void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency)
651 } 689 }
652 690
653 if (count == 1 && found->u.mgd.powersave && 691 if (count == 1 && found->u.mgd.powersave &&
654 (found->u.mgd.flags & IEEE80211_STA_ASSOCIATED) && 692 found->u.mgd.associated && list_empty(&found->u.mgd.work_list) &&
655 !(found->u.mgd.flags & IEEE80211_STA_PROBEREQ_POLL)) { 693 !(found->u.mgd.flags & (IEEE80211_STA_BEACON_POLL |
694 IEEE80211_STA_CONNECTION_POLL))) {
656 s32 beaconint_us; 695 s32 beaconint_us;
657 696
658 if (latency < 0) 697 if (latency < 0)
@@ -806,9 +845,6 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
806 u16 capab, bool erp_valid, u8 erp) 845 u16 capab, bool erp_valid, u8 erp)
807{ 846{
808 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 847 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
809#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
810 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
811#endif
812 u32 changed = 0; 848 u32 changed = 0;
813 bool use_protection; 849 bool use_protection;
814 bool use_short_preamble; 850 bool use_short_preamble;
@@ -825,42 +861,16 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
825 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); 861 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
826 862
827 if (use_protection != bss_conf->use_cts_prot) { 863 if (use_protection != bss_conf->use_cts_prot) {
828#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
829 if (net_ratelimit()) {
830 printk(KERN_DEBUG "%s: CTS protection %s (BSSID=%pM)\n",
831 sdata->dev->name,
832 use_protection ? "enabled" : "disabled",
833 ifmgd->bssid);
834 }
835#endif
836 bss_conf->use_cts_prot = use_protection; 864 bss_conf->use_cts_prot = use_protection;
837 changed |= BSS_CHANGED_ERP_CTS_PROT; 865 changed |= BSS_CHANGED_ERP_CTS_PROT;
838 } 866 }
839 867
840 if (use_short_preamble != bss_conf->use_short_preamble) { 868 if (use_short_preamble != bss_conf->use_short_preamble) {
841#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
842 if (net_ratelimit()) {
843 printk(KERN_DEBUG "%s: switched to %s barker preamble"
844 " (BSSID=%pM)\n",
845 sdata->dev->name,
846 use_short_preamble ? "short" : "long",
847 ifmgd->bssid);
848 }
849#endif
850 bss_conf->use_short_preamble = use_short_preamble; 869 bss_conf->use_short_preamble = use_short_preamble;
851 changed |= BSS_CHANGED_ERP_PREAMBLE; 870 changed |= BSS_CHANGED_ERP_PREAMBLE;
852 } 871 }
853 872
854 if (use_short_slot != bss_conf->use_short_slot) { 873 if (use_short_slot != bss_conf->use_short_slot) {
855#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
856 if (net_ratelimit()) {
857 printk(KERN_DEBUG "%s: switched to %s slot time"
858 " (BSSID=%pM)\n",
859 sdata->dev->name,
860 use_short_slot ? "short" : "long",
861 ifmgd->bssid);
862 }
863#endif
864 bss_conf->use_short_slot = use_short_slot; 874 bss_conf->use_short_slot = use_short_slot;
865 changed |= BSS_CHANGED_ERP_SLOT; 875 changed |= BSS_CHANGED_ERP_SLOT;
866 } 876 }
@@ -868,105 +878,29 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
868 return changed; 878 return changed;
869} 879}
870 880
871static void ieee80211_sta_send_apinfo(struct ieee80211_sub_if_data *sdata)
872{
873 union iwreq_data wrqu;
874
875 memset(&wrqu, 0, sizeof(wrqu));
876 if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED)
877 memcpy(wrqu.ap_addr.sa_data, sdata->u.mgd.bssid, ETH_ALEN);
878 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
879 wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL);
880}
881
882static void ieee80211_sta_send_associnfo(struct ieee80211_sub_if_data *sdata)
883{
884 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
885 char *buf;
886 size_t len;
887 int i;
888 union iwreq_data wrqu;
889
890 if (!ifmgd->assocreq_ies && !ifmgd->assocresp_ies)
891 return;
892
893 buf = kmalloc(50 + 2 * (ifmgd->assocreq_ies_len +
894 ifmgd->assocresp_ies_len), GFP_KERNEL);
895 if (!buf)
896 return;
897
898 len = sprintf(buf, "ASSOCINFO(");
899 if (ifmgd->assocreq_ies) {
900 len += sprintf(buf + len, "ReqIEs=");
901 for (i = 0; i < ifmgd->assocreq_ies_len; i++) {
902 len += sprintf(buf + len, "%02x",
903 ifmgd->assocreq_ies[i]);
904 }
905 }
906 if (ifmgd->assocresp_ies) {
907 if (ifmgd->assocreq_ies)
908 len += sprintf(buf + len, " ");
909 len += sprintf(buf + len, "RespIEs=");
910 for (i = 0; i < ifmgd->assocresp_ies_len; i++) {
911 len += sprintf(buf + len, "%02x",
912 ifmgd->assocresp_ies[i]);
913 }
914 }
915 len += sprintf(buf + len, ")");
916
917 if (len > IW_CUSTOM_MAX) {
918 len = sprintf(buf, "ASSOCRESPIE=");
919 for (i = 0; i < ifmgd->assocresp_ies_len; i++) {
920 len += sprintf(buf + len, "%02x",
921 ifmgd->assocresp_ies[i]);
922 }
923 }
924
925 if (len <= IW_CUSTOM_MAX) {
926 memset(&wrqu, 0, sizeof(wrqu));
927 wrqu.data.length = len;
928 wireless_send_event(sdata->dev, IWEVCUSTOM, &wrqu, buf);
929 }
930
931 kfree(buf);
932}
933
934
935static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, 881static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
882 struct ieee80211_bss *bss,
936 u32 bss_info_changed) 883 u32 bss_info_changed)
937{ 884{
938 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
939 struct ieee80211_local *local = sdata->local; 885 struct ieee80211_local *local = sdata->local;
940 struct ieee80211_conf *conf = &local_to_hw(local)->conf;
941
942 struct ieee80211_bss *bss;
943 886
944 bss_info_changed |= BSS_CHANGED_ASSOC; 887 bss_info_changed |= BSS_CHANGED_ASSOC;
945 ifmgd->flags |= IEEE80211_STA_ASSOCIATED; 888 /* set timing information */
946 889 sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval;
947 bss = ieee80211_rx_bss_get(local, ifmgd->bssid, 890 sdata->vif.bss_conf.timestamp = bss->cbss.tsf;
948 conf->channel->center_freq, 891 sdata->vif.bss_conf.dtim_period = bss->dtim_period;
949 ifmgd->ssid, ifmgd->ssid_len);
950 if (bss) {
951 /* set timing information */
952 sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval;
953 sdata->vif.bss_conf.timestamp = bss->cbss.tsf;
954 sdata->vif.bss_conf.dtim_period = bss->dtim_period;
955 892
956 bss_info_changed |= BSS_CHANGED_BEACON_INT; 893 bss_info_changed |= BSS_CHANGED_BEACON_INT;
957 bss_info_changed |= ieee80211_handle_bss_capability(sdata, 894 bss_info_changed |= ieee80211_handle_bss_capability(sdata,
958 bss->cbss.capability, bss->has_erp_value, bss->erp_value); 895 bss->cbss.capability, bss->has_erp_value, bss->erp_value);
959 896
960 cfg80211_hold_bss(&bss->cbss); 897 sdata->u.mgd.associated = bss;
898 memcpy(sdata->u.mgd.bssid, bss->cbss.bssid, ETH_ALEN);
961 899
962 ieee80211_rx_bss_put(local, bss); 900 /* just to be sure */
963 } 901 sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL |
902 IEEE80211_STA_BEACON_POLL);
964 903
965 ifmgd->flags |= IEEE80211_STA_PREV_BSSID_SET;
966 memcpy(ifmgd->prev_bssid, sdata->u.mgd.bssid, ETH_ALEN);
967 ieee80211_sta_send_associnfo(sdata);
968
969 ifmgd->last_probe = jiffies;
970 ieee80211_led_assoc(local, 1); 904 ieee80211_led_assoc(local, 1);
971 905
972 sdata->vif.bss_conf.assoc = 1; 906 sdata->vif.bss_conf.assoc = 1;
@@ -991,167 +925,140 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
991 925
992 netif_tx_start_all_queues(sdata->dev); 926 netif_tx_start_all_queues(sdata->dev);
993 netif_carrier_on(sdata->dev); 927 netif_carrier_on(sdata->dev);
994
995 ieee80211_sta_send_apinfo(sdata);
996} 928}
997 929
998static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata) 930static enum rx_mgmt_action __must_check
931ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata,
932 struct ieee80211_mgd_work *wk)
999{ 933{
1000 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 934 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1001 struct ieee80211_local *local = sdata->local; 935 struct ieee80211_local *local = sdata->local;
1002 936
1003 ifmgd->direct_probe_tries++; 937 wk->tries++;
1004 if (ifmgd->direct_probe_tries > IEEE80211_AUTH_MAX_TRIES) { 938 if (wk->tries > IEEE80211_AUTH_MAX_TRIES) {
1005 printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n", 939 printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n",
1006 sdata->dev->name, ifmgd->bssid); 940 sdata->dev->name, wk->bss->cbss.bssid);
1007 ifmgd->state = IEEE80211_STA_MLME_DISABLED;
1008 ieee80211_recalc_idle(local);
1009 cfg80211_send_auth_timeout(sdata->dev, ifmgd->bssid);
1010 941
1011 /* 942 /*
1012 * Most likely AP is not in the range so remove the 943 * Most likely AP is not in the range so remove the
1013 * bss information associated to the AP 944 * bss struct for that AP.
1014 */ 945 */
1015 ieee80211_rx_bss_remove(sdata, ifmgd->bssid, 946 cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss);
1016 sdata->local->hw.conf.channel->center_freq,
1017 ifmgd->ssid, ifmgd->ssid_len);
1018 947
1019 /* 948 /*
1020 * We might have a pending scan which had no chance to run yet 949 * We might have a pending scan which had no chance to run yet
1021 * due to state == IEEE80211_STA_MLME_DIRECT_PROBE. 950 * due to work needing to be done. Hence, queue the STAs work
1022 * Hence, queue the STAs work again 951 * again for that.
1023 */ 952 */
1024 queue_work(local->hw.workqueue, &ifmgd->work); 953 queue_work(local->hw.workqueue, &ifmgd->work);
1025 return; 954 return RX_MGMT_CFG80211_AUTH_TO;
1026 } 955 }
1027 956
1028 printk(KERN_DEBUG "%s: direct probe to AP %pM try %d\n", 957 printk(KERN_DEBUG "%s: direct probe to AP %pM (try %d)\n",
1029 sdata->dev->name, ifmgd->bssid, 958 sdata->dev->name, wk->bss->cbss.bssid,
1030 ifmgd->direct_probe_tries); 959 wk->tries);
1031 960
1032 ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE; 961 /*
1033 962 * Direct probe is sent to broadcast address as some APs
1034 /* Direct probe is sent to broadcast address as some APs
1035 * will not answer to direct packet in unassociated state. 963 * will not answer to direct packet in unassociated state.
1036 */ 964 */
1037 ieee80211_send_probe_req(sdata, NULL, 965 ieee80211_send_probe_req(sdata, NULL, wk->ssid, wk->ssid_len, NULL, 0);
1038 ifmgd->ssid, ifmgd->ssid_len, NULL, 0);
1039 966
1040 mod_timer(&ifmgd->timer, jiffies + IEEE80211_AUTH_TIMEOUT); 967 wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
968 run_again(ifmgd, wk->timeout);
969
970 return RX_MGMT_NONE;
1041} 971}
1042 972
1043 973
1044static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata) 974static enum rx_mgmt_action __must_check
975ieee80211_authenticate(struct ieee80211_sub_if_data *sdata,
976 struct ieee80211_mgd_work *wk)
1045{ 977{
1046 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 978 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1047 struct ieee80211_local *local = sdata->local; 979 struct ieee80211_local *local = sdata->local;
1048 u8 *ies;
1049 size_t ies_len;
1050 980
1051 ifmgd->auth_tries++; 981 wk->tries++;
1052 if (ifmgd->auth_tries > IEEE80211_AUTH_MAX_TRIES) { 982 if (wk->tries > IEEE80211_AUTH_MAX_TRIES) {
1053 printk(KERN_DEBUG "%s: authentication with AP %pM" 983 printk(KERN_DEBUG "%s: authentication with AP %pM"
1054 " timed out\n", 984 " timed out\n",
1055 sdata->dev->name, ifmgd->bssid); 985 sdata->dev->name, wk->bss->cbss.bssid);
1056 ifmgd->state = IEEE80211_STA_MLME_DISABLED; 986
1057 ieee80211_recalc_idle(local); 987 /*
1058 cfg80211_send_auth_timeout(sdata->dev, ifmgd->bssid); 988 * Most likely AP is not in the range so remove the
1059 ieee80211_rx_bss_remove(sdata, ifmgd->bssid, 989 * bss struct for that AP.
1060 sdata->local->hw.conf.channel->center_freq, 990 */
1061 ifmgd->ssid, ifmgd->ssid_len); 991 cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss);
1062 992
1063 /* 993 /*
1064 * We might have a pending scan which had no chance to run yet 994 * We might have a pending scan which had no chance to run yet
1065 * due to state == IEEE80211_STA_MLME_AUTHENTICATE. 995 * due to work needing to be done. Hence, queue the STAs work
1066 * Hence, queue the STAs work again 996 * again for that.
1067 */ 997 */
1068 queue_work(local->hw.workqueue, &ifmgd->work); 998 queue_work(local->hw.workqueue, &ifmgd->work);
1069 return; 999 return RX_MGMT_CFG80211_AUTH_TO;
1070 } 1000 }
1071 1001
1072 ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE; 1002 printk(KERN_DEBUG "%s: authenticate with AP %pM (try %d)\n",
1073 printk(KERN_DEBUG "%s: authenticate with AP %pM\n", 1003 sdata->dev->name, wk->bss->cbss.bssid, wk->tries);
1074 sdata->dev->name, ifmgd->bssid);
1075 1004
1076 if (ifmgd->flags & IEEE80211_STA_EXT_SME) { 1005 ieee80211_send_auth(sdata, 1, wk->auth_alg, wk->ie, wk->ie_len,
1077 ies = ifmgd->sme_auth_ie; 1006 wk->bss->cbss.bssid, NULL, 0, 0);
1078 ies_len = ifmgd->sme_auth_ie_len; 1007 wk->auth_transaction = 2;
1079 } else { 1008
1080 ies = NULL; 1009 wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
1081 ies_len = 0; 1010 run_again(ifmgd, wk->timeout);
1082 }
1083 ieee80211_send_auth(sdata, 1, ifmgd->auth_alg, ies, ies_len,
1084 ifmgd->bssid, 0);
1085 ifmgd->auth_transaction = 2;
1086 1011
1087 mod_timer(&ifmgd->timer, jiffies + IEEE80211_AUTH_TIMEOUT); 1012 return RX_MGMT_NONE;
1088} 1013}
1089 1014
1090/* 1015static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata)
1091 * The disassoc 'reason' argument can be either our own reason
1092 * if self disconnected or a reason code from the AP.
1093 */
1094static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1095 bool deauth, bool self_disconnected,
1096 u16 reason)
1097{ 1016{
1098 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1017 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1099 struct ieee80211_local *local = sdata->local; 1018 struct ieee80211_local *local = sdata->local;
1100 struct ieee80211_conf *conf = &local_to_hw(local)->conf;
1101 struct ieee80211_bss *bss;
1102 struct sta_info *sta; 1019 struct sta_info *sta;
1103 u32 changed = 0, config_changed = 0; 1020 u32 changed = 0, config_changed = 0;
1021 u8 bssid[ETH_ALEN];
1104 1022
1105 if (deauth) { 1023 ASSERT_MGD_MTX(ifmgd);
1106 ifmgd->direct_probe_tries = 0; 1024
1107 ifmgd->auth_tries = 0; 1025 if (WARN_ON(!ifmgd->associated))
1108 } 1026 return;
1109 ifmgd->assoc_scan_tries = 0; 1027
1110 ifmgd->assoc_tries = 0; 1028 memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN);
1029
1030 ifmgd->associated = NULL;
1031 memset(ifmgd->bssid, 0, ETH_ALEN);
1032
1033 /*
1034 * we need to commit the associated = NULL change because the
1035 * scan code uses that to determine whether this iface should
1036 * go to/wake up from powersave or not -- and could otherwise
1037 * wake the queues erroneously.
1038 */
1039 smp_mb();
1040
1041 /*
1042 * Thus, we can only afterwards stop the queues -- to account
1043 * for the case where another CPU is finishing a scan at this
1044 * time -- we don't want the scan code to enable queues.
1045 */
1111 1046
1112 netif_tx_stop_all_queues(sdata->dev); 1047 netif_tx_stop_all_queues(sdata->dev);
1113 netif_carrier_off(sdata->dev); 1048 netif_carrier_off(sdata->dev);
1114 1049
1115 rcu_read_lock(); 1050 rcu_read_lock();
1116 sta = sta_info_get(local, ifmgd->bssid); 1051 sta = sta_info_get(local, bssid);
1117 if (sta) 1052 if (sta)
1118 ieee80211_sta_tear_down_BA_sessions(sta); 1053 ieee80211_sta_tear_down_BA_sessions(sta);
1119 rcu_read_unlock(); 1054 rcu_read_unlock();
1120 1055
1121 bss = ieee80211_rx_bss_get(local, ifmgd->bssid,
1122 conf->channel->center_freq,
1123 ifmgd->ssid, ifmgd->ssid_len);
1124
1125 if (bss) {
1126 cfg80211_unhold_bss(&bss->cbss);
1127 ieee80211_rx_bss_put(local, bss);
1128 }
1129
1130 if (self_disconnected) {
1131 if (deauth)
1132 ieee80211_send_deauth_disassoc(sdata,
1133 IEEE80211_STYPE_DEAUTH, reason);
1134 else
1135 ieee80211_send_deauth_disassoc(sdata,
1136 IEEE80211_STYPE_DISASSOC, reason);
1137 }
1138
1139 ifmgd->flags &= ~IEEE80211_STA_ASSOCIATED;
1140 changed |= ieee80211_reset_erp_info(sdata); 1056 changed |= ieee80211_reset_erp_info(sdata);
1141 1057
1142 ieee80211_led_assoc(local, 0); 1058 ieee80211_led_assoc(local, 0);
1143 changed |= BSS_CHANGED_ASSOC; 1059 changed |= BSS_CHANGED_ASSOC;
1144 sdata->vif.bss_conf.assoc = false; 1060 sdata->vif.bss_conf.assoc = false;
1145 1061
1146 ieee80211_sta_send_apinfo(sdata);
1147
1148 if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT) {
1149 ifmgd->state = IEEE80211_STA_MLME_DISABLED;
1150 ieee80211_rx_bss_remove(sdata, ifmgd->bssid,
1151 sdata->local->hw.conf.channel->center_freq,
1152 ifmgd->ssid, ifmgd->ssid_len);
1153 }
1154
1155 ieee80211_set_wmm_default(sdata); 1062 ieee80211_set_wmm_default(sdata);
1156 1063
1157 ieee80211_recalc_idle(local); 1064 ieee80211_recalc_idle(local);
@@ -1180,7 +1087,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1180 1087
1181 rcu_read_lock(); 1088 rcu_read_lock();
1182 1089
1183 sta = sta_info_get(local, ifmgd->bssid); 1090 sta = sta_info_get(local, bssid);
1184 if (!sta) { 1091 if (!sta) {
1185 rcu_read_unlock(); 1092 rcu_read_unlock();
1186 return; 1093 return;
@@ -1193,83 +1100,42 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1193 sta_info_destroy(sta); 1100 sta_info_destroy(sta);
1194} 1101}
1195 1102
1196static int ieee80211_sta_wep_configured(struct ieee80211_sub_if_data *sdata) 1103static enum rx_mgmt_action __must_check
1197{ 1104ieee80211_associate(struct ieee80211_sub_if_data *sdata,
1198 if (!sdata || !sdata->default_key || 1105 struct ieee80211_mgd_work *wk)
1199 sdata->default_key->conf.alg != ALG_WEP)
1200 return 0;
1201 return 1;
1202}
1203
1204static int ieee80211_privacy_mismatch(struct ieee80211_sub_if_data *sdata)
1205{
1206 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1207 struct ieee80211_local *local = sdata->local;
1208 struct ieee80211_bss *bss;
1209 int bss_privacy;
1210 int wep_privacy;
1211 int privacy_invoked;
1212
1213 if (!ifmgd || (ifmgd->flags & IEEE80211_STA_EXT_SME))
1214 return 0;
1215
1216 bss = ieee80211_rx_bss_get(local, ifmgd->bssid,
1217 local->hw.conf.channel->center_freq,
1218 ifmgd->ssid, ifmgd->ssid_len);
1219 if (!bss)
1220 return 0;
1221
1222 bss_privacy = !!(bss->cbss.capability & WLAN_CAPABILITY_PRIVACY);
1223 wep_privacy = !!ieee80211_sta_wep_configured(sdata);
1224 privacy_invoked = !!(ifmgd->flags & IEEE80211_STA_PRIVACY_INVOKED);
1225
1226 ieee80211_rx_bss_put(local, bss);
1227
1228 if ((bss_privacy == wep_privacy) || (bss_privacy == privacy_invoked))
1229 return 0;
1230
1231 return 1;
1232}
1233
1234static void ieee80211_associate(struct ieee80211_sub_if_data *sdata)
1235{ 1106{
1236 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1107 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1237 struct ieee80211_local *local = sdata->local; 1108 struct ieee80211_local *local = sdata->local;
1238 1109
1239 ifmgd->assoc_tries++; 1110 wk->tries++;
1240 if (ifmgd->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) { 1111 if (wk->tries > IEEE80211_ASSOC_MAX_TRIES) {
1241 printk(KERN_DEBUG "%s: association with AP %pM" 1112 printk(KERN_DEBUG "%s: association with AP %pM"
1242 " timed out\n", 1113 " timed out\n",
1243 sdata->dev->name, ifmgd->bssid); 1114 sdata->dev->name, wk->bss->cbss.bssid);
1244 ifmgd->state = IEEE80211_STA_MLME_DISABLED; 1115
1245 ieee80211_recalc_idle(local); 1116 /*
1246 cfg80211_send_assoc_timeout(sdata->dev, ifmgd->bssid); 1117 * Most likely AP is not in the range so remove the
1247 ieee80211_rx_bss_remove(sdata, ifmgd->bssid, 1118 * bss struct for that AP.
1248 sdata->local->hw.conf.channel->center_freq, 1119 */
1249 ifmgd->ssid, ifmgd->ssid_len); 1120 cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss);
1121
1250 /* 1122 /*
1251 * We might have a pending scan which had no chance to run yet 1123 * We might have a pending scan which had no chance to run yet
1252 * due to state == IEEE80211_STA_MLME_ASSOCIATE. 1124 * due to work needing to be done. Hence, queue the STAs work
1253 * Hence, queue the STAs work again 1125 * again for that.
1254 */ 1126 */
1255 queue_work(local->hw.workqueue, &ifmgd->work); 1127 queue_work(local->hw.workqueue, &ifmgd->work);
1256 return; 1128 return RX_MGMT_CFG80211_ASSOC_TO;
1257 } 1129 }
1258 1130
1259 ifmgd->state = IEEE80211_STA_MLME_ASSOCIATE; 1131 printk(KERN_DEBUG "%s: associate with AP %pM (try %d)\n",
1260 printk(KERN_DEBUG "%s: associate with AP %pM\n", 1132 sdata->dev->name, wk->bss->cbss.bssid, wk->tries);
1261 sdata->dev->name, ifmgd->bssid); 1133 ieee80211_send_assoc(sdata, wk);
1262 if (ieee80211_privacy_mismatch(sdata)) {
1263 printk(KERN_DEBUG "%s: mismatch in privacy configuration and "
1264 "mixed-cell disabled - abort association\n", sdata->dev->name);
1265 ifmgd->state = IEEE80211_STA_MLME_DISABLED;
1266 ieee80211_recalc_idle(local);
1267 return;
1268 }
1269 1134
1270 ieee80211_send_assoc(sdata); 1135 wk->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT;
1136 run_again(ifmgd, wk->timeout);
1271 1137
1272 mod_timer(&ifmgd->timer, jiffies + IEEE80211_ASSOC_TIMEOUT); 1138 return RX_MGMT_NONE;
1273} 1139}
1274 1140
1275void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, 1141void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
@@ -1280,50 +1146,83 @@ void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
1280 * from AP because we know that the connection is working both ways 1146 * from AP because we know that the connection is working both ways
1281 * at that time. But multicast frames (and hence also beacons) must 1147 * at that time. But multicast frames (and hence also beacons) must
1282 * be ignored here, because we need to trigger the timer during 1148 * be ignored here, because we need to trigger the timer during
1283 * data idle periods for sending the periodical probe request to 1149 * data idle periods for sending the periodic probe request to the
1284 * the AP. 1150 * AP we're connected to.
1285 */ 1151 */
1286 if (!is_multicast_ether_addr(hdr->addr1)) 1152 if (is_multicast_ether_addr(hdr->addr1))
1287 mod_timer(&sdata->u.mgd.timer, 1153 return;
1288 jiffies + IEEE80211_MONITORING_INTERVAL); 1154
1155 mod_timer(&sdata->u.mgd.conn_mon_timer,
1156 round_jiffies_up(jiffies + IEEE80211_CONNECTION_IDLE_TIME));
1289} 1157}
1290 1158
1291void ieee80211_beacon_loss_work(struct work_struct *work) 1159static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata,
1160 bool beacon)
1292{ 1161{
1293 struct ieee80211_sub_if_data *sdata =
1294 container_of(work, struct ieee80211_sub_if_data,
1295 u.mgd.beacon_loss_work);
1296 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1162 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1163 const u8 *ssid;
1164 bool already = false;
1297 1165
1298 /* 1166 if (!netif_running(sdata->dev))
1299 * The driver has already reported this event and we have
1300 * already sent a probe request. Maybe the AP died and the
1301 * driver keeps reporting until we disassociate... We have
1302 * to ignore that because otherwise we would continually
1303 * reset the timer and never check whether we received a
1304 * probe response!
1305 */
1306 if (ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL)
1307 return; 1167 return;
1308 1168
1169 mutex_lock(&ifmgd->mtx);
1170
1171 if (!ifmgd->associated)
1172 goto out;
1173
1309#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 1174#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1310 if (net_ratelimit()) { 1175 if (beacon && net_ratelimit())
1311 printk(KERN_DEBUG "%s: driver reports beacon loss from AP %pM " 1176 printk(KERN_DEBUG "%s: detected beacon loss from AP "
1312 "- sending probe request\n", sdata->dev->name, 1177 "- sending probe request\n", sdata->dev->name);
1313 sdata->u.mgd.bssid);
1314 }
1315#endif 1178#endif
1316 1179
1317 ifmgd->flags |= IEEE80211_STA_PROBEREQ_POLL; 1180 /*
1181 * The driver/our work has already reported this event or the
1182 * connection monitoring has kicked in and we have already sent
1183 * a probe request. Or maybe the AP died and the driver keeps
1184 * reporting until we disassociate...
1185 *
1186 * In either case we have to ignore the current call to this
1187 * function (except for setting the correct probe reason bit)
1188 * because otherwise we would reset the timer every time and
1189 * never check whether we received a probe response!
1190 */
1191 if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
1192 IEEE80211_STA_CONNECTION_POLL))
1193 already = true;
1194
1195 if (beacon)
1196 ifmgd->flags |= IEEE80211_STA_BEACON_POLL;
1197 else
1198 ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL;
1199
1200 if (already)
1201 goto out;
1202
1203 ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT;
1318 1204
1319 mutex_lock(&sdata->local->iflist_mtx); 1205 mutex_lock(&sdata->local->iflist_mtx);
1320 ieee80211_recalc_ps(sdata->local, -1); 1206 ieee80211_recalc_ps(sdata->local, -1);
1321 mutex_unlock(&sdata->local->iflist_mtx); 1207 mutex_unlock(&sdata->local->iflist_mtx);
1322 1208
1323 ieee80211_send_probe_req(sdata, ifmgd->bssid, ifmgd->ssid, 1209 ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID);
1324 ifmgd->ssid_len, NULL, 0); 1210 ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid,
1211 ssid + 2, ssid[1], NULL, 0);
1212
1213 run_again(ifmgd, ifmgd->probe_timeout);
1325 1214
1326 mod_timer(&ifmgd->timer, jiffies + IEEE80211_PROBE_WAIT); 1215 out:
1216 mutex_unlock(&ifmgd->mtx);
1217}
1218
1219void ieee80211_beacon_loss_work(struct work_struct *work)
1220{
1221 struct ieee80211_sub_if_data *sdata =
1222 container_of(work, struct ieee80211_sub_if_data,
1223 u.mgd.beacon_loss_work);
1224
1225 ieee80211_mgd_probe_ap(sdata, true);
1327} 1226}
1328 1227
1329void ieee80211_beacon_loss(struct ieee80211_vif *vif) 1228void ieee80211_beacon_loss(struct ieee80211_vif *vif)
@@ -1335,105 +1234,16 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif)
1335} 1234}
1336EXPORT_SYMBOL(ieee80211_beacon_loss); 1235EXPORT_SYMBOL(ieee80211_beacon_loss);
1337 1236
1338static void ieee80211_associated(struct ieee80211_sub_if_data *sdata) 1237static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata,
1339{ 1238 struct ieee80211_mgd_work *wk)
1340 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1341 struct ieee80211_local *local = sdata->local;
1342 struct sta_info *sta;
1343 unsigned long last_rx;
1344 bool disassoc = false;
1345
1346 /* TODO: start monitoring current AP signal quality and number of
1347 * missed beacons. Scan other channels every now and then and search
1348 * for better APs. */
1349 /* TODO: remove expired BSSes */
1350
1351 ifmgd->state = IEEE80211_STA_MLME_ASSOCIATED;
1352
1353 rcu_read_lock();
1354
1355 sta = sta_info_get(local, ifmgd->bssid);
1356 if (!sta) {
1357 printk(KERN_DEBUG "%s: No STA entry for own AP %pM\n",
1358 sdata->dev->name, ifmgd->bssid);
1359 disassoc = true;
1360 rcu_read_unlock();
1361 goto out;
1362 }
1363
1364 last_rx = sta->last_rx;
1365 rcu_read_unlock();
1366
1367 if ((ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) &&
1368 time_after(jiffies, last_rx + IEEE80211_PROBE_WAIT)) {
1369 printk(KERN_DEBUG "%s: no probe response from AP %pM "
1370 "- disassociating\n",
1371 sdata->dev->name, ifmgd->bssid);
1372 disassoc = true;
1373 ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL;
1374 goto out;
1375 }
1376
1377 /*
1378 * Beacon filtering is only enabled with power save and then the
1379 * stack should not check for beacon loss.
1380 */
1381 if (!((local->hw.flags & IEEE80211_HW_BEACON_FILTER) &&
1382 (local->hw.conf.flags & IEEE80211_CONF_PS)) &&
1383 time_after(jiffies,
1384 ifmgd->last_beacon + IEEE80211_MONITORING_INTERVAL)) {
1385#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1386 if (net_ratelimit()) {
1387 printk(KERN_DEBUG "%s: beacon loss from AP %pM "
1388 "- sending probe request\n",
1389 sdata->dev->name, ifmgd->bssid);
1390 }
1391#endif
1392 ifmgd->flags |= IEEE80211_STA_PROBEREQ_POLL;
1393 mutex_lock(&local->iflist_mtx);
1394 ieee80211_recalc_ps(local, -1);
1395 mutex_unlock(&local->iflist_mtx);
1396 ieee80211_send_probe_req(sdata, ifmgd->bssid, ifmgd->ssid,
1397 ifmgd->ssid_len, NULL, 0);
1398 mod_timer(&ifmgd->timer, jiffies + IEEE80211_PROBE_WAIT);
1399 goto out;
1400 }
1401
1402 if (time_after(jiffies, last_rx + IEEE80211_PROBE_IDLE_TIME)) {
1403 ifmgd->flags |= IEEE80211_STA_PROBEREQ_POLL;
1404 mutex_lock(&local->iflist_mtx);
1405 ieee80211_recalc_ps(local, -1);
1406 mutex_unlock(&local->iflist_mtx);
1407 ieee80211_send_probe_req(sdata, ifmgd->bssid, ifmgd->ssid,
1408 ifmgd->ssid_len, NULL, 0);
1409 }
1410
1411 out:
1412 if (!disassoc)
1413 mod_timer(&ifmgd->timer,
1414 jiffies + IEEE80211_MONITORING_INTERVAL);
1415 else
1416 ieee80211_set_disassoc(sdata, true, true,
1417 WLAN_REASON_PREV_AUTH_NOT_VALID);
1418}
1419
1420
1421static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata)
1422{ 1239{
1423 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1240 wk->state = IEEE80211_MGD_STATE_IDLE;
1424
1425 printk(KERN_DEBUG "%s: authenticated\n", sdata->dev->name); 1241 printk(KERN_DEBUG "%s: authenticated\n", sdata->dev->name);
1426 ifmgd->flags |= IEEE80211_STA_AUTHENTICATED;
1427 if (ifmgd->flags & IEEE80211_STA_EXT_SME) {
1428 /* Wait for SME to request association */
1429 ifmgd->state = IEEE80211_STA_MLME_DISABLED;
1430 ieee80211_recalc_idle(sdata->local);
1431 } else
1432 ieee80211_associate(sdata);
1433} 1242}
1434 1243
1435 1244
1436static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, 1245static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
1246 struct ieee80211_mgd_work *wk,
1437 struct ieee80211_mgmt *mgmt, 1247 struct ieee80211_mgmt *mgmt,
1438 size_t len) 1248 size_t len)
1439{ 1249{
@@ -1444,161 +1254,133 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
1444 ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); 1254 ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
1445 if (!elems.challenge) 1255 if (!elems.challenge)
1446 return; 1256 return;
1447 ieee80211_send_auth(sdata, 3, sdata->u.mgd.auth_alg, 1257 ieee80211_send_auth(sdata, 3, wk->auth_alg,
1448 elems.challenge - 2, elems.challenge_len + 2, 1258 elems.challenge - 2, elems.challenge_len + 2,
1449 sdata->u.mgd.bssid, 1); 1259 wk->bss->cbss.bssid,
1450 sdata->u.mgd.auth_transaction = 4; 1260 wk->key, wk->key_len, wk->key_idx);
1261 wk->auth_transaction = 4;
1451} 1262}
1452 1263
1453static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, 1264static enum rx_mgmt_action __must_check
1454 struct ieee80211_mgmt *mgmt, 1265ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1455 size_t len) 1266 struct ieee80211_mgd_work *wk,
1267 struct ieee80211_mgmt *mgmt, size_t len)
1456{ 1268{
1457 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1458 u16 auth_alg, auth_transaction, status_code; 1269 u16 auth_alg, auth_transaction, status_code;
1459 1270
1460 if (ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE) 1271 if (wk->state != IEEE80211_MGD_STATE_AUTH)
1461 return; 1272 return RX_MGMT_NONE;
1462 1273
1463 if (len < 24 + 6) 1274 if (len < 24 + 6)
1464 return; 1275 return RX_MGMT_NONE;
1465 1276
1466 if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0) 1277 if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0)
1467 return; 1278 return RX_MGMT_NONE;
1468 1279
1469 if (memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0) 1280 if (memcmp(wk->bss->cbss.bssid, mgmt->bssid, ETH_ALEN) != 0)
1470 return; 1281 return RX_MGMT_NONE;
1471 1282
1472 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); 1283 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
1473 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); 1284 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
1474 status_code = le16_to_cpu(mgmt->u.auth.status_code); 1285 status_code = le16_to_cpu(mgmt->u.auth.status_code);
1475 1286
1476 if (auth_alg != ifmgd->auth_alg || 1287 if (auth_alg != wk->auth_alg ||
1477 auth_transaction != ifmgd->auth_transaction) 1288 auth_transaction != wk->auth_transaction)
1478 return; 1289 return RX_MGMT_NONE;
1479 1290
1480 if (status_code != WLAN_STATUS_SUCCESS) { 1291 if (status_code != WLAN_STATUS_SUCCESS) {
1481 if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { 1292 list_del(&wk->list);
1482 u8 algs[3]; 1293 kfree(wk);
1483 const int num_algs = ARRAY_SIZE(algs); 1294 return RX_MGMT_CFG80211_AUTH;
1484 int i, pos;
1485 algs[0] = algs[1] = algs[2] = 0xff;
1486 if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_OPEN)
1487 algs[0] = WLAN_AUTH_OPEN;
1488 if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY)
1489 algs[1] = WLAN_AUTH_SHARED_KEY;
1490 if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_LEAP)
1491 algs[2] = WLAN_AUTH_LEAP;
1492 if (ifmgd->auth_alg == WLAN_AUTH_OPEN)
1493 pos = 0;
1494 else if (ifmgd->auth_alg == WLAN_AUTH_SHARED_KEY)
1495 pos = 1;
1496 else
1497 pos = 2;
1498 for (i = 0; i < num_algs; i++) {
1499 pos++;
1500 if (pos >= num_algs)
1501 pos = 0;
1502 if (algs[pos] == ifmgd->auth_alg ||
1503 algs[pos] == 0xff)
1504 continue;
1505 if (algs[pos] == WLAN_AUTH_SHARED_KEY &&
1506 !ieee80211_sta_wep_configured(sdata))
1507 continue;
1508 ifmgd->auth_alg = algs[pos];
1509 break;
1510 }
1511 }
1512 return;
1513 } 1295 }
1514 1296
1515 switch (ifmgd->auth_alg) { 1297 switch (wk->auth_alg) {
1516 case WLAN_AUTH_OPEN: 1298 case WLAN_AUTH_OPEN:
1517 case WLAN_AUTH_LEAP: 1299 case WLAN_AUTH_LEAP:
1518 case WLAN_AUTH_FT: 1300 case WLAN_AUTH_FT:
1519 ieee80211_auth_completed(sdata); 1301 ieee80211_auth_completed(sdata, wk);
1520 cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, len); 1302 return RX_MGMT_CFG80211_AUTH;
1521 break;
1522 case WLAN_AUTH_SHARED_KEY: 1303 case WLAN_AUTH_SHARED_KEY:
1523 if (ifmgd->auth_transaction == 4) { 1304 if (wk->auth_transaction == 4) {
1524 ieee80211_auth_completed(sdata); 1305 ieee80211_auth_completed(sdata, wk);
1525 cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, len); 1306 return RX_MGMT_CFG80211_AUTH;
1526 } else 1307 } else
1527 ieee80211_auth_challenge(sdata, mgmt, len); 1308 ieee80211_auth_challenge(sdata, wk, mgmt, len);
1528 break; 1309 break;
1529 } 1310 }
1311
1312 return RX_MGMT_NONE;
1530} 1313}
1531 1314
1532 1315
1533static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, 1316static enum rx_mgmt_action __must_check
1534 struct ieee80211_mgmt *mgmt, 1317ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
1535 size_t len) 1318 struct ieee80211_mgd_work *wk,
1319 struct ieee80211_mgmt *mgmt, size_t len)
1536{ 1320{
1537 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1321 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1322 const u8 *bssid = NULL;
1538 u16 reason_code; 1323 u16 reason_code;
1539 1324
1540 if (len < 24 + 2) 1325 if (len < 24 + 2)
1541 return; 1326 return RX_MGMT_NONE;
1542 1327
1543 if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN)) 1328 ASSERT_MGD_MTX(ifmgd);
1544 return; 1329
1330 if (wk)
1331 bssid = wk->bss->cbss.bssid;
1332 else
1333 bssid = ifmgd->associated->cbss.bssid;
1545 1334
1546 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); 1335 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
1547 1336
1548 if (ifmgd->flags & IEEE80211_STA_AUTHENTICATED) 1337 printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n",
1549 printk(KERN_DEBUG "%s: deauthenticated (Reason: %u)\n", 1338 sdata->dev->name, bssid, reason_code);
1550 sdata->dev->name, reason_code);
1551 1339
1552 if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) && 1340 if (!wk) {
1553 (ifmgd->state == IEEE80211_STA_MLME_AUTHENTICATE || 1341 ieee80211_set_disassoc(sdata);
1554 ifmgd->state == IEEE80211_STA_MLME_ASSOCIATE || 1342 } else {
1555 ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)) { 1343 list_del(&wk->list);
1556 ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE; 1344 kfree(wk);
1557 mod_timer(&ifmgd->timer, jiffies +
1558 IEEE80211_RETRY_AUTH_INTERVAL);
1559 } 1345 }
1560 1346
1561 ieee80211_set_disassoc(sdata, true, false, 0); 1347 return RX_MGMT_CFG80211_DEAUTH;
1562 ifmgd->flags &= ~IEEE80211_STA_AUTHENTICATED;
1563 cfg80211_send_deauth(sdata->dev, (u8 *) mgmt, len);
1564} 1348}
1565 1349
1566 1350
1567static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, 1351static enum rx_mgmt_action __must_check
1568 struct ieee80211_mgmt *mgmt, 1352ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
1569 size_t len) 1353 struct ieee80211_mgmt *mgmt, size_t len)
1570{ 1354{
1571 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1355 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1572 u16 reason_code; 1356 u16 reason_code;
1573 1357
1574 if (len < 24 + 2) 1358 if (len < 24 + 2)
1575 return; 1359 return RX_MGMT_NONE;
1576 1360
1577 if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN)) 1361 ASSERT_MGD_MTX(ifmgd);
1578 return;
1579 1362
1580 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); 1363 if (WARN_ON(!ifmgd->associated))
1364 return RX_MGMT_NONE;
1581 1365
1582 if (ifmgd->flags & IEEE80211_STA_ASSOCIATED) 1366 if (WARN_ON(memcmp(ifmgd->associated->cbss.bssid, mgmt->sa, ETH_ALEN)))
1583 printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n", 1367 return RX_MGMT_NONE;
1584 sdata->dev->name, reason_code);
1585 1368
1586 if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) && 1369 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
1587 ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) {
1588 ifmgd->state = IEEE80211_STA_MLME_ASSOCIATE;
1589 mod_timer(&ifmgd->timer, jiffies +
1590 IEEE80211_RETRY_AUTH_INTERVAL);
1591 }
1592 1370
1593 ieee80211_set_disassoc(sdata, false, false, reason_code); 1371 printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n",
1594 cfg80211_send_disassoc(sdata->dev, (u8 *) mgmt, len); 1372 sdata->dev->name, reason_code);
1373
1374 ieee80211_set_disassoc(sdata);
1375 return RX_MGMT_CFG80211_DISASSOC;
1595} 1376}
1596 1377
1597 1378
1598static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, 1379static enum rx_mgmt_action __must_check
1599 struct ieee80211_mgmt *mgmt, 1380ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1600 size_t len, 1381 struct ieee80211_mgd_work *wk,
1601 int reassoc) 1382 struct ieee80211_mgmt *mgmt, size_t len,
1383 bool reassoc)
1602{ 1384{
1603 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1385 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1604 struct ieee80211_local *local = sdata->local; 1386 struct ieee80211_local *local = sdata->local;
@@ -1614,17 +1396,16 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1614 bool have_higher_than_11mbit = false, newsta = false; 1396 bool have_higher_than_11mbit = false, newsta = false;
1615 u16 ap_ht_cap_flags; 1397 u16 ap_ht_cap_flags;
1616 1398
1617 /* AssocResp and ReassocResp have identical structure, so process both 1399 /*
1618 * of them in this function. */ 1400 * AssocResp and ReassocResp have identical structure, so process both
1619 1401 * of them in this function.
1620 if (ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE) 1402 */
1621 return;
1622 1403
1623 if (len < 24 + 6) 1404 if (len < 24 + 6)
1624 return; 1405 return RX_MGMT_NONE;
1625 1406
1626 if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0) 1407 if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0)
1627 return; 1408 return RX_MGMT_NONE;
1628 1409
1629 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); 1410 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
1630 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); 1411 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
@@ -1647,26 +1428,18 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1647 printk(KERN_DEBUG "%s: AP rejected association temporarily; " 1428 printk(KERN_DEBUG "%s: AP rejected association temporarily; "
1648 "comeback duration %u TU (%u ms)\n", 1429 "comeback duration %u TU (%u ms)\n",
1649 sdata->dev->name, tu, ms); 1430 sdata->dev->name, tu, ms);
1431 wk->timeout = jiffies + msecs_to_jiffies(ms);
1650 if (ms > IEEE80211_ASSOC_TIMEOUT) 1432 if (ms > IEEE80211_ASSOC_TIMEOUT)
1651 mod_timer(&ifmgd->timer, 1433 run_again(ifmgd, jiffies + msecs_to_jiffies(ms));
1652 jiffies + msecs_to_jiffies(ms)); 1434 return RX_MGMT_NONE;
1653 return;
1654 } 1435 }
1655 1436
1656 if (status_code != WLAN_STATUS_SUCCESS) { 1437 if (status_code != WLAN_STATUS_SUCCESS) {
1657 printk(KERN_DEBUG "%s: AP denied association (code=%d)\n", 1438 printk(KERN_DEBUG "%s: AP denied association (code=%d)\n",
1658 sdata->dev->name, status_code); 1439 sdata->dev->name, status_code);
1659 /* if this was a reassociation, ensure we try a "full" 1440 list_del(&wk->list);
1660 * association next time. This works around some broken APs 1441 kfree(wk);
1661 * which do not correctly reject reassociation requests. */ 1442 return RX_MGMT_CFG80211_ASSOC;
1662 ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET;
1663 cfg80211_send_rx_assoc(sdata->dev, (u8 *) mgmt, len);
1664 if (ifmgd->flags & IEEE80211_STA_EXT_SME) {
1665 /* Wait for SME to decide what to do next */
1666 ifmgd->state = IEEE80211_STA_MLME_DISABLED;
1667 ieee80211_recalc_idle(local);
1668 }
1669 return;
1670 } 1443 }
1671 1444
1672 if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) 1445 if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14)))
@@ -1677,51 +1450,35 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1677 if (!elems.supp_rates) { 1450 if (!elems.supp_rates) {
1678 printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n", 1451 printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n",
1679 sdata->dev->name); 1452 sdata->dev->name);
1680 return; 1453 return RX_MGMT_NONE;
1681 } 1454 }
1682 1455
1683 printk(KERN_DEBUG "%s: associated\n", sdata->dev->name); 1456 printk(KERN_DEBUG "%s: associated\n", sdata->dev->name);
1684 ifmgd->aid = aid; 1457 ifmgd->aid = aid;
1685 ifmgd->ap_capab = capab_info;
1686
1687 kfree(ifmgd->assocresp_ies);
1688 ifmgd->assocresp_ies_len = len - (pos - (u8 *) mgmt);
1689 ifmgd->assocresp_ies = kmalloc(ifmgd->assocresp_ies_len, GFP_KERNEL);
1690 if (ifmgd->assocresp_ies)
1691 memcpy(ifmgd->assocresp_ies, pos, ifmgd->assocresp_ies_len);
1692 1458
1693 rcu_read_lock(); 1459 rcu_read_lock();
1694 1460
1695 /* Add STA entry for the AP */ 1461 /* Add STA entry for the AP */
1696 sta = sta_info_get(local, ifmgd->bssid); 1462 sta = sta_info_get(local, wk->bss->cbss.bssid);
1697 if (!sta) { 1463 if (!sta) {
1698 newsta = true; 1464 newsta = true;
1699 1465
1700 sta = sta_info_alloc(sdata, ifmgd->bssid, GFP_ATOMIC); 1466 rcu_read_unlock();
1467
1468 sta = sta_info_alloc(sdata, wk->bss->cbss.bssid, GFP_KERNEL);
1701 if (!sta) { 1469 if (!sta) {
1702 printk(KERN_DEBUG "%s: failed to alloc STA entry for" 1470 printk(KERN_DEBUG "%s: failed to alloc STA entry for"
1703 " the AP\n", sdata->dev->name); 1471 " the AP\n", sdata->dev->name);
1704 rcu_read_unlock(); 1472 return RX_MGMT_NONE;
1705 return;
1706 } 1473 }
1707 1474
1708 /* update new sta with its last rx activity */ 1475 set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC |
1709 sta->last_rx = jiffies; 1476 WLAN_STA_ASSOC_AP);
1710 } 1477 if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT))
1711 1478 set_sta_flags(sta, WLAN_STA_AUTHORIZED);
1712 /*
1713 * FIXME: Do we really need to update the sta_info's information here?
1714 * We already know about the AP (we found it in our list) so it
1715 * should already be filled with the right info, no?
1716 * As is stands, all this is racy because typically we assume
1717 * the information that is filled in here (except flags) doesn't
1718 * change while a STA structure is alive. As such, it should move
1719 * to between the sta_info_alloc() and sta_info_insert() above.
1720 */
1721 1479
1722 set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP); 1480 rcu_read_lock();
1723 if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) 1481 }
1724 set_sta_flags(sta, WLAN_STA_AUTHORIZED);
1725 1482
1726 rates = 0; 1483 rates = 0;
1727 basic_rates = 0; 1484 basic_rates = 0;
@@ -1771,8 +1528,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1771 else 1528 else
1772 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; 1529 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
1773 1530
1774 /* If TKIP/WEP is used, no need to parse AP's HT capabilities */ 1531 if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
1775 if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED))
1776 ieee80211_ht_cap_ie_to_sta_ht_cap(sband, 1532 ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
1777 elems.ht_cap_elem, &sta->sta.ht_cap); 1533 elems.ht_cap_elem, &sta->sta.ht_cap);
1778 1534
@@ -1792,7 +1548,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1792 printk(KERN_DEBUG "%s: failed to insert STA entry for" 1548 printk(KERN_DEBUG "%s: failed to insert STA entry for"
1793 " the AP (error %d)\n", sdata->dev->name, err); 1549 " the AP (error %d)\n", sdata->dev->name, err);
1794 rcu_read_unlock(); 1550 rcu_read_unlock();
1795 return; 1551 return RX_MGMT_NONE;
1796 } 1552 }
1797 } 1553 }
1798 1554
@@ -1806,24 +1562,27 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1806 1562
1807 if (elems.ht_info_elem && elems.wmm_param && 1563 if (elems.ht_info_elem && elems.wmm_param &&
1808 (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && 1564 (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) &&
1809 !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED)) 1565 !(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
1810 changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, 1566 changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
1567 wk->bss->cbss.bssid,
1811 ap_ht_cap_flags); 1568 ap_ht_cap_flags);
1812 1569
1813 /* set AID and assoc capability, 1570 /* set AID and assoc capability,
1814 * ieee80211_set_associated() will tell the driver */ 1571 * ieee80211_set_associated() will tell the driver */
1815 bss_conf->aid = aid; 1572 bss_conf->aid = aid;
1816 bss_conf->assoc_capability = capab_info; 1573 bss_conf->assoc_capability = capab_info;
1817 ieee80211_set_associated(sdata, changed); 1574 ieee80211_set_associated(sdata, wk->bss, changed);
1818 1575
1819 /* 1576 /*
1820 * initialise the time of last beacon to be the association time, 1577 * Start timer to probe the connection to the AP now.
1821 * otherwise beacon loss check will trigger immediately 1578 * Also start the timer that will detect beacon loss.
1822 */ 1579 */
1823 ifmgd->last_beacon = jiffies; 1580 ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt);
1581 mod_beacon_timer(sdata);
1824 1582
1825 ieee80211_associated(sdata); 1583 list_del(&wk->list);
1826 cfg80211_send_rx_assoc(sdata->dev, (u8 *) mgmt, len); 1584 kfree(wk);
1585 return RX_MGMT_CFG80211_ASSOC;
1827} 1586}
1828 1587
1829 1588
@@ -1851,23 +1610,25 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
1851 1610
1852 bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, 1611 bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems,
1853 channel, beacon); 1612 channel, beacon);
1854 if (!bss) 1613 if (bss)
1614 ieee80211_rx_bss_put(local, bss);
1615
1616 if (!sdata->u.mgd.associated)
1855 return; 1617 return;
1856 1618
1857 if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) && 1619 if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) &&
1858 (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN) == 0)) { 1620 (memcmp(mgmt->bssid, sdata->u.mgd.associated->cbss.bssid,
1621 ETH_ALEN) == 0)) {
1859 struct ieee80211_channel_sw_ie *sw_elem = 1622 struct ieee80211_channel_sw_ie *sw_elem =
1860 (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem; 1623 (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem;
1861 ieee80211_sta_process_chanswitch(sdata, sw_elem, bss); 1624 ieee80211_sta_process_chanswitch(sdata, sw_elem, bss);
1862 } 1625 }
1863
1864 ieee80211_rx_bss_put(local, bss);
1865} 1626}
1866 1627
1867 1628
1868static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, 1629static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
1869 struct ieee80211_mgmt *mgmt, 1630 struct ieee80211_mgd_work *wk,
1870 size_t len, 1631 struct ieee80211_mgmt *mgmt, size_t len,
1871 struct ieee80211_rx_status *rx_status) 1632 struct ieee80211_rx_status *rx_status)
1872{ 1633{
1873 struct ieee80211_if_managed *ifmgd; 1634 struct ieee80211_if_managed *ifmgd;
@@ -1876,6 +1637,8 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
1876 1637
1877 ifmgd = &sdata->u.mgd; 1638 ifmgd = &sdata->u.mgd;
1878 1639
1640 ASSERT_MGD_MTX(ifmgd);
1641
1879 if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) 1642 if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN))
1880 return; /* ignore ProbeResp to foreign address */ 1643 return; /* ignore ProbeResp to foreign address */
1881 1644
@@ -1889,17 +1652,32 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
1889 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); 1652 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
1890 1653
1891 /* direct probe may be part of the association flow */ 1654 /* direct probe may be part of the association flow */
1892 if (ifmgd->state == IEEE80211_STA_MLME_DIRECT_PROBE) { 1655 if (wk && wk->state == IEEE80211_MGD_STATE_PROBE) {
1893 printk(KERN_DEBUG "%s direct probe responded\n", 1656 printk(KERN_DEBUG "%s direct probe responded\n",
1894 sdata->dev->name); 1657 sdata->dev->name);
1895 ieee80211_authenticate(sdata); 1658 wk->tries = 0;
1659 wk->state = IEEE80211_MGD_STATE_AUTH;
1660 WARN_ON(ieee80211_authenticate(sdata, wk) != RX_MGMT_NONE);
1896 } 1661 }
1897 1662
1898 if (ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) { 1663 if (ifmgd->associated &&
1899 ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL; 1664 memcmp(mgmt->bssid, ifmgd->associated->cbss.bssid, ETH_ALEN) == 0 &&
1665 ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
1666 IEEE80211_STA_CONNECTION_POLL)) {
1667 ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
1668 IEEE80211_STA_BEACON_POLL);
1900 mutex_lock(&sdata->local->iflist_mtx); 1669 mutex_lock(&sdata->local->iflist_mtx);
1901 ieee80211_recalc_ps(sdata->local, -1); 1670 ieee80211_recalc_ps(sdata->local, -1);
1902 mutex_unlock(&sdata->local->iflist_mtx); 1671 mutex_unlock(&sdata->local->iflist_mtx);
1672 /*
1673 * We've received a probe response, but are not sure whether
1674 * we have or will be receiving any beacons or data, so let's
1675 * schedule the timers again, just in case.
1676 */
1677 mod_beacon_timer(sdata);
1678 mod_timer(&ifmgd->conn_mon_timer,
1679 round_jiffies_up(jiffies +
1680 IEEE80211_CONNECTION_IDLE_TIME));
1903 } 1681 }
1904} 1682}
1905 1683
@@ -1937,6 +1715,9 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1937 bool erp_valid, directed_tim = false; 1715 bool erp_valid, directed_tim = false;
1938 u8 erp_value = 0; 1716 u8 erp_value = 0;
1939 u32 ncrc; 1717 u32 ncrc;
1718 u8 *bssid;
1719
1720 ASSERT_MGD_MTX(ifmgd);
1940 1721
1941 /* Process beacon from the current BSS */ 1722 /* Process beacon from the current BSS */
1942 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; 1723 baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
@@ -1946,23 +1727,41 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1946 if (rx_status->freq != local->hw.conf.channel->center_freq) 1727 if (rx_status->freq != local->hw.conf.channel->center_freq)
1947 return; 1728 return;
1948 1729
1949 if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED) || 1730 /*
1950 memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0) 1731 * We might have received a number of frames, among them a
1732 * disassoc frame and a beacon...
1733 */
1734 if (!ifmgd->associated)
1951 return; 1735 return;
1952 1736
1953 if (ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) { 1737 bssid = ifmgd->associated->cbss.bssid;
1738
1739 /*
1740 * And in theory even frames from a different AP we were just
1741 * associated to a split-second ago!
1742 */
1743 if (memcmp(bssid, mgmt->bssid, ETH_ALEN) != 0)
1744 return;
1745
1746 if (ifmgd->flags & IEEE80211_STA_BEACON_POLL) {
1954#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 1747#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1955 if (net_ratelimit()) { 1748 if (net_ratelimit()) {
1956 printk(KERN_DEBUG "%s: cancelling probereq poll due " 1749 printk(KERN_DEBUG "%s: cancelling probereq poll due "
1957 "to a received beacon\n", sdata->dev->name); 1750 "to a received beacon\n", sdata->dev->name);
1958 } 1751 }
1959#endif 1752#endif
1960 ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL; 1753 ifmgd->flags &= ~IEEE80211_STA_BEACON_POLL;
1961 mutex_lock(&local->iflist_mtx); 1754 mutex_lock(&local->iflist_mtx);
1962 ieee80211_recalc_ps(local, -1); 1755 ieee80211_recalc_ps(local, -1);
1963 mutex_unlock(&local->iflist_mtx); 1756 mutex_unlock(&local->iflist_mtx);
1964 } 1757 }
1965 1758
1759 /*
1760 * Push the beacon loss detection into the future since
1761 * we are processing a beacon from the AP just now.
1762 */
1763 mod_beacon_timer(sdata);
1764
1966 ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); 1765 ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4);
1967 ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable, 1766 ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable,
1968 len - baselen, &elems, 1767 len - baselen, &elems,
@@ -2019,15 +1818,15 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2019 1818
2020 1819
2021 if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && 1820 if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param &&
2022 !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED)) { 1821 !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) {
2023 struct sta_info *sta; 1822 struct sta_info *sta;
2024 struct ieee80211_supported_band *sband; 1823 struct ieee80211_supported_band *sband;
2025 u16 ap_ht_cap_flags; 1824 u16 ap_ht_cap_flags;
2026 1825
2027 rcu_read_lock(); 1826 rcu_read_lock();
2028 1827
2029 sta = sta_info_get(local, ifmgd->bssid); 1828 sta = sta_info_get(local, bssid);
2030 if (!sta) { 1829 if (WARN_ON(!sta)) {
2031 rcu_read_unlock(); 1830 rcu_read_unlock();
2032 return; 1831 return;
2033 } 1832 }
@@ -2042,7 +1841,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2042 rcu_read_unlock(); 1841 rcu_read_unlock();
2043 1842
2044 changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, 1843 changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
2045 ap_ht_cap_flags); 1844 bssid, ap_ht_cap_flags);
2046 } 1845 }
2047 1846
2048 if (elems.country_elem) { 1847 if (elems.country_elem) {
@@ -2063,8 +1862,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2063} 1862}
2064 1863
2065ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, 1864ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata,
2066 struct sk_buff *skb, 1865 struct sk_buff *skb)
2067 struct ieee80211_rx_status *rx_status)
2068{ 1866{
2069 struct ieee80211_local *local = sdata->local; 1867 struct ieee80211_local *local = sdata->local;
2070 struct ieee80211_mgmt *mgmt; 1868 struct ieee80211_mgmt *mgmt;
@@ -2080,12 +1878,12 @@ ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata,
2080 case IEEE80211_STYPE_PROBE_REQ: 1878 case IEEE80211_STYPE_PROBE_REQ:
2081 case IEEE80211_STYPE_PROBE_RESP: 1879 case IEEE80211_STYPE_PROBE_RESP:
2082 case IEEE80211_STYPE_BEACON: 1880 case IEEE80211_STYPE_BEACON:
2083 memcpy(skb->cb, rx_status, sizeof(*rx_status));
2084 case IEEE80211_STYPE_AUTH: 1881 case IEEE80211_STYPE_AUTH:
2085 case IEEE80211_STYPE_ASSOC_RESP: 1882 case IEEE80211_STYPE_ASSOC_RESP:
2086 case IEEE80211_STYPE_REASSOC_RESP: 1883 case IEEE80211_STYPE_REASSOC_RESP:
2087 case IEEE80211_STYPE_DEAUTH: 1884 case IEEE80211_STYPE_DEAUTH:
2088 case IEEE80211_STYPE_DISASSOC: 1885 case IEEE80211_STYPE_DISASSOC:
1886 case IEEE80211_STYPE_ACTION:
2089 skb_queue_tail(&sdata->u.mgd.skb_queue, skb); 1887 skb_queue_tail(&sdata->u.mgd.skb_queue, skb);
2090 queue_work(local->hw.workqueue, &sdata->u.mgd.work); 1888 queue_work(local->hw.workqueue, &sdata->u.mgd.work);
2091 return RX_QUEUED; 1889 return RX_QUEUED;
@@ -2097,40 +1895,116 @@ ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata,
2097static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 1895static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
2098 struct sk_buff *skb) 1896 struct sk_buff *skb)
2099{ 1897{
1898 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2100 struct ieee80211_rx_status *rx_status; 1899 struct ieee80211_rx_status *rx_status;
2101 struct ieee80211_mgmt *mgmt; 1900 struct ieee80211_mgmt *mgmt;
1901 struct ieee80211_mgd_work *wk;
1902 enum rx_mgmt_action rma = RX_MGMT_NONE;
2102 u16 fc; 1903 u16 fc;
2103 1904
2104 rx_status = (struct ieee80211_rx_status *) skb->cb; 1905 rx_status = (struct ieee80211_rx_status *) skb->cb;
2105 mgmt = (struct ieee80211_mgmt *) skb->data; 1906 mgmt = (struct ieee80211_mgmt *) skb->data;
2106 fc = le16_to_cpu(mgmt->frame_control); 1907 fc = le16_to_cpu(mgmt->frame_control);
2107 1908
2108 switch (fc & IEEE80211_FCTL_STYPE) { 1909 mutex_lock(&ifmgd->mtx);
2109 case IEEE80211_STYPE_PROBE_RESP: 1910
2110 ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, 1911 if (ifmgd->associated &&
2111 rx_status); 1912 memcmp(ifmgd->associated->cbss.bssid, mgmt->bssid,
2112 break; 1913 ETH_ALEN) == 0) {
2113 case IEEE80211_STYPE_BEACON: 1914 switch (fc & IEEE80211_FCTL_STYPE) {
2114 ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, 1915 case IEEE80211_STYPE_BEACON:
2115 rx_status); 1916 ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len,
2116 break; 1917 rx_status);
2117 case IEEE80211_STYPE_AUTH: 1918 break;
2118 ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len); 1919 case IEEE80211_STYPE_PROBE_RESP:
2119 break; 1920 ieee80211_rx_mgmt_probe_resp(sdata, NULL, mgmt,
2120 case IEEE80211_STYPE_ASSOC_RESP: 1921 skb->len, rx_status);
2121 ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 0); 1922 break;
1923 case IEEE80211_STYPE_DEAUTH:
1924 rma = ieee80211_rx_mgmt_deauth(sdata, NULL,
1925 mgmt, skb->len);
1926 break;
1927 case IEEE80211_STYPE_DISASSOC:
1928 rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len);
1929 break;
1930 case IEEE80211_STYPE_ACTION:
1931 /* XXX: differentiate, can only happen for CSA now! */
1932 ieee80211_sta_process_chanswitch(sdata,
1933 &mgmt->u.action.u.chan_switch.sw_elem,
1934 ifmgd->associated);
1935 break;
1936 }
1937 mutex_unlock(&ifmgd->mtx);
1938
1939 switch (rma) {
1940 case RX_MGMT_NONE:
1941 /* no action */
1942 break;
1943 case RX_MGMT_CFG80211_DEAUTH:
1944 cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len,
1945 NULL);
1946 break;
1947 case RX_MGMT_CFG80211_DISASSOC:
1948 cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len,
1949 NULL);
1950 break;
1951 default:
1952 WARN(1, "unexpected: %d", rma);
1953 }
1954 goto out;
1955 }
1956
1957 list_for_each_entry(wk, &ifmgd->work_list, list) {
1958 if (memcmp(wk->bss->cbss.bssid, mgmt->bssid, ETH_ALEN) != 0)
1959 continue;
1960
1961 switch (fc & IEEE80211_FCTL_STYPE) {
1962 case IEEE80211_STYPE_PROBE_RESP:
1963 ieee80211_rx_mgmt_probe_resp(sdata, wk, mgmt, skb->len,
1964 rx_status);
1965 break;
1966 case IEEE80211_STYPE_AUTH:
1967 rma = ieee80211_rx_mgmt_auth(sdata, wk, mgmt, skb->len);
1968 break;
1969 case IEEE80211_STYPE_ASSOC_RESP:
1970 rma = ieee80211_rx_mgmt_assoc_resp(sdata, wk, mgmt,
1971 skb->len, false);
1972 break;
1973 case IEEE80211_STYPE_REASSOC_RESP:
1974 rma = ieee80211_rx_mgmt_assoc_resp(sdata, wk, mgmt,
1975 skb->len, true);
1976 break;
1977 case IEEE80211_STYPE_DEAUTH:
1978 rma = ieee80211_rx_mgmt_deauth(sdata, wk, mgmt,
1979 skb->len);
1980 break;
1981 }
1982 /*
1983 * We've processed this frame for that work, so it can't
1984 * belong to another work struct.
1985 * NB: this is also required for correctness because the
1986 * called functions can free 'wk', and for 'rma'!
1987 */
2122 break; 1988 break;
2123 case IEEE80211_STYPE_REASSOC_RESP: 1989 }
2124 ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 1); 1990
1991 mutex_unlock(&ifmgd->mtx);
1992
1993 switch (rma) {
1994 case RX_MGMT_NONE:
1995 /* no action */
2125 break; 1996 break;
2126 case IEEE80211_STYPE_DEAUTH: 1997 case RX_MGMT_CFG80211_AUTH:
2127 ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); 1998 cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, skb->len);
2128 break; 1999 break;
2129 case IEEE80211_STYPE_DISASSOC: 2000 case RX_MGMT_CFG80211_ASSOC:
2130 ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); 2001 cfg80211_send_rx_assoc(sdata->dev, (u8 *) mgmt, skb->len);
2131 break; 2002 break;
2003 default:
2004 WARN(1, "unexpected: %d", rma);
2132 } 2005 }
2133 2006
2007 out:
2134 kfree_skb(skb); 2008 kfree_skb(skb);
2135} 2009}
2136 2010
@@ -2146,125 +2020,9 @@ static void ieee80211_sta_timer(unsigned long data)
2146 return; 2020 return;
2147 } 2021 }
2148 2022
2149 set_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request);
2150 queue_work(local->hw.workqueue, &ifmgd->work); 2023 queue_work(local->hw.workqueue, &ifmgd->work);
2151} 2024}
2152 2025
2153static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata)
2154{
2155 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2156 struct ieee80211_local *local = sdata->local;
2157
2158 /* Reset own TSF to allow time synchronization work. */
2159 drv_reset_tsf(local);
2160
2161 ifmgd->wmm_last_param_set = -1; /* allow any WMM update */
2162
2163
2164 if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_OPEN)
2165 ifmgd->auth_alg = WLAN_AUTH_OPEN;
2166 else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY)
2167 ifmgd->auth_alg = WLAN_AUTH_SHARED_KEY;
2168 else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_LEAP)
2169 ifmgd->auth_alg = WLAN_AUTH_LEAP;
2170 else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_FT)
2171 ifmgd->auth_alg = WLAN_AUTH_FT;
2172 else
2173 ifmgd->auth_alg = WLAN_AUTH_OPEN;
2174 ifmgd->auth_transaction = -1;
2175 ifmgd->flags &= ~IEEE80211_STA_ASSOCIATED;
2176 ifmgd->assoc_scan_tries = 0;
2177 ifmgd->direct_probe_tries = 0;
2178 ifmgd->auth_tries = 0;
2179 ifmgd->assoc_tries = 0;
2180 netif_tx_stop_all_queues(sdata->dev);
2181 netif_carrier_off(sdata->dev);
2182}
2183
2184static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata)
2185{
2186 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2187 struct ieee80211_local *local = sdata->local;
2188 struct ieee80211_bss *bss;
2189 u8 *bssid = ifmgd->bssid, *ssid = ifmgd->ssid;
2190 u8 ssid_len = ifmgd->ssid_len;
2191 u16 capa_mask = WLAN_CAPABILITY_ESS;
2192 u16 capa_val = WLAN_CAPABILITY_ESS;
2193 struct ieee80211_channel *chan = local->oper_channel;
2194
2195 if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) &&
2196 ifmgd->flags & (IEEE80211_STA_AUTO_SSID_SEL |
2197 IEEE80211_STA_AUTO_BSSID_SEL |
2198 IEEE80211_STA_AUTO_CHANNEL_SEL)) {
2199 capa_mask |= WLAN_CAPABILITY_PRIVACY;
2200 if (sdata->default_key)
2201 capa_val |= WLAN_CAPABILITY_PRIVACY;
2202 }
2203
2204 if (ifmgd->flags & IEEE80211_STA_AUTO_CHANNEL_SEL)
2205 chan = NULL;
2206
2207 if (ifmgd->flags & IEEE80211_STA_AUTO_BSSID_SEL)
2208 bssid = NULL;
2209
2210 if (ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL) {
2211 ssid = NULL;
2212 ssid_len = 0;
2213 }
2214
2215 bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan,
2216 bssid, ssid, ssid_len,
2217 capa_mask, capa_val);
2218
2219 if (bss) {
2220 local->oper_channel = bss->cbss.channel;
2221 local->oper_channel_type = NL80211_CHAN_NO_HT;
2222 ieee80211_hw_config(local, 0);
2223
2224 if (!(ifmgd->flags & IEEE80211_STA_SSID_SET))
2225 ieee80211_sta_set_ssid(sdata, bss->ssid,
2226 bss->ssid_len);
2227 ieee80211_sta_set_bssid(sdata, bss->cbss.bssid);
2228 ieee80211_sta_def_wmm_params(sdata, bss->supp_rates_len,
2229 bss->supp_rates);
2230 if (sdata->u.mgd.mfp == IEEE80211_MFP_REQUIRED)
2231 sdata->u.mgd.flags |= IEEE80211_STA_MFP_ENABLED;
2232 else
2233 sdata->u.mgd.flags &= ~IEEE80211_STA_MFP_ENABLED;
2234
2235 /* Send out direct probe if no probe resp was received or
2236 * the one we have is outdated
2237 */
2238 if (!bss->last_probe_resp ||
2239 time_after(jiffies, bss->last_probe_resp
2240 + IEEE80211_SCAN_RESULT_EXPIRE))
2241 ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE;
2242 else
2243 ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE;
2244
2245 ieee80211_rx_bss_put(local, bss);
2246 ieee80211_sta_reset_auth(sdata);
2247 return 0;
2248 } else {
2249 if (ifmgd->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) {
2250
2251 ifmgd->assoc_scan_tries++;
2252
2253 ieee80211_request_internal_scan(sdata, ifmgd->ssid,
2254 ssid_len);
2255
2256 ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE;
2257 set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request);
2258 } else {
2259 ifmgd->assoc_scan_tries = 0;
2260 ifmgd->state = IEEE80211_STA_MLME_DISABLED;
2261 ieee80211_recalc_idle(local);
2262 }
2263 }
2264 return -1;
2265}
2266
2267
2268static void ieee80211_sta_work(struct work_struct *work) 2026static void ieee80211_sta_work(struct work_struct *work)
2269{ 2027{
2270 struct ieee80211_sub_if_data *sdata = 2028 struct ieee80211_sub_if_data *sdata =
@@ -2272,6 +2030,10 @@ static void ieee80211_sta_work(struct work_struct *work)
2272 struct ieee80211_local *local = sdata->local; 2030 struct ieee80211_local *local = sdata->local;
2273 struct ieee80211_if_managed *ifmgd; 2031 struct ieee80211_if_managed *ifmgd;
2274 struct sk_buff *skb; 2032 struct sk_buff *skb;
2033 struct ieee80211_mgd_work *wk, *tmp;
2034 LIST_HEAD(free_work);
2035 enum rx_mgmt_action rma;
2036 bool anybusy = false;
2275 2037
2276 if (!netif_running(sdata->dev)) 2038 if (!netif_running(sdata->dev))
2277 return; 2039 return;
@@ -2294,66 +2056,179 @@ static void ieee80211_sta_work(struct work_struct *work)
2294 2056
2295 ifmgd = &sdata->u.mgd; 2057 ifmgd = &sdata->u.mgd;
2296 2058
2059 /* first process frames to avoid timing out while a frame is pending */
2297 while ((skb = skb_dequeue(&ifmgd->skb_queue))) 2060 while ((skb = skb_dequeue(&ifmgd->skb_queue)))
2298 ieee80211_sta_rx_queued_mgmt(sdata, skb); 2061 ieee80211_sta_rx_queued_mgmt(sdata, skb);
2299 2062
2300 if (ifmgd->state != IEEE80211_STA_MLME_DIRECT_PROBE && 2063 /* then process the rest of the work */
2301 ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE && 2064 mutex_lock(&ifmgd->mtx);
2302 ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE && 2065
2303 test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) { 2066 if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
2304 queue_delayed_work(local->hw.workqueue, &local->scan_work, 2067 IEEE80211_STA_CONNECTION_POLL) &&
2305 round_jiffies_relative(0)); 2068 ifmgd->associated) {
2306 return; 2069 if (time_is_after_jiffies(ifmgd->probe_timeout))
2070 run_again(ifmgd, ifmgd->probe_timeout);
2071 else {
2072 u8 bssid[ETH_ALEN];
2073 /*
2074 * We actually lost the connection ... or did we?
2075 * Let's make sure!
2076 */
2077 ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL |
2078 IEEE80211_STA_BEACON_POLL);
2079 memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN);
2080 printk(KERN_DEBUG "No probe response from AP %pM"
2081 " after %dms, disconnecting.\n",
2082 bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ);
2083 ieee80211_set_disassoc(sdata);
2084 mutex_unlock(&ifmgd->mtx);
2085 /*
2086 * must be outside lock due to cfg80211,
2087 * but that's not a problem.
2088 */
2089 ieee80211_send_deauth_disassoc(sdata, bssid,
2090 IEEE80211_STYPE_DEAUTH,
2091 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
2092 NULL);
2093 mutex_lock(&ifmgd->mtx);
2094 }
2307 } 2095 }
2308 2096
2309 if (test_and_clear_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request)) { 2097 list_for_each_entry(wk, &ifmgd->work_list, list) {
2310 if (ieee80211_sta_config_auth(sdata)) 2098 if (wk->state != IEEE80211_MGD_STATE_IDLE) {
2311 return; 2099 anybusy = true;
2312 clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request); 2100 break;
2313 } else if (!test_and_clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request)) 2101 }
2314 return; 2102 }
2315 2103
2316 ieee80211_recalc_idle(local); 2104 ieee80211_recalc_idle(local);
2317 2105
2318 switch (ifmgd->state) { 2106 if (!anybusy) {
2319 case IEEE80211_STA_MLME_DISABLED: 2107 mutex_unlock(&ifmgd->mtx);
2320 break; 2108
2321 case IEEE80211_STA_MLME_DIRECT_PROBE: 2109 if (test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request))
2322 ieee80211_direct_probe(sdata); 2110 queue_delayed_work(local->hw.workqueue,
2323 break; 2111 &local->scan_work,
2324 case IEEE80211_STA_MLME_AUTHENTICATE: 2112 round_jiffies_relative(0));
2325 ieee80211_authenticate(sdata); 2113 return;
2326 break;
2327 case IEEE80211_STA_MLME_ASSOCIATE:
2328 ieee80211_associate(sdata);
2329 break;
2330 case IEEE80211_STA_MLME_ASSOCIATED:
2331 ieee80211_associated(sdata);
2332 break;
2333 default:
2334 WARN_ON(1);
2335 break;
2336 } 2114 }
2337 2115
2338 if (ieee80211_privacy_mismatch(sdata)) { 2116 list_for_each_entry_safe(wk, tmp, &ifmgd->work_list, list) {
2339 printk(KERN_DEBUG "%s: privacy configuration mismatch and " 2117 if (time_is_after_jiffies(wk->timeout)) {
2340 "mixed-cell disabled - disassociate\n", sdata->dev->name); 2118 /*
2119 * This work item isn't supposed to be worked on
2120 * right now, but take care to adjust the timer
2121 * properly.
2122 */
2123 run_again(ifmgd, wk->timeout);
2124 continue;
2125 }
2126
2127 switch (wk->state) {
2128 default:
2129 WARN_ON(1);
2130 /* fall through */
2131 case IEEE80211_MGD_STATE_IDLE:
2132 /* nothing */
2133 rma = RX_MGMT_NONE;
2134 break;
2135 case IEEE80211_MGD_STATE_PROBE:
2136 rma = ieee80211_direct_probe(sdata, wk);
2137 break;
2138 case IEEE80211_MGD_STATE_AUTH:
2139 rma = ieee80211_authenticate(sdata, wk);
2140 break;
2141 case IEEE80211_MGD_STATE_ASSOC:
2142 rma = ieee80211_associate(sdata, wk);
2143 break;
2144 }
2145
2146 switch (rma) {
2147 case RX_MGMT_NONE:
2148 /* no action required */
2149 break;
2150 case RX_MGMT_CFG80211_AUTH_TO:
2151 case RX_MGMT_CFG80211_ASSOC_TO:
2152 list_del(&wk->list);
2153 list_add(&wk->list, &free_work);
2154 wk->tries = rma; /* small abuse but only local */
2155 break;
2156 default:
2157 WARN(1, "unexpected: %d", rma);
2158 }
2159 }
2160
2161 mutex_unlock(&ifmgd->mtx);
2162
2163 list_for_each_entry_safe(wk, tmp, &free_work, list) {
2164 switch (wk->tries) {
2165 case RX_MGMT_CFG80211_AUTH_TO:
2166 cfg80211_send_auth_timeout(sdata->dev,
2167 wk->bss->cbss.bssid);
2168 break;
2169 case RX_MGMT_CFG80211_ASSOC_TO:
2170 cfg80211_send_assoc_timeout(sdata->dev,
2171 wk->bss->cbss.bssid);
2172 break;
2173 default:
2174 WARN(1, "unexpected: %d", wk->tries);
2175 }
2341 2176
2342 ieee80211_set_disassoc(sdata, false, true, 2177 list_del(&wk->list);
2343 WLAN_REASON_UNSPECIFIED); 2178 kfree(wk);
2344 } 2179 }
2180
2181 ieee80211_recalc_idle(local);
2182}
2183
2184static void ieee80211_sta_bcn_mon_timer(unsigned long data)
2185{
2186 struct ieee80211_sub_if_data *sdata =
2187 (struct ieee80211_sub_if_data *) data;
2188 struct ieee80211_local *local = sdata->local;
2189
2190 if (local->quiescing)
2191 return;
2192
2193 queue_work(sdata->local->hw.workqueue,
2194 &sdata->u.mgd.beacon_loss_work);
2195}
2196
2197static void ieee80211_sta_conn_mon_timer(unsigned long data)
2198{
2199 struct ieee80211_sub_if_data *sdata =
2200 (struct ieee80211_sub_if_data *) data;
2201 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2202 struct ieee80211_local *local = sdata->local;
2203
2204 if (local->quiescing)
2205 return;
2206
2207 queue_work(local->hw.workqueue, &ifmgd->monitor_work);
2208}
2209
2210static void ieee80211_sta_monitor_work(struct work_struct *work)
2211{
2212 struct ieee80211_sub_if_data *sdata =
2213 container_of(work, struct ieee80211_sub_if_data,
2214 u.mgd.monitor_work);
2215
2216 if (sdata->local->sw_scanning || sdata->local->hw_scanning)
2217 return;
2218
2219 ieee80211_mgd_probe_ap(sdata, false);
2345} 2220}
2346 2221
2347static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata) 2222static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata)
2348{ 2223{
2349 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 2224 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
2350 /* 2225 sdata->u.mgd.flags &= ~(IEEE80211_STA_BEACON_POLL |
2351 * Need to update last_beacon to avoid beacon loss 2226 IEEE80211_STA_CONNECTION_POLL);
2352 * test to trigger.
2353 */
2354 sdata->u.mgd.last_beacon = jiffies;
2355
2356 2227
2228 /* let's probe the connection once */
2229 queue_work(sdata->local->hw.workqueue,
2230 &sdata->u.mgd.monitor_work);
2231 /* and do all the other regular work too */
2357 queue_work(sdata->local->hw.workqueue, 2232 queue_work(sdata->local->hw.workqueue,
2358 &sdata->u.mgd.work); 2233 &sdata->u.mgd.work);
2359 } 2234 }
@@ -2378,6 +2253,11 @@ void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata)
2378 cancel_work_sync(&ifmgd->chswitch_work); 2253 cancel_work_sync(&ifmgd->chswitch_work);
2379 if (del_timer_sync(&ifmgd->chswitch_timer)) 2254 if (del_timer_sync(&ifmgd->chswitch_timer))
2380 set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running); 2255 set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running);
2256
2257 cancel_work_sync(&ifmgd->monitor_work);
2258 /* these will just be re-established on connection */
2259 del_timer_sync(&ifmgd->conn_mon_timer);
2260 del_timer_sync(&ifmgd->bcn_mon_timer);
2381} 2261}
2382 2262
2383void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) 2263void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata)
@@ -2395,210 +2275,265 @@ void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata)
2395void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) 2275void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
2396{ 2276{
2397 struct ieee80211_if_managed *ifmgd; 2277 struct ieee80211_if_managed *ifmgd;
2398 u32 hw_flags;
2399 2278
2400 ifmgd = &sdata->u.mgd; 2279 ifmgd = &sdata->u.mgd;
2401 INIT_WORK(&ifmgd->work, ieee80211_sta_work); 2280 INIT_WORK(&ifmgd->work, ieee80211_sta_work);
2281 INIT_WORK(&ifmgd->monitor_work, ieee80211_sta_monitor_work);
2402 INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work); 2282 INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work);
2403 INIT_WORK(&ifmgd->beacon_loss_work, ieee80211_beacon_loss_work); 2283 INIT_WORK(&ifmgd->beacon_loss_work, ieee80211_beacon_loss_work);
2404 setup_timer(&ifmgd->timer, ieee80211_sta_timer, 2284 setup_timer(&ifmgd->timer, ieee80211_sta_timer,
2405 (unsigned long) sdata); 2285 (unsigned long) sdata);
2286 setup_timer(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer,
2287 (unsigned long) sdata);
2288 setup_timer(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer,
2289 (unsigned long) sdata);
2406 setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 2290 setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer,
2407 (unsigned long) sdata); 2291 (unsigned long) sdata);
2408 skb_queue_head_init(&ifmgd->skb_queue); 2292 skb_queue_head_init(&ifmgd->skb_queue);
2409 2293
2294 INIT_LIST_HEAD(&ifmgd->work_list);
2295
2410 ifmgd->capab = WLAN_CAPABILITY_ESS; 2296 ifmgd->capab = WLAN_CAPABILITY_ESS;
2411 ifmgd->auth_algs = IEEE80211_AUTH_ALG_OPEN | 2297 ifmgd->flags = 0;
2412 IEEE80211_AUTH_ALG_SHARED_KEY;
2413 ifmgd->flags |= IEEE80211_STA_CREATE_IBSS |
2414 IEEE80211_STA_AUTO_BSSID_SEL |
2415 IEEE80211_STA_AUTO_CHANNEL_SEL;
2416 if (sdata->local->hw.queues >= 4) 2298 if (sdata->local->hw.queues >= 4)
2417 ifmgd->flags |= IEEE80211_STA_WMM_ENABLED; 2299 ifmgd->flags |= IEEE80211_STA_WMM_ENABLED;
2418 2300
2419 hw_flags = sdata->local->hw.flags; 2301 mutex_init(&ifmgd->mtx);
2420
2421 if (hw_flags & IEEE80211_HW_SUPPORTS_PS) {
2422 ifmgd->powersave = CONFIG_MAC80211_DEFAULT_PS_VALUE;
2423 sdata->local->hw.conf.dynamic_ps_timeout = 500;
2424 }
2425} 2302}
2426 2303
2427/* configuration hooks */ 2304/* scan finished notification */
2428void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata) 2305void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
2429{ 2306{
2430 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2307 struct ieee80211_sub_if_data *sdata = local->scan_sdata;
2431 struct ieee80211_local *local = sdata->local;
2432
2433 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
2434 return;
2435
2436 if ((ifmgd->flags & (IEEE80211_STA_BSSID_SET |
2437 IEEE80211_STA_AUTO_BSSID_SEL)) &&
2438 (ifmgd->flags & (IEEE80211_STA_SSID_SET |
2439 IEEE80211_STA_AUTO_SSID_SEL))) {
2440
2441 if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
2442 ieee80211_set_disassoc(sdata, true, true,
2443 WLAN_REASON_DEAUTH_LEAVING);
2444
2445 if (ifmgd->ssid_len == 0) {
2446 /*
2447 * Only allow association to be started if a valid SSID
2448 * is configured.
2449 */
2450 return;
2451 }
2452 2308
2453 if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) || 2309 /* Restart STA timers */
2454 ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE) 2310 rcu_read_lock();
2455 set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request); 2311 list_for_each_entry_rcu(sdata, &local->interfaces, list)
2456 else if (ifmgd->flags & IEEE80211_STA_EXT_SME) 2312 ieee80211_restart_sta_timer(sdata);
2457 set_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request); 2313 rcu_read_unlock();
2458 queue_work(local->hw.workqueue, &ifmgd->work);
2459 }
2460} 2314}
2461 2315
2462int ieee80211_sta_commit(struct ieee80211_sub_if_data *sdata) 2316int ieee80211_max_network_latency(struct notifier_block *nb,
2317 unsigned long data, void *dummy)
2463{ 2318{
2464 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2319 s32 latency_usec = (s32) data;
2320 struct ieee80211_local *local =
2321 container_of(nb, struct ieee80211_local,
2322 network_latency_notifier);
2465 2323
2466 if (ifmgd->ssid_len) 2324 mutex_lock(&local->iflist_mtx);
2467 ifmgd->flags |= IEEE80211_STA_SSID_SET; 2325 ieee80211_recalc_ps(local, latency_usec);
2468 else 2326 mutex_unlock(&local->iflist_mtx);
2469 ifmgd->flags &= ~IEEE80211_STA_SSID_SET;
2470 2327
2471 return 0; 2328 return 0;
2472} 2329}
2473 2330
2474int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len) 2331/* config hooks */
2332int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
2333 struct cfg80211_auth_request *req)
2475{ 2334{
2476 struct ieee80211_if_managed *ifmgd; 2335 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2336 const u8 *ssid;
2337 struct ieee80211_mgd_work *wk;
2338 u16 auth_alg;
2477 2339
2478 if (len > IEEE80211_MAX_SSID_LEN) 2340 switch (req->auth_type) {
2479 return -EINVAL; 2341 case NL80211_AUTHTYPE_OPEN_SYSTEM:
2342 auth_alg = WLAN_AUTH_OPEN;
2343 break;
2344 case NL80211_AUTHTYPE_SHARED_KEY:
2345 auth_alg = WLAN_AUTH_SHARED_KEY;
2346 break;
2347 case NL80211_AUTHTYPE_FT:
2348 auth_alg = WLAN_AUTH_FT;
2349 break;
2350 case NL80211_AUTHTYPE_NETWORK_EAP:
2351 auth_alg = WLAN_AUTH_LEAP;
2352 break;
2353 default:
2354 return -EOPNOTSUPP;
2355 }
2480 2356
2481 ifmgd = &sdata->u.mgd; 2357 wk = kzalloc(sizeof(*wk) + req->ie_len, GFP_KERNEL);
2358 if (!wk)
2359 return -ENOMEM;
2482 2360
2483 if (ifmgd->ssid_len != len || memcmp(ifmgd->ssid, ssid, len) != 0) { 2361 wk->bss = (void *)req->bss;
2484 if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
2485 ieee80211_set_disassoc(sdata, true, true,
2486 WLAN_REASON_DEAUTH_LEAVING);
2487 2362
2488 /* 2363 if (req->ie && req->ie_len) {
2489 * Do not use reassociation if SSID is changed (different ESS). 2364 memcpy(wk->ie, req->ie, req->ie_len);
2490 */ 2365 wk->ie_len = req->ie_len;
2491 ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET;
2492 memset(ifmgd->ssid, 0, sizeof(ifmgd->ssid));
2493 memcpy(ifmgd->ssid, ssid, len);
2494 ifmgd->ssid_len = len;
2495 } 2366 }
2496 2367
2497 return ieee80211_sta_commit(sdata); 2368 if (req->key && req->key_len) {
2498} 2369 wk->key_len = req->key_len;
2370 wk->key_idx = req->key_idx;
2371 memcpy(wk->key, req->key, req->key_len);
2372 }
2499 2373
2500int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len) 2374 ssid = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID);
2501{ 2375 memcpy(wk->ssid, ssid + 2, ssid[1]);
2502 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2376 wk->ssid_len = ssid[1];
2503 memcpy(ssid, ifmgd->ssid, ifmgd->ssid_len); 2377
2504 *len = ifmgd->ssid_len; 2378 wk->state = IEEE80211_MGD_STATE_PROBE;
2379 wk->auth_alg = auth_alg;
2380
2381 /*
2382 * XXX: if still associated need to tell AP that we're going
2383 * to sleep and then change channel etc.
2384 */
2385 sdata->local->oper_channel = req->bss->channel;
2386 ieee80211_hw_config(sdata->local, 0);
2387
2388 mutex_lock(&ifmgd->mtx);
2389 list_add(&wk->list, &sdata->u.mgd.work_list);
2390 mutex_unlock(&ifmgd->mtx);
2391
2392 queue_work(sdata->local->hw.workqueue, &sdata->u.mgd.work);
2505 return 0; 2393 return 0;
2506} 2394}
2507 2395
2508int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid) 2396int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
2397 struct cfg80211_assoc_request *req)
2509{ 2398{
2510 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2399 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2400 struct ieee80211_mgd_work *wk, *found = NULL;
2401 int i, err;
2511 2402
2512 if (compare_ether_addr(bssid, ifmgd->bssid) != 0 && 2403 mutex_lock(&ifmgd->mtx);
2513 ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
2514 ieee80211_set_disassoc(sdata, true, true,
2515 WLAN_REASON_DEAUTH_LEAVING);
2516 2404
2517 if (is_valid_ether_addr(bssid)) { 2405 list_for_each_entry(wk, &ifmgd->work_list, list) {
2518 memcpy(ifmgd->bssid, bssid, ETH_ALEN); 2406 if (&wk->bss->cbss == req->bss &&
2519 ifmgd->flags |= IEEE80211_STA_BSSID_SET; 2407 wk->state == IEEE80211_MGD_STATE_IDLE) {
2520 } else { 2408 found = wk;
2521 memset(ifmgd->bssid, 0, ETH_ALEN); 2409 break;
2522 ifmgd->flags &= ~IEEE80211_STA_BSSID_SET; 2410 }
2523 } 2411 }
2524 2412
2525 return ieee80211_sta_commit(sdata); 2413 if (!found) {
2526} 2414 err = -ENOLINK;
2415 goto out;
2416 }
2527 2417
2528int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, 2418 list_del(&found->list);
2529 const char *ie, size_t len) 2419
2530{ 2420 wk = krealloc(found, sizeof(*wk) + req->ie_len, GFP_KERNEL);
2531 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2421 if (!wk) {
2422 list_add(&found->list, &ifmgd->work_list);
2423 err = -ENOMEM;
2424 goto out;
2425 }
2532 2426
2533 if (len == 0 && ifmgd->extra_ie_len == 0) 2427 list_add(&wk->list, &ifmgd->work_list);
2534 return -EALREADY;
2535 2428
2536 if (len == ifmgd->extra_ie_len && ifmgd->extra_ie && 2429 ifmgd->flags &= ~IEEE80211_STA_DISABLE_11N;
2537 memcmp(ifmgd->extra_ie, ie, len) == 0)
2538 return -EALREADY;
2539 2430
2540 kfree(ifmgd->extra_ie); 2431 for (i = 0; i < req->crypto.n_ciphers_pairwise; i++)
2541 if (len == 0) { 2432 if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 ||
2542 ifmgd->extra_ie = NULL; 2433 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP ||
2543 ifmgd->extra_ie_len = 0; 2434 req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104)
2544 return 0; 2435 ifmgd->flags |= IEEE80211_STA_DISABLE_11N;
2545 } 2436
2546 ifmgd->extra_ie = kmalloc(len, GFP_KERNEL); 2437 sdata->local->oper_channel = req->bss->channel;
2547 if (!ifmgd->extra_ie) { 2438 ieee80211_hw_config(sdata->local, 0);
2548 ifmgd->extra_ie_len = 0; 2439
2549 return -ENOMEM; 2440 if (req->ie && req->ie_len) {
2441 memcpy(wk->ie, req->ie, req->ie_len);
2442 wk->ie_len = req->ie_len;
2443 } else
2444 wk->ie_len = 0;
2445
2446 if (req->prev_bssid)
2447 memcpy(wk->prev_bssid, req->prev_bssid, ETH_ALEN);
2448
2449 wk->state = IEEE80211_MGD_STATE_ASSOC;
2450 wk->tries = 0;
2451
2452 if (req->use_mfp) {
2453 ifmgd->mfp = IEEE80211_MFP_REQUIRED;
2454 ifmgd->flags |= IEEE80211_STA_MFP_ENABLED;
2455 } else {
2456 ifmgd->mfp = IEEE80211_MFP_DISABLED;
2457 ifmgd->flags &= ~IEEE80211_STA_MFP_ENABLED;
2550 } 2458 }
2551 memcpy(ifmgd->extra_ie, ie, len);
2552 ifmgd->extra_ie_len = len;
2553 return 0;
2554}
2555 2459
2556int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason) 2460 if (req->crypto.control_port)
2557{ 2461 ifmgd->flags |= IEEE80211_STA_CONTROL_PORT;
2558 printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n", 2462 else
2559 sdata->dev->name, reason); 2463 ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT;
2560 2464
2561 ieee80211_set_disassoc(sdata, true, true, reason); 2465 queue_work(sdata->local->hw.workqueue, &sdata->u.mgd.work);
2562 return 0; 2466
2467 err = 0;
2468
2469 out:
2470 mutex_unlock(&ifmgd->mtx);
2471 return err;
2563} 2472}
2564 2473
2565int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason) 2474int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
2475 struct cfg80211_deauth_request *req,
2476 void *cookie)
2566{ 2477{
2567 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2478 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2479 struct ieee80211_mgd_work *wk;
2480 const u8 *bssid = NULL;
2568 2481
2569 printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n", 2482 printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n",
2570 sdata->dev->name, reason); 2483 sdata->dev->name, req->reason_code);
2484
2485 mutex_lock(&ifmgd->mtx);
2486
2487 if (ifmgd->associated && &ifmgd->associated->cbss == req->bss) {
2488 bssid = req->bss->bssid;
2489 ieee80211_set_disassoc(sdata);
2490 } else list_for_each_entry(wk, &ifmgd->work_list, list) {
2491 if (&wk->bss->cbss == req->bss) {
2492 bssid = req->bss->bssid;
2493 list_del(&wk->list);
2494 kfree(wk);
2495 break;
2496 }
2497 }
2571 2498
2572 if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED)) 2499 /* cfg80211 should catch this... */
2500 if (WARN_ON(!bssid)) {
2501 mutex_unlock(&ifmgd->mtx);
2573 return -ENOLINK; 2502 return -ENOLINK;
2503 }
2504
2505 mutex_unlock(&ifmgd->mtx);
2506
2507 ieee80211_send_deauth_disassoc(sdata, bssid,
2508 IEEE80211_STYPE_DEAUTH, req->reason_code,
2509 cookie);
2574 2510
2575 ieee80211_set_disassoc(sdata, false, true, reason);
2576 return 0; 2511 return 0;
2577} 2512}
2578 2513
2579/* scan finished notification */ 2514int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
2580void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) 2515 struct cfg80211_disassoc_request *req,
2516 void *cookie)
2581{ 2517{
2582 struct ieee80211_sub_if_data *sdata = local->scan_sdata; 2518 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2583 2519
2584 /* Restart STA timers */ 2520 printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n",
2585 rcu_read_lock(); 2521 sdata->dev->name, req->reason_code);
2586 list_for_each_entry_rcu(sdata, &local->interfaces, list)
2587 ieee80211_restart_sta_timer(sdata);
2588 rcu_read_unlock();
2589}
2590 2522
2591int ieee80211_max_network_latency(struct notifier_block *nb, 2523 mutex_lock(&ifmgd->mtx);
2592 unsigned long data, void *dummy)
2593{
2594 s32 latency_usec = (s32) data;
2595 struct ieee80211_local *local =
2596 container_of(nb, struct ieee80211_local,
2597 network_latency_notifier);
2598 2524
2599 mutex_lock(&local->iflist_mtx); 2525 /* cfg80211 should catch that */
2600 ieee80211_recalc_ps(local, latency_usec); 2526 if (WARN_ON(&ifmgd->associated->cbss != req->bss)) {
2601 mutex_unlock(&local->iflist_mtx); 2527 mutex_unlock(&ifmgd->mtx);
2528 return -ENOLINK;
2529 }
2530
2531 ieee80211_set_disassoc(sdata);
2532
2533 mutex_unlock(&ifmgd->mtx);
2602 2534
2535 ieee80211_send_deauth_disassoc(sdata, req->bss->bssid,
2536 IEEE80211_STYPE_DISASSOC, req->reason_code,
2537 cookie);
2603 return 0; 2538 return 0;
2604} 2539}
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 4641f00a1e5c..b33efc4fc267 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -198,6 +198,35 @@ static void rate_control_release(struct kref *kref)
198 kfree(ctrl_ref); 198 kfree(ctrl_ref);
199} 199}
200 200
201static bool rc_no_data_or_no_ack(struct ieee80211_tx_rate_control *txrc)
202{
203 struct sk_buff *skb = txrc->skb;
204 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
205 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
206 __le16 fc;
207
208 fc = hdr->frame_control;
209
210 return ((info->flags & IEEE80211_TX_CTL_NO_ACK) || !ieee80211_is_data(fc));
211}
212
213bool rate_control_send_low(struct ieee80211_sta *sta,
214 void *priv_sta,
215 struct ieee80211_tx_rate_control *txrc)
216{
217 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
218
219 if (!sta || !priv_sta || rc_no_data_or_no_ack(txrc)) {
220 info->control.rates[0].idx = rate_lowest_index(txrc->sband, sta);
221 info->control.rates[0].count =
222 (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
223 1 : txrc->hw->max_rate_tries;
224 return true;
225 }
226 return false;
227}
228EXPORT_SYMBOL(rate_control_send_low);
229
201void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, 230void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
202 struct sta_info *sta, 231 struct sta_info *sta,
203 struct ieee80211_tx_rate_control *txrc) 232 struct ieee80211_tx_rate_control *txrc)
@@ -258,7 +287,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
258 struct rate_control_ref *ref, *old; 287 struct rate_control_ref *ref, *old;
259 288
260 ASSERT_RTNL(); 289 ASSERT_RTNL();
261 if (local->open_count || netif_running(local->mdev)) 290 if (local->open_count)
262 return -EBUSY; 291 return -EBUSY;
263 292
264 ref = rate_control_alloc(name, local); 293 ref = rate_control_alloc(name, local);
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 37771abd8f5a..7c5142988bbb 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -70,20 +70,6 @@ rix_to_ndx(struct minstrel_sta_info *mi, int rix)
70 return i; 70 return i;
71} 71}
72 72
73static inline bool
74use_low_rate(struct sk_buff *skb)
75{
76 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
77 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
78 u16 fc;
79
80 fc = le16_to_cpu(hdr->frame_control);
81
82 return ((info->flags & IEEE80211_TX_CTL_NO_ACK) ||
83 (fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA);
84}
85
86
87static void 73static void
88minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) 74minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
89{ 75{
@@ -232,7 +218,6 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
232 void *priv_sta, struct ieee80211_tx_rate_control *txrc) 218 void *priv_sta, struct ieee80211_tx_rate_control *txrc)
233{ 219{
234 struct sk_buff *skb = txrc->skb; 220 struct sk_buff *skb = txrc->skb;
235 struct ieee80211_supported_band *sband = txrc->sband;
236 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 221 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
237 struct minstrel_sta_info *mi = priv_sta; 222 struct minstrel_sta_info *mi = priv_sta;
238 struct minstrel_priv *mp = priv; 223 struct minstrel_priv *mp = priv;
@@ -245,14 +230,8 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
245 int mrr_ndx[3]; 230 int mrr_ndx[3];
246 int sample_rate; 231 int sample_rate;
247 232
248 if (!sta || !mi || use_low_rate(skb)) { 233 if (rate_control_send_low(sta, priv_sta, txrc))
249 ar[0].idx = rate_lowest_index(sband, sta);
250 if (info->flags & IEEE80211_TX_CTL_NO_ACK)
251 ar[0].count = 1;
252 else
253 ar[0].count = mp->max_retry;
254 return; 234 return;
255 }
256 235
257 mrr = mp->has_mrr && !txrc->rts && !txrc->bss_conf->use_cts_prot; 236 mrr = mp->has_mrr && !txrc->rts && !txrc->bss_conf->use_cts_prot;
258 237
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c
index a0bef767ceb5..8c053be9dc24 100644
--- a/net/mac80211/rc80211_pid_algo.c
+++ b/net/mac80211/rc80211_pid_algo.c
@@ -276,11 +276,9 @@ rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta,
276{ 276{
277 struct sk_buff *skb = txrc->skb; 277 struct sk_buff *skb = txrc->skb;
278 struct ieee80211_supported_band *sband = txrc->sband; 278 struct ieee80211_supported_band *sband = txrc->sband;
279 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
280 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 279 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
281 struct rc_pid_sta_info *spinfo = priv_sta; 280 struct rc_pid_sta_info *spinfo = priv_sta;
282 int rateidx; 281 int rateidx;
283 u16 fc;
284 282
285 if (txrc->rts) 283 if (txrc->rts)
286 info->control.rates[0].count = 284 info->control.rates[0].count =
@@ -290,16 +288,8 @@ rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta,
290 txrc->hw->conf.short_frame_max_tx_count; 288 txrc->hw->conf.short_frame_max_tx_count;
291 289
292 /* Send management frames and NO_ACK data using lowest rate. */ 290 /* Send management frames and NO_ACK data using lowest rate. */
293 fc = le16_to_cpu(hdr->frame_control); 291 if (rate_control_send_low(sta, priv_sta, txrc))
294 if (!sta || !spinfo ||
295 (fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
296 info->flags & IEEE80211_TX_CTL_NO_ACK) {
297 info->control.rates[0].idx = rate_lowest_index(sband, sta);
298 if (info->flags & IEEE80211_TX_CTL_NO_ACK)
299 info->control.rates[0].count = 1;
300
301 return; 292 return;
302 }
303 293
304 rateidx = spinfo->txrate_idx; 294 rateidx = spinfo->txrate_idx;
305 295
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 0936fc24942d..b6ddde3848fb 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -30,7 +30,6 @@
30static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, 30static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
31 struct tid_ampdu_rx *tid_agg_rx, 31 struct tid_ampdu_rx *tid_agg_rx,
32 struct sk_buff *skb, 32 struct sk_buff *skb,
33 struct ieee80211_rx_status *status,
34 u16 mpdu_seq_num, 33 u16 mpdu_seq_num,
35 int bar_req); 34 int bar_req);
36/* 35/*
@@ -59,11 +58,11 @@ static struct sk_buff *remove_monitor_info(struct ieee80211_local *local,
59 return skb; 58 return skb;
60} 59}
61 60
62static inline int should_drop_frame(struct ieee80211_rx_status *status, 61static inline int should_drop_frame(struct sk_buff *skb,
63 struct sk_buff *skb,
64 int present_fcs_len, 62 int present_fcs_len,
65 int radiotap_len) 63 int radiotap_len)
66{ 64{
65 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
67 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 66 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
68 67
69 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) 68 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
@@ -111,10 +110,10 @@ ieee80211_rx_radiotap_len(struct ieee80211_local *local,
111static void 110static void
112ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, 111ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
113 struct sk_buff *skb, 112 struct sk_buff *skb,
114 struct ieee80211_rx_status *status,
115 struct ieee80211_rate *rate, 113 struct ieee80211_rate *rate,
116 int rtap_len) 114 int rtap_len)
117{ 115{
116 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
118 struct ieee80211_radiotap_header *rthdr; 117 struct ieee80211_radiotap_header *rthdr;
119 unsigned char *pos; 118 unsigned char *pos;
120 119
@@ -220,9 +219,9 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
220 */ 219 */
221static struct sk_buff * 220static struct sk_buff *
222ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, 221ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
223 struct ieee80211_rx_status *status,
224 struct ieee80211_rate *rate) 222 struct ieee80211_rate *rate)
225{ 223{
224 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(origskb);
226 struct ieee80211_sub_if_data *sdata; 225 struct ieee80211_sub_if_data *sdata;
227 int needed_headroom = 0; 226 int needed_headroom = 0;
228 struct sk_buff *skb, *skb2; 227 struct sk_buff *skb, *skb2;
@@ -248,8 +247,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
248 present_fcs_len = FCS_LEN; 247 present_fcs_len = FCS_LEN;
249 248
250 if (!local->monitors) { 249 if (!local->monitors) {
251 if (should_drop_frame(status, origskb, present_fcs_len, 250 if (should_drop_frame(origskb, present_fcs_len, rtap_len)) {
252 rtap_len)) {
253 dev_kfree_skb(origskb); 251 dev_kfree_skb(origskb);
254 return NULL; 252 return NULL;
255 } 253 }
@@ -257,7 +255,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
257 return remove_monitor_info(local, origskb, rtap_len); 255 return remove_monitor_info(local, origskb, rtap_len);
258 } 256 }
259 257
260 if (should_drop_frame(status, origskb, present_fcs_len, rtap_len)) { 258 if (should_drop_frame(origskb, present_fcs_len, rtap_len)) {
261 /* only need to expand headroom if necessary */ 259 /* only need to expand headroom if necessary */
262 skb = origskb; 260 skb = origskb;
263 origskb = NULL; 261 origskb = NULL;
@@ -289,7 +287,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
289 287
290 /* if necessary, prepend radiotap information */ 288 /* if necessary, prepend radiotap information */
291 if (!(status->flag & RX_FLAG_RADIOTAP)) 289 if (!(status->flag & RX_FLAG_RADIOTAP))
292 ieee80211_add_rx_radiotap_header(local, skb, status, rate, 290 ieee80211_add_rx_radiotap_header(local, skb, rate,
293 needed_headroom); 291 needed_headroom);
294 292
295 skb_reset_mac_header(skb); 293 skb_reset_mac_header(skb);
@@ -421,12 +419,11 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
421 struct sk_buff *skb = rx->skb; 419 struct sk_buff *skb = rx->skb;
422 420
423 if (unlikely(local->hw_scanning)) 421 if (unlikely(local->hw_scanning))
424 return ieee80211_scan_rx(rx->sdata, skb, rx->status); 422 return ieee80211_scan_rx(rx->sdata, skb);
425 423
426 if (unlikely(local->sw_scanning)) { 424 if (unlikely(local->sw_scanning)) {
427 /* drop all the other packets during a software scan anyway */ 425 /* drop all the other packets during a software scan anyway */
428 if (ieee80211_scan_rx(rx->sdata, skb, rx->status) 426 if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED)
429 != RX_QUEUED)
430 dev_kfree_skb(skb); 427 dev_kfree_skb(skb);
431 return RX_QUEUED; 428 return RX_QUEUED;
432 } 429 }
@@ -836,28 +833,22 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
836 if (!sta) 833 if (!sta)
837 return RX_CONTINUE; 834 return RX_CONTINUE;
838 835
839 /* Update last_rx only for IBSS packets which are for the current 836 /*
840 * BSSID to avoid keeping the current IBSS network alive in cases where 837 * Update last_rx only for IBSS packets which are for the current
841 * other STAs are using different BSSID. */ 838 * BSSID to avoid keeping the current IBSS network alive in cases
839 * where other STAs start using different BSSID.
840 */
842 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { 841 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) {
843 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, 842 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len,
844 NL80211_IFTYPE_ADHOC); 843 NL80211_IFTYPE_ADHOC);
845 if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) 844 if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0)
846 sta->last_rx = jiffies; 845 sta->last_rx = jiffies;
847 } else 846 } else if (!is_multicast_ether_addr(hdr->addr1)) {
848 if (!is_multicast_ether_addr(hdr->addr1) || 847 /*
849 rx->sdata->vif.type == NL80211_IFTYPE_STATION) {
850 /* Update last_rx only for unicast frames in order to prevent
851 * the Probe Request frames (the only broadcast frames from a
852 * STA in infrastructure mode) from keeping a connection alive.
853 * Mesh beacons will update last_rx when if they are found to 848 * Mesh beacons will update last_rx when if they are found to
854 * match the current local configuration when processed. 849 * match the current local configuration when processed.
855 */ 850 */
856 if (rx->sdata->vif.type == NL80211_IFTYPE_STATION && 851 sta->last_rx = jiffies;
857 ieee80211_is_beacon(hdr->frame_control)) {
858 rx->sdata->u.mgd.last_beacon = jiffies;
859 } else
860 sta->last_rx = jiffies;
861 } 852 }
862 853
863 if (!(rx->flags & IEEE80211_RX_RA_MATCH)) 854 if (!(rx->flags & IEEE80211_RX_RA_MATCH))
@@ -1487,10 +1478,13 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1487 struct ieee80211s_hdr *mesh_hdr; 1478 struct ieee80211s_hdr *mesh_hdr;
1488 unsigned int hdrlen; 1479 unsigned int hdrlen;
1489 struct sk_buff *skb = rx->skb, *fwd_skb; 1480 struct sk_buff *skb = rx->skb, *fwd_skb;
1481 struct ieee80211_local *local = rx->local;
1482 struct ieee80211_sub_if_data *sdata;
1490 1483
1491 hdr = (struct ieee80211_hdr *) skb->data; 1484 hdr = (struct ieee80211_hdr *) skb->data;
1492 hdrlen = ieee80211_hdrlen(hdr->frame_control); 1485 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1493 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); 1486 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
1487 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1494 1488
1495 if (!ieee80211_is_data(hdr->frame_control)) 1489 if (!ieee80211_is_data(hdr->frame_control))
1496 return RX_CONTINUE; 1490 return RX_CONTINUE;
@@ -1500,10 +1494,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1500 return RX_DROP_MONITOR; 1494 return RX_DROP_MONITOR;
1501 1495
1502 if (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6){ 1496 if (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6){
1503 struct ieee80211_sub_if_data *sdata;
1504 struct mesh_path *mppath; 1497 struct mesh_path *mppath;
1505 1498
1506 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1507 rcu_read_lock(); 1499 rcu_read_lock();
1508 mppath = mpp_path_lookup(mesh_hdr->eaddr2, sdata); 1500 mppath = mpp_path_lookup(mesh_hdr->eaddr2, sdata);
1509 if (!mppath) { 1501 if (!mppath) {
@@ -1529,6 +1521,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1529 dropped_frames_ttl); 1521 dropped_frames_ttl);
1530 else { 1522 else {
1531 struct ieee80211_hdr *fwd_hdr; 1523 struct ieee80211_hdr *fwd_hdr;
1524 struct ieee80211_tx_info *info;
1525
1532 fwd_skb = skb_copy(skb, GFP_ATOMIC); 1526 fwd_skb = skb_copy(skb, GFP_ATOMIC);
1533 1527
1534 if (!fwd_skb && net_ratelimit()) 1528 if (!fwd_skb && net_ratelimit())
@@ -1542,9 +1536,25 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1542 */ 1536 */
1543 memcpy(fwd_hdr->addr1, fwd_hdr->addr2, ETH_ALEN); 1537 memcpy(fwd_hdr->addr1, fwd_hdr->addr2, ETH_ALEN);
1544 memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN); 1538 memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN);
1545 fwd_skb->dev = rx->local->mdev; 1539 info = IEEE80211_SKB_CB(fwd_skb);
1540 memset(info, 0, sizeof(*info));
1541 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
1546 fwd_skb->iif = rx->dev->ifindex; 1542 fwd_skb->iif = rx->dev->ifindex;
1547 dev_queue_xmit(fwd_skb); 1543 ieee80211_select_queue(local, fwd_skb);
1544 if (is_multicast_ether_addr(fwd_hdr->addr3))
1545 memcpy(fwd_hdr->addr1, fwd_hdr->addr3,
1546 ETH_ALEN);
1547 else {
1548 int err = mesh_nexthop_lookup(fwd_skb, sdata);
1549 /* Failed to immediately resolve next hop:
1550 * fwded frame was dropped or will be added
1551 * later to the pending skb queue. */
1552 if (err)
1553 return RX_DROP_MONITOR;
1554 }
1555 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
1556 fwded_frames);
1557 ieee80211_add_pending_skb(local, fwd_skb);
1548 } 1558 }
1549 } 1559 }
1550 1560
@@ -1620,7 +1630,7 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx)
1620 /* manage reordering buffer according to requested */ 1630 /* manage reordering buffer according to requested */
1621 /* sequence number */ 1631 /* sequence number */
1622 rcu_read_lock(); 1632 rcu_read_lock();
1623 ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, NULL, 1633 ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL,
1624 start_seq_num, 1); 1634 start_seq_num, 1);
1625 rcu_read_unlock(); 1635 rcu_read_unlock();
1626 return RX_DROP_UNUSABLE; 1636 return RX_DROP_UNUSABLE;
@@ -1644,12 +1654,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
1644 1654
1645 if (compare_ether_addr(mgmt->sa, sdata->u.mgd.bssid) != 0 || 1655 if (compare_ether_addr(mgmt->sa, sdata->u.mgd.bssid) != 0 ||
1646 compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid) != 0) { 1656 compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid) != 0) {
1647 /* Not from the current AP. */ 1657 /* Not from the current AP or not associated yet. */
1648 return;
1649 }
1650
1651 if (sdata->u.mgd.state == IEEE80211_STA_MLME_ASSOCIATE) {
1652 /* Association in progress; ignore SA Query */
1653 return; 1658 return;
1654 } 1659 }
1655 1660
@@ -1686,7 +1691,6 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
1686 struct ieee80211_local *local = rx->local; 1691 struct ieee80211_local *local = rx->local;
1687 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); 1692 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1688 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; 1693 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data;
1689 struct ieee80211_bss *bss;
1690 int len = rx->skb->len; 1694 int len = rx->skb->len;
1691 1695
1692 if (!ieee80211_is_action(mgmt->frame_control)) 1696 if (!ieee80211_is_action(mgmt->frame_control))
@@ -1764,17 +1768,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
1764 if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN)) 1768 if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN))
1765 return RX_DROP_MONITOR; 1769 return RX_DROP_MONITOR;
1766 1770
1767 bss = ieee80211_rx_bss_get(local, sdata->u.mgd.bssid, 1771 return ieee80211_sta_rx_mgmt(sdata, rx->skb);
1768 local->hw.conf.channel->center_freq,
1769 sdata->u.mgd.ssid,
1770 sdata->u.mgd.ssid_len);
1771 if (!bss)
1772 return RX_DROP_MONITOR;
1773
1774 ieee80211_sta_process_chanswitch(sdata,
1775 &mgmt->u.action.u.chan_switch.sw_elem, bss);
1776 ieee80211_rx_bss_put(local, bss);
1777 break;
1778 } 1772 }
1779 break; 1773 break;
1780 case WLAN_CATEGORY_SA_QUERY: 1774 case WLAN_CATEGORY_SA_QUERY:
@@ -1817,19 +1811,18 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
1817 return RX_DROP_MONITOR; 1811 return RX_DROP_MONITOR;
1818 1812
1819 if (ieee80211_vif_is_mesh(&sdata->vif)) 1813 if (ieee80211_vif_is_mesh(&sdata->vif))
1820 return ieee80211_mesh_rx_mgmt(sdata, rx->skb, rx->status); 1814 return ieee80211_mesh_rx_mgmt(sdata, rx->skb);
1821 1815
1822 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 1816 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1823 return ieee80211_ibss_rx_mgmt(sdata, rx->skb, rx->status); 1817 return ieee80211_ibss_rx_mgmt(sdata, rx->skb);
1824 1818
1825 if (sdata->vif.type == NL80211_IFTYPE_STATION) 1819 if (sdata->vif.type == NL80211_IFTYPE_STATION)
1826 return ieee80211_sta_rx_mgmt(sdata, rx->skb, rx->status); 1820 return ieee80211_sta_rx_mgmt(sdata, rx->skb);
1827 1821
1828 return RX_DROP_MONITOR; 1822 return RX_DROP_MONITOR;
1829} 1823}
1830 1824
1831static void ieee80211_rx_michael_mic_report(struct net_device *dev, 1825static void ieee80211_rx_michael_mic_report(struct ieee80211_hdr *hdr,
1832 struct ieee80211_hdr *hdr,
1833 struct ieee80211_rx_data *rx) 1826 struct ieee80211_rx_data *rx)
1834{ 1827{
1835 int keyidx; 1828 int keyidx;
@@ -1866,7 +1859,8 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev,
1866 !ieee80211_is_auth(hdr->frame_control)) 1859 !ieee80211_is_auth(hdr->frame_control))
1867 goto ignore; 1860 goto ignore;
1868 1861
1869 mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL); 1862 mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL,
1863 GFP_ATOMIC);
1870 ignore: 1864 ignore:
1871 dev_kfree_skb(rx->skb); 1865 dev_kfree_skb(rx->skb);
1872 rx->skb = NULL; 1866 rx->skb = NULL;
@@ -2028,13 +2022,8 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2028 case NL80211_IFTYPE_STATION: 2022 case NL80211_IFTYPE_STATION:
2029 if (!bssid) 2023 if (!bssid)
2030 return 0; 2024 return 0;
2031 if (!ieee80211_bssid_match(bssid, sdata->u.mgd.bssid)) { 2025 if (!multicast &&
2032 if (!(rx->flags & IEEE80211_RX_IN_SCAN)) 2026 compare_ether_addr(sdata->dev->dev_addr, hdr->addr1) != 0) {
2033 return 0;
2034 rx->flags &= ~IEEE80211_RX_RA_MATCH;
2035 } else if (!multicast &&
2036 compare_ether_addr(sdata->dev->dev_addr,
2037 hdr->addr1) != 0) {
2038 if (!(sdata->dev->flags & IFF_PROMISC)) 2027 if (!(sdata->dev->flags & IFF_PROMISC))
2039 return 0; 2028 return 0;
2040 rx->flags &= ~IEEE80211_RX_RA_MATCH; 2029 rx->flags &= ~IEEE80211_RX_RA_MATCH;
@@ -2114,9 +2103,9 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2114 */ 2103 */
2115static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, 2104static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2116 struct sk_buff *skb, 2105 struct sk_buff *skb,
2117 struct ieee80211_rx_status *status,
2118 struct ieee80211_rate *rate) 2106 struct ieee80211_rate *rate)
2119{ 2107{
2108 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2120 struct ieee80211_local *local = hw_to_local(hw); 2109 struct ieee80211_local *local = hw_to_local(hw);
2121 struct ieee80211_sub_if_data *sdata; 2110 struct ieee80211_sub_if_data *sdata;
2122 struct ieee80211_hdr *hdr; 2111 struct ieee80211_hdr *hdr;
@@ -2143,7 +2132,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2143 } 2132 }
2144 2133
2145 if ((status->flag & RX_FLAG_MMIC_ERROR)) { 2134 if ((status->flag & RX_FLAG_MMIC_ERROR)) {
2146 ieee80211_rx_michael_mic_report(local->mdev, hdr, &rx); 2135 ieee80211_rx_michael_mic_report(hdr, &rx);
2147 return; 2136 return;
2148 } 2137 }
2149 2138
@@ -2227,20 +2216,21 @@ static void ieee80211_release_reorder_frame(struct ieee80211_hw *hw,
2227{ 2216{
2228 struct ieee80211_supported_band *sband; 2217 struct ieee80211_supported_band *sband;
2229 struct ieee80211_rate *rate; 2218 struct ieee80211_rate *rate;
2230 struct ieee80211_rx_status status; 2219 struct sk_buff *skb = tid_agg_rx->reorder_buf[index];
2220 struct ieee80211_rx_status *status;
2231 2221
2232 if (!tid_agg_rx->reorder_buf[index]) 2222 if (!skb)
2233 goto no_frame; 2223 goto no_frame;
2234 2224
2225 status = IEEE80211_SKB_RXCB(skb);
2226
2235 /* release the reordered frames to stack */ 2227 /* release the reordered frames to stack */
2236 memcpy(&status, tid_agg_rx->reorder_buf[index]->cb, sizeof(status)); 2228 sband = hw->wiphy->bands[status->band];
2237 sband = hw->wiphy->bands[status.band]; 2229 if (status->flag & RX_FLAG_HT)
2238 if (status.flag & RX_FLAG_HT)
2239 rate = sband->bitrates; /* TODO: HT rates */ 2230 rate = sband->bitrates; /* TODO: HT rates */
2240 else 2231 else
2241 rate = &sband->bitrates[status.rate_idx]; 2232 rate = &sband->bitrates[status->rate_idx];
2242 __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], 2233 __ieee80211_rx_handle_packet(hw, skb, rate);
2243 &status, rate);
2244 tid_agg_rx->stored_mpdu_num--; 2234 tid_agg_rx->stored_mpdu_num--;
2245 tid_agg_rx->reorder_buf[index] = NULL; 2235 tid_agg_rx->reorder_buf[index] = NULL;
2246 2236
@@ -2265,7 +2255,6 @@ no_frame:
2265static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, 2255static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
2266 struct tid_ampdu_rx *tid_agg_rx, 2256 struct tid_ampdu_rx *tid_agg_rx,
2267 struct sk_buff *skb, 2257 struct sk_buff *skb,
2268 struct ieee80211_rx_status *rxstatus,
2269 u16 mpdu_seq_num, 2258 u16 mpdu_seq_num,
2270 int bar_req) 2259 int bar_req)
2271{ 2260{
@@ -2324,8 +2313,6 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
2324 /* put the frame in the reordering buffer */ 2313 /* put the frame in the reordering buffer */
2325 tid_agg_rx->reorder_buf[index] = skb; 2314 tid_agg_rx->reorder_buf[index] = skb;
2326 tid_agg_rx->reorder_time[index] = jiffies; 2315 tid_agg_rx->reorder_time[index] = jiffies;
2327 memcpy(tid_agg_rx->reorder_buf[index]->cb, rxstatus,
2328 sizeof(*rxstatus));
2329 tid_agg_rx->stored_mpdu_num++; 2316 tid_agg_rx->stored_mpdu_num++;
2330 /* release the buffer until next missing frame */ 2317 /* release the buffer until next missing frame */
2331 index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) 2318 index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn)
@@ -2374,8 +2361,7 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
2374} 2361}
2375 2362
2376static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, 2363static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
2377 struct sk_buff *skb, 2364 struct sk_buff *skb)
2378 struct ieee80211_rx_status *status)
2379{ 2365{
2380 struct ieee80211_hw *hw = &local->hw; 2366 struct ieee80211_hw *hw = &local->hw;
2381 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 2367 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -2424,7 +2410,7 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
2424 2410
2425 /* according to mpdu sequence number deal with reordering buffer */ 2411 /* according to mpdu sequence number deal with reordering buffer */
2426 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; 2412 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4;
2427 ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb, status, 2413 ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb,
2428 mpdu_seq_num, 0); 2414 mpdu_seq_num, 0);
2429 end_reorder: 2415 end_reorder:
2430 return ret; 2416 return ret;
@@ -2434,12 +2420,12 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
2434 * This is the receive path handler. It is called by a low level driver when an 2420 * This is the receive path handler. It is called by a low level driver when an
2435 * 802.11 MPDU is received from the hardware. 2421 * 802.11 MPDU is received from the hardware.
2436 */ 2422 */
2437void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, 2423void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
2438 struct ieee80211_rx_status *status)
2439{ 2424{
2440 struct ieee80211_local *local = hw_to_local(hw); 2425 struct ieee80211_local *local = hw_to_local(hw);
2441 struct ieee80211_rate *rate = NULL; 2426 struct ieee80211_rate *rate = NULL;
2442 struct ieee80211_supported_band *sband; 2427 struct ieee80211_supported_band *sband;
2428 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2443 2429
2444 if (status->band < 0 || 2430 if (status->band < 0 ||
2445 status->band >= IEEE80211_NUM_BANDS) { 2431 status->band >= IEEE80211_NUM_BANDS) {
@@ -2494,7 +2480,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2494 * if it was previously present. 2480 * if it was previously present.
2495 * Also, frames with less than 16 bytes are dropped. 2481 * Also, frames with less than 16 bytes are dropped.
2496 */ 2482 */
2497 skb = ieee80211_rx_monitor(local, skb, status, rate); 2483 skb = ieee80211_rx_monitor(local, skb, rate);
2498 if (!skb) { 2484 if (!skb) {
2499 rcu_read_unlock(); 2485 rcu_read_unlock();
2500 return; 2486 return;
@@ -2512,8 +2498,8 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2512 * frames from other than operational channel), but that should not 2498 * frames from other than operational channel), but that should not
2513 * happen in normal networks. 2499 * happen in normal networks.
2514 */ 2500 */
2515 if (!ieee80211_rx_reorder_ampdu(local, skb, status)) 2501 if (!ieee80211_rx_reorder_ampdu(local, skb))
2516 __ieee80211_rx_handle_packet(hw, skb, status, rate); 2502 __ieee80211_rx_handle_packet(hw, skb, rate);
2517 2503
2518 rcu_read_unlock(); 2504 rcu_read_unlock();
2519} 2505}
@@ -2521,16 +2507,12 @@ EXPORT_SYMBOL(__ieee80211_rx);
2521 2507
2522/* This is a version of the rx handler that can be called from hard irq 2508/* This is a version of the rx handler that can be called from hard irq
2523 * context. Post the skb on the queue and schedule the tasklet */ 2509 * context. Post the skb on the queue and schedule the tasklet */
2524void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb, 2510void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
2525 struct ieee80211_rx_status *status)
2526{ 2511{
2527 struct ieee80211_local *local = hw_to_local(hw); 2512 struct ieee80211_local *local = hw_to_local(hw);
2528 2513
2529 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb)); 2514 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb));
2530 2515
2531 skb->dev = local->mdev;
2532 /* copy status into skb->cb for use by tasklet */
2533 memcpy(skb->cb, status, sizeof(*status));
2534 skb->pkt_type = IEEE80211_RX_MSG; 2516 skb->pkt_type = IEEE80211_RX_MSG;
2535 skb_queue_tail(&local->skb_queue, skb); 2517 skb_queue_tail(&local->skb_queue, skb);
2536 tasklet_schedule(&local->tasklet); 2518 tasklet_schedule(&local->tasklet);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 2a8d09ad17ff..74820656dc89 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -26,7 +26,7 @@
26 26
27#define IEEE80211_PROBE_DELAY (HZ / 33) 27#define IEEE80211_PROBE_DELAY (HZ / 33)
28#define IEEE80211_CHANNEL_TIME (HZ / 33) 28#define IEEE80211_CHANNEL_TIME (HZ / 33)
29#define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 5) 29#define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 8)
30 30
31struct ieee80211_bss * 31struct ieee80211_bss *
32ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, 32ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq,
@@ -121,23 +121,10 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
121 return bss; 121 return bss;
122} 122}
123 123
124void ieee80211_rx_bss_remove(struct ieee80211_sub_if_data *sdata, u8 *bssid,
125 int freq, u8 *ssid, u8 ssid_len)
126{
127 struct ieee80211_bss *bss;
128 struct ieee80211_local *local = sdata->local;
129
130 bss = ieee80211_rx_bss_get(local, bssid, freq, ssid, ssid_len);
131 if (bss) {
132 cfg80211_unlink_bss(local->hw.wiphy, (void *)bss);
133 ieee80211_rx_bss_put(local, bss);
134 }
135}
136
137ieee80211_rx_result 124ieee80211_rx_result
138ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 125ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
139 struct ieee80211_rx_status *rx_status)
140{ 126{
127 struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
141 struct ieee80211_mgmt *mgmt; 128 struct ieee80211_mgmt *mgmt;
142 struct ieee80211_bss *bss; 129 struct ieee80211_bss *bss;
143 u8 *elements; 130 u8 *elements;
@@ -307,16 +294,13 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
307 if (was_hw_scan) 294 if (was_hw_scan)
308 goto done; 295 goto done;
309 296
310 netif_tx_lock_bh(local->mdev); 297 spin_lock_bh(&local->filter_lock);
311 netif_addr_lock(local->mdev);
312 local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; 298 local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC;
313 drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC, 299 drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC,
314 &local->filter_flags, 300 &local->filter_flags,
315 local->mdev->mc_count, 301 local->mc_count,
316 local->mdev->mc_list); 302 local->mc_list);
317 303 spin_unlock_bh(&local->filter_lock);
318 netif_addr_unlock(local->mdev);
319 netif_tx_unlock_bh(local->mdev);
320 304
321 drv_sw_scan_complete(local); 305 drv_sw_scan_complete(local);
322 306
@@ -327,7 +311,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
327 311
328 /* Tell AP we're back */ 312 /* Tell AP we're back */
329 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 313 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
330 if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { 314 if (sdata->u.mgd.associated) {
331 ieee80211_scan_ps_disable(sdata); 315 ieee80211_scan_ps_disable(sdata);
332 netif_tx_wake_all_queues(sdata->dev); 316 netif_tx_wake_all_queues(sdata->dev);
333 } 317 }
@@ -383,7 +367,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local)
383 sdata, BSS_CHANGED_BEACON_ENABLED); 367 sdata, BSS_CHANGED_BEACON_ENABLED);
384 368
385 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 369 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
386 if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { 370 if (sdata->u.mgd.associated) {
387 netif_tx_stop_all_queues(sdata->dev); 371 netif_tx_stop_all_queues(sdata->dev);
388 ieee80211_scan_ps_enable(sdata); 372 ieee80211_scan_ps_enable(sdata);
389 } 373 }
@@ -395,13 +379,13 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local)
395 local->scan_state = SCAN_SET_CHANNEL; 379 local->scan_state = SCAN_SET_CHANNEL;
396 local->scan_channel_idx = 0; 380 local->scan_channel_idx = 0;
397 381
398 netif_addr_lock_bh(local->mdev); 382 spin_lock_bh(&local->filter_lock);
399 local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; 383 local->filter_flags |= FIF_BCN_PRBRESP_PROMISC;
400 drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC, 384 drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC,
401 &local->filter_flags, 385 &local->filter_flags,
402 local->mdev->mc_count, 386 local->mc_count,
403 local->mdev->mc_list); 387 local->mc_list);
404 netif_addr_unlock_bh(local->mdev); 388 spin_unlock_bh(&local->filter_lock);
405 389
406 /* TODO: start scan as soon as all nullfunc frames are ACKed */ 390 /* TODO: start scan as soon as all nullfunc frames are ACKed */
407 queue_delayed_work(local->hw.workqueue, &local->scan_work, 391 queue_delayed_work(local->hw.workqueue, &local->scan_work,
@@ -443,10 +427,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
443 427
444 if (req != &local->int_scan_req && 428 if (req != &local->int_scan_req &&
445 sdata->vif.type == NL80211_IFTYPE_STATION && 429 sdata->vif.type == NL80211_IFTYPE_STATION &&
446 (ifmgd->state == IEEE80211_STA_MLME_DIRECT_PROBE || 430 !list_empty(&ifmgd->work_list)) {
447 ifmgd->state == IEEE80211_STA_MLME_AUTHENTICATE || 431 /* actually wait for the work it's doing to finish/time out */
448 ifmgd->state == IEEE80211_STA_MLME_ASSOCIATE)) {
449 /* actually wait for the assoc to finish/time out */
450 set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); 432 set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request);
451 return 0; 433 return 0;
452 } 434 }
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 49a1a1f76511..4ecf10a9bd00 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -308,6 +308,23 @@ struct sta_info {
308 struct dentry *inactive_ms; 308 struct dentry *inactive_ms;
309 struct dentry *last_seq_ctrl; 309 struct dentry *last_seq_ctrl;
310 struct dentry *agg_status; 310 struct dentry *agg_status;
311 struct dentry *aid;
312 struct dentry *dev;
313 struct dentry *rx_packets;
314 struct dentry *tx_packets;
315 struct dentry *rx_bytes;
316 struct dentry *tx_bytes;
317 struct dentry *rx_duplicates;
318 struct dentry *rx_fragments;
319 struct dentry *rx_dropped;
320 struct dentry *tx_fragments;
321 struct dentry *tx_filtered;
322 struct dentry *tx_retry_failed;
323 struct dentry *tx_retry_count;
324 struct dentry *last_signal;
325 struct dentry *last_qual;
326 struct dentry *last_noise;
327 struct dentry *wep_weak_iv_count;
311 bool add_has_run; 328 bool add_has_run;
312 } debugfs; 329 } debugfs;
313#endif 330#endif
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 3a8922cd1038..2572509d5568 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -451,7 +451,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
451 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 451 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
452 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; 452 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
453 453
454 if (unlikely(tx->skb->do_not_encrypt)) 454 if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT))
455 tx->key = NULL; 455 tx->key = NULL;
456 else if (tx->sta && (key = rcu_dereference(tx->sta->key))) 456 else if (tx->sta && (key = rcu_dereference(tx->sta->key)))
457 tx->key = key; 457 tx->key = key;
@@ -497,7 +497,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
497 } 497 }
498 498
499 if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) 499 if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
500 tx->skb->do_not_encrypt = 1; 500 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
501 501
502 return TX_CONTINUE; 502 return TX_CONTINUE;
503} 503}
@@ -512,6 +512,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
512 int i, len; 512 int i, len;
513 bool inval = false, rts = false, short_preamble = false; 513 bool inval = false, rts = false, short_preamble = false;
514 struct ieee80211_tx_rate_control txrc; 514 struct ieee80211_tx_rate_control txrc;
515 u32 sta_flags;
515 516
516 memset(&txrc, 0, sizeof(txrc)); 517 memset(&txrc, 0, sizeof(txrc));
517 518
@@ -544,7 +545,26 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
544 (tx->sta && test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) 545 (tx->sta && test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))))
545 txrc.short_preamble = short_preamble = true; 546 txrc.short_preamble = short_preamble = true;
546 547
548 sta_flags = tx->sta ? get_sta_flags(tx->sta) : 0;
549
550 /*
551 * Lets not bother rate control if we're associated and cannot
552 * talk to the sta. This should not happen.
553 */
554 if (WARN((tx->local->sw_scanning) &&
555 (sta_flags & WLAN_STA_ASSOC) &&
556 !rate_usable_index_exists(sband, &tx->sta->sta),
557 "%s: Dropped data frame as no usable bitrate found while "
558 "scanning and associated. Target station: "
559 "%pM on %d GHz band\n",
560 tx->dev->name, hdr->addr1,
561 tx->channel->band ? 5 : 2))
562 return TX_DROP;
547 563
564 /*
565 * If we're associated with the sta at this point we know we can at
566 * least send the frame at the lowest bit rate.
567 */
548 rate_control_get_rate(tx->sdata, tx->sta, &txrc); 568 rate_control_get_rate(tx->sdata, tx->sta, &txrc);
549 569
550 if (unlikely(info->control.rates[0].idx < 0)) 570 if (unlikely(info->control.rates[0].idx < 0))
@@ -754,9 +774,7 @@ static int ieee80211_fragment(struct ieee80211_local *local,
754 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); 774 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb));
755 skb_copy_queue_mapping(tmp, skb); 775 skb_copy_queue_mapping(tmp, skb);
756 tmp->priority = skb->priority; 776 tmp->priority = skb->priority;
757 tmp->do_not_encrypt = skb->do_not_encrypt;
758 tmp->dev = skb->dev; 777 tmp->dev = skb->dev;
759 tmp->iif = skb->iif;
760 778
761 /* copy header and data */ 779 /* copy header and data */
762 memcpy(skb_put(tmp, hdrlen), skb->data, hdrlen); 780 memcpy(skb_put(tmp, hdrlen), skb->data, hdrlen);
@@ -784,7 +802,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
784 802
785 /* 803 /*
786 * Warn when submitting a fragmented A-MPDU frame and drop it. 804 * Warn when submitting a fragmented A-MPDU frame and drop it.
787 * This scenario is handled in __ieee80211_tx_prepare but extra 805 * This scenario is handled in ieee80211_tx_prepare but extra
788 * caution taken here as fragmented ampdu may cause Tx stop. 806 * caution taken here as fragmented ampdu may cause Tx stop.
789 */ 807 */
790 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) 808 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
@@ -923,11 +941,12 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
923 struct ieee80211_radiotap_header *rthdr = 941 struct ieee80211_radiotap_header *rthdr =
924 (struct ieee80211_radiotap_header *) skb->data; 942 (struct ieee80211_radiotap_header *) skb->data;
925 struct ieee80211_supported_band *sband; 943 struct ieee80211_supported_band *sband;
944 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
926 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); 945 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len);
927 946
928 sband = tx->local->hw.wiphy->bands[tx->channel->band]; 947 sband = tx->local->hw.wiphy->bands[tx->channel->band];
929 948
930 skb->do_not_encrypt = 1; 949 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
931 tx->flags &= ~IEEE80211_TX_FRAGMENTED; 950 tx->flags &= ~IEEE80211_TX_FRAGMENTED;
932 951
933 /* 952 /*
@@ -965,7 +984,7 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
965 skb_trim(skb, skb->len - FCS_LEN); 984 skb_trim(skb, skb->len - FCS_LEN);
966 } 985 }
967 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) 986 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP)
968 tx->skb->do_not_encrypt = 0; 987 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT;
969 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) 988 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG)
970 tx->flags |= IEEE80211_TX_FRAGMENTED; 989 tx->flags |= IEEE80211_TX_FRAGMENTED;
971 break; 990 break;
@@ -998,13 +1017,12 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
998 * initialises @tx 1017 * initialises @tx
999 */ 1018 */
1000static ieee80211_tx_result 1019static ieee80211_tx_result
1001__ieee80211_tx_prepare(struct ieee80211_tx_data *tx, 1020ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
1002 struct sk_buff *skb, 1021 struct ieee80211_tx_data *tx,
1003 struct net_device *dev) 1022 struct sk_buff *skb)
1004{ 1023{
1005 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1024 struct ieee80211_local *local = sdata->local;
1006 struct ieee80211_hdr *hdr; 1025 struct ieee80211_hdr *hdr;
1007 struct ieee80211_sub_if_data *sdata;
1008 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1026 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1009 int hdrlen, tid; 1027 int hdrlen, tid;
1010 u8 *qc, *state; 1028 u8 *qc, *state;
@@ -1012,9 +1030,9 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
1012 1030
1013 memset(tx, 0, sizeof(*tx)); 1031 memset(tx, 0, sizeof(*tx));
1014 tx->skb = skb; 1032 tx->skb = skb;
1015 tx->dev = dev; /* use original interface */ 1033 tx->dev = sdata->dev; /* use original interface */
1016 tx->local = local; 1034 tx->local = local;
1017 tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1035 tx->sdata = sdata;
1018 tx->channel = local->hw.conf.channel; 1036 tx->channel = local->hw.conf.channel;
1019 /* 1037 /*
1020 * Set this flag (used below to indicate "automatic fragmentation"), 1038 * Set this flag (used below to indicate "automatic fragmentation"),
@@ -1023,7 +1041,6 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
1023 tx->flags |= IEEE80211_TX_FRAGMENTED; 1041 tx->flags |= IEEE80211_TX_FRAGMENTED;
1024 1042
1025 /* process and remove the injection radiotap header */ 1043 /* process and remove the injection radiotap header */
1026 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1027 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) { 1044 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) {
1028 if (!__ieee80211_parse_tx_radiotap(tx, skb)) 1045 if (!__ieee80211_parse_tx_radiotap(tx, skb))
1029 return TX_DROP; 1046 return TX_DROP;
@@ -1119,50 +1136,28 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
1119 return TX_CONTINUE; 1136 return TX_CONTINUE;
1120} 1137}
1121 1138
1122/*
1123 * NB: @tx is uninitialised when passed in here
1124 */
1125static int ieee80211_tx_prepare(struct ieee80211_local *local,
1126 struct ieee80211_tx_data *tx,
1127 struct sk_buff *skb)
1128{
1129 struct net_device *dev;
1130
1131 dev = dev_get_by_index(&init_net, skb->iif);
1132 if (unlikely(dev && !is_ieee80211_device(local, dev))) {
1133 dev_put(dev);
1134 dev = NULL;
1135 }
1136 if (unlikely(!dev))
1137 return -ENODEV;
1138 /*
1139 * initialises tx with control
1140 *
1141 * return value is safe to ignore here because this function
1142 * can only be invoked for multicast frames
1143 *
1144 * XXX: clean up
1145 */
1146 __ieee80211_tx_prepare(tx, skb, dev);
1147 dev_put(dev);
1148 return 0;
1149}
1150
1151static int __ieee80211_tx(struct ieee80211_local *local, 1139static int __ieee80211_tx(struct ieee80211_local *local,
1152 struct sk_buff **skbp, 1140 struct sk_buff **skbp,
1153 struct sta_info *sta) 1141 struct sta_info *sta,
1142 bool txpending)
1154{ 1143{
1155 struct sk_buff *skb = *skbp, *next; 1144 struct sk_buff *skb = *skbp, *next;
1156 struct ieee80211_tx_info *info; 1145 struct ieee80211_tx_info *info;
1146 unsigned long flags;
1157 int ret, len; 1147 int ret, len;
1158 bool fragm = false; 1148 bool fragm = false;
1159 1149
1160 local->mdev->trans_start = jiffies;
1161
1162 while (skb) { 1150 while (skb) {
1163 if (ieee80211_queue_stopped(&local->hw, 1151 int q = skb_get_queue_mapping(skb);
1164 skb_get_queue_mapping(skb))) 1152
1165 return IEEE80211_TX_PENDING; 1153 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
1154 ret = IEEE80211_TX_OK;
1155 if (local->queue_stop_reasons[q] ||
1156 (!txpending && !skb_queue_empty(&local->pending[q])))
1157 ret = IEEE80211_TX_PENDING;
1158 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
1159 if (ret != IEEE80211_TX_OK)
1160 return ret;
1166 1161
1167 info = IEEE80211_SKB_CB(skb); 1162 info = IEEE80211_SKB_CB(skb);
1168 1163
@@ -1234,10 +1229,10 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
1234 return 0; 1229 return 0;
1235} 1230}
1236 1231
1237static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, 1232static void ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1238 bool txpending) 1233 struct sk_buff *skb, bool txpending)
1239{ 1234{
1240 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1235 struct ieee80211_local *local = sdata->local;
1241 struct ieee80211_tx_data tx; 1236 struct ieee80211_tx_data tx;
1242 ieee80211_tx_result res_prepare; 1237 ieee80211_tx_result res_prepare;
1243 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1238 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1248,8 +1243,6 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
1248 1243
1249 queue = skb_get_queue_mapping(skb); 1244 queue = skb_get_queue_mapping(skb);
1250 1245
1251 WARN_ON(!txpending && !skb_queue_empty(&local->pending[queue]));
1252
1253 if (unlikely(skb->len < 10)) { 1246 if (unlikely(skb->len < 10)) {
1254 dev_kfree_skb(skb); 1247 dev_kfree_skb(skb);
1255 return; 1248 return;
@@ -1258,7 +1251,7 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
1258 rcu_read_lock(); 1251 rcu_read_lock();
1259 1252
1260 /* initialises tx */ 1253 /* initialises tx */
1261 res_prepare = __ieee80211_tx_prepare(&tx, skb, dev); 1254 res_prepare = ieee80211_tx_prepare(sdata, &tx, skb);
1262 1255
1263 if (unlikely(res_prepare == TX_DROP)) { 1256 if (unlikely(res_prepare == TX_DROP)) {
1264 dev_kfree_skb(skb); 1257 dev_kfree_skb(skb);
@@ -1277,7 +1270,7 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
1277 1270
1278 retries = 0; 1271 retries = 0;
1279 retry: 1272 retry:
1280 ret = __ieee80211_tx(local, &tx.skb, tx.sta); 1273 ret = __ieee80211_tx(local, &tx.skb, tx.sta, txpending);
1281 switch (ret) { 1274 switch (ret) {
1282 case IEEE80211_TX_OK: 1275 case IEEE80211_TX_OK:
1283 break; 1276 break;
@@ -1295,34 +1288,35 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
1295 1288
1296 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 1289 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
1297 1290
1298 if (__netif_subqueue_stopped(local->mdev, queue)) { 1291 if (local->queue_stop_reasons[queue] ||
1292 !skb_queue_empty(&local->pending[queue])) {
1293 /*
1294 * if queue is stopped, queue up frames for later
1295 * transmission from the tasklet
1296 */
1299 do { 1297 do {
1300 next = skb->next; 1298 next = skb->next;
1301 skb->next = NULL; 1299 skb->next = NULL;
1302 if (unlikely(txpending)) 1300 if (unlikely(txpending))
1303 skb_queue_head(&local->pending[queue], 1301 __skb_queue_head(&local->pending[queue],
1304 skb); 1302 skb);
1305 else 1303 else
1306 skb_queue_tail(&local->pending[queue], 1304 __skb_queue_tail(&local->pending[queue],
1307 skb); 1305 skb);
1308 } while ((skb = next)); 1306 } while ((skb = next));
1309 1307
1310 /*
1311 * Make sure nobody will enable the queue on us
1312 * (without going through the tasklet) nor disable the
1313 * netdev queue underneath the pending handling code.
1314 */
1315 __set_bit(IEEE80211_QUEUE_STOP_REASON_PENDING,
1316 &local->queue_stop_reasons[queue]);
1317
1318 spin_unlock_irqrestore(&local->queue_stop_reason_lock, 1308 spin_unlock_irqrestore(&local->queue_stop_reason_lock,
1319 flags); 1309 flags);
1320 } else { 1310 } else {
1311 /*
1312 * otherwise retry, but this is a race condition or
1313 * a driver bug (which we warn about if it persists)
1314 */
1321 spin_unlock_irqrestore(&local->queue_stop_reason_lock, 1315 spin_unlock_irqrestore(&local->queue_stop_reason_lock,
1322 flags); 1316 flags);
1323 1317
1324 retries++; 1318 retries++;
1325 if (WARN(retries > 10, "tx refused but queue active")) 1319 if (WARN(retries > 10, "tx refused but queue active\n"))
1326 goto drop; 1320 goto drop;
1327 goto retry; 1321 goto retry;
1328 } 1322 }
@@ -1383,14 +1377,13 @@ static int ieee80211_skb_resize(struct ieee80211_local *local,
1383 return 0; 1377 return 0;
1384} 1378}
1385 1379
1386int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) 1380static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
1381 struct sk_buff *skb)
1387{ 1382{
1388 struct ieee80211_master_priv *mpriv = netdev_priv(dev); 1383 struct ieee80211_local *local = sdata->local;
1389 struct ieee80211_local *local = mpriv->local;
1390 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1384 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1391 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1385 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1392 struct net_device *odev = NULL; 1386 struct ieee80211_sub_if_data *tmp_sdata;
1393 struct ieee80211_sub_if_data *osdata;
1394 int headroom; 1387 int headroom;
1395 bool may_encrypt; 1388 bool may_encrypt;
1396 enum { 1389 enum {
@@ -1399,20 +1392,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
1399 UNKNOWN_ADDRESS, 1392 UNKNOWN_ADDRESS,
1400 } monitor_iface = NOT_MONITOR; 1393 } monitor_iface = NOT_MONITOR;
1401 1394
1402 if (skb->iif) 1395 dev_hold(sdata->dev);
1403 odev = dev_get_by_index(&init_net, skb->iif);
1404 if (unlikely(odev && !is_ieee80211_device(local, odev))) {
1405 dev_put(odev);
1406 odev = NULL;
1407 }
1408 if (unlikely(!odev)) {
1409#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
1410 printk(KERN_DEBUG "%s: Discarded packet with nonexistent "
1411 "originating device\n", dev->name);
1412#endif
1413 dev_kfree_skb(skb);
1414 return NETDEV_TX_OK;
1415 }
1416 1396
1417 if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && 1397 if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
1418 local->hw.conf.dynamic_ps_timeout > 0 && 1398 local->hw.conf.dynamic_ps_timeout > 0 &&
@@ -1428,26 +1408,18 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
1428 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); 1408 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
1429 } 1409 }
1430 1410
1431 memset(info, 0, sizeof(*info));
1432
1433 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 1411 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
1434 1412
1435 osdata = IEEE80211_DEV_TO_SUB_IF(odev); 1413 if (ieee80211_vif_is_mesh(&sdata->vif) &&
1436
1437 if (ieee80211_vif_is_mesh(&osdata->vif) &&
1438 ieee80211_is_data(hdr->frame_control)) { 1414 ieee80211_is_data(hdr->frame_control)) {
1439 if (is_multicast_ether_addr(hdr->addr3)) 1415 if (is_multicast_ether_addr(hdr->addr3))
1440 memcpy(hdr->addr1, hdr->addr3, ETH_ALEN); 1416 memcpy(hdr->addr1, hdr->addr3, ETH_ALEN);
1441 else 1417 else
1442 if (mesh_nexthop_lookup(skb, osdata)) { 1418 if (mesh_nexthop_lookup(skb, sdata)) {
1443 dev_put(odev); 1419 dev_put(sdata->dev);
1444 return NETDEV_TX_OK; 1420 return;
1445 } 1421 }
1446 if (memcmp(odev->dev_addr, hdr->addr4, ETH_ALEN) != 0) 1422 } else if (unlikely(sdata->vif.type == NL80211_IFTYPE_MONITOR)) {
1447 IEEE80211_IFSTA_MESH_CTR_INC(&osdata->u.mesh,
1448 fwded_frames);
1449 } else if (unlikely(osdata->vif.type == NL80211_IFTYPE_MONITOR)) {
1450 struct ieee80211_sub_if_data *sdata;
1451 int hdrlen; 1423 int hdrlen;
1452 u16 len_rthdr; 1424 u16 len_rthdr;
1453 1425
@@ -1471,19 +1443,17 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
1471 */ 1443 */
1472 1444
1473 rcu_read_lock(); 1445 rcu_read_lock();
1474 list_for_each_entry_rcu(sdata, &local->interfaces, 1446 list_for_each_entry_rcu(tmp_sdata, &local->interfaces,
1475 list) { 1447 list) {
1476 if (!netif_running(sdata->dev)) 1448 if (!netif_running(tmp_sdata->dev))
1477 continue; 1449 continue;
1478 if (sdata->vif.type != NL80211_IFTYPE_AP) 1450 if (tmp_sdata->vif.type != NL80211_IFTYPE_AP)
1479 continue; 1451 continue;
1480 if (compare_ether_addr(sdata->dev->dev_addr, 1452 if (compare_ether_addr(tmp_sdata->dev->dev_addr,
1481 hdr->addr2)) { 1453 hdr->addr2)) {
1482 dev_hold(sdata->dev); 1454 dev_hold(tmp_sdata->dev);
1483 dev_put(odev); 1455 dev_put(sdata->dev);
1484 osdata = sdata; 1456 sdata = tmp_sdata;
1485 odev = osdata->dev;
1486 skb->iif = sdata->dev->ifindex;
1487 monitor_iface = FOUND_SDATA; 1457 monitor_iface = FOUND_SDATA;
1488 break; 1458 break;
1489 } 1459 }
@@ -1492,31 +1462,31 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
1492 } 1462 }
1493 } 1463 }
1494 1464
1495 may_encrypt = !skb->do_not_encrypt; 1465 may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT);
1496 1466
1497 headroom = osdata->local->tx_headroom; 1467 headroom = local->tx_headroom;
1498 if (may_encrypt) 1468 if (may_encrypt)
1499 headroom += IEEE80211_ENCRYPT_HEADROOM; 1469 headroom += IEEE80211_ENCRYPT_HEADROOM;
1500 headroom -= skb_headroom(skb); 1470 headroom -= skb_headroom(skb);
1501 headroom = max_t(int, 0, headroom); 1471 headroom = max_t(int, 0, headroom);
1502 1472
1503 if (ieee80211_skb_resize(osdata->local, skb, headroom, may_encrypt)) { 1473 if (ieee80211_skb_resize(local, skb, headroom, may_encrypt)) {
1504 dev_kfree_skb(skb); 1474 dev_kfree_skb(skb);
1505 dev_put(odev); 1475 dev_put(sdata->dev);
1506 return NETDEV_TX_OK; 1476 return;
1507 } 1477 }
1508 1478
1509 if (osdata->vif.type == NL80211_IFTYPE_AP_VLAN) 1479 tmp_sdata = sdata;
1510 osdata = container_of(osdata->bss, 1480 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
1511 struct ieee80211_sub_if_data, 1481 tmp_sdata = container_of(sdata->bss,
1512 u.ap); 1482 struct ieee80211_sub_if_data,
1483 u.ap);
1513 if (likely(monitor_iface != UNKNOWN_ADDRESS)) 1484 if (likely(monitor_iface != UNKNOWN_ADDRESS))
1514 info->control.vif = &osdata->vif; 1485 info->control.vif = &tmp_sdata->vif;
1515
1516 ieee80211_tx(odev, skb, false);
1517 dev_put(odev);
1518 1486
1519 return NETDEV_TX_OK; 1487 ieee80211_select_queue(local, skb);
1488 ieee80211_tx(sdata, skb, false);
1489 dev_put(sdata->dev);
1520} 1490}
1521 1491
1522int ieee80211_monitor_start_xmit(struct sk_buff *skb, 1492int ieee80211_monitor_start_xmit(struct sk_buff *skb,
@@ -1526,6 +1496,7 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb,
1526 struct ieee80211_channel *chan = local->hw.conf.channel; 1496 struct ieee80211_channel *chan = local->hw.conf.channel;
1527 struct ieee80211_radiotap_header *prthdr = 1497 struct ieee80211_radiotap_header *prthdr =
1528 (struct ieee80211_radiotap_header *)skb->data; 1498 (struct ieee80211_radiotap_header *)skb->data;
1499 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1529 u16 len_rthdr; 1500 u16 len_rthdr;
1530 1501
1531 /* 1502 /*
@@ -1563,15 +1534,9 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb,
1563 if (unlikely(skb->len < len_rthdr)) 1534 if (unlikely(skb->len < len_rthdr))
1564 goto fail; /* skb too short for claimed rt header extent */ 1535 goto fail; /* skb too short for claimed rt header extent */
1565 1536
1566 skb->dev = local->mdev;
1567
1568 /* needed because we set skb device to master */ 1537 /* needed because we set skb device to master */
1569 skb->iif = dev->ifindex; 1538 skb->iif = dev->ifindex;
1570 1539
1571 /* sometimes we do encrypt injected frames, will be fixed
1572 * up in radiotap parser if not wanted */
1573 skb->do_not_encrypt = 0;
1574
1575 /* 1540 /*
1576 * fix up the pointers accounting for the radiotap 1541 * fix up the pointers accounting for the radiotap
1577 * header still being in there. We are being given 1542 * header still being in there. We are being given
@@ -1586,8 +1551,10 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb,
1586 skb_set_network_header(skb, len_rthdr); 1551 skb_set_network_header(skb, len_rthdr);
1587 skb_set_transport_header(skb, len_rthdr); 1552 skb_set_transport_header(skb, len_rthdr);
1588 1553
1589 /* pass the radiotap header up to the next stage intact */ 1554 memset(info, 0, sizeof(*info));
1590 dev_queue_xmit(skb); 1555
1556 /* pass the radiotap header up to xmit */
1557 ieee80211_xmit(IEEE80211_DEV_TO_SUB_IF(dev), skb);
1591 return NETDEV_TX_OK; 1558 return NETDEV_TX_OK;
1592 1559
1593fail: 1560fail:
@@ -1615,6 +1582,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1615{ 1582{
1616 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1583 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1617 struct ieee80211_local *local = sdata->local; 1584 struct ieee80211_local *local = sdata->local;
1585 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1618 int ret = NETDEV_TX_BUSY, head_need; 1586 int ret = NETDEV_TX_BUSY, head_need;
1619 u16 ethertype, hdrlen, meshhdrlen = 0; 1587 u16 ethertype, hdrlen, meshhdrlen = 0;
1620 __le16 fc; 1588 __le16 fc;
@@ -1627,7 +1595,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1627 u32 sta_flags = 0; 1595 u32 sta_flags = 0;
1628 1596
1629 if (unlikely(skb->len < ETH_HLEN)) { 1597 if (unlikely(skb->len < ETH_HLEN)) {
1630 ret = 0; 1598 ret = NETDEV_TX_OK;
1631 goto fail; 1599 goto fail;
1632 } 1600 }
1633 1601
@@ -1664,7 +1632,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1664 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { 1632 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) {
1665 /* Do not send frames with mesh_ttl == 0 */ 1633 /* Do not send frames with mesh_ttl == 0 */
1666 sdata->u.mesh.mshstats.dropped_frames_ttl++; 1634 sdata->u.mesh.mshstats.dropped_frames_ttl++;
1667 ret = 0; 1635 ret = NETDEV_TX_OK;
1668 goto fail; 1636 goto fail;
1669 } 1637 }
1670 memset(&mesh_hdr, 0, sizeof(mesh_hdr)); 1638 memset(&mesh_hdr, 0, sizeof(mesh_hdr));
@@ -1724,7 +1692,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1724 hdrlen = 24; 1692 hdrlen = 24;
1725 break; 1693 break;
1726 default: 1694 default:
1727 ret = 0; 1695 ret = NETDEV_TX_OK;
1728 goto fail; 1696 goto fail;
1729 } 1697 }
1730 1698
@@ -1766,7 +1734,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1766 1734
1767 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); 1735 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
1768 1736
1769 ret = 0; 1737 ret = NETDEV_TX_OK;
1770 goto fail; 1738 goto fail;
1771 } 1739 }
1772 1740
@@ -1844,7 +1812,6 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1844 1812
1845 skb->iif = dev->ifindex; 1813 skb->iif = dev->ifindex;
1846 1814
1847 skb->dev = local->mdev;
1848 dev->stats.tx_packets++; 1815 dev->stats.tx_packets++;
1849 dev->stats.tx_bytes += skb->len; 1816 dev->stats.tx_bytes += skb->len;
1850 1817
@@ -1855,13 +1822,15 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1855 skb_set_network_header(skb, nh_pos); 1822 skb_set_network_header(skb, nh_pos);
1856 skb_set_transport_header(skb, h_pos); 1823 skb_set_transport_header(skb, h_pos);
1857 1824
1825 memset(info, 0, sizeof(*info));
1826
1858 dev->trans_start = jiffies; 1827 dev->trans_start = jiffies;
1859 dev_queue_xmit(skb); 1828 ieee80211_xmit(sdata, skb);
1860 1829
1861 return 0; 1830 return NETDEV_TX_OK;
1862 1831
1863 fail: 1832 fail:
1864 if (!ret) 1833 if (ret == NETDEV_TX_OK)
1865 dev_kfree_skb(skb); 1834 dev_kfree_skb(skb);
1866 1835
1867 return ret; 1836 return ret;
@@ -1898,7 +1867,6 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
1898 return true; 1867 return true;
1899 } 1868 }
1900 1869
1901 /* validate info->control.vif against skb->iif */
1902 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1870 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1903 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 1871 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
1904 sdata = container_of(sdata->bss, 1872 sdata = container_of(sdata->bss,
@@ -1912,12 +1880,13 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
1912 } 1880 }
1913 1881
1914 if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { 1882 if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) {
1915 ieee80211_tx(dev, skb, true); 1883 /* do not use sdata, it may have been changed above */
1884 ieee80211_tx(IEEE80211_DEV_TO_SUB_IF(dev), skb, true);
1916 } else { 1885 } else {
1917 hdr = (struct ieee80211_hdr *)skb->data; 1886 hdr = (struct ieee80211_hdr *)skb->data;
1918 sta = sta_info_get(local, hdr->addr1); 1887 sta = sta_info_get(local, hdr->addr1);
1919 1888
1920 ret = __ieee80211_tx(local, &skb, sta); 1889 ret = __ieee80211_tx(local, &skb, sta, true);
1921 if (ret != IEEE80211_TX_OK) 1890 if (ret != IEEE80211_TX_OK)
1922 result = false; 1891 result = false;
1923 } 1892 }
@@ -1929,59 +1898,43 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
1929} 1898}
1930 1899
1931/* 1900/*
1932 * Transmit all pending packets. Called from tasklet, locks master device 1901 * Transmit all pending packets. Called from tasklet.
1933 * TX lock so that no new packets can come in.
1934 */ 1902 */
1935void ieee80211_tx_pending(unsigned long data) 1903void ieee80211_tx_pending(unsigned long data)
1936{ 1904{
1937 struct ieee80211_local *local = (struct ieee80211_local *)data; 1905 struct ieee80211_local *local = (struct ieee80211_local *)data;
1938 struct net_device *dev = local->mdev;
1939 unsigned long flags; 1906 unsigned long flags;
1940 int i; 1907 int i;
1941 bool next; 1908 bool txok;
1942 1909
1943 rcu_read_lock(); 1910 rcu_read_lock();
1944 netif_tx_lock_bh(dev);
1945 1911
1912 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
1946 for (i = 0; i < local->hw.queues; i++) { 1913 for (i = 0; i < local->hw.queues; i++) {
1947 /* 1914 /*
1948 * If queue is stopped by something other than due to pending 1915 * If queue is stopped by something other than due to pending
1949 * frames, or we have no pending frames, proceed to next queue. 1916 * frames, or we have no pending frames, proceed to next queue.
1950 */ 1917 */
1951 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 1918 if (local->queue_stop_reasons[i] ||
1952 next = false;
1953 if (local->queue_stop_reasons[i] !=
1954 BIT(IEEE80211_QUEUE_STOP_REASON_PENDING) ||
1955 skb_queue_empty(&local->pending[i])) 1919 skb_queue_empty(&local->pending[i]))
1956 next = true;
1957 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
1958
1959 if (next)
1960 continue; 1920 continue;
1961 1921
1962 /*
1963 * start the queue now to allow processing our packets,
1964 * we're under the tx lock here anyway so nothing will
1965 * happen as a result of this
1966 */
1967 netif_start_subqueue(local->mdev, i);
1968
1969 while (!skb_queue_empty(&local->pending[i])) { 1922 while (!skb_queue_empty(&local->pending[i])) {
1970 struct sk_buff *skb = skb_dequeue(&local->pending[i]); 1923 struct sk_buff *skb = __skb_dequeue(&local->pending[i]);
1971 1924 spin_unlock_irqrestore(&local->queue_stop_reason_lock,
1972 if (!ieee80211_tx_pending_skb(local, skb)) { 1925 flags);
1973 skb_queue_head(&local->pending[i], skb); 1926
1927 txok = ieee80211_tx_pending_skb(local, skb);
1928 if (!txok)
1929 __skb_queue_head(&local->pending[i], skb);
1930 spin_lock_irqsave(&local->queue_stop_reason_lock,
1931 flags);
1932 if (!txok)
1974 break; 1933 break;
1975 }
1976 } 1934 }
1977
1978 /* Start regular packet processing again. */
1979 if (skb_queue_empty(&local->pending[i]))
1980 ieee80211_wake_queue_by_reason(&local->hw, i,
1981 IEEE80211_QUEUE_STOP_REASON_PENDING);
1982 } 1935 }
1936 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
1983 1937
1984 netif_tx_unlock_bh(dev);
1985 rcu_read_unlock(); 1938 rcu_read_unlock();
1986} 1939}
1987 1940
@@ -2156,8 +2109,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
2156 2109
2157 info = IEEE80211_SKB_CB(skb); 2110 info = IEEE80211_SKB_CB(skb);
2158 2111
2159 skb->do_not_encrypt = 1; 2112 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
2160
2161 info->band = band; 2113 info->band = band;
2162 /* 2114 /*
2163 * XXX: For now, always use the lowest rate 2115 * XXX: For now, always use the lowest rate
@@ -2228,9 +2180,6 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2228 sdata = vif_to_sdata(vif); 2180 sdata = vif_to_sdata(vif);
2229 bss = &sdata->u.ap; 2181 bss = &sdata->u.ap;
2230 2182
2231 if (!bss)
2232 return NULL;
2233
2234 rcu_read_lock(); 2183 rcu_read_lock();
2235 beacon = rcu_dereference(bss->beacon); 2184 beacon = rcu_dereference(bss->beacon);
2236 2185
@@ -2256,7 +2205,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2256 cpu_to_le16(IEEE80211_FCTL_MOREDATA); 2205 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
2257 } 2206 }
2258 2207
2259 if (!ieee80211_tx_prepare(local, &tx, skb)) 2208 if (!ieee80211_tx_prepare(sdata, &tx, skb))
2260 break; 2209 break;
2261 dev_kfree_skb_any(skb); 2210 dev_kfree_skb_any(skb);
2262 } 2211 }
@@ -2276,3 +2225,25 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2276 return skb; 2225 return skb;
2277} 2226}
2278EXPORT_SYMBOL(ieee80211_get_buffered_bc); 2227EXPORT_SYMBOL(ieee80211_get_buffered_bc);
2228
2229void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
2230 int encrypt)
2231{
2232 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2233 skb_set_mac_header(skb, 0);
2234 skb_set_network_header(skb, 0);
2235 skb_set_transport_header(skb, 0);
2236
2237 skb->iif = sdata->dev->ifindex;
2238 if (!encrypt)
2239 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
2240
2241 /*
2242 * The other path calling ieee80211_xmit is from the tasklet,
2243 * and while we can handle concurrent transmissions locking
2244 * requirements are that we do not come into tx with bhs on.
2245 */
2246 local_bh_disable();
2247 ieee80211_xmit(sdata, skb);
2248 local_bh_enable();
2249}
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 915e77769312..7fc55846d601 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -31,6 +31,7 @@
31#include "mesh.h" 31#include "mesh.h"
32#include "wme.h" 32#include "wme.h"
33#include "led.h" 33#include "led.h"
34#include "wep.h"
34 35
35/* privid for wiphys to determine whether they belong to us or not */ 36/* privid for wiphys to determine whether they belong to us or not */
36void *mac80211_wiphy_privid = &mac80211_wiphy_privid; 37void *mac80211_wiphy_privid = &mac80211_wiphy_privid;
@@ -274,16 +275,12 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
274 275
275 __clear_bit(reason, &local->queue_stop_reasons[queue]); 276 __clear_bit(reason, &local->queue_stop_reasons[queue]);
276 277
277 if (!skb_queue_empty(&local->pending[queue]) &&
278 local->queue_stop_reasons[queue] ==
279 BIT(IEEE80211_QUEUE_STOP_REASON_PENDING))
280 tasklet_schedule(&local->tx_pending_tasklet);
281
282 if (local->queue_stop_reasons[queue] != 0) 278 if (local->queue_stop_reasons[queue] != 0)
283 /* someone still has this queue stopped */ 279 /* someone still has this queue stopped */
284 return; 280 return;
285 281
286 netif_wake_subqueue(local->mdev, queue); 282 if (!skb_queue_empty(&local->pending[queue]))
283 tasklet_schedule(&local->tx_pending_tasklet);
287} 284}
288 285
289void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, 286void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
@@ -312,14 +309,6 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
312 if (WARN_ON(queue >= hw->queues)) 309 if (WARN_ON(queue >= hw->queues))
313 return; 310 return;
314 311
315 /*
316 * Only stop if it was previously running, this is necessary
317 * for correct pending packets handling because there we may
318 * start (but not wake) the queue and rely on that.
319 */
320 if (!local->queue_stop_reasons[queue])
321 netif_stop_subqueue(local->mdev, queue);
322
323 __set_bit(reason, &local->queue_stop_reasons[queue]); 312 __set_bit(reason, &local->queue_stop_reasons[queue]);
324} 313}
325 314
@@ -350,8 +339,7 @@ void ieee80211_add_pending_skb(struct ieee80211_local *local,
350 339
351 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 340 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
352 __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 341 __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
353 __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_PENDING); 342 __skb_queue_tail(&local->pending[queue], skb);
354 skb_queue_tail(&local->pending[queue], skb);
355 __ieee80211_wake_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 343 __ieee80211_wake_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
356 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 344 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
357} 345}
@@ -372,16 +360,12 @@ int ieee80211_add_pending_skbs(struct ieee80211_local *local,
372 while ((skb = skb_dequeue(skbs))) { 360 while ((skb = skb_dequeue(skbs))) {
373 ret++; 361 ret++;
374 queue = skb_get_queue_mapping(skb); 362 queue = skb_get_queue_mapping(skb);
375 skb_queue_tail(&local->pending[queue], skb); 363 __skb_queue_tail(&local->pending[queue], skb);
376 } 364 }
377 365
378 for (i = 0; i < hw->queues; i++) { 366 for (i = 0; i < hw->queues; i++)
379 if (ret)
380 __ieee80211_stop_queue(hw, i,
381 IEEE80211_QUEUE_STOP_REASON_PENDING);
382 __ieee80211_wake_queue(hw, i, 367 __ieee80211_wake_queue(hw, i,
383 IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 368 IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
384 }
385 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 369 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
386 370
387 return ret; 371 return ret;
@@ -412,11 +396,16 @@ EXPORT_SYMBOL(ieee80211_stop_queues);
412int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue) 396int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue)
413{ 397{
414 struct ieee80211_local *local = hw_to_local(hw); 398 struct ieee80211_local *local = hw_to_local(hw);
399 unsigned long flags;
400 int ret;
415 401
416 if (WARN_ON(queue >= hw->queues)) 402 if (WARN_ON(queue >= hw->queues))
417 return true; 403 return true;
418 404
419 return __netif_subqueue_stopped(local->mdev, queue); 405 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
406 ret = !!local->queue_stop_reasons[queue];
407 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
408 return ret;
420} 409}
421EXPORT_SYMBOL(ieee80211_queue_stopped); 410EXPORT_SYMBOL(ieee80211_queue_stopped);
422 411
@@ -760,20 +749,6 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
760 ieee80211_set_wmm_default(sdata); 749 ieee80211_set_wmm_default(sdata);
761} 750}
762 751
763void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
764 int encrypt)
765{
766 skb->dev = sdata->local->mdev;
767 skb_set_mac_header(skb, 0);
768 skb_set_network_header(skb, 0);
769 skb_set_transport_header(skb, 0);
770
771 skb->iif = sdata->dev->ifindex;
772 skb->do_not_encrypt = !encrypt;
773
774 dev_queue_xmit(skb);
775}
776
777u32 ieee80211_mandatory_rates(struct ieee80211_local *local, 752u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
778 enum ieee80211_band band) 753 enum ieee80211_band band)
779{ 754{
@@ -804,12 +779,13 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
804 779
805void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 780void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
806 u16 transaction, u16 auth_alg, 781 u16 transaction, u16 auth_alg,
807 u8 *extra, size_t extra_len, 782 u8 *extra, size_t extra_len, const u8 *bssid,
808 const u8 *bssid, int encrypt) 783 const u8 *key, u8 key_len, u8 key_idx)
809{ 784{
810 struct ieee80211_local *local = sdata->local; 785 struct ieee80211_local *local = sdata->local;
811 struct sk_buff *skb; 786 struct sk_buff *skb;
812 struct ieee80211_mgmt *mgmt; 787 struct ieee80211_mgmt *mgmt;
788 int err;
813 789
814 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 790 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
815 sizeof(*mgmt) + 6 + extra_len); 791 sizeof(*mgmt) + 6 + extra_len);
@@ -824,8 +800,6 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
824 memset(mgmt, 0, 24 + 6); 800 memset(mgmt, 0, 24 + 6);
825 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 801 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
826 IEEE80211_STYPE_AUTH); 802 IEEE80211_STYPE_AUTH);
827 if (encrypt)
828 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
829 memcpy(mgmt->da, bssid, ETH_ALEN); 803 memcpy(mgmt->da, bssid, ETH_ALEN);
830 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 804 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
831 memcpy(mgmt->bssid, bssid, ETH_ALEN); 805 memcpy(mgmt->bssid, bssid, ETH_ALEN);
@@ -835,7 +809,13 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
835 if (extra) 809 if (extra)
836 memcpy(skb_put(skb, extra_len), extra, extra_len); 810 memcpy(skb_put(skb, extra_len), extra, extra_len);
837 811
838 ieee80211_tx_skb(sdata, skb, encrypt); 812 if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
813 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
814 err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx);
815 WARN_ON(err);
816 }
817
818 ieee80211_tx_skb(sdata, skb, 0);
839} 819}
840 820
841int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, 821int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
@@ -1043,9 +1023,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1043 /* reconfigure hardware */ 1023 /* reconfigure hardware */
1044 ieee80211_hw_config(local, ~0); 1024 ieee80211_hw_config(local, ~0);
1045 1025
1046 netif_addr_lock_bh(local->mdev); 1026 spin_lock_bh(&local->filter_lock);
1047 ieee80211_configure_filter(local); 1027 ieee80211_configure_filter(local);
1048 netif_addr_unlock_bh(local->mdev); 1028 spin_unlock_bh(&local->filter_lock);
1049 1029
1050 /* Finally also reconfigure all the BSS information */ 1030 /* Finally also reconfigure all the BSS information */
1051 list_for_each_entry(sdata, &local->interfaces, list) { 1031 list_for_each_entry(sdata, &local->interfaces, list) {
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index ef73105b3061..8a980f136941 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -67,10 +67,10 @@ static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen)
67 67
68 68
69static void ieee80211_wep_get_iv(struct ieee80211_local *local, 69static void ieee80211_wep_get_iv(struct ieee80211_local *local,
70 struct ieee80211_key *key, u8 *iv) 70 int keylen, int keyidx, u8 *iv)
71{ 71{
72 local->wep_iv++; 72 local->wep_iv++;
73 if (ieee80211_wep_weak_iv(local->wep_iv, key->conf.keylen)) 73 if (ieee80211_wep_weak_iv(local->wep_iv, keylen))
74 local->wep_iv += 0x0100; 74 local->wep_iv += 0x0100;
75 75
76 if (!iv) 76 if (!iv)
@@ -79,13 +79,13 @@ static void ieee80211_wep_get_iv(struct ieee80211_local *local,
79 *iv++ = (local->wep_iv >> 16) & 0xff; 79 *iv++ = (local->wep_iv >> 16) & 0xff;
80 *iv++ = (local->wep_iv >> 8) & 0xff; 80 *iv++ = (local->wep_iv >> 8) & 0xff;
81 *iv++ = local->wep_iv & 0xff; 81 *iv++ = local->wep_iv & 0xff;
82 *iv++ = key->conf.keyidx << 6; 82 *iv++ = keyidx << 6;
83} 83}
84 84
85 85
86static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, 86static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
87 struct sk_buff *skb, 87 struct sk_buff *skb,
88 struct ieee80211_key *key) 88 int keylen, int keyidx)
89{ 89{
90 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 90 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
91 unsigned int hdrlen; 91 unsigned int hdrlen;
@@ -100,7 +100,7 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
100 hdrlen = ieee80211_hdrlen(hdr->frame_control); 100 hdrlen = ieee80211_hdrlen(hdr->frame_control);
101 newhdr = skb_push(skb, WEP_IV_LEN); 101 newhdr = skb_push(skb, WEP_IV_LEN);
102 memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen); 102 memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen);
103 ieee80211_wep_get_iv(local, key, newhdr + hdrlen); 103 ieee80211_wep_get_iv(local, keylen, keyidx, newhdr + hdrlen);
104 return newhdr + hdrlen; 104 return newhdr + hdrlen;
105} 105}
106 106
@@ -144,26 +144,17 @@ void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
144 * 144 *
145 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) 145 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
146 */ 146 */
147int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb, 147int ieee80211_wep_encrypt(struct ieee80211_local *local,
148 struct ieee80211_key *key) 148 struct sk_buff *skb,
149 const u8 *key, int keylen, int keyidx)
149{ 150{
150 u32 klen; 151 u8 *iv;
151 u8 *rc4key, *iv;
152 size_t len; 152 size_t len;
153 u8 rc4key[3 + WLAN_KEY_LEN_WEP104];
153 154
154 if (!key || key->conf.alg != ALG_WEP) 155 iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx);
155 return -1; 156 if (!iv)
156
157 klen = 3 + key->conf.keylen;
158 rc4key = kmalloc(klen, GFP_ATOMIC);
159 if (!rc4key)
160 return -1;
161
162 iv = ieee80211_wep_add_iv(local, skb, key);
163 if (!iv) {
164 kfree(rc4key);
165 return -1; 157 return -1;
166 }
167 158
168 len = skb->len - (iv + WEP_IV_LEN - skb->data); 159 len = skb->len - (iv + WEP_IV_LEN - skb->data);
169 160
@@ -171,16 +162,14 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
171 memcpy(rc4key, iv, 3); 162 memcpy(rc4key, iv, 3);
172 163
173 /* Copy rest of the WEP key (the secret part) */ 164 /* Copy rest of the WEP key (the secret part) */
174 memcpy(rc4key + 3, key->conf.key, key->conf.keylen); 165 memcpy(rc4key + 3, key, keylen);
175 166
176 /* Add room for ICV */ 167 /* Add room for ICV */
177 skb_put(skb, WEP_ICV_LEN); 168 skb_put(skb, WEP_ICV_LEN);
178 169
179 ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, klen, 170 ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, keylen + 3,
180 iv + WEP_IV_LEN, len); 171 iv + WEP_IV_LEN, len);
181 172
182 kfree(rc4key);
183
184 return 0; 173 return 0;
185} 174}
186 175
@@ -216,8 +205,9 @@ int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
216 * failure. If frame is OK, IV and ICV will be removed, i.e., decrypted payload 205 * failure. If frame is OK, IV and ICV will be removed, i.e., decrypted payload
217 * is moved to the beginning of the skb and skb length will be reduced. 206 * is moved to the beginning of the skb and skb length will be reduced.
218 */ 207 */
219int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, 208static int ieee80211_wep_decrypt(struct ieee80211_local *local,
220 struct ieee80211_key *key) 209 struct sk_buff *skb,
210 struct ieee80211_key *key)
221{ 211{
222 u32 klen; 212 u32 klen;
223 u8 *rc4key; 213 u8 *rc4key;
@@ -314,12 +304,16 @@ static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
314 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 304 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
315 305
316 if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) { 306 if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
317 if (ieee80211_wep_encrypt(tx->local, skb, tx->key)) 307 if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key,
308 tx->key->conf.keylen,
309 tx->key->conf.keyidx))
318 return -1; 310 return -1;
319 } else { 311 } else {
320 info->control.hw_key = &tx->key->conf; 312 info->control.hw_key = &tx->key->conf;
321 if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) { 313 if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) {
322 if (!ieee80211_wep_add_iv(tx->local, skb, tx->key)) 314 if (!ieee80211_wep_add_iv(tx->local, skb,
315 tx->key->conf.keylen,
316 tx->key->conf.keyidx))
323 return -1; 317 return -1;
324 } 318 }
325 } 319 }
diff --git a/net/mac80211/wep.h b/net/mac80211/wep.h
index d3f0db48314e..fe29d7e5759f 100644
--- a/net/mac80211/wep.h
+++ b/net/mac80211/wep.h
@@ -20,12 +20,11 @@ int ieee80211_wep_init(struct ieee80211_local *local);
20void ieee80211_wep_free(struct ieee80211_local *local); 20void ieee80211_wep_free(struct ieee80211_local *local);
21void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key, 21void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
22 size_t klen, u8 *data, size_t data_len); 22 size_t klen, u8 *data, size_t data_len);
23int ieee80211_wep_encrypt(struct ieee80211_local *local,
24 struct sk_buff *skb,
25 const u8 *key, int keylen, int keyidx);
23int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key, 26int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
24 size_t klen, u8 *data, size_t data_len); 27 size_t klen, u8 *data, size_t data_len);
25int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
26 struct ieee80211_key *key);
27int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
28 struct ieee80211_key *key);
29bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); 28bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
30 29
31ieee80211_rx_result 30ieee80211_rx_result
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index 1da81f456744..5acb8140ee58 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -27,29 +27,6 @@
27#include "aes_ccm.h" 27#include "aes_ccm.h"
28 28
29 29
30static int ieee80211_ioctl_siwgenie(struct net_device *dev,
31 struct iw_request_info *info,
32 struct iw_point *data, char *extra)
33{
34 struct ieee80211_sub_if_data *sdata;
35
36 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
37
38 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
39 int ret = ieee80211_sta_set_extra_ie(sdata, extra, data->length);
40 if (ret && ret != -EALREADY)
41 return ret;
42 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
43 sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME;
44 sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT;
45 if (ret != -EALREADY)
46 ieee80211_sta_req_auth(sdata);
47 return 0;
48 }
49
50 return -EOPNOTSUPP;
51}
52
53static int ieee80211_ioctl_siwfreq(struct net_device *dev, 30static int ieee80211_ioctl_siwfreq(struct net_device *dev,
54 struct iw_request_info *info, 31 struct iw_request_info *info,
55 struct iw_freq *freq, char *extra) 32 struct iw_freq *freq, char *extra)
@@ -61,16 +38,13 @@ static int ieee80211_ioctl_siwfreq(struct net_device *dev,
61 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 38 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
62 return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra); 39 return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra);
63 else if (sdata->vif.type == NL80211_IFTYPE_STATION) 40 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
64 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL; 41 return cfg80211_mgd_wext_siwfreq(dev, info, freq, extra);
65 42
66 /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */ 43 /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
67 if (freq->e == 0) { 44 if (freq->e == 0) {
68 if (freq->m < 0) { 45 if (freq->m < 0)
69 if (sdata->vif.type == NL80211_IFTYPE_STATION) 46 return -EINVAL;
70 sdata->u.mgd.flags |= 47 else
71 IEEE80211_STA_AUTO_CHANNEL_SEL;
72 return 0;
73 } else
74 chan = ieee80211_get_channel(local->hw.wiphy, 48 chan = ieee80211_get_channel(local->hw.wiphy,
75 ieee80211_channel_to_frequency(freq->m)); 49 ieee80211_channel_to_frequency(freq->m));
76 } else { 50 } else {
@@ -95,9 +69,6 @@ static int ieee80211_ioctl_siwfreq(struct net_device *dev,
95 if (local->oper_channel == chan) 69 if (local->oper_channel == chan)
96 return 0; 70 return 0;
97 71
98 if (sdata->vif.type == NL80211_IFTYPE_STATION)
99 ieee80211_sta_req_auth(sdata);
100
101 local->oper_channel = chan; 72 local->oper_channel = chan;
102 local->oper_channel_type = NL80211_CHAN_NO_HT; 73 local->oper_channel_type = NL80211_CHAN_NO_HT;
103 ieee80211_hw_config(local, 0); 74 ieee80211_hw_config(local, 0);
@@ -115,6 +86,8 @@ static int ieee80211_ioctl_giwfreq(struct net_device *dev,
115 86
116 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 87 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
117 return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); 88 return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
89 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
90 return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
118 91
119 freq->m = local->oper_channel->center_freq; 92 freq->m = local->oper_channel->center_freq;
120 freq->e = 6; 93 freq->e = 6;
@@ -128,31 +101,11 @@ static int ieee80211_ioctl_siwessid(struct net_device *dev,
128 struct iw_point *data, char *ssid) 101 struct iw_point *data, char *ssid)
129{ 102{
130 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 103 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
131 size_t len = data->length;
132 int ret;
133 104
134 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 105 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
135 return cfg80211_ibss_wext_siwessid(dev, info, data, ssid); 106 return cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
136 107 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
137 /* iwconfig uses nul termination in SSID.. */ 108 return cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
138 if (len > 0 && ssid[len - 1] == '\0')
139 len--;
140
141 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
142 if (data->flags)
143 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL;
144 else
145 sdata->u.mgd.flags |= IEEE80211_STA_AUTO_SSID_SEL;
146
147 ret = ieee80211_sta_set_ssid(sdata, ssid, len);
148 if (ret)
149 return ret;
150
151 sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME;
152 sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT;
153 ieee80211_sta_req_auth(sdata);
154 return 0;
155 }
156 109
157 return -EOPNOTSUPP; 110 return -EOPNOTSUPP;
158} 111}
@@ -162,23 +115,14 @@ static int ieee80211_ioctl_giwessid(struct net_device *dev,
162 struct iw_request_info *info, 115 struct iw_request_info *info,
163 struct iw_point *data, char *ssid) 116 struct iw_point *data, char *ssid)
164{ 117{
165 size_t len;
166 struct ieee80211_sub_if_data *sdata; 118 struct ieee80211_sub_if_data *sdata;
167 119
168 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 120 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
169 121
170 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 122 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
171 return cfg80211_ibss_wext_giwessid(dev, info, data, ssid); 123 return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
172 124 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
173 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 125 return cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
174 int res = ieee80211_sta_get_ssid(sdata, ssid, &len);
175 if (res == 0) {
176 data->length = len;
177 data->flags = 1;
178 } else
179 data->flags = 0;
180 return res;
181 }
182 126
183 return -EOPNOTSUPP; 127 return -EOPNOTSUPP;
184} 128}
@@ -193,40 +137,11 @@ static int ieee80211_ioctl_siwap(struct net_device *dev,
193 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 137 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
194 return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra); 138 return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
195 139
196 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 140 if (sdata->vif.type == NL80211_IFTYPE_STATION)
197 int ret; 141 return cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
198
199 if (is_zero_ether_addr((u8 *) &ap_addr->sa_data))
200 sdata->u.mgd.flags |= IEEE80211_STA_AUTO_BSSID_SEL |
201 IEEE80211_STA_AUTO_CHANNEL_SEL;
202 else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data))
203 sdata->u.mgd.flags |= IEEE80211_STA_AUTO_BSSID_SEL;
204 else
205 sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
206 ret = ieee80211_sta_set_bssid(sdata, (u8 *) &ap_addr->sa_data);
207 if (ret)
208 return ret;
209 sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME;
210 sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT;
211 ieee80211_sta_req_auth(sdata);
212 return 0;
213 } else if (sdata->vif.type == NL80211_IFTYPE_WDS) {
214 /*
215 * If it is necessary to update the WDS peer address
216 * while the interface is running, then we need to do
217 * more work here, namely if it is running we need to
218 * add a new and remove the old STA entry, this is
219 * normally handled by _open() and _stop().
220 */
221 if (netif_running(dev))
222 return -EBUSY;
223
224 memcpy(&sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
225 ETH_ALEN);
226
227 return 0;
228 }
229 142
143 if (sdata->vif.type == NL80211_IFTYPE_WDS)
144 return cfg80211_wds_wext_siwap(dev, info, ap_addr, extra);
230 return -EOPNOTSUPP; 145 return -EOPNOTSUPP;
231} 146}
232 147
@@ -240,326 +155,13 @@ static int ieee80211_ioctl_giwap(struct net_device *dev,
240 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 155 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
241 return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra); 156 return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
242 157
243 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
244 if (sdata->u.mgd.state == IEEE80211_STA_MLME_ASSOCIATED) {
245 ap_addr->sa_family = ARPHRD_ETHER;
246 memcpy(&ap_addr->sa_data, sdata->u.mgd.bssid, ETH_ALEN);
247 } else
248 memset(&ap_addr->sa_data, 0, ETH_ALEN);
249 return 0;
250 } else if (sdata->vif.type == NL80211_IFTYPE_WDS) {
251 ap_addr->sa_family = ARPHRD_ETHER;
252 memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN);
253 return 0;
254 }
255
256 return -EOPNOTSUPP;
257}
258
259
260static int ieee80211_ioctl_siwrate(struct net_device *dev,
261 struct iw_request_info *info,
262 struct iw_param *rate, char *extra)
263{
264 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
265 int i, err = -EINVAL;
266 u32 target_rate = rate->value / 100000;
267 struct ieee80211_sub_if_data *sdata;
268 struct ieee80211_supported_band *sband;
269
270 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
271
272 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
273
274 /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates
275 * target_rate = X, rate->fixed = 1 means only rate X
276 * target_rate = X, rate->fixed = 0 means all rates <= X */
277 sdata->max_ratectrl_rateidx = -1;
278 sdata->force_unicast_rateidx = -1;
279 if (rate->value < 0)
280 return 0;
281
282 for (i=0; i< sband->n_bitrates; i++) {
283 struct ieee80211_rate *brate = &sband->bitrates[i];
284 int this_rate = brate->bitrate;
285
286 if (target_rate == this_rate) {
287 sdata->max_ratectrl_rateidx = i;
288 if (rate->fixed)
289 sdata->force_unicast_rateidx = i;
290 err = 0;
291 break;
292 }
293 }
294 return err;
295}
296
297static int ieee80211_ioctl_giwrate(struct net_device *dev,
298 struct iw_request_info *info,
299 struct iw_param *rate, char *extra)
300{
301 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
302 struct sta_info *sta;
303 struct ieee80211_sub_if_data *sdata;
304 struct ieee80211_supported_band *sband;
305
306 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
307
308 if (sdata->vif.type != NL80211_IFTYPE_STATION)
309 return -EOPNOTSUPP;
310
311 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
312
313 rcu_read_lock();
314
315 sta = sta_info_get(local, sdata->u.mgd.bssid);
316
317 if (sta && !(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS))
318 rate->value = sband->bitrates[sta->last_tx_rate.idx].bitrate;
319 else
320 rate->value = 0;
321
322 rcu_read_unlock();
323
324 if (!sta)
325 return -ENODEV;
326
327 rate->value *= 100000;
328
329 return 0;
330}
331
332static int ieee80211_ioctl_siwpower(struct net_device *dev,
333 struct iw_request_info *info,
334 struct iw_param *wrq,
335 char *extra)
336{
337 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
338 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
339 struct ieee80211_conf *conf = &local->hw.conf;
340 int timeout = 0;
341 bool ps;
342
343 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
344 return -EOPNOTSUPP;
345
346 if (sdata->vif.type != NL80211_IFTYPE_STATION)
347 return -EINVAL;
348
349 if (wrq->disabled) {
350 ps = false;
351 timeout = 0;
352 goto set;
353 }
354
355 switch (wrq->flags & IW_POWER_MODE) {
356 case IW_POWER_ON: /* If not specified */
357 case IW_POWER_MODE: /* If set all mask */
358 case IW_POWER_ALL_R: /* If explicitely state all */
359 ps = true;
360 break;
361 default: /* Otherwise we ignore */
362 return -EINVAL;
363 }
364
365 if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT))
366 return -EINVAL;
367
368 if (wrq->flags & IW_POWER_TIMEOUT)
369 timeout = wrq->value / 1000;
370
371 set:
372 if (ps == sdata->u.mgd.powersave && timeout == conf->dynamic_ps_timeout)
373 return 0;
374
375 sdata->u.mgd.powersave = ps;
376 conf->dynamic_ps_timeout = timeout;
377
378 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
379 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
380
381 ieee80211_recalc_ps(local, -1);
382
383 return 0;
384}
385
386static int ieee80211_ioctl_giwpower(struct net_device *dev,
387 struct iw_request_info *info,
388 union iwreq_data *wrqu,
389 char *extra)
390{
391 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
392
393 wrqu->power.disabled = !sdata->u.mgd.powersave;
394
395 return 0;
396}
397
398static int ieee80211_ioctl_siwauth(struct net_device *dev,
399 struct iw_request_info *info,
400 struct iw_param *data, char *extra)
401{
402 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
403 int ret = 0;
404
405 switch (data->flags & IW_AUTH_INDEX) {
406 case IW_AUTH_WPA_VERSION:
407 case IW_AUTH_CIPHER_GROUP:
408 case IW_AUTH_WPA_ENABLED:
409 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
410 case IW_AUTH_KEY_MGMT:
411 case IW_AUTH_CIPHER_GROUP_MGMT:
412 break;
413 case IW_AUTH_CIPHER_PAIRWISE:
414 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
415 if (data->value & (IW_AUTH_CIPHER_WEP40 |
416 IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_TKIP))
417 sdata->u.mgd.flags |=
418 IEEE80211_STA_TKIP_WEP_USED;
419 else
420 sdata->u.mgd.flags &=
421 ~IEEE80211_STA_TKIP_WEP_USED;
422 }
423 break;
424 case IW_AUTH_DROP_UNENCRYPTED:
425 sdata->drop_unencrypted = !!data->value;
426 break;
427 case IW_AUTH_PRIVACY_INVOKED:
428 if (sdata->vif.type != NL80211_IFTYPE_STATION)
429 ret = -EINVAL;
430 else {
431 sdata->u.mgd.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
432 /*
433 * Privacy invoked by wpa_supplicant, store the
434 * value and allow associating to a protected
435 * network without having a key up front.
436 */
437 if (data->value)
438 sdata->u.mgd.flags |=
439 IEEE80211_STA_PRIVACY_INVOKED;
440 }
441 break;
442 case IW_AUTH_80211_AUTH_ALG:
443 if (sdata->vif.type == NL80211_IFTYPE_STATION)
444 sdata->u.mgd.auth_algs = data->value;
445 else
446 ret = -EOPNOTSUPP;
447 break;
448 case IW_AUTH_MFP:
449 if (!(sdata->local->hw.flags & IEEE80211_HW_MFP_CAPABLE)) {
450 ret = -EOPNOTSUPP;
451 break;
452 }
453 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
454 switch (data->value) {
455 case IW_AUTH_MFP_DISABLED:
456 sdata->u.mgd.mfp = IEEE80211_MFP_DISABLED;
457 break;
458 case IW_AUTH_MFP_OPTIONAL:
459 sdata->u.mgd.mfp = IEEE80211_MFP_OPTIONAL;
460 break;
461 case IW_AUTH_MFP_REQUIRED:
462 sdata->u.mgd.mfp = IEEE80211_MFP_REQUIRED;
463 break;
464 default:
465 ret = -EINVAL;
466 }
467 } else
468 ret = -EOPNOTSUPP;
469 break;
470 default:
471 ret = -EOPNOTSUPP;
472 break;
473 }
474 return ret;
475}
476
477/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
478static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
479{
480 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
481 struct iw_statistics *wstats = &local->wstats;
482 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
483 struct sta_info *sta = NULL;
484
485 rcu_read_lock();
486
487 if (sdata->vif.type == NL80211_IFTYPE_STATION) 158 if (sdata->vif.type == NL80211_IFTYPE_STATION)
488 sta = sta_info_get(local, sdata->u.mgd.bssid); 159 return cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
489
490 if (!sta) {
491 wstats->discard.fragment = 0;
492 wstats->discard.misc = 0;
493 wstats->qual.qual = 0;
494 wstats->qual.level = 0;
495 wstats->qual.noise = 0;
496 wstats->qual.updated = IW_QUAL_ALL_INVALID;
497 } else {
498 wstats->qual.updated = 0;
499 /*
500 * mirror what cfg80211 does for iwrange/scan results,
501 * otherwise userspace gets confused.
502 */
503 if (local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC |
504 IEEE80211_HW_SIGNAL_DBM)) {
505 wstats->qual.updated |= IW_QUAL_LEVEL_UPDATED;
506 wstats->qual.updated |= IW_QUAL_QUAL_UPDATED;
507 } else {
508 wstats->qual.updated |= IW_QUAL_LEVEL_INVALID;
509 wstats->qual.updated |= IW_QUAL_QUAL_INVALID;
510 }
511
512 if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) {
513 wstats->qual.level = sta->last_signal;
514 wstats->qual.qual = sta->last_signal;
515 } else if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) {
516 int sig = sta->last_signal;
517
518 wstats->qual.updated |= IW_QUAL_DBM;
519 wstats->qual.level = sig;
520 if (sig < -110)
521 sig = -110;
522 else if (sig > -40)
523 sig = -40;
524 wstats->qual.qual = sig + 110;
525 }
526
527 if (local->hw.flags & IEEE80211_HW_NOISE_DBM) {
528 /*
529 * This assumes that if driver reports noise, it also
530 * reports signal in dBm.
531 */
532 wstats->qual.noise = sta->last_noise;
533 wstats->qual.updated |= IW_QUAL_NOISE_UPDATED;
534 } else {
535 wstats->qual.updated |= IW_QUAL_NOISE_INVALID;
536 }
537 }
538 160
539 rcu_read_unlock(); 161 if (sdata->vif.type == NL80211_IFTYPE_WDS)
540 162 return cfg80211_wds_wext_giwap(dev, info, ap_addr, extra);
541 return wstats;
542}
543 163
544static int ieee80211_ioctl_giwauth(struct net_device *dev, 164 return -EOPNOTSUPP;
545 struct iw_request_info *info,
546 struct iw_param *data, char *extra)
547{
548 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
549 int ret = 0;
550
551 switch (data->flags & IW_AUTH_INDEX) {
552 case IW_AUTH_80211_AUTH_ALG:
553 if (sdata->vif.type == NL80211_IFTYPE_STATION)
554 data->value = sdata->u.mgd.auth_algs;
555 else
556 ret = -EOPNOTSUPP;
557 break;
558 default:
559 ret = -EOPNOTSUPP;
560 break;
561 }
562 return ret;
563} 165}
564 166
565 167
@@ -599,8 +201,8 @@ static const iw_handler ieee80211_handler[] =
599 (iw_handler) NULL, /* SIOCGIWNICKN */ 201 (iw_handler) NULL, /* SIOCGIWNICKN */
600 (iw_handler) NULL, /* -- hole -- */ 202 (iw_handler) NULL, /* -- hole -- */
601 (iw_handler) NULL, /* -- hole -- */ 203 (iw_handler) NULL, /* -- hole -- */
602 (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */ 204 (iw_handler) cfg80211_wext_siwrate, /* SIOCSIWRATE */
603 (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */ 205 (iw_handler) cfg80211_wext_giwrate, /* SIOCGIWRATE */
604 (iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */ 206 (iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */
605 (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */ 207 (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
606 (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */ 208 (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
@@ -611,14 +213,14 @@ static const iw_handler ieee80211_handler[] =
611 (iw_handler) cfg80211_wext_giwretry, /* SIOCGIWRETRY */ 213 (iw_handler) cfg80211_wext_giwretry, /* SIOCGIWRETRY */
612 (iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */ 214 (iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */
613 (iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */ 215 (iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */
614 (iw_handler) ieee80211_ioctl_siwpower, /* SIOCSIWPOWER */ 216 (iw_handler) cfg80211_wext_siwpower, /* SIOCSIWPOWER */
615 (iw_handler) ieee80211_ioctl_giwpower, /* SIOCGIWPOWER */ 217 (iw_handler) cfg80211_wext_giwpower, /* SIOCGIWPOWER */
616 (iw_handler) NULL, /* -- hole -- */ 218 (iw_handler) NULL, /* -- hole -- */
617 (iw_handler) NULL, /* -- hole -- */ 219 (iw_handler) NULL, /* -- hole -- */
618 (iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */ 220 (iw_handler) cfg80211_wext_siwgenie, /* SIOCSIWGENIE */
619 (iw_handler) NULL, /* SIOCGIWGENIE */ 221 (iw_handler) NULL, /* SIOCGIWGENIE */
620 (iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */ 222 (iw_handler) cfg80211_wext_siwauth, /* SIOCSIWAUTH */
621 (iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */ 223 (iw_handler) cfg80211_wext_giwauth, /* SIOCGIWAUTH */
622 (iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */ 224 (iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */
623 (iw_handler) NULL, /* SIOCGIWENCODEEXT */ 225 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
624 (iw_handler) NULL, /* SIOCSIWPMKSA */ 226 (iw_handler) NULL, /* SIOCSIWPMKSA */
@@ -629,5 +231,5 @@ const struct iw_handler_def ieee80211_iw_handler_def =
629{ 231{
630 .num_standard = ARRAY_SIZE(ieee80211_handler), 232 .num_standard = ARRAY_SIZE(ieee80211_handler),
631 .standard = (iw_handler *) ieee80211_handler, 233 .standard = (iw_handler *) ieee80211_handler,
632 .get_wireless_stats = ieee80211_get_wireless_stats, 234 .get_wireless_stats = cfg80211_wireless_stats,
633}; 235};
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 116a923b14d6..b19b7696f3a2 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -85,10 +85,8 @@ static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
85 return ieee802_1d_to_ac[skb->priority]; 85 return ieee802_1d_to_ac[skb->priority];
86} 86}
87 87
88u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb) 88void ieee80211_select_queue(struct ieee80211_local *local, struct sk_buff *skb)
89{ 89{
90 struct ieee80211_master_priv *mpriv = netdev_priv(dev);
91 struct ieee80211_local *local = mpriv->local;
92 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 90 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
93 u16 queue; 91 u16 queue;
94 u8 tid; 92 u8 tid;
@@ -113,5 +111,5 @@ u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb)
113 *p = 0; 111 *p = 0;
114 } 112 }
115 113
116 return queue; 114 skb_set_queue_mapping(skb, queue);
117} 115}
diff --git a/net/mac80211/wme.h b/net/mac80211/wme.h
index 7520d2e014dc..d4fd87ca5118 100644
--- a/net/mac80211/wme.h
+++ b/net/mac80211/wme.h
@@ -20,6 +20,7 @@
20 20
21extern const int ieee802_1d_to_ac[8]; 21extern const int ieee802_1d_to_ac[8];
22 22
23u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb); 23void ieee80211_select_queue(struct ieee80211_local *local,
24 struct sk_buff *skb);
24 25
25#endif /* _WME_H */ 26#endif /* _WME_H */
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index dcfae8884b86..70778694877b 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -122,7 +122,8 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
122 return RX_DROP_UNUSABLE; 122 return RX_DROP_UNUSABLE;
123 123
124 mac80211_ev_michael_mic_failure(rx->sdata, rx->key->conf.keyidx, 124 mac80211_ev_michael_mic_failure(rx->sdata, rx->key->conf.keyidx,
125 (void *) skb->data, NULL); 125 (void *) skb->data, NULL,
126 GFP_ATOMIC);
126 return RX_DROP_UNUSABLE; 127 return RX_DROP_UNUSABLE;
127 } 128 }
128 129