diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-14 13:37:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-14 13:37:28 -0400 |
commit | d7e9660ad9d5e0845f52848bce31bcf5cdcdea6b (patch) | |
tree | c6c67d145771187b194d79d603742b31090a59d6 /net/mac80211 | |
parent | b8cb48aae1b8c50b37dcb7710363aa69a7a0d9ca (diff) | |
parent | 13af7a6ea502fcdd4c0e3d7de6e332b102309491 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1623 commits)
netxen: update copyright
netxen: fix tx timeout recovery
netxen: fix file firmware leak
netxen: improve pci memory access
netxen: change firmware write size
tg3: Fix return ring size breakage
netxen: build fix for INET=n
cdc-phonet: autoconfigure Phonet address
Phonet: back-end for autoconfigured addresses
Phonet: fix netlink address dump error handling
ipv6: Add IFA_F_DADFAILED flag
net: Add DEVTYPE support for Ethernet based devices
mv643xx_eth.c: remove unused txq_set_wrr()
ucc_geth: Fix hangs after switching from full to half duplex
ucc_geth: Rearrange some code to avoid forward declarations
phy/marvell: Make non-aneg speed/duplex forcing work for 88E1111 PHYs
drivers/net/phy: introduce missing kfree
drivers/net/wan: introduce missing kfree
net: force bridge module(s) to be GPL
Subject: [PATCH] appletalk: Fix skb leak when ipddp interface is not loaded
...
Fixed up trivial conflicts:
- arch/x86/include/asm/socket.h
converted to <asm-generic/socket.h> in the x86 tree. The generic
header has the same new #define's, so that works out fine.
- drivers/net/tun.c
fix conflict between 89f56d1e9 ("tun: reuse struct sock fields") that
switched over to using 'tun->socket.sk' instead of the redundantly
available (and thus removed) 'tun->sk', and 2b980dbd ("lsm: Add hooks
to the TUN driver") which added a new 'tun->sk' use.
Noted in 'next' by Stephen Rothwell.
Diffstat (limited to 'net/mac80211')
40 files changed, 3385 insertions, 3170 deletions
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig index 7836ee928983..4d5543af3123 100644 --- a/net/mac80211/Kconfig +++ b/net/mac80211/Kconfig | |||
@@ -6,7 +6,6 @@ config MAC80211 | |||
6 | select CRYPTO_ARC4 | 6 | select CRYPTO_ARC4 |
7 | select CRYPTO_AES | 7 | select CRYPTO_AES |
8 | select CRC32 | 8 | select CRC32 |
9 | select WIRELESS_EXT | ||
10 | ---help--- | 9 | ---help--- |
11 | This option enables the hardware independent IEEE 802.11 | 10 | This option enables the hardware independent IEEE 802.11 |
12 | networking stack. | 11 | networking stack. |
@@ -14,24 +13,7 @@ config MAC80211 | |||
14 | comment "CFG80211 needs to be enabled for MAC80211" | 13 | comment "CFG80211 needs to be enabled for MAC80211" |
15 | depends on CFG80211=n | 14 | depends on CFG80211=n |
16 | 15 | ||
17 | config MAC80211_DEFAULT_PS | 16 | if MAC80211 != n |
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 | |||
28 | config MAC80211_DEFAULT_PS_VALUE | ||
29 | int | ||
30 | default 1 if MAC80211_DEFAULT_PS | ||
31 | default 0 | ||
32 | |||
33 | menu "Rate control algorithm selection" | ||
34 | depends on MAC80211 != n | ||
35 | 17 | ||
36 | config MAC80211_RC_PID | 18 | config MAC80211_RC_PID |
37 | bool "PID controller based rate control algorithm" if EMBEDDED | 19 | bool "PID controller based rate control algorithm" if EMBEDDED |
@@ -78,17 +60,17 @@ config MAC80211_RC_DEFAULT | |||
78 | default "pid" if MAC80211_RC_DEFAULT_PID | 60 | default "pid" if MAC80211_RC_DEFAULT_PID |
79 | default "" | 61 | default "" |
80 | 62 | ||
81 | endmenu | 63 | endif |
82 | 64 | ||
83 | config MAC80211_MESH | 65 | config MAC80211_MESH |
84 | bool "Enable mac80211 mesh networking (pre-802.11s) support" | 66 | bool "Enable mac80211 mesh networking (pre-802.11s) support" |
85 | depends on MAC80211 && EXPERIMENTAL | 67 | depends on MAC80211 && EXPERIMENTAL |
86 | depends on BROKEN | ||
87 | ---help--- | 68 | ---help--- |
88 | This options enables support of Draft 802.11s mesh networking. | 69 | This options enables support of Draft 802.11s mesh networking. |
89 | The implementation is based on Draft 1.08 of the Mesh Networking | 70 | The implementation is based on Draft 2.08 of the Mesh Networking |
90 | amendment. For more information visit http://o11s.org/. | 71 | amendment. However, no compliance with that draft is claimed or even |
91 | 72 | possible, as drafts leave a number of identifiers to be defined after | |
73 | ratification. For more information visit http://o11s.org/. | ||
92 | 74 | ||
93 | config MAC80211_LEDS | 75 | config MAC80211_LEDS |
94 | bool "Enable LED triggers" | 76 | bool "Enable LED triggers" |
@@ -222,3 +204,15 @@ config MAC80211_DEBUG_COUNTERS | |||
222 | and show them in debugfs. | 204 | and show them in debugfs. |
223 | 205 | ||
224 | If unsure, say N. | 206 | If unsure, say N. |
207 | |||
208 | config MAC80211_DRIVER_API_TRACER | ||
209 | bool "Driver API tracer" | ||
210 | depends on MAC80211_DEBUG_MENU | ||
211 | depends on EVENT_TRACING | ||
212 | help | ||
213 | Say Y here to make mac80211 register with the ftrace | ||
214 | framework for the driver API -- you can see which | ||
215 | driver methods it is calling then by looking at the | ||
216 | trace. | ||
217 | |||
218 | If unsure, say N. | ||
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index 0e3ab88bb706..9f3cf7129324 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile | |||
@@ -3,7 +3,6 @@ obj-$(CONFIG_MAC80211) += mac80211.o | |||
3 | # mac80211 objects | 3 | # mac80211 objects |
4 | mac80211-y := \ | 4 | mac80211-y := \ |
5 | main.o \ | 5 | main.o \ |
6 | wext.o \ | ||
7 | sta_info.o \ | 6 | sta_info.o \ |
8 | wep.o \ | 7 | wep.o \ |
9 | wpa.o \ | 8 | wpa.o \ |
@@ -41,6 +40,9 @@ mac80211-$(CONFIG_MAC80211_MESH) += \ | |||
41 | 40 | ||
42 | mac80211-$(CONFIG_PM) += pm.o | 41 | mac80211-$(CONFIG_PM) += pm.o |
43 | 42 | ||
43 | mac80211-$(CONFIG_MAC80211_DRIVER_API_TRACER) += driver-trace.o | ||
44 | CFLAGS_driver-trace.o := -I$(src) | ||
45 | |||
44 | # objects for PID algorithm | 46 | # objects for PID algorithm |
45 | rc80211_pid-y := rc80211_pid_algo.o | 47 | rc80211_pid-y := rc80211_pid_algo.o |
46 | rc80211_pid-$(CONFIG_MAC80211_DEBUGFS) += rc80211_pid_debugfs.o | 48 | rc80211_pid-$(CONFIG_MAC80211_DEBUGFS) += rc80211_pid_debugfs.o |
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c index a24e59816b93..bd765f30dba2 100644 --- a/net/mac80211/agg-tx.c +++ b/net/mac80211/agg-tx.c | |||
@@ -391,9 +391,6 @@ static void ieee80211_agg_splice_packets(struct ieee80211_local *local, | |||
391 | 391 | ||
392 | if (!skb_queue_empty(&sta->ampdu_mlme.tid_tx[tid]->pending)) { | 392 | if (!skb_queue_empty(&sta->ampdu_mlme.tid_tx[tid]->pending)) { |
393 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 393 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
394 | /* mark queue as pending, it is stopped already */ | ||
395 | __set_bit(IEEE80211_QUEUE_STOP_REASON_PENDING, | ||
396 | &local->queue_stop_reasons[queue]); | ||
397 | /* copy over remaining packets */ | 394 | /* copy over remaining packets */ |
398 | skb_queue_splice_tail_init( | 395 | skb_queue_splice_tail_init( |
399 | &sta->ampdu_mlme.tid_tx[tid]->pending, | 396 | &sta->ampdu_mlme.tid_tx[tid]->pending, |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 3f47276caeb8..5608f6c68413 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -57,36 +57,21 @@ static int ieee80211_add_iface(struct wiphy *wiphy, char *name, | |||
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | 59 | ||
60 | static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) | 60 | static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev) |
61 | { | 61 | { |
62 | struct net_device *dev; | 62 | ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev)); |
63 | struct ieee80211_sub_if_data *sdata; | ||
64 | |||
65 | /* we're under RTNL */ | ||
66 | dev = __dev_get_by_index(&init_net, ifindex); | ||
67 | if (!dev) | ||
68 | return -ENODEV; | ||
69 | |||
70 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
71 | |||
72 | ieee80211_if_remove(sdata); | ||
73 | 63 | ||
74 | return 0; | 64 | return 0; |
75 | } | 65 | } |
76 | 66 | ||
77 | static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, | 67 | static int ieee80211_change_iface(struct wiphy *wiphy, |
68 | struct net_device *dev, | ||
78 | enum nl80211_iftype type, u32 *flags, | 69 | enum nl80211_iftype type, u32 *flags, |
79 | struct vif_params *params) | 70 | struct vif_params *params) |
80 | { | 71 | { |
81 | struct net_device *dev; | ||
82 | struct ieee80211_sub_if_data *sdata; | 72 | struct ieee80211_sub_if_data *sdata; |
83 | int ret; | 73 | int ret; |
84 | 74 | ||
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)) | 75 | if (!nl80211_type_check(type)) |
91 | return -EINVAL; | 76 | return -EINVAL; |
92 | 77 | ||
@@ -338,6 +323,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
338 | { | 323 | { |
339 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 324 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
340 | 325 | ||
326 | sinfo->generation = sdata->local->sta_generation; | ||
327 | |||
341 | sinfo->filled = STATION_INFO_INACTIVE_TIME | | 328 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
342 | STATION_INFO_RX_BYTES | | 329 | STATION_INFO_RX_BYTES | |
343 | STATION_INFO_TX_BYTES | | 330 | STATION_INFO_TX_BYTES | |
@@ -924,6 +911,8 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, | |||
924 | else | 911 | else |
925 | memset(next_hop, 0, ETH_ALEN); | 912 | memset(next_hop, 0, ETH_ALEN); |
926 | 913 | ||
914 | pinfo->generation = mesh_paths_generation; | ||
915 | |||
927 | pinfo->filled = MPATH_INFO_FRAME_QLEN | | 916 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
928 | MPATH_INFO_DSN | | 917 | MPATH_INFO_DSN | |
929 | MPATH_INFO_METRIC | | 918 | MPATH_INFO_METRIC | |
@@ -1177,123 +1166,29 @@ static int ieee80211_scan(struct wiphy *wiphy, | |||
1177 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, | 1166 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
1178 | struct cfg80211_auth_request *req) | 1167 | struct cfg80211_auth_request *req) |
1179 | { | 1168 | { |
1180 | struct ieee80211_sub_if_data *sdata; | 1169 | 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 | } | 1170 | } |
1231 | 1171 | ||
1232 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, | 1172 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, |
1233 | struct cfg80211_assoc_request *req) | 1173 | struct cfg80211_assoc_request *req) |
1234 | { | 1174 | { |
1235 | struct ieee80211_sub_if_data *sdata; | 1175 | 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 | } | 1176 | } |
1280 | 1177 | ||
1281 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, | 1178 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, |
1282 | struct cfg80211_deauth_request *req) | 1179 | struct cfg80211_deauth_request *req, |
1180 | void *cookie) | ||
1283 | { | 1181 | { |
1284 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1182 | return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), |
1285 | 1183 | req, cookie); | |
1286 | /* TODO: req->ie, req->peer_addr */ | ||
1287 | return ieee80211_sta_deauthenticate(sdata, req->reason_code); | ||
1288 | } | 1184 | } |
1289 | 1185 | ||
1290 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, | 1186 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, |
1291 | struct cfg80211_disassoc_request *req) | 1187 | struct cfg80211_disassoc_request *req, |
1188 | void *cookie) | ||
1292 | { | 1189 | { |
1293 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1190 | return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), |
1294 | 1191 | req, cookie); | |
1295 | /* TODO: req->ie, req->peer_addr */ | ||
1296 | return ieee80211_sta_disassociate(sdata, req->reason_code); | ||
1297 | } | 1192 | } |
1298 | 1193 | ||
1299 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, | 1194 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
@@ -1374,6 +1269,16 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm) | |||
1374 | return 0; | 1269 | return 0; |
1375 | } | 1270 | } |
1376 | 1271 | ||
1272 | static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev, | ||
1273 | u8 *addr) | ||
1274 | { | ||
1275 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1276 | |||
1277 | memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN); | ||
1278 | |||
1279 | return 0; | ||
1280 | } | ||
1281 | |||
1377 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) | 1282 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) |
1378 | { | 1283 | { |
1379 | struct ieee80211_local *local = wiphy_priv(wiphy); | 1284 | struct ieee80211_local *local = wiphy_priv(wiphy); |
@@ -1381,6 +1286,85 @@ static void ieee80211_rfkill_poll(struct wiphy *wiphy) | |||
1381 | drv_rfkill_poll(local); | 1286 | drv_rfkill_poll(local); |
1382 | } | 1287 | } |
1383 | 1288 | ||
1289 | #ifdef CONFIG_NL80211_TESTMODE | ||
1290 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len) | ||
1291 | { | ||
1292 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
1293 | |||
1294 | if (!local->ops->testmode_cmd) | ||
1295 | return -EOPNOTSUPP; | ||
1296 | |||
1297 | return local->ops->testmode_cmd(&local->hw, data, len); | ||
1298 | } | ||
1299 | #endif | ||
1300 | |||
1301 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, | ||
1302 | bool enabled, int timeout) | ||
1303 | { | ||
1304 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1305 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
1306 | struct ieee80211_conf *conf = &local->hw.conf; | ||
1307 | |||
1308 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) | ||
1309 | return -EOPNOTSUPP; | ||
1310 | |||
1311 | if (enabled == sdata->u.mgd.powersave && | ||
1312 | timeout == conf->dynamic_ps_timeout) | ||
1313 | return 0; | ||
1314 | |||
1315 | sdata->u.mgd.powersave = enabled; | ||
1316 | conf->dynamic_ps_timeout = timeout; | ||
1317 | |||
1318 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) | ||
1319 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | ||
1320 | |||
1321 | ieee80211_recalc_ps(local, -1); | ||
1322 | |||
1323 | return 0; | ||
1324 | } | ||
1325 | |||
1326 | static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, | ||
1327 | struct net_device *dev, | ||
1328 | const u8 *addr, | ||
1329 | const struct cfg80211_bitrate_mask *mask) | ||
1330 | { | ||
1331 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1332 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
1333 | int i, err = -EINVAL; | ||
1334 | u32 target_rate; | ||
1335 | struct ieee80211_supported_band *sband; | ||
1336 | |||
1337 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
1338 | |||
1339 | /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates | ||
1340 | * target_rate = X, rate->fixed = 1 means only rate X | ||
1341 | * target_rate = X, rate->fixed = 0 means all rates <= X */ | ||
1342 | sdata->max_ratectrl_rateidx = -1; | ||
1343 | sdata->force_unicast_rateidx = -1; | ||
1344 | |||
1345 | if (mask->fixed) | ||
1346 | target_rate = mask->fixed / 100; | ||
1347 | else if (mask->maxrate) | ||
1348 | target_rate = mask->maxrate / 100; | ||
1349 | else | ||
1350 | return 0; | ||
1351 | |||
1352 | for (i=0; i< sband->n_bitrates; i++) { | ||
1353 | struct ieee80211_rate *brate = &sband->bitrates[i]; | ||
1354 | int this_rate = brate->bitrate; | ||
1355 | |||
1356 | if (target_rate == this_rate) { | ||
1357 | sdata->max_ratectrl_rateidx = i; | ||
1358 | if (mask->fixed) | ||
1359 | sdata->force_unicast_rateidx = i; | ||
1360 | err = 0; | ||
1361 | break; | ||
1362 | } | ||
1363 | } | ||
1364 | |||
1365 | return err; | ||
1366 | } | ||
1367 | |||
1384 | struct cfg80211_ops mac80211_config_ops = { | 1368 | struct cfg80211_ops mac80211_config_ops = { |
1385 | .add_virtual_intf = ieee80211_add_iface, | 1369 | .add_virtual_intf = ieee80211_add_iface, |
1386 | .del_virtual_intf = ieee80211_del_iface, | 1370 | .del_virtual_intf = ieee80211_del_iface, |
@@ -1422,5 +1406,9 @@ struct cfg80211_ops mac80211_config_ops = { | |||
1422 | .set_wiphy_params = ieee80211_set_wiphy_params, | 1406 | .set_wiphy_params = ieee80211_set_wiphy_params, |
1423 | .set_tx_power = ieee80211_set_tx_power, | 1407 | .set_tx_power = ieee80211_set_tx_power, |
1424 | .get_tx_power = ieee80211_get_tx_power, | 1408 | .get_tx_power = ieee80211_get_tx_power, |
1409 | .set_wds_peer = ieee80211_set_wds_peer, | ||
1425 | .rfkill_poll = ieee80211_rfkill_poll, | 1410 | .rfkill_poll = ieee80211_rfkill_poll, |
1411 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) | ||
1412 | .set_power_mgmt = ieee80211_set_power_mgmt, | ||
1413 | .set_bitrate_mask = ieee80211_set_bitrate_mask, | ||
1426 | }; | 1414 | }; |
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..61234e79022b 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); | |||
95 | IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC); | 95 | IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC); |
96 | 96 | ||
97 | /* STA attributes */ | 97 | /* STA attributes */ |
98 | IEEE80211_IF_FILE(state, u.mgd.state, DEC); | ||
99 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); | 98 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); |
100 | IEEE80211_IF_FILE(prev_bssid, u.mgd.prev_bssid, MAC); | ||
101 | IEEE80211_IF_FILE(ssid_len, u.mgd.ssid_len, SIZE); | ||
102 | IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); | 99 | IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); |
103 | IEEE80211_IF_FILE(ap_capab, u.mgd.ap_capab, HEX); | ||
104 | IEEE80211_IF_FILE(capab, u.mgd.capab, HEX); | 100 | IEEE80211_IF_FILE(capab, u.mgd.capab, HEX); |
105 | IEEE80211_IF_FILE(extra_ie_len, u.mgd.extra_ie_len, SIZE); | ||
106 | IEEE80211_IF_FILE(auth_tries, u.mgd.auth_tries, DEC); | ||
107 | IEEE80211_IF_FILE(assoc_tries, u.mgd.assoc_tries, DEC); | ||
108 | IEEE80211_IF_FILE(auth_algs, u.mgd.auth_algs, HEX); | ||
109 | IEEE80211_IF_FILE(auth_alg, u.mgd.auth_alg, DEC); | ||
110 | IEEE80211_IF_FILE(auth_transaction, u.mgd.auth_transaction, DEC); | ||
111 | |||
112 | static 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 */ |
127 | IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); | 103 | IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); |
@@ -140,6 +116,8 @@ IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC); | |||
140 | 116 | ||
141 | #ifdef CONFIG_MAC80211_MESH | 117 | #ifdef CONFIG_MAC80211_MESH |
142 | /* Mesh stats attributes */ | 118 | /* Mesh stats attributes */ |
119 | IEEE80211_IF_FILE(fwded_mcast, u.mesh.mshstats.fwded_mcast, DEC); | ||
120 | IEEE80211_IF_FILE(fwded_unicast, u.mesh.mshstats.fwded_unicast, DEC); | ||
143 | IEEE80211_IF_FILE(fwded_frames, u.mesh.mshstats.fwded_frames, DEC); | 121 | IEEE80211_IF_FILE(fwded_frames, u.mesh.mshstats.fwded_frames, DEC); |
144 | IEEE80211_IF_FILE(dropped_frames_ttl, u.mesh.mshstats.dropped_frames_ttl, DEC); | 122 | IEEE80211_IF_FILE(dropped_frames_ttl, u.mesh.mshstats.dropped_frames_ttl, DEC); |
145 | IEEE80211_IF_FILE(dropped_frames_no_route, | 123 | IEEE80211_IF_FILE(dropped_frames_no_route, |
@@ -184,20 +162,9 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata) | |||
184 | DEBUGFS_ADD(force_unicast_rateidx, sta); | 162 | DEBUGFS_ADD(force_unicast_rateidx, sta); |
185 | DEBUGFS_ADD(max_ratectrl_rateidx, sta); | 163 | DEBUGFS_ADD(max_ratectrl_rateidx, sta); |
186 | 164 | ||
187 | DEBUGFS_ADD(state, sta); | ||
188 | DEBUGFS_ADD(bssid, sta); | 165 | DEBUGFS_ADD(bssid, sta); |
189 | DEBUGFS_ADD(prev_bssid, sta); | ||
190 | DEBUGFS_ADD(ssid_len, sta); | ||
191 | DEBUGFS_ADD(aid, sta); | 166 | DEBUGFS_ADD(aid, sta); |
192 | DEBUGFS_ADD(ap_capab, sta); | ||
193 | DEBUGFS_ADD(capab, sta); | 167 | 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 | } | 168 | } |
202 | 169 | ||
203 | static void add_ap_files(struct ieee80211_sub_if_data *sdata) | 170 | static void add_ap_files(struct ieee80211_sub_if_data *sdata) |
@@ -240,6 +207,8 @@ static void add_mesh_stats(struct ieee80211_sub_if_data *sdata) | |||
240 | { | 207 | { |
241 | sdata->mesh_stats_dir = debugfs_create_dir("mesh_stats", | 208 | sdata->mesh_stats_dir = debugfs_create_dir("mesh_stats", |
242 | sdata->debugfsdir); | 209 | sdata->debugfsdir); |
210 | MESHSTATS_ADD(fwded_mcast); | ||
211 | MESHSTATS_ADD(fwded_unicast); | ||
243 | MESHSTATS_ADD(fwded_frames); | 212 | MESHSTATS_ADD(fwded_frames); |
244 | MESHSTATS_ADD(dropped_frames_ttl); | 213 | MESHSTATS_ADD(dropped_frames_ttl); |
245 | MESHSTATS_ADD(dropped_frames_no_route); | 214 | MESHSTATS_ADD(dropped_frames_no_route); |
@@ -317,20 +286,9 @@ static void del_sta_files(struct ieee80211_sub_if_data *sdata) | |||
317 | DEBUGFS_DEL(force_unicast_rateidx, sta); | 286 | DEBUGFS_DEL(force_unicast_rateidx, sta); |
318 | DEBUGFS_DEL(max_ratectrl_rateidx, sta); | 287 | DEBUGFS_DEL(max_ratectrl_rateidx, sta); |
319 | 288 | ||
320 | DEBUGFS_DEL(state, sta); | ||
321 | DEBUGFS_DEL(bssid, sta); | 289 | DEBUGFS_DEL(bssid, sta); |
322 | DEBUGFS_DEL(prev_bssid, sta); | ||
323 | DEBUGFS_DEL(ssid_len, sta); | ||
324 | DEBUGFS_DEL(aid, sta); | 290 | DEBUGFS_DEL(aid, sta); |
325 | DEBUGFS_DEL(ap_capab, sta); | ||
326 | DEBUGFS_DEL(capab, sta); | 291 | 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 | } | 292 | } |
335 | 293 | ||
336 | static void del_ap_files(struct ieee80211_sub_if_data *sdata) | 294 | static void del_ap_files(struct ieee80211_sub_if_data *sdata) |
@@ -373,6 +331,8 @@ static void del_monitor_files(struct ieee80211_sub_if_data *sdata) | |||
373 | 331 | ||
374 | static void del_mesh_stats(struct ieee80211_sub_if_data *sdata) | 332 | static void del_mesh_stats(struct ieee80211_sub_if_data *sdata) |
375 | { | 333 | { |
334 | MESHSTATS_DEL(fwded_mcast); | ||
335 | MESHSTATS_DEL(fwded_unicast); | ||
376 | MESHSTATS_DEL(fwded_frames); | 336 | MESHSTATS_DEL(fwded_frames); |
377 | MESHSTATS_DEL(dropped_frames_ttl); | 337 | MESHSTATS_DEL(dropped_frames_ttl); |
378 | MESHSTATS_DEL(dropped_frames_no_route); | 338 | MESHSTATS_DEL(dropped_frames_no_route); |
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); | |||
120 | static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, | 120 | static 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 | ||
208 | void ieee80211_sta_debugfs_remove(struct sta_info *sta) | 217 | void 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..020a94a31106 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 | ||
7 | static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb) | 8 | static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb) |
8 | { | 9 | { |
@@ -11,29 +12,49 @@ static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb) | |||
11 | 12 | ||
12 | static inline int drv_start(struct ieee80211_local *local) | 13 | static inline int drv_start(struct ieee80211_local *local) |
13 | { | 14 | { |
14 | return local->ops->start(&local->hw); | 15 | int ret; |
16 | |||
17 | local->started = true; | ||
18 | smp_mb(); | ||
19 | ret = local->ops->start(&local->hw); | ||
20 | trace_drv_start(local, ret); | ||
21 | return ret; | ||
15 | } | 22 | } |
16 | 23 | ||
17 | static inline void drv_stop(struct ieee80211_local *local) | 24 | static inline void drv_stop(struct ieee80211_local *local) |
18 | { | 25 | { |
19 | local->ops->stop(&local->hw); | 26 | local->ops->stop(&local->hw); |
27 | trace_drv_stop(local); | ||
28 | |||
29 | /* sync away all work on the tasklet before clearing started */ | ||
30 | tasklet_disable(&local->tasklet); | ||
31 | tasklet_enable(&local->tasklet); | ||
32 | |||
33 | barrier(); | ||
34 | |||
35 | local->started = false; | ||
20 | } | 36 | } |
21 | 37 | ||
22 | static inline int drv_add_interface(struct ieee80211_local *local, | 38 | static inline int drv_add_interface(struct ieee80211_local *local, |
23 | struct ieee80211_if_init_conf *conf) | 39 | struct ieee80211_if_init_conf *conf) |
24 | { | 40 | { |
25 | return local->ops->add_interface(&local->hw, conf); | 41 | int ret = local->ops->add_interface(&local->hw, conf); |
42 | trace_drv_add_interface(local, conf->mac_addr, conf->vif, ret); | ||
43 | return ret; | ||
26 | } | 44 | } |
27 | 45 | ||
28 | static inline void drv_remove_interface(struct ieee80211_local *local, | 46 | static inline void drv_remove_interface(struct ieee80211_local *local, |
29 | struct ieee80211_if_init_conf *conf) | 47 | struct ieee80211_if_init_conf *conf) |
30 | { | 48 | { |
31 | local->ops->remove_interface(&local->hw, conf); | 49 | local->ops->remove_interface(&local->hw, conf); |
50 | trace_drv_remove_interface(local, conf->mac_addr, conf->vif); | ||
32 | } | 51 | } |
33 | 52 | ||
34 | static inline int drv_config(struct ieee80211_local *local, u32 changed) | 53 | static inline int drv_config(struct ieee80211_local *local, u32 changed) |
35 | { | 54 | { |
36 | return local->ops->config(&local->hw, changed); | 55 | int ret = local->ops->config(&local->hw, changed); |
56 | trace_drv_config(local, changed, ret); | ||
57 | return ret; | ||
37 | } | 58 | } |
38 | 59 | ||
39 | static inline void drv_bss_info_changed(struct ieee80211_local *local, | 60 | static inline void drv_bss_info_changed(struct ieee80211_local *local, |
@@ -43,24 +64,45 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local, | |||
43 | { | 64 | { |
44 | if (local->ops->bss_info_changed) | 65 | if (local->ops->bss_info_changed) |
45 | local->ops->bss_info_changed(&local->hw, vif, info, changed); | 66 | local->ops->bss_info_changed(&local->hw, vif, info, changed); |
67 | trace_drv_bss_info_changed(local, vif, info, changed); | ||
68 | } | ||
69 | |||
70 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, | ||
71 | int mc_count, | ||
72 | struct dev_addr_list *mc_list) | ||
73 | { | ||
74 | u64 ret = 0; | ||
75 | |||
76 | if (local->ops->prepare_multicast) | ||
77 | ret = local->ops->prepare_multicast(&local->hw, mc_count, | ||
78 | mc_list); | ||
79 | |||
80 | trace_drv_prepare_multicast(local, mc_count, ret); | ||
81 | |||
82 | return ret; | ||
46 | } | 83 | } |
47 | 84 | ||
48 | static inline void drv_configure_filter(struct ieee80211_local *local, | 85 | static inline void drv_configure_filter(struct ieee80211_local *local, |
49 | unsigned int changed_flags, | 86 | unsigned int changed_flags, |
50 | unsigned int *total_flags, | 87 | unsigned int *total_flags, |
51 | int mc_count, | 88 | u64 multicast) |
52 | struct dev_addr_list *mc_list) | ||
53 | { | 89 | { |
90 | might_sleep(); | ||
91 | |||
54 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, | 92 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
55 | mc_count, mc_list); | 93 | multicast); |
94 | trace_drv_configure_filter(local, changed_flags, total_flags, | ||
95 | multicast); | ||
56 | } | 96 | } |
57 | 97 | ||
58 | static inline int drv_set_tim(struct ieee80211_local *local, | 98 | static inline int drv_set_tim(struct ieee80211_local *local, |
59 | struct ieee80211_sta *sta, bool set) | 99 | struct ieee80211_sta *sta, bool set) |
60 | { | 100 | { |
101 | int ret = 0; | ||
61 | if (local->ops->set_tim) | 102 | if (local->ops->set_tim) |
62 | return local->ops->set_tim(&local->hw, sta, set); | 103 | ret = local->ops->set_tim(&local->hw, sta, set); |
63 | return 0; | 104 | trace_drv_set_tim(local, sta, set, ret); |
105 | return ret; | ||
64 | } | 106 | } |
65 | 107 | ||
66 | static inline int drv_set_key(struct ieee80211_local *local, | 108 | static inline int drv_set_key(struct ieee80211_local *local, |
@@ -68,7 +110,9 @@ static inline int drv_set_key(struct ieee80211_local *local, | |||
68 | struct ieee80211_sta *sta, | 110 | struct ieee80211_sta *sta, |
69 | struct ieee80211_key_conf *key) | 111 | struct ieee80211_key_conf *key) |
70 | { | 112 | { |
71 | return local->ops->set_key(&local->hw, cmd, vif, sta, key); | 113 | int ret = local->ops->set_key(&local->hw, cmd, vif, sta, key); |
114 | trace_drv_set_key(local, cmd, vif, sta, key, ret); | ||
115 | return ret; | ||
72 | } | 116 | } |
73 | 117 | ||
74 | static inline void drv_update_tkip_key(struct ieee80211_local *local, | 118 | static inline void drv_update_tkip_key(struct ieee80211_local *local, |
@@ -79,32 +123,41 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local, | |||
79 | if (local->ops->update_tkip_key) | 123 | if (local->ops->update_tkip_key) |
80 | local->ops->update_tkip_key(&local->hw, conf, address, | 124 | local->ops->update_tkip_key(&local->hw, conf, address, |
81 | iv32, phase1key); | 125 | iv32, phase1key); |
126 | trace_drv_update_tkip_key(local, conf, address, iv32); | ||
82 | } | 127 | } |
83 | 128 | ||
84 | static inline int drv_hw_scan(struct ieee80211_local *local, | 129 | static inline int drv_hw_scan(struct ieee80211_local *local, |
85 | struct cfg80211_scan_request *req) | 130 | struct cfg80211_scan_request *req) |
86 | { | 131 | { |
87 | return local->ops->hw_scan(&local->hw, req); | 132 | int ret = local->ops->hw_scan(&local->hw, req); |
133 | trace_drv_hw_scan(local, req, ret); | ||
134 | return ret; | ||
88 | } | 135 | } |
89 | 136 | ||
90 | static inline void drv_sw_scan_start(struct ieee80211_local *local) | 137 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
91 | { | 138 | { |
92 | if (local->ops->sw_scan_start) | 139 | if (local->ops->sw_scan_start) |
93 | local->ops->sw_scan_start(&local->hw); | 140 | local->ops->sw_scan_start(&local->hw); |
141 | trace_drv_sw_scan_start(local); | ||
94 | } | 142 | } |
95 | 143 | ||
96 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) | 144 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) |
97 | { | 145 | { |
98 | if (local->ops->sw_scan_complete) | 146 | if (local->ops->sw_scan_complete) |
99 | local->ops->sw_scan_complete(&local->hw); | 147 | local->ops->sw_scan_complete(&local->hw); |
148 | trace_drv_sw_scan_complete(local); | ||
100 | } | 149 | } |
101 | 150 | ||
102 | static inline int drv_get_stats(struct ieee80211_local *local, | 151 | static inline int drv_get_stats(struct ieee80211_local *local, |
103 | struct ieee80211_low_level_stats *stats) | 152 | struct ieee80211_low_level_stats *stats) |
104 | { | 153 | { |
105 | if (!local->ops->get_stats) | 154 | int ret = -EOPNOTSUPP; |
106 | return -EOPNOTSUPP; | 155 | |
107 | return local->ops->get_stats(&local->hw, stats); | 156 | if (local->ops->get_stats) |
157 | ret = local->ops->get_stats(&local->hw, stats); | ||
158 | trace_drv_get_stats(local, stats, ret); | ||
159 | |||
160 | return ret; | ||
108 | } | 161 | } |
109 | 162 | ||
110 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, | 163 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, |
@@ -112,14 +165,17 @@ static inline void drv_get_tkip_seq(struct ieee80211_local *local, | |||
112 | { | 165 | { |
113 | if (local->ops->get_tkip_seq) | 166 | if (local->ops->get_tkip_seq) |
114 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); | 167 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); |
168 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); | ||
115 | } | 169 | } |
116 | 170 | ||
117 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, | 171 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
118 | u32 value) | 172 | u32 value) |
119 | { | 173 | { |
174 | int ret = 0; | ||
120 | if (local->ops->set_rts_threshold) | 175 | if (local->ops->set_rts_threshold) |
121 | return local->ops->set_rts_threshold(&local->hw, value); | 176 | ret = local->ops->set_rts_threshold(&local->hw, value); |
122 | return 0; | 177 | trace_drv_set_rts_threshold(local, value, ret); |
178 | return ret; | ||
123 | } | 179 | } |
124 | 180 | ||
125 | static inline void drv_sta_notify(struct ieee80211_local *local, | 181 | static inline void drv_sta_notify(struct ieee80211_local *local, |
@@ -129,46 +185,57 @@ static inline void drv_sta_notify(struct ieee80211_local *local, | |||
129 | { | 185 | { |
130 | if (local->ops->sta_notify) | 186 | if (local->ops->sta_notify) |
131 | local->ops->sta_notify(&local->hw, vif, cmd, sta); | 187 | local->ops->sta_notify(&local->hw, vif, cmd, sta); |
188 | trace_drv_sta_notify(local, vif, cmd, sta); | ||
132 | } | 189 | } |
133 | 190 | ||
134 | static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, | 191 | static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, |
135 | const struct ieee80211_tx_queue_params *params) | 192 | const struct ieee80211_tx_queue_params *params) |
136 | { | 193 | { |
194 | int ret = -EOPNOTSUPP; | ||
137 | if (local->ops->conf_tx) | 195 | if (local->ops->conf_tx) |
138 | return local->ops->conf_tx(&local->hw, queue, params); | 196 | ret = local->ops->conf_tx(&local->hw, queue, params); |
139 | return -EOPNOTSUPP; | 197 | trace_drv_conf_tx(local, queue, params, ret); |
198 | return ret; | ||
140 | } | 199 | } |
141 | 200 | ||
142 | static inline int drv_get_tx_stats(struct ieee80211_local *local, | 201 | static inline int drv_get_tx_stats(struct ieee80211_local *local, |
143 | struct ieee80211_tx_queue_stats *stats) | 202 | struct ieee80211_tx_queue_stats *stats) |
144 | { | 203 | { |
145 | return local->ops->get_tx_stats(&local->hw, stats); | 204 | int ret = local->ops->get_tx_stats(&local->hw, stats); |
205 | trace_drv_get_tx_stats(local, stats, ret); | ||
206 | return ret; | ||
146 | } | 207 | } |
147 | 208 | ||
148 | static inline u64 drv_get_tsf(struct ieee80211_local *local) | 209 | static inline u64 drv_get_tsf(struct ieee80211_local *local) |
149 | { | 210 | { |
211 | u64 ret = -1ULL; | ||
150 | if (local->ops->get_tsf) | 212 | if (local->ops->get_tsf) |
151 | return local->ops->get_tsf(&local->hw); | 213 | ret = local->ops->get_tsf(&local->hw); |
152 | return -1ULL; | 214 | trace_drv_get_tsf(local, ret); |
215 | return ret; | ||
153 | } | 216 | } |
154 | 217 | ||
155 | static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) | 218 | static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) |
156 | { | 219 | { |
157 | if (local->ops->set_tsf) | 220 | if (local->ops->set_tsf) |
158 | local->ops->set_tsf(&local->hw, tsf); | 221 | local->ops->set_tsf(&local->hw, tsf); |
222 | trace_drv_set_tsf(local, tsf); | ||
159 | } | 223 | } |
160 | 224 | ||
161 | static inline void drv_reset_tsf(struct ieee80211_local *local) | 225 | static inline void drv_reset_tsf(struct ieee80211_local *local) |
162 | { | 226 | { |
163 | if (local->ops->reset_tsf) | 227 | if (local->ops->reset_tsf) |
164 | local->ops->reset_tsf(&local->hw); | 228 | local->ops->reset_tsf(&local->hw); |
229 | trace_drv_reset_tsf(local); | ||
165 | } | 230 | } |
166 | 231 | ||
167 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) | 232 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) |
168 | { | 233 | { |
234 | int ret = 1; | ||
169 | if (local->ops->tx_last_beacon) | 235 | if (local->ops->tx_last_beacon) |
170 | return local->ops->tx_last_beacon(&local->hw); | 236 | ret = local->ops->tx_last_beacon(&local->hw); |
171 | return 1; | 237 | trace_drv_tx_last_beacon(local, ret); |
238 | return ret; | ||
172 | } | 239 | } |
173 | 240 | ||
174 | static inline int drv_ampdu_action(struct ieee80211_local *local, | 241 | static inline int drv_ampdu_action(struct ieee80211_local *local, |
@@ -176,10 +243,12 @@ static inline int drv_ampdu_action(struct ieee80211_local *local, | |||
176 | struct ieee80211_sta *sta, u16 tid, | 243 | struct ieee80211_sta *sta, u16 tid, |
177 | u16 *ssn) | 244 | u16 *ssn) |
178 | { | 245 | { |
246 | int ret = -EOPNOTSUPP; | ||
179 | if (local->ops->ampdu_action) | 247 | if (local->ops->ampdu_action) |
180 | return local->ops->ampdu_action(&local->hw, action, | 248 | ret = local->ops->ampdu_action(&local->hw, action, |
181 | sta, tid, ssn); | 249 | sta, tid, ssn); |
182 | return -EOPNOTSUPP; | 250 | trace_drv_ampdu_action(local, action, sta, tid, ssn, ret); |
251 | return ret; | ||
183 | } | 252 | } |
184 | 253 | ||
185 | 254 | ||
diff --git a/net/mac80211/driver-trace.c b/net/mac80211/driver-trace.c new file mode 100644 index 000000000000..8ed8711b1a6d --- /dev/null +++ b/net/mac80211/driver-trace.c | |||
@@ -0,0 +1,9 @@ | |||
1 | /* bug in tracepoint.h, it should include this */ | ||
2 | #include <linux/module.h> | ||
3 | |||
4 | /* sparse isn't too happy with all macros... */ | ||
5 | #ifndef __CHECKER__ | ||
6 | #include "driver-ops.h" | ||
7 | #define CREATE_TRACE_POINTS | ||
8 | #include "driver-trace.h" | ||
9 | #endif | ||
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h new file mode 100644 index 000000000000..37b9051afcf3 --- /dev/null +++ b/net/mac80211/driver-trace.h | |||
@@ -0,0 +1,672 @@ | |||
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, ...) \ | ||
11 | static 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 | |||
33 | TRACE_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 | |||
53 | TRACE_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 | |||
71 | TRACE_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 | |||
99 | TRACE_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 | |||
123 | TRACE_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 | |||
148 | TRACE_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 | |||
194 | TRACE_EVENT(drv_prepare_multicast, | ||
195 | TP_PROTO(struct ieee80211_local *local, int mc_count, u64 ret), | ||
196 | |||
197 | TP_ARGS(local, mc_count, ret), | ||
198 | |||
199 | TP_STRUCT__entry( | ||
200 | LOCAL_ENTRY | ||
201 | __field(int, mc_count) | ||
202 | __field(u64, ret) | ||
203 | ), | ||
204 | |||
205 | TP_fast_assign( | ||
206 | LOCAL_ASSIGN; | ||
207 | __entry->mc_count = mc_count; | ||
208 | __entry->ret = ret; | ||
209 | ), | ||
210 | |||
211 | TP_printk( | ||
212 | LOCAL_PR_FMT " prepare mc (%d): %llx", | ||
213 | LOCAL_PR_ARG, __entry->mc_count, | ||
214 | (unsigned long long) __entry->ret | ||
215 | ) | ||
216 | ); | ||
217 | |||
218 | TRACE_EVENT(drv_configure_filter, | ||
219 | TP_PROTO(struct ieee80211_local *local, | ||
220 | unsigned int changed_flags, | ||
221 | unsigned int *total_flags, | ||
222 | u64 multicast), | ||
223 | |||
224 | TP_ARGS(local, changed_flags, total_flags, multicast), | ||
225 | |||
226 | TP_STRUCT__entry( | ||
227 | LOCAL_ENTRY | ||
228 | __field(unsigned int, changed) | ||
229 | __field(unsigned int, total) | ||
230 | __field(u64, multicast) | ||
231 | ), | ||
232 | |||
233 | TP_fast_assign( | ||
234 | LOCAL_ASSIGN; | ||
235 | __entry->changed = changed_flags; | ||
236 | __entry->total = *total_flags; | ||
237 | __entry->multicast = multicast; | ||
238 | ), | ||
239 | |||
240 | TP_printk( | ||
241 | LOCAL_PR_FMT " changed:%#x total:%#x", | ||
242 | LOCAL_PR_ARG, __entry->changed, __entry->total | ||
243 | ) | ||
244 | ); | ||
245 | |||
246 | TRACE_EVENT(drv_set_tim, | ||
247 | TP_PROTO(struct ieee80211_local *local, | ||
248 | struct ieee80211_sta *sta, bool set, int ret), | ||
249 | |||
250 | TP_ARGS(local, sta, set, ret), | ||
251 | |||
252 | TP_STRUCT__entry( | ||
253 | LOCAL_ENTRY | ||
254 | STA_ENTRY | ||
255 | __field(bool, set) | ||
256 | __field(int, ret) | ||
257 | ), | ||
258 | |||
259 | TP_fast_assign( | ||
260 | LOCAL_ASSIGN; | ||
261 | STA_ASSIGN; | ||
262 | __entry->set = set; | ||
263 | __entry->ret = ret; | ||
264 | ), | ||
265 | |||
266 | TP_printk( | ||
267 | LOCAL_PR_FMT STA_PR_FMT " set:%d ret:%d", | ||
268 | LOCAL_PR_ARG, STA_PR_FMT, __entry->set, __entry->ret | ||
269 | ) | ||
270 | ); | ||
271 | |||
272 | TRACE_EVENT(drv_set_key, | ||
273 | TP_PROTO(struct ieee80211_local *local, | ||
274 | enum set_key_cmd cmd, struct ieee80211_vif *vif, | ||
275 | struct ieee80211_sta *sta, | ||
276 | struct ieee80211_key_conf *key, int ret), | ||
277 | |||
278 | TP_ARGS(local, cmd, vif, sta, key, ret), | ||
279 | |||
280 | TP_STRUCT__entry( | ||
281 | LOCAL_ENTRY | ||
282 | VIF_ENTRY | ||
283 | STA_ENTRY | ||
284 | __field(enum ieee80211_key_alg, alg) | ||
285 | __field(u8, hw_key_idx) | ||
286 | __field(u8, flags) | ||
287 | __field(s8, keyidx) | ||
288 | __field(int, ret) | ||
289 | ), | ||
290 | |||
291 | TP_fast_assign( | ||
292 | LOCAL_ASSIGN; | ||
293 | VIF_ASSIGN; | ||
294 | STA_ASSIGN; | ||
295 | __entry->alg = key->alg; | ||
296 | __entry->flags = key->flags; | ||
297 | __entry->keyidx = key->keyidx; | ||
298 | __entry->hw_key_idx = key->hw_key_idx; | ||
299 | __entry->ret = ret; | ||
300 | ), | ||
301 | |||
302 | TP_printk( | ||
303 | LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " ret:%d", | ||
304 | LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->ret | ||
305 | ) | ||
306 | ); | ||
307 | |||
308 | TRACE_EVENT(drv_update_tkip_key, | ||
309 | TP_PROTO(struct ieee80211_local *local, | ||
310 | struct ieee80211_key_conf *conf, | ||
311 | const u8 *address, u32 iv32), | ||
312 | |||
313 | TP_ARGS(local, conf, address, iv32), | ||
314 | |||
315 | TP_STRUCT__entry( | ||
316 | LOCAL_ENTRY | ||
317 | __array(u8, addr, 6) | ||
318 | __field(u32, iv32) | ||
319 | ), | ||
320 | |||
321 | TP_fast_assign( | ||
322 | LOCAL_ASSIGN; | ||
323 | memcpy(__entry->addr, address, 6); | ||
324 | __entry->iv32 = iv32; | ||
325 | ), | ||
326 | |||
327 | TP_printk( | ||
328 | LOCAL_PR_FMT " addr:%pM iv32:%#x", | ||
329 | LOCAL_PR_ARG, __entry->addr, __entry->iv32 | ||
330 | ) | ||
331 | ); | ||
332 | |||
333 | TRACE_EVENT(drv_hw_scan, | ||
334 | TP_PROTO(struct ieee80211_local *local, | ||
335 | struct cfg80211_scan_request *req, int ret), | ||
336 | |||
337 | TP_ARGS(local, req, ret), | ||
338 | |||
339 | TP_STRUCT__entry( | ||
340 | LOCAL_ENTRY | ||
341 | __field(int, ret) | ||
342 | ), | ||
343 | |||
344 | TP_fast_assign( | ||
345 | LOCAL_ASSIGN; | ||
346 | __entry->ret = ret; | ||
347 | ), | ||
348 | |||
349 | TP_printk( | ||
350 | LOCAL_PR_FMT " ret:%d", | ||
351 | LOCAL_PR_ARG, __entry->ret | ||
352 | ) | ||
353 | ); | ||
354 | |||
355 | TRACE_EVENT(drv_sw_scan_start, | ||
356 | TP_PROTO(struct ieee80211_local *local), | ||
357 | |||
358 | TP_ARGS(local), | ||
359 | |||
360 | TP_STRUCT__entry( | ||
361 | LOCAL_ENTRY | ||
362 | ), | ||
363 | |||
364 | TP_fast_assign( | ||
365 | LOCAL_ASSIGN; | ||
366 | ), | ||
367 | |||
368 | TP_printk( | ||
369 | LOCAL_PR_FMT, LOCAL_PR_ARG | ||
370 | ) | ||
371 | ); | ||
372 | |||
373 | TRACE_EVENT(drv_sw_scan_complete, | ||
374 | TP_PROTO(struct ieee80211_local *local), | ||
375 | |||
376 | TP_ARGS(local), | ||
377 | |||
378 | TP_STRUCT__entry( | ||
379 | LOCAL_ENTRY | ||
380 | ), | ||
381 | |||
382 | TP_fast_assign( | ||
383 | LOCAL_ASSIGN; | ||
384 | ), | ||
385 | |||
386 | TP_printk( | ||
387 | LOCAL_PR_FMT, LOCAL_PR_ARG | ||
388 | ) | ||
389 | ); | ||
390 | |||
391 | TRACE_EVENT(drv_get_stats, | ||
392 | TP_PROTO(struct ieee80211_local *local, | ||
393 | struct ieee80211_low_level_stats *stats, | ||
394 | int ret), | ||
395 | |||
396 | TP_ARGS(local, stats, ret), | ||
397 | |||
398 | TP_STRUCT__entry( | ||
399 | LOCAL_ENTRY | ||
400 | __field(int, ret) | ||
401 | __field(unsigned int, ackfail) | ||
402 | __field(unsigned int, rtsfail) | ||
403 | __field(unsigned int, fcserr) | ||
404 | __field(unsigned int, rtssucc) | ||
405 | ), | ||
406 | |||
407 | TP_fast_assign( | ||
408 | LOCAL_ASSIGN; | ||
409 | __entry->ret = ret; | ||
410 | __entry->ackfail = stats->dot11ACKFailureCount; | ||
411 | __entry->rtsfail = stats->dot11RTSFailureCount; | ||
412 | __entry->fcserr = stats->dot11FCSErrorCount; | ||
413 | __entry->rtssucc = stats->dot11RTSSuccessCount; | ||
414 | ), | ||
415 | |||
416 | TP_printk( | ||
417 | LOCAL_PR_FMT " ret:%d", | ||
418 | LOCAL_PR_ARG, __entry->ret | ||
419 | ) | ||
420 | ); | ||
421 | |||
422 | TRACE_EVENT(drv_get_tkip_seq, | ||
423 | TP_PROTO(struct ieee80211_local *local, | ||
424 | u8 hw_key_idx, u32 *iv32, u16 *iv16), | ||
425 | |||
426 | TP_ARGS(local, hw_key_idx, iv32, iv16), | ||
427 | |||
428 | TP_STRUCT__entry( | ||
429 | LOCAL_ENTRY | ||
430 | __field(u8, hw_key_idx) | ||
431 | __field(u32, iv32) | ||
432 | __field(u16, iv16) | ||
433 | ), | ||
434 | |||
435 | TP_fast_assign( | ||
436 | LOCAL_ASSIGN; | ||
437 | __entry->hw_key_idx = hw_key_idx; | ||
438 | __entry->iv32 = *iv32; | ||
439 | __entry->iv16 = *iv16; | ||
440 | ), | ||
441 | |||
442 | TP_printk( | ||
443 | LOCAL_PR_FMT, LOCAL_PR_ARG | ||
444 | ) | ||
445 | ); | ||
446 | |||
447 | TRACE_EVENT(drv_set_rts_threshold, | ||
448 | TP_PROTO(struct ieee80211_local *local, u32 value, int ret), | ||
449 | |||
450 | TP_ARGS(local, value, ret), | ||
451 | |||
452 | TP_STRUCT__entry( | ||
453 | LOCAL_ENTRY | ||
454 | __field(u32, value) | ||
455 | __field(int, ret) | ||
456 | ), | ||
457 | |||
458 | TP_fast_assign( | ||
459 | LOCAL_ASSIGN; | ||
460 | __entry->ret = ret; | ||
461 | __entry->value = value; | ||
462 | ), | ||
463 | |||
464 | TP_printk( | ||
465 | LOCAL_PR_FMT " value:%d ret:%d", | ||
466 | LOCAL_PR_ARG, __entry->value, __entry->ret | ||
467 | ) | ||
468 | ); | ||
469 | |||
470 | TRACE_EVENT(drv_sta_notify, | ||
471 | TP_PROTO(struct ieee80211_local *local, | ||
472 | struct ieee80211_vif *vif, | ||
473 | enum sta_notify_cmd cmd, | ||
474 | struct ieee80211_sta *sta), | ||
475 | |||
476 | TP_ARGS(local, vif, cmd, sta), | ||
477 | |||
478 | TP_STRUCT__entry( | ||
479 | LOCAL_ENTRY | ||
480 | VIF_ENTRY | ||
481 | STA_ENTRY | ||
482 | __field(u32, cmd) | ||
483 | ), | ||
484 | |||
485 | TP_fast_assign( | ||
486 | LOCAL_ASSIGN; | ||
487 | VIF_ASSIGN; | ||
488 | STA_ASSIGN; | ||
489 | __entry->cmd = cmd; | ||
490 | ), | ||
491 | |||
492 | TP_printk( | ||
493 | LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " cmd:%d", | ||
494 | LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->cmd | ||
495 | ) | ||
496 | ); | ||
497 | |||
498 | TRACE_EVENT(drv_conf_tx, | ||
499 | TP_PROTO(struct ieee80211_local *local, u16 queue, | ||
500 | const struct ieee80211_tx_queue_params *params, | ||
501 | int ret), | ||
502 | |||
503 | TP_ARGS(local, queue, params, ret), | ||
504 | |||
505 | TP_STRUCT__entry( | ||
506 | LOCAL_ENTRY | ||
507 | __field(u16, queue) | ||
508 | __field(u16, txop) | ||
509 | __field(u16, cw_min) | ||
510 | __field(u16, cw_max) | ||
511 | __field(u8, aifs) | ||
512 | __field(int, ret) | ||
513 | ), | ||
514 | |||
515 | TP_fast_assign( | ||
516 | LOCAL_ASSIGN; | ||
517 | __entry->queue = queue; | ||
518 | __entry->ret = ret; | ||
519 | __entry->txop = params->txop; | ||
520 | __entry->cw_max = params->cw_max; | ||
521 | __entry->cw_min = params->cw_min; | ||
522 | __entry->aifs = params->aifs; | ||
523 | ), | ||
524 | |||
525 | TP_printk( | ||
526 | LOCAL_PR_FMT " queue:%d ret:%d", | ||
527 | LOCAL_PR_ARG, __entry->queue, __entry->ret | ||
528 | ) | ||
529 | ); | ||
530 | |||
531 | TRACE_EVENT(drv_get_tx_stats, | ||
532 | TP_PROTO(struct ieee80211_local *local, | ||
533 | struct ieee80211_tx_queue_stats *stats, | ||
534 | int ret), | ||
535 | |||
536 | TP_ARGS(local, stats, ret), | ||
537 | |||
538 | TP_STRUCT__entry( | ||
539 | LOCAL_ENTRY | ||
540 | __field(int, ret) | ||
541 | ), | ||
542 | |||
543 | TP_fast_assign( | ||
544 | LOCAL_ASSIGN; | ||
545 | __entry->ret = ret; | ||
546 | ), | ||
547 | |||
548 | TP_printk( | ||
549 | LOCAL_PR_FMT " ret:%d", | ||
550 | LOCAL_PR_ARG, __entry->ret | ||
551 | ) | ||
552 | ); | ||
553 | |||
554 | TRACE_EVENT(drv_get_tsf, | ||
555 | TP_PROTO(struct ieee80211_local *local, u64 ret), | ||
556 | |||
557 | TP_ARGS(local, ret), | ||
558 | |||
559 | TP_STRUCT__entry( | ||
560 | LOCAL_ENTRY | ||
561 | __field(u64, ret) | ||
562 | ), | ||
563 | |||
564 | TP_fast_assign( | ||
565 | LOCAL_ASSIGN; | ||
566 | __entry->ret = ret; | ||
567 | ), | ||
568 | |||
569 | TP_printk( | ||
570 | LOCAL_PR_FMT " ret:%llu", | ||
571 | LOCAL_PR_ARG, (unsigned long long)__entry->ret | ||
572 | ) | ||
573 | ); | ||
574 | |||
575 | TRACE_EVENT(drv_set_tsf, | ||
576 | TP_PROTO(struct ieee80211_local *local, u64 tsf), | ||
577 | |||
578 | TP_ARGS(local, tsf), | ||
579 | |||
580 | TP_STRUCT__entry( | ||
581 | LOCAL_ENTRY | ||
582 | __field(u64, tsf) | ||
583 | ), | ||
584 | |||
585 | TP_fast_assign( | ||
586 | LOCAL_ASSIGN; | ||
587 | __entry->tsf = tsf; | ||
588 | ), | ||
589 | |||
590 | TP_printk( | ||
591 | LOCAL_PR_FMT " tsf:%llu", | ||
592 | LOCAL_PR_ARG, (unsigned long long)__entry->tsf | ||
593 | ) | ||
594 | ); | ||
595 | |||
596 | TRACE_EVENT(drv_reset_tsf, | ||
597 | TP_PROTO(struct ieee80211_local *local), | ||
598 | |||
599 | TP_ARGS(local), | ||
600 | |||
601 | TP_STRUCT__entry( | ||
602 | LOCAL_ENTRY | ||
603 | ), | ||
604 | |||
605 | TP_fast_assign( | ||
606 | LOCAL_ASSIGN; | ||
607 | ), | ||
608 | |||
609 | TP_printk( | ||
610 | LOCAL_PR_FMT, LOCAL_PR_ARG | ||
611 | ) | ||
612 | ); | ||
613 | |||
614 | TRACE_EVENT(drv_tx_last_beacon, | ||
615 | TP_PROTO(struct ieee80211_local *local, int ret), | ||
616 | |||
617 | TP_ARGS(local, ret), | ||
618 | |||
619 | TP_STRUCT__entry( | ||
620 | LOCAL_ENTRY | ||
621 | __field(int, ret) | ||
622 | ), | ||
623 | |||
624 | TP_fast_assign( | ||
625 | LOCAL_ASSIGN; | ||
626 | __entry->ret = ret; | ||
627 | ), | ||
628 | |||
629 | TP_printk( | ||
630 | LOCAL_PR_FMT " ret:%d", | ||
631 | LOCAL_PR_ARG, __entry->ret | ||
632 | ) | ||
633 | ); | ||
634 | |||
635 | TRACE_EVENT(drv_ampdu_action, | ||
636 | TP_PROTO(struct ieee80211_local *local, | ||
637 | enum ieee80211_ampdu_mlme_action action, | ||
638 | struct ieee80211_sta *sta, u16 tid, | ||
639 | u16 *ssn, int ret), | ||
640 | |||
641 | TP_ARGS(local, action, sta, tid, ssn, ret), | ||
642 | |||
643 | TP_STRUCT__entry( | ||
644 | LOCAL_ENTRY | ||
645 | STA_ENTRY | ||
646 | __field(u32, action) | ||
647 | __field(u16, tid) | ||
648 | __field(u16, ssn) | ||
649 | __field(int, ret) | ||
650 | ), | ||
651 | |||
652 | TP_fast_assign( | ||
653 | LOCAL_ASSIGN; | ||
654 | STA_ASSIGN; | ||
655 | __entry->ret = ret; | ||
656 | __entry->action = action; | ||
657 | __entry->tid = tid; | ||
658 | __entry->ssn = *ssn; | ||
659 | ), | ||
660 | |||
661 | TP_printk( | ||
662 | LOCAL_PR_FMT STA_PR_FMT " action:%d tid:%d ret:%d", | ||
663 | LOCAL_PR_ARG, STA_PR_ARG, __entry->action, __entry->tid, __entry->ret | ||
664 | ) | ||
665 | ); | ||
666 | #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ | ||
667 | |||
668 | #undef TRACE_INCLUDE_PATH | ||
669 | #define TRACE_INCLUDE_PATH . | ||
670 | #undef TRACE_INCLUDE_FILE | ||
671 | #define TRACE_INCLUDE_FILE driver-trace | ||
672 | #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 | */ |
19 | void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, | 18 | void 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..920ec8792f4b 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 | ||
63 | static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | 63 | static 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 | ||
@@ -743,7 +742,7 @@ static void ieee80211_ibss_work(struct work_struct *work) | |||
743 | if (!netif_running(sdata->dev)) | 742 | if (!netif_running(sdata->dev)) |
744 | return; | 743 | return; |
745 | 744 | ||
746 | if (local->sw_scanning || local->hw_scanning) | 745 | if (local->scanning) |
747 | return; | 746 | return; |
748 | 747 | ||
749 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC)) | 748 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC)) |
@@ -782,7 +781,7 @@ static void ieee80211_ibss_timer(unsigned long data) | |||
782 | } | 781 | } |
783 | 782 | ||
784 | set_bit(IEEE80211_IBSS_REQ_RUN, &ifibss->request); | 783 | set_bit(IEEE80211_IBSS_REQ_RUN, &ifibss->request); |
785 | queue_work(local->hw.workqueue, &ifibss->work); | 784 | ieee80211_queue_work(&local->hw, &ifibss->work); |
786 | } | 785 | } |
787 | 786 | ||
788 | #ifdef CONFIG_PM | 787 | #ifdef CONFIG_PM |
@@ -836,8 +835,7 @@ void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local) | |||
836 | } | 835 | } |
837 | 836 | ||
838 | ieee80211_rx_result | 837 | ieee80211_rx_result |
839 | ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | 838 | ieee80211_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,11 +850,10 @@ 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); |
859 | queue_work(local->hw.workqueue, &sdata->u.ibss.work); | 856 | ieee80211_queue_work(&local->hw, &sdata->u.ibss.work); |
860 | return RX_QUEUED; | 857 | return RX_QUEUED; |
861 | } | 858 | } |
862 | 859 | ||
@@ -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; |
@@ -913,7 +912,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | |||
913 | ieee80211_recalc_idle(sdata->local); | 912 | ieee80211_recalc_idle(sdata->local); |
914 | 913 | ||
915 | set_bit(IEEE80211_IBSS_REQ_RUN, &sdata->u.ibss.request); | 914 | set_bit(IEEE80211_IBSS_REQ_RUN, &sdata->u.ibss.request); |
916 | queue_work(sdata->local->hw.workqueue, &sdata->u.ibss.work); | 915 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.ibss.work); |
917 | 916 | ||
918 | return 0; | 917 | return 0; |
919 | } | 918 | } |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 68eb5052179a..588005c84a6d 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/etherdevice.h> | 25 | #include <linux/etherdevice.h> |
26 | #include <net/cfg80211.h> | 26 | #include <net/cfg80211.h> |
27 | #include <net/iw_handler.h> | ||
28 | #include <net/mac80211.h> | 27 | #include <net/mac80211.h> |
29 | #include "key.h" | 28 | #include "key.h" |
30 | #include "sta_info.h" | 29 | #include "sta_info.h" |
@@ -213,7 +212,9 @@ struct ieee80211_if_vlan { | |||
213 | }; | 212 | }; |
214 | 213 | ||
215 | struct mesh_stats { | 214 | struct mesh_stats { |
216 | __u32 fwded_frames; /* Mesh forwarded frames */ | 215 | __u32 fwded_mcast; /* Mesh forwarded multicast frames */ |
216 | __u32 fwded_unicast; /* Mesh forwarded unicast frames */ | ||
217 | __u32 fwded_frames; /* Mesh total forwarded frames */ | ||
217 | __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ | 218 | __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ |
218 | __u32 dropped_frames_no_route; /* Not transmitted, no route found */ | 219 | __u32 dropped_frames_no_route; /* Not transmitted, no route found */ |
219 | atomic_t estab_plinks; | 220 | atomic_t estab_plinks; |
@@ -227,86 +228,81 @@ struct mesh_preq_queue { | |||
227 | u8 flags; | 228 | u8 flags; |
228 | }; | 229 | }; |
229 | 230 | ||
231 | enum ieee80211_mgd_state { | ||
232 | IEEE80211_MGD_STATE_IDLE, | ||
233 | IEEE80211_MGD_STATE_PROBE, | ||
234 | IEEE80211_MGD_STATE_AUTH, | ||
235 | IEEE80211_MGD_STATE_ASSOC, | ||
236 | }; | ||
237 | |||
238 | struct ieee80211_mgd_work { | ||
239 | struct list_head list; | ||
240 | struct ieee80211_bss *bss; | ||
241 | int ie_len; | ||
242 | u8 prev_bssid[ETH_ALEN]; | ||
243 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | ||
244 | u8 ssid_len; | ||
245 | unsigned long timeout; | ||
246 | enum ieee80211_mgd_state state; | ||
247 | u16 auth_alg, auth_transaction; | ||
248 | |||
249 | int tries; | ||
250 | |||
251 | u8 key[WLAN_KEY_LEN_WEP104]; | ||
252 | u8 key_len, key_idx; | ||
253 | |||
254 | /* must be last */ | ||
255 | u8 ie[0]; /* for auth or assoc frame, not probe */ | ||
256 | }; | ||
257 | |||
230 | /* flags used in struct ieee80211_if_managed.flags */ | 258 | /* flags used in struct ieee80211_if_managed.flags */ |
231 | #define IEEE80211_STA_SSID_SET BIT(0) | 259 | enum ieee80211_sta_flags { |
232 | #define IEEE80211_STA_BSSID_SET BIT(1) | 260 | IEEE80211_STA_BEACON_POLL = BIT(0), |
233 | #define IEEE80211_STA_PREV_BSSID_SET BIT(2) | 261 | IEEE80211_STA_CONNECTION_POLL = BIT(1), |
234 | #define IEEE80211_STA_AUTHENTICATED BIT(3) | 262 | IEEE80211_STA_CONTROL_PORT = BIT(2), |
235 | #define IEEE80211_STA_ASSOCIATED BIT(4) | 263 | IEEE80211_STA_WMM_ENABLED = BIT(3), |
236 | #define IEEE80211_STA_PROBEREQ_POLL BIT(5) | 264 | IEEE80211_STA_DISABLE_11N = BIT(4), |
237 | #define IEEE80211_STA_CREATE_IBSS BIT(6) | 265 | IEEE80211_STA_CSA_RECEIVED = BIT(5), |
238 | #define IEEE80211_STA_CONTROL_PORT BIT(7) | 266 | IEEE80211_STA_MFP_ENABLED = BIT(6), |
239 | #define IEEE80211_STA_WMM_ENABLED BIT(8) | 267 | }; |
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 | 268 | ||
254 | /* bitfield of allowed auth algs */ | 269 | /* flags for MLME request */ |
255 | #define IEEE80211_AUTH_ALG_OPEN BIT(0) | 270 | enum ieee80211_sta_request { |
256 | #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) | 271 | IEEE80211_STA_REQ_SCAN, |
257 | #define IEEE80211_AUTH_ALG_LEAP BIT(2) | 272 | }; |
258 | #define IEEE80211_AUTH_ALG_FT BIT(3) | ||
259 | 273 | ||
260 | struct ieee80211_if_managed { | 274 | struct ieee80211_if_managed { |
261 | struct timer_list timer; | 275 | struct timer_list timer; |
276 | struct timer_list conn_mon_timer; | ||
277 | struct timer_list bcn_mon_timer; | ||
262 | struct timer_list chswitch_timer; | 278 | struct timer_list chswitch_timer; |
263 | struct work_struct work; | 279 | struct work_struct work; |
280 | struct work_struct monitor_work; | ||
264 | struct work_struct chswitch_work; | 281 | struct work_struct chswitch_work; |
265 | struct work_struct beacon_loss_work; | 282 | struct work_struct beacon_loss_work; |
266 | 283 | ||
267 | u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; | 284 | unsigned long probe_timeout; |
285 | int probe_send_count; | ||
268 | 286 | ||
269 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 287 | struct mutex mtx; |
270 | size_t ssid_len; | 288 | struct ieee80211_bss *associated; |
289 | struct ieee80211_mgd_work *old_associate_work; | ||
290 | struct list_head work_list; | ||
271 | 291 | ||
272 | enum { | 292 | 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 | 293 | ||
280 | u16 aid; | 294 | u16 aid; |
281 | u16 ap_capab, capab; | 295 | 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 | 296 | ||
289 | struct sk_buff_head skb_queue; | 297 | struct sk_buff_head skb_queue; |
290 | 298 | ||
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 */ | 299 | unsigned long timers_running; /* used for quiesce/restart */ |
297 | bool powersave; /* powersave requested for this iface */ | 300 | bool powersave; /* powersave requested for this iface */ |
298 | 301 | ||
299 | unsigned long request; | 302 | unsigned long request; |
300 | 303 | ||
301 | unsigned long last_probe; | ||
302 | unsigned long last_beacon; | ||
303 | |||
304 | unsigned int flags; | 304 | unsigned int flags; |
305 | 305 | ||
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; | 306 | u32 beacon_crc; |
311 | 307 | ||
312 | enum { | 308 | enum { |
@@ -316,10 +312,6 @@ struct ieee80211_if_managed { | |||
316 | } mfp; /* management frame protection */ | 312 | } mfp; /* management frame protection */ |
317 | 313 | ||
318 | int wmm_last_param_set; | 314 | 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 | }; | 315 | }; |
324 | 316 | ||
325 | enum ieee80211_ibss_request { | 317 | enum ieee80211_ibss_request { |
@@ -339,6 +331,7 @@ struct ieee80211_if_ibss { | |||
339 | 331 | ||
340 | bool fixed_bssid; | 332 | bool fixed_bssid; |
341 | bool fixed_channel; | 333 | bool fixed_channel; |
334 | bool privacy; | ||
342 | 335 | ||
343 | u8 bssid[ETH_ALEN]; | 336 | u8 bssid[ETH_ALEN]; |
344 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 337 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
@@ -364,7 +357,7 @@ struct ieee80211_if_mesh { | |||
364 | 357 | ||
365 | unsigned long timers_running; | 358 | unsigned long timers_running; |
366 | 359 | ||
367 | bool housekeeping; | 360 | unsigned long wrkq_flags; |
368 | 361 | ||
369 | u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN]; | 362 | u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN]; |
370 | size_t mesh_id_len; | 363 | size_t mesh_id_len; |
@@ -374,6 +367,10 @@ struct ieee80211_if_mesh { | |||
374 | u8 mesh_pm_id[4]; | 367 | u8 mesh_pm_id[4]; |
375 | /* Congestion Control Mode Identifier */ | 368 | /* Congestion Control Mode Identifier */ |
376 | u8 mesh_cc_id[4]; | 369 | u8 mesh_cc_id[4]; |
370 | /* Synchronization Protocol Identifier */ | ||
371 | u8 mesh_sp_id[4]; | ||
372 | /* Authentication Protocol Identifier */ | ||
373 | u8 mesh_auth_id[4]; | ||
377 | /* Local mesh Destination Sequence Number */ | 374 | /* Local mesh Destination Sequence Number */ |
378 | u32 dsn; | 375 | u32 dsn; |
379 | /* Last used PREQ ID */ | 376 | /* Last used PREQ ID */ |
@@ -478,20 +475,9 @@ struct ieee80211_sub_if_data { | |||
478 | union { | 475 | union { |
479 | struct { | 476 | struct { |
480 | struct dentry *drop_unencrypted; | 477 | struct dentry *drop_unencrypted; |
481 | struct dentry *state; | ||
482 | struct dentry *bssid; | 478 | struct dentry *bssid; |
483 | struct dentry *prev_bssid; | ||
484 | struct dentry *ssid_len; | ||
485 | struct dentry *aid; | 479 | struct dentry *aid; |
486 | struct dentry *ap_capab; | ||
487 | struct dentry *capab; | 480 | 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; | 481 | struct dentry *force_unicast_rateidx; |
496 | struct dentry *max_ratectrl_rateidx; | 482 | struct dentry *max_ratectrl_rateidx; |
497 | } sta; | 483 | } sta; |
@@ -526,6 +512,8 @@ struct ieee80211_sub_if_data { | |||
526 | #ifdef CONFIG_MAC80211_MESH | 512 | #ifdef CONFIG_MAC80211_MESH |
527 | struct dentry *mesh_stats_dir; | 513 | struct dentry *mesh_stats_dir; |
528 | struct { | 514 | struct { |
515 | struct dentry *fwded_mcast; | ||
516 | struct dentry *fwded_unicast; | ||
529 | struct dentry *fwded_frames; | 517 | struct dentry *fwded_frames; |
530 | struct dentry *dropped_frames_ttl; | 518 | struct dentry *dropped_frames_ttl; |
531 | struct dentry *dropped_frames_no_route; | 519 | struct dentry *dropped_frames_no_route; |
@@ -588,12 +576,44 @@ enum queue_stop_reason { | |||
588 | IEEE80211_QUEUE_STOP_REASON_CSA, | 576 | IEEE80211_QUEUE_STOP_REASON_CSA, |
589 | IEEE80211_QUEUE_STOP_REASON_AGGREGATION, | 577 | IEEE80211_QUEUE_STOP_REASON_AGGREGATION, |
590 | IEEE80211_QUEUE_STOP_REASON_SUSPEND, | 578 | IEEE80211_QUEUE_STOP_REASON_SUSPEND, |
591 | IEEE80211_QUEUE_STOP_REASON_PENDING, | ||
592 | IEEE80211_QUEUE_STOP_REASON_SKB_ADD, | 579 | IEEE80211_QUEUE_STOP_REASON_SKB_ADD, |
593 | }; | 580 | }; |
594 | 581 | ||
595 | struct ieee80211_master_priv { | 582 | /** |
596 | struct ieee80211_local *local; | 583 | * mac80211 scan flags - currently active scan mode |
584 | * | ||
585 | * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as | ||
586 | * well be on the operating channel | ||
587 | * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to | ||
588 | * determine if we are on the operating channel or not | ||
589 | * @SCAN_OFF_CHANNEL: We're off our operating channel for scanning, | ||
590 | * gets only set in conjunction with SCAN_SW_SCANNING | ||
591 | */ | ||
592 | enum { | ||
593 | SCAN_SW_SCANNING, | ||
594 | SCAN_HW_SCANNING, | ||
595 | SCAN_OFF_CHANNEL, | ||
596 | }; | ||
597 | |||
598 | /** | ||
599 | * enum mac80211_scan_state - scan state machine states | ||
600 | * | ||
601 | * @SCAN_DECISION: Main entry point to the scan state machine, this state | ||
602 | * determines if we should keep on scanning or switch back to the | ||
603 | * operating channel | ||
604 | * @SCAN_SET_CHANNEL: Set the next channel to be scanned | ||
605 | * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses | ||
606 | * @SCAN_LEAVE_OPER_CHANNEL: Leave the operating channel, notify the AP | ||
607 | * about us leaving the channel and stop all associated STA interfaces | ||
608 | * @SCAN_ENTER_OPER_CHANNEL: Enter the operating channel again, notify the | ||
609 | * AP about us being back and restart all associated STA interfaces | ||
610 | */ | ||
611 | enum mac80211_scan_state { | ||
612 | SCAN_DECISION, | ||
613 | SCAN_SET_CHANNEL, | ||
614 | SCAN_SEND_PROBE, | ||
615 | SCAN_LEAVE_OPER_CHANNEL, | ||
616 | SCAN_ENTER_OPER_CHANNEL, | ||
597 | }; | 617 | }; |
598 | 618 | ||
599 | struct ieee80211_local { | 619 | struct ieee80211_local { |
@@ -604,17 +624,33 @@ struct ieee80211_local { | |||
604 | 624 | ||
605 | const struct ieee80211_ops *ops; | 625 | const struct ieee80211_ops *ops; |
606 | 626 | ||
627 | /* | ||
628 | * private workqueue to mac80211. mac80211 makes this accessible | ||
629 | * via ieee80211_queue_work() | ||
630 | */ | ||
631 | struct workqueue_struct *workqueue; | ||
632 | |||
607 | unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES]; | 633 | unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES]; |
608 | /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ | 634 | /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ |
609 | spinlock_t queue_stop_reason_lock; | 635 | spinlock_t queue_stop_reason_lock; |
610 | 636 | ||
611 | struct net_device *mdev; /* wmaster# - "master" 802.11 device */ | ||
612 | int open_count; | 637 | int open_count; |
613 | int monitors, cooked_mntrs; | 638 | int monitors, cooked_mntrs; |
614 | /* number of interfaces with corresponding FIF_ flags */ | 639 | /* number of interfaces with corresponding FIF_ flags */ |
615 | int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss; | 640 | int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll; |
616 | unsigned int filter_flags; /* FIF_* */ | 641 | unsigned int filter_flags; /* FIF_* */ |
617 | struct iw_statistics wstats; | 642 | struct iw_statistics wstats; |
643 | |||
644 | /* protects the aggregated multicast list and filter calls */ | ||
645 | spinlock_t filter_lock; | ||
646 | |||
647 | /* used for uploading changed mc list */ | ||
648 | struct work_struct reconfig_filter; | ||
649 | |||
650 | /* aggregated multicast list */ | ||
651 | struct dev_addr_list *mc_list; | ||
652 | int mc_count; | ||
653 | |||
618 | bool tim_in_locked_section; /* see ieee80211_beacon_get() */ | 654 | bool tim_in_locked_section; /* see ieee80211_beacon_get() */ |
619 | 655 | ||
620 | /* | 656 | /* |
@@ -631,6 +667,9 @@ struct ieee80211_local { | |||
631 | */ | 667 | */ |
632 | bool quiescing; | 668 | bool quiescing; |
633 | 669 | ||
670 | /* device is started */ | ||
671 | bool started; | ||
672 | |||
634 | int tx_headroom; /* required headroom for hardware/radiotap */ | 673 | int tx_headroom; /* required headroom for hardware/radiotap */ |
635 | 674 | ||
636 | /* Tasklet and skb queue to process calls from IRQ mode. All frames | 675 | /* Tasklet and skb queue to process calls from IRQ mode. All frames |
@@ -653,6 +692,7 @@ struct ieee80211_local { | |||
653 | struct list_head sta_list; | 692 | struct list_head sta_list; |
654 | struct sta_info *sta_hash[STA_HASH_SIZE]; | 693 | struct sta_info *sta_hash[STA_HASH_SIZE]; |
655 | struct timer_list sta_cleanup; | 694 | struct timer_list sta_cleanup; |
695 | int sta_generation; | ||
656 | 696 | ||
657 | struct sk_buff_head pending[IEEE80211_MAX_QUEUES]; | 697 | struct sk_buff_head pending[IEEE80211_MAX_QUEUES]; |
658 | struct tasklet_struct tx_pending_tasklet; | 698 | struct tasklet_struct tx_pending_tasklet; |
@@ -687,9 +727,9 @@ struct ieee80211_local { | |||
687 | 727 | ||
688 | /* Scanning and BSS list */ | 728 | /* Scanning and BSS list */ |
689 | struct mutex scan_mtx; | 729 | struct mutex scan_mtx; |
690 | bool sw_scanning, hw_scanning; | 730 | unsigned long scanning; |
691 | struct cfg80211_ssid scan_ssid; | 731 | struct cfg80211_ssid scan_ssid; |
692 | struct cfg80211_scan_request int_scan_req; | 732 | struct cfg80211_scan_request *int_scan_req; |
693 | struct cfg80211_scan_request *scan_req; | 733 | struct cfg80211_scan_request *scan_req; |
694 | struct ieee80211_channel *scan_channel; | 734 | struct ieee80211_channel *scan_channel; |
695 | const u8 *orig_ies; | 735 | const u8 *orig_ies; |
@@ -697,7 +737,7 @@ struct ieee80211_local { | |||
697 | int scan_channel_idx; | 737 | int scan_channel_idx; |
698 | int scan_ies_len; | 738 | int scan_ies_len; |
699 | 739 | ||
700 | enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; | 740 | enum mac80211_scan_state next_scan_state; |
701 | struct delayed_work scan_work; | 741 | struct delayed_work scan_work; |
702 | struct ieee80211_sub_if_data *scan_sdata; | 742 | struct ieee80211_sub_if_data *scan_sdata; |
703 | enum nl80211_channel_type oper_channel_type; | 743 | enum nl80211_channel_type oper_channel_type; |
@@ -834,10 +874,6 @@ struct ieee80211_local { | |||
834 | static inline struct ieee80211_sub_if_data * | 874 | static inline struct ieee80211_sub_if_data * |
835 | IEEE80211_DEV_TO_SUB_IF(struct net_device *dev) | 875 | IEEE80211_DEV_TO_SUB_IF(struct net_device *dev) |
836 | { | 876 | { |
837 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
838 | |||
839 | BUG_ON(!local || local->mdev == dev); | ||
840 | |||
841 | return netdev_priv(dev); | 877 | return netdev_priv(dev); |
842 | } | 878 | } |
843 | 879 | ||
@@ -937,21 +973,20 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | |||
937 | void ieee80211_configure_filter(struct ieee80211_local *local); | 973 | void ieee80211_configure_filter(struct ieee80211_local *local); |
938 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); | 974 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); |
939 | 975 | ||
940 | /* wireless extensions */ | ||
941 | extern const struct iw_handler_def ieee80211_iw_handler_def; | ||
942 | |||
943 | /* STA code */ | 976 | /* STA code */ |
944 | void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); | 977 | void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); |
978 | int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, | ||
979 | struct cfg80211_auth_request *req); | ||
980 | int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | ||
981 | struct cfg80211_assoc_request *req); | ||
982 | int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, | ||
983 | struct cfg80211_deauth_request *req, | ||
984 | void *cookie); | ||
985 | int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, | ||
986 | struct cfg80211_disassoc_request *req, | ||
987 | void *cookie); | ||
945 | ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, | 988 | ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, |
946 | struct sk_buff *skb, | 989 | struct sk_buff *skb); |
947 | struct ieee80211_rx_status *rx_status); | ||
948 | int ieee80211_sta_commit(struct ieee80211_sub_if_data *sdata); | ||
949 | int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len); | ||
950 | int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len); | ||
951 | int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid); | ||
952 | void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata); | ||
953 | int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason); | ||
954 | int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason); | ||
955 | void ieee80211_send_pspoll(struct ieee80211_local *local, | 990 | void ieee80211_send_pspoll(struct ieee80211_local *local, |
956 | struct ieee80211_sub_if_data *sdata); | 991 | struct ieee80211_sub_if_data *sdata); |
957 | void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency); | 992 | void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency); |
@@ -967,8 +1002,7 @@ void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata); | |||
967 | void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local); | 1002 | void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local); |
968 | void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata); | 1003 | void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata); |
969 | ieee80211_rx_result | 1004 | ieee80211_rx_result |
970 | ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | 1005 | ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); |
971 | struct ieee80211_rx_status *rx_status); | ||
972 | struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | 1006 | struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, |
973 | u8 *bssid, u8 *addr, u32 supp_rates); | 1007 | u8 *bssid, u8 *addr, u32 supp_rates); |
974 | int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | 1008 | int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, |
@@ -983,16 +1017,9 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata, | |||
983 | const u8 *ssid, u8 ssid_len); | 1017 | const u8 *ssid, u8 ssid_len); |
984 | int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, | 1018 | int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, |
985 | struct cfg80211_scan_request *req); | 1019 | struct cfg80211_scan_request *req); |
986 | int ieee80211_scan_results(struct ieee80211_local *local, | ||
987 | struct iw_request_info *info, | ||
988 | char *buf, size_t len); | ||
989 | void ieee80211_scan_cancel(struct ieee80211_local *local); | 1020 | void ieee80211_scan_cancel(struct ieee80211_local *local); |
990 | ieee80211_rx_result | 1021 | ieee80211_rx_result |
991 | ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, | 1022 | ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); |
992 | struct sk_buff *skb, | ||
993 | struct ieee80211_rx_status *rx_status); | ||
994 | int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, | ||
995 | const char *ie, size_t len); | ||
996 | 1023 | ||
997 | void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local); | 1024 | void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local); |
998 | struct ieee80211_bss * | 1025 | struct ieee80211_bss * |
@@ -1008,8 +1035,6 @@ ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, | |||
1008 | u8 *ssid, u8 ssid_len); | 1035 | u8 *ssid, u8 ssid_len); |
1009 | void ieee80211_rx_bss_put(struct ieee80211_local *local, | 1036 | void ieee80211_rx_bss_put(struct ieee80211_local *local, |
1010 | struct ieee80211_bss *bss); | 1037 | struct ieee80211_bss *bss); |
1011 | void ieee80211_rx_bss_remove(struct ieee80211_sub_if_data *sdata, u8 *bssid, | ||
1012 | int freq, u8 *ssid, u8 ssid_len); | ||
1013 | 1038 | ||
1014 | /* interface handling */ | 1039 | /* interface handling */ |
1015 | int ieee80211_if_add(struct ieee80211_local *local, const char *name, | 1040 | int ieee80211_if_add(struct ieee80211_local *local, const char *name, |
@@ -1025,9 +1050,10 @@ void ieee80211_recalc_idle(struct ieee80211_local *local); | |||
1025 | /* tx handling */ | 1050 | /* tx handling */ |
1026 | void ieee80211_clear_tx_pending(struct ieee80211_local *local); | 1051 | void ieee80211_clear_tx_pending(struct ieee80211_local *local); |
1027 | void ieee80211_tx_pending(unsigned long data); | 1052 | void ieee80211_tx_pending(unsigned long data); |
1028 | int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev); | 1053 | netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, |
1029 | int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); | 1054 | struct net_device *dev); |
1030 | int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); | 1055 | netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, |
1056 | struct net_device *dev); | ||
1031 | 1057 | ||
1032 | /* HT */ | 1058 | /* HT */ |
1033 | void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband, | 1059 | void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband, |
@@ -1065,6 +1091,7 @@ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, | |||
1065 | 1091 | ||
1066 | /* Suspend/resume and hw reconfiguration */ | 1092 | /* Suspend/resume and hw reconfiguration */ |
1067 | int ieee80211_reconfig(struct ieee80211_local *local); | 1093 | int ieee80211_reconfig(struct ieee80211_local *local); |
1094 | void ieee80211_stop_device(struct ieee80211_local *local); | ||
1068 | 1095 | ||
1069 | #ifdef CONFIG_PM | 1096 | #ifdef CONFIG_PM |
1070 | int __ieee80211_suspend(struct ieee80211_hw *hw); | 1097 | int __ieee80211_suspend(struct ieee80211_hw *hw); |
@@ -1092,7 +1119,8 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, | |||
1092 | int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, | 1119 | int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, |
1093 | int rate, int erp, int short_preamble); | 1120 | int rate, int erp, int short_preamble); |
1094 | void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, | 1121 | void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, |
1095 | struct ieee80211_hdr *hdr, const u8 *tsc); | 1122 | struct ieee80211_hdr *hdr, const u8 *tsc, |
1123 | gfp_t gfp); | ||
1096 | void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata); | 1124 | void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata); |
1097 | void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | 1125 | void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, |
1098 | int encrypt); | 1126 | int encrypt); |
@@ -1129,8 +1157,8 @@ int ieee80211_add_pending_skbs(struct ieee80211_local *local, | |||
1129 | 1157 | ||
1130 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | 1158 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, |
1131 | u16 transaction, u16 auth_alg, | 1159 | u16 transaction, u16 auth_alg, |
1132 | u8 *extra, size_t extra_len, | 1160 | u8 *extra, size_t extra_len, const u8 *bssid, |
1133 | const u8 *bssid, int encrypt); | 1161 | const u8 *key, u8 key_len, u8 key_idx); |
1134 | int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, | 1162 | int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, |
1135 | const u8 *ie, size_t ie_len); | 1163 | const u8 *ie, size_t ie_len); |
1136 | void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, | 1164 | void 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..b8295cbd7e8f 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 | */ |
@@ -224,18 +220,15 @@ static int ieee80211_open(struct net_device *dev) | |||
224 | local->fif_fcsfail++; | 220 | local->fif_fcsfail++; |
225 | if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL) | 221 | if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL) |
226 | local->fif_plcpfail++; | 222 | local->fif_plcpfail++; |
227 | if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL) | 223 | if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL) { |
228 | local->fif_control++; | 224 | local->fif_control++; |
225 | local->fif_pspoll++; | ||
226 | } | ||
229 | if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) | 227 | if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) |
230 | local->fif_other_bss++; | 228 | local->fif_other_bss++; |
231 | 229 | ||
232 | netif_addr_lock_bh(local->mdev); | ||
233 | ieee80211_configure_filter(local); | 230 | ieee80211_configure_filter(local); |
234 | netif_addr_unlock_bh(local->mdev); | ||
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,12 +239,15 @@ 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); | ||
250 | ieee80211_configure_filter(local); | 242 | ieee80211_configure_filter(local); |
251 | netif_addr_unlock_bh(local->mdev); | ||
252 | 243 | ||
253 | ieee80211_start_mesh(sdata); | 244 | ieee80211_start_mesh(sdata); |
245 | } else if (sdata->vif.type == NL80211_IFTYPE_AP) { | ||
246 | local->fif_pspoll++; | ||
247 | |||
248 | ieee80211_configure_filter(local); | ||
254 | } | 249 | } |
250 | |||
255 | changed |= ieee80211_reset_erp_info(sdata); | 251 | changed |= ieee80211_reset_erp_info(sdata); |
256 | ieee80211_bss_info_change_notify(sdata, changed); | 252 | ieee80211_bss_info_change_notify(sdata, changed); |
257 | ieee80211_enable_keys(sdata); | 253 | ieee80211_enable_keys(sdata); |
@@ -281,15 +277,6 @@ static int ieee80211_open(struct net_device *dev) | |||
281 | } | 277 | } |
282 | } | 278 | } |
283 | 279 | ||
284 | 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); | ||
290 | tasklet_enable(&local->tasklet); | ||
291 | } | ||
292 | |||
293 | /* | 280 | /* |
294 | * set_multicast_list will be invoked by the networking core | 281 | * set_multicast_list will be invoked by the networking core |
295 | * which will check whether any increments here were done in | 282 | * which will check whether any increments here were done in |
@@ -323,7 +310,7 @@ static int ieee80211_open(struct net_device *dev) | |||
323 | * to fix this. | 310 | * to fix this. |
324 | */ | 311 | */ |
325 | if (sdata->vif.type == NL80211_IFTYPE_STATION) | 312 | if (sdata->vif.type == NL80211_IFTYPE_STATION) |
326 | queue_work(local->hw.workqueue, &sdata->u.mgd.work); | 313 | ieee80211_queue_work(&local->hw, &sdata->u.mgd.work); |
327 | 314 | ||
328 | netif_tx_start_all_queues(dev); | 315 | netif_tx_start_all_queues(dev); |
329 | 316 | ||
@@ -346,7 +333,10 @@ static int ieee80211_stop(struct net_device *dev) | |||
346 | struct ieee80211_local *local = sdata->local; | 333 | struct ieee80211_local *local = sdata->local; |
347 | struct ieee80211_if_init_conf conf; | 334 | struct ieee80211_if_init_conf conf; |
348 | struct sta_info *sta; | 335 | struct sta_info *sta; |
336 | unsigned long flags; | ||
337 | struct sk_buff *skb, *tmp; | ||
349 | u32 hw_reconf_flags = 0; | 338 | u32 hw_reconf_flags = 0; |
339 | int i; | ||
350 | 340 | ||
351 | /* | 341 | /* |
352 | * Stop TX on this interface first. | 342 | * Stop TX on this interface first. |
@@ -366,18 +356,6 @@ static int ieee80211_stop(struct net_device *dev) | |||
366 | rcu_read_unlock(); | 356 | rcu_read_unlock(); |
367 | 357 | ||
368 | /* | 358 | /* |
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. | 359 | * Remove all stations associated with this interface. |
382 | * | 360 | * |
383 | * This must be done before calling ops->remove_interface() | 361 | * This must be done before calling ops->remove_interface() |
@@ -408,13 +386,24 @@ static int ieee80211_stop(struct net_device *dev) | |||
408 | if (sdata->flags & IEEE80211_SDATA_PROMISC) | 386 | if (sdata->flags & IEEE80211_SDATA_PROMISC) |
409 | atomic_dec(&local->iff_promiscs); | 387 | atomic_dec(&local->iff_promiscs); |
410 | 388 | ||
411 | dev_mc_unsync(local->mdev, dev); | 389 | if (sdata->vif.type == NL80211_IFTYPE_AP) |
390 | local->fif_pspoll--; | ||
391 | |||
392 | netif_addr_lock_bh(dev); | ||
393 | spin_lock_bh(&local->filter_lock); | ||
394 | __dev_addr_unsync(&local->mc_list, &local->mc_count, | ||
395 | &dev->mc_list, &dev->mc_count); | ||
396 | spin_unlock_bh(&local->filter_lock); | ||
397 | netif_addr_unlock_bh(dev); | ||
398 | |||
399 | ieee80211_configure_filter(local); | ||
400 | |||
412 | del_timer_sync(&local->dynamic_ps_timer); | 401 | del_timer_sync(&local->dynamic_ps_timer); |
413 | cancel_work_sync(&local->dynamic_ps_enable_work); | 402 | cancel_work_sync(&local->dynamic_ps_enable_work); |
414 | 403 | ||
415 | /* APs need special treatment */ | 404 | /* APs need special treatment */ |
416 | if (sdata->vif.type == NL80211_IFTYPE_AP) { | 405 | if (sdata->vif.type == NL80211_IFTYPE_AP) { |
417 | struct ieee80211_sub_if_data *vlan, *tmp; | 406 | struct ieee80211_sub_if_data *vlan, *tmpsdata; |
418 | struct beacon_data *old_beacon = sdata->u.ap.beacon; | 407 | struct beacon_data *old_beacon = sdata->u.ap.beacon; |
419 | 408 | ||
420 | /* remove beacon */ | 409 | /* remove beacon */ |
@@ -423,7 +412,7 @@ static int ieee80211_stop(struct net_device *dev) | |||
423 | kfree(old_beacon); | 412 | kfree(old_beacon); |
424 | 413 | ||
425 | /* down all dependent devices, that is VLANs */ | 414 | /* down all dependent devices, that is VLANs */ |
426 | list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans, | 415 | list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, |
427 | u.vlan.list) | 416 | u.vlan.list) |
428 | dev_close(vlan->dev); | 417 | dev_close(vlan->dev); |
429 | WARN_ON(!list_empty(&sdata->u.ap.vlans)); | 418 | WARN_ON(!list_empty(&sdata->u.ap.vlans)); |
@@ -452,29 +441,30 @@ static int ieee80211_stop(struct net_device *dev) | |||
452 | local->fif_fcsfail--; | 441 | local->fif_fcsfail--; |
453 | if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL) | 442 | if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL) |
454 | local->fif_plcpfail--; | 443 | local->fif_plcpfail--; |
455 | if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL) | 444 | if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL) { |
445 | local->fif_pspoll--; | ||
456 | local->fif_control--; | 446 | local->fif_control--; |
447 | } | ||
457 | if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) | 448 | if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) |
458 | local->fif_other_bss--; | 449 | local->fif_other_bss--; |
459 | 450 | ||
460 | netif_addr_lock_bh(local->mdev); | ||
461 | ieee80211_configure_filter(local); | 451 | ieee80211_configure_filter(local); |
462 | netif_addr_unlock_bh(local->mdev); | ||
463 | break; | 452 | break; |
464 | case NL80211_IFTYPE_STATION: | 453 | case NL80211_IFTYPE_STATION: |
465 | memset(sdata->u.mgd.bssid, 0, ETH_ALEN); | ||
466 | del_timer_sync(&sdata->u.mgd.chswitch_timer); | 454 | del_timer_sync(&sdata->u.mgd.chswitch_timer); |
467 | del_timer_sync(&sdata->u.mgd.timer); | 455 | del_timer_sync(&sdata->u.mgd.timer); |
456 | del_timer_sync(&sdata->u.mgd.conn_mon_timer); | ||
457 | del_timer_sync(&sdata->u.mgd.bcn_mon_timer); | ||
468 | /* | 458 | /* |
469 | * If the timer fired while we waited for it, it will have | 459 | * If any of the timers fired while we waited for it, it will |
470 | * requeued the work. Now the work will be running again | 460 | * have queued its work. Now the work will be running again |
471 | * but will not rearm the timer again because it checks | 461 | * but will not rearm the timer again because it checks |
472 | * whether the interface is running, which, at this point, | 462 | * whether the interface is running, which, at this point, |
473 | * it no longer is. | 463 | * it no longer is. |
474 | */ | 464 | */ |
475 | cancel_work_sync(&sdata->u.mgd.work); | 465 | cancel_work_sync(&sdata->u.mgd.work); |
476 | cancel_work_sync(&sdata->u.mgd.chswitch_work); | 466 | cancel_work_sync(&sdata->u.mgd.chswitch_work); |
477 | 467 | cancel_work_sync(&sdata->u.mgd.monitor_work); | |
478 | cancel_work_sync(&sdata->u.mgd.beacon_loss_work); | 468 | cancel_work_sync(&sdata->u.mgd.beacon_loss_work); |
479 | 469 | ||
480 | /* | 470 | /* |
@@ -485,12 +475,6 @@ static int ieee80211_stop(struct net_device *dev) | |||
485 | */ | 475 | */ |
486 | synchronize_rcu(); | 476 | synchronize_rcu(); |
487 | skb_queue_purge(&sdata->u.mgd.skb_queue); | 477 | 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 */ | 478 | /* fall through */ |
495 | case NL80211_IFTYPE_ADHOC: | 479 | case NL80211_IFTYPE_ADHOC: |
496 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { | 480 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
@@ -507,37 +491,23 @@ static int ieee80211_stop(struct net_device *dev) | |||
507 | local->fif_other_bss--; | 491 | local->fif_other_bss--; |
508 | atomic_dec(&local->iff_allmultis); | 492 | atomic_dec(&local->iff_allmultis); |
509 | 493 | ||
510 | netif_addr_lock_bh(local->mdev); | ||
511 | ieee80211_configure_filter(local); | 494 | ieee80211_configure_filter(local); |
512 | netif_addr_unlock_bh(local->mdev); | ||
513 | 495 | ||
514 | ieee80211_stop_mesh(sdata); | 496 | ieee80211_stop_mesh(sdata); |
515 | } | 497 | } |
516 | /* fall through */ | 498 | /* fall through */ |
517 | default: | 499 | default: |
518 | if (local->scan_sdata == sdata) { | 500 | if (local->scan_sdata == sdata) |
519 | if (!local->ops->hw_scan) | 501 | ieee80211_scan_cancel(local); |
520 | cancel_delayed_work_sync(&local->scan_work); | 502 | |
521 | /* | 503 | /* |
522 | * The software scan can no longer run now, so we can | 504 | * Disable beaconing for AP and mesh, IBSS can't |
523 | * clear out the scan_sdata reference. However, the | 505 | * still be joined to a network at this point. |
524 | * hardware scan may still be running. The complete | 506 | */ |
525 | * function must be prepared to handle a NULL value. | 507 | if (sdata->vif.type == NL80211_IFTYPE_AP || |
526 | */ | 508 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) { |
527 | local->scan_sdata = NULL; | 509 | ieee80211_bss_info_change_notify(sdata, |
528 | /* | 510 | BSS_CHANGED_BEACON_ENABLED); |
529 | * The memory barrier guarantees that another CPU | ||
530 | * that is hardware-scanning will now see the fact | ||
531 | * that this interface is gone. | ||
532 | */ | ||
533 | smp_mb(); | ||
534 | /* | ||
535 | * If software scanning, complete the scan but since | ||
536 | * the scan_sdata is NULL already don't send out a | ||
537 | * scan event to userspace -- the scan is incomplete. | ||
538 | */ | ||
539 | if (local->sw_scanning) | ||
540 | ieee80211_scan_completed(&local->hw, true); | ||
541 | } | 511 | } |
542 | 512 | ||
543 | conf.vif = &sdata->vif; | 513 | conf.vif = &sdata->vif; |
@@ -555,17 +525,8 @@ static int ieee80211_stop(struct net_device *dev) | |||
555 | ieee80211_recalc_ps(local, -1); | 525 | ieee80211_recalc_ps(local, -1); |
556 | 526 | ||
557 | if (local->open_count == 0) { | 527 | if (local->open_count == 0) { |
558 | if (netif_running(local->mdev)) | 528 | ieee80211_clear_tx_pending(local); |
559 | dev_close(local->mdev); | 529 | ieee80211_stop_device(local); |
560 | |||
561 | drv_stop(local); | ||
562 | |||
563 | ieee80211_led_radio(local, false); | ||
564 | |||
565 | flush_workqueue(local->hw.workqueue); | ||
566 | |||
567 | tasklet_disable(&local->tx_pending_tasklet); | ||
568 | tasklet_disable(&local->tasklet); | ||
569 | 530 | ||
570 | /* no reconfiguring after stop! */ | 531 | /* no reconfiguring after stop! */ |
571 | hw_reconf_flags = 0; | 532 | hw_reconf_flags = 0; |
@@ -575,6 +536,18 @@ static int ieee80211_stop(struct net_device *dev) | |||
575 | if (hw_reconf_flags) | 536 | if (hw_reconf_flags) |
576 | ieee80211_hw_config(local, hw_reconf_flags); | 537 | ieee80211_hw_config(local, hw_reconf_flags); |
577 | 538 | ||
539 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | ||
540 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { | ||
541 | skb_queue_walk_safe(&local->pending[i], skb, tmp) { | ||
542 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
543 | if (info->control.vif == &sdata->vif) { | ||
544 | __skb_unlink(skb, &local->pending[i]); | ||
545 | dev_kfree_skb_irq(skb); | ||
546 | } | ||
547 | } | ||
548 | } | ||
549 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
550 | |||
578 | return 0; | 551 | return 0; |
579 | } | 552 | } |
580 | 553 | ||
@@ -604,8 +577,11 @@ static void ieee80211_set_multicast_list(struct net_device *dev) | |||
604 | atomic_dec(&local->iff_promiscs); | 577 | atomic_dec(&local->iff_promiscs); |
605 | sdata->flags ^= IEEE80211_SDATA_PROMISC; | 578 | sdata->flags ^= IEEE80211_SDATA_PROMISC; |
606 | } | 579 | } |
607 | 580 | spin_lock_bh(&local->filter_lock); | |
608 | dev_mc_sync(local->mdev, dev); | 581 | __dev_addr_sync(&local->mc_list, &local->mc_count, |
582 | &dev->mc_list, &dev->mc_count); | ||
583 | spin_unlock_bh(&local->filter_lock); | ||
584 | ieee80211_queue_work(&local->hw, &local->reconfig_filter); | ||
609 | } | 585 | } |
610 | 586 | ||
611 | /* | 587 | /* |
@@ -652,11 +628,6 @@ static void ieee80211_teardown_sdata(struct net_device *dev) | |||
652 | kfree_skb(sdata->u.ibss.presp); | 628 | kfree_skb(sdata->u.ibss.presp); |
653 | break; | 629 | break; |
654 | case NL80211_IFTYPE_STATION: | 630 | 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: | 631 | case NL80211_IFTYPE_WDS: |
661 | case NL80211_IFTYPE_AP_VLAN: | 632 | case NL80211_IFTYPE_AP_VLAN: |
662 | case NL80211_IFTYPE_MONITOR: | 633 | case NL80211_IFTYPE_MONITOR: |
@@ -695,7 +666,6 @@ static void ieee80211_if_setup(struct net_device *dev) | |||
695 | { | 666 | { |
696 | ether_setup(dev); | 667 | ether_setup(dev); |
697 | dev->netdev_ops = &ieee80211_dataif_ops; | 668 | dev->netdev_ops = &ieee80211_dataif_ops; |
698 | dev->wireless_handlers = &ieee80211_iw_handler_def; | ||
699 | dev->destructor = free_netdev; | 669 | dev->destructor = free_netdev; |
700 | } | 670 | } |
701 | 671 | ||
@@ -784,6 +754,10 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, | |||
784 | return 0; | 754 | return 0; |
785 | } | 755 | } |
786 | 756 | ||
757 | static struct device_type wiphy_type = { | ||
758 | .name = "wlan", | ||
759 | }; | ||
760 | |||
787 | int ieee80211_if_add(struct ieee80211_local *local, const char *name, | 761 | int ieee80211_if_add(struct ieee80211_local *local, const char *name, |
788 | struct net_device **new_dev, enum nl80211_iftype type, | 762 | struct net_device **new_dev, enum nl80211_iftype type, |
789 | struct vif_params *params) | 763 | struct vif_params *params) |
@@ -798,6 +772,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, | |||
798 | name, ieee80211_if_setup); | 772 | name, ieee80211_if_setup); |
799 | if (!ndev) | 773 | if (!ndev) |
800 | return -ENOMEM; | 774 | return -ENOMEM; |
775 | dev_net_set(ndev, wiphy_net(local->hw.wiphy)); | ||
801 | 776 | ||
802 | ndev->needed_headroom = local->tx_headroom + | 777 | ndev->needed_headroom = local->tx_headroom + |
803 | 4*6 /* four MAC addresses */ | 778 | 4*6 /* four MAC addresses */ |
@@ -814,7 +789,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, | |||
814 | 789 | ||
815 | memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN); | 790 | memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN); |
816 | SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy)); | 791 | SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy)); |
817 | ndev->features |= NETIF_F_NETNS_LOCAL; | 792 | SET_NETDEV_DEVTYPE(ndev, &wiphy_type); |
818 | 793 | ||
819 | /* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */ | 794 | /* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */ |
820 | sdata = netdev_priv(ndev); | 795 | sdata = netdev_priv(ndev); |
@@ -931,7 +906,7 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local) | |||
931 | struct ieee80211_sub_if_data *sdata; | 906 | struct ieee80211_sub_if_data *sdata; |
932 | int count = 0; | 907 | int count = 0; |
933 | 908 | ||
934 | if (local->hw_scanning || local->sw_scanning) | 909 | if (local->scanning) |
935 | return ieee80211_idle_off(local, "scanning"); | 910 | return ieee80211_idle_off(local, "scanning"); |
936 | 911 | ||
937 | list_for_each_entry(sdata, &local->interfaces, list) { | 912 | list_for_each_entry(sdata, &local->interfaces, list) { |
@@ -939,7 +914,8 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local) | |||
939 | continue; | 914 | continue; |
940 | /* do not count disabled managed interfaces */ | 915 | /* do not count disabled managed interfaces */ |
941 | if (sdata->vif.type == NL80211_IFTYPE_STATION && | 916 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
942 | sdata->u.mgd.state == IEEE80211_STA_MLME_DISABLED) | 917 | !sdata->u.mgd.associated && |
918 | list_empty(&sdata->u.mgd.work_list)) | ||
943 | continue; | 919 | continue; |
944 | /* do not count unused IBSS interfaces */ | 920 | /* do not count unused IBSS interfaces */ |
945 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && | 921 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && |
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 092a017b237e..797f53942e5f 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -50,9 +50,9 @@ struct ieee80211_tx_status_rtap_hdr { | |||
50 | } __attribute__ ((packed)); | 50 | } __attribute__ ((packed)); |
51 | 51 | ||
52 | 52 | ||
53 | /* must be called under mdev tx lock */ | ||
54 | void ieee80211_configure_filter(struct ieee80211_local *local) | 53 | void ieee80211_configure_filter(struct ieee80211_local *local) |
55 | { | 54 | { |
55 | u64 mc; | ||
56 | unsigned int changed_flags; | 56 | unsigned int changed_flags; |
57 | unsigned int new_flags = 0; | 57 | unsigned int new_flags = 0; |
58 | 58 | ||
@@ -62,7 +62,7 @@ void ieee80211_configure_filter(struct ieee80211_local *local) | |||
62 | if (atomic_read(&local->iff_allmultis)) | 62 | if (atomic_read(&local->iff_allmultis)) |
63 | new_flags |= FIF_ALLMULTI; | 63 | new_flags |= FIF_ALLMULTI; |
64 | 64 | ||
65 | if (local->monitors) | 65 | if (local->monitors || local->scanning) |
66 | new_flags |= FIF_BCN_PRBRESP_PROMISC; | 66 | new_flags |= FIF_BCN_PRBRESP_PROMISC; |
67 | 67 | ||
68 | if (local->fif_fcsfail) | 68 | if (local->fif_fcsfail) |
@@ -77,77 +77,29 @@ void ieee80211_configure_filter(struct ieee80211_local *local) | |||
77 | if (local->fif_other_bss) | 77 | if (local->fif_other_bss) |
78 | new_flags |= FIF_OTHER_BSS; | 78 | new_flags |= FIF_OTHER_BSS; |
79 | 79 | ||
80 | if (local->fif_pspoll) | ||
81 | new_flags |= FIF_PSPOLL; | ||
82 | |||
83 | spin_lock_bh(&local->filter_lock); | ||
80 | changed_flags = local->filter_flags ^ new_flags; | 84 | changed_flags = local->filter_flags ^ new_flags; |
81 | 85 | ||
86 | mc = drv_prepare_multicast(local, local->mc_count, local->mc_list); | ||
87 | spin_unlock_bh(&local->filter_lock); | ||
88 | |||
82 | /* be a bit nasty */ | 89 | /* be a bit nasty */ |
83 | new_flags |= (1<<31); | 90 | new_flags |= (1<<31); |
84 | 91 | ||
85 | drv_configure_filter(local, changed_flags, &new_flags, | 92 | drv_configure_filter(local, changed_flags, &new_flags, mc); |
86 | local->mdev->mc_count, | ||
87 | local->mdev->mc_list); | ||
88 | 93 | ||
89 | WARN_ON(new_flags & (1<<31)); | 94 | WARN_ON(new_flags & (1<<31)); |
90 | 95 | ||
91 | local->filter_flags = new_flags & ~(1<<31); | 96 | local->filter_flags = new_flags & ~(1<<31); |
92 | } | 97 | } |
93 | 98 | ||
94 | /* master interface */ | 99 | static void ieee80211_reconfig_filter(struct work_struct *work) |
95 | |||
96 | static 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 | |||
102 | static 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 | |||
110 | static int ieee80211_master_open(struct net_device *dev) | ||
111 | { | 100 | { |
112 | struct ieee80211_master_priv *mpriv = netdev_priv(dev); | 101 | struct ieee80211_local *local = |
113 | struct ieee80211_local *local = mpriv->local; | 102 | container_of(work, struct ieee80211_local, reconfig_filter); |
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 | |||
133 | static 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 | |||
147 | static 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 | 103 | ||
152 | ieee80211_configure_filter(local); | 104 | ieee80211_configure_filter(local); |
153 | } | 105 | } |
@@ -259,7 +211,8 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | |||
259 | } | 211 | } |
260 | 212 | ||
261 | if (changed & BSS_CHANGED_BEACON_ENABLED) { | 213 | if (changed & BSS_CHANGED_BEACON_ENABLED) { |
262 | if (local->sw_scanning) { | 214 | if (local->quiescing || !netif_running(sdata->dev) || |
215 | test_bit(SCAN_SW_SCANNING, &local->scanning)) { | ||
263 | sdata->vif.bss_conf.enable_beacon = false; | 216 | sdata->vif.bss_conf.enable_beacon = false; |
264 | } else { | 217 | } else { |
265 | /* | 218 | /* |
@@ -288,9 +241,6 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | |||
288 | 241 | ||
289 | drv_bss_info_changed(local, &sdata->vif, | 242 | drv_bss_info_changed(local, &sdata->vif, |
290 | &sdata->vif.bss_conf, changed); | 243 | &sdata->vif.bss_conf, changed); |
291 | |||
292 | /* DEPRECATED */ | ||
293 | local->hw.conf.beacon_int = sdata->vif.bss_conf.beacon_int; | ||
294 | } | 244 | } |
295 | 245 | ||
296 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata) | 246 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata) |
@@ -310,7 +260,6 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, | |||
310 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 260 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
311 | int tmp; | 261 | int tmp; |
312 | 262 | ||
313 | skb->dev = local->mdev; | ||
314 | skb->pkt_type = IEEE80211_TX_STATUS_MSG; | 263 | skb->pkt_type = IEEE80211_TX_STATUS_MSG; |
315 | skb_queue_tail(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS ? | 264 | skb_queue_tail(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS ? |
316 | &local->skb_queue : &local->skb_queue_unreliable, skb); | 265 | &local->skb_queue : &local->skb_queue_unreliable, skb); |
@@ -330,19 +279,16 @@ static void ieee80211_tasklet_handler(unsigned long data) | |||
330 | { | 279 | { |
331 | struct ieee80211_local *local = (struct ieee80211_local *) data; | 280 | struct ieee80211_local *local = (struct ieee80211_local *) data; |
332 | struct sk_buff *skb; | 281 | struct sk_buff *skb; |
333 | struct ieee80211_rx_status rx_status; | ||
334 | struct ieee80211_ra_tid *ra_tid; | 282 | struct ieee80211_ra_tid *ra_tid; |
335 | 283 | ||
336 | while ((skb = skb_dequeue(&local->skb_queue)) || | 284 | while ((skb = skb_dequeue(&local->skb_queue)) || |
337 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { | 285 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { |
338 | switch (skb->pkt_type) { | 286 | switch (skb->pkt_type) { |
339 | case IEEE80211_RX_MSG: | 287 | 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 | 288 | /* Clear skb->pkt_type in order to not confuse kernel |
343 | * netstack. */ | 289 | * netstack. */ |
344 | skb->pkt_type = 0; | 290 | skb->pkt_type = 0; |
345 | __ieee80211_rx(local_to_hw(local), skb, &rx_status); | 291 | ieee80211_rx(local_to_hw(local), skb); |
346 | break; | 292 | break; |
347 | case IEEE80211_TX_STATUS_MSG: | 293 | case IEEE80211_TX_STATUS_MSG: |
348 | skb->pkt_type = 0; | 294 | skb->pkt_type = 0; |
@@ -375,6 +321,31 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local, | |||
375 | { | 321 | { |
376 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 322 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
377 | 323 | ||
324 | /* | ||
325 | * XXX: This is temporary! | ||
326 | * | ||
327 | * The problem here is that when we get here, the driver will | ||
328 | * quite likely have pretty much overwritten info->control by | ||
329 | * using info->driver_data or info->rate_driver_data. Thus, | ||
330 | * when passing out the frame to the driver again, we would be | ||
331 | * passing completely bogus data since the driver would then | ||
332 | * expect a properly filled info->control. In mac80211 itself | ||
333 | * the same problem occurs, since we need info->control.vif | ||
334 | * internally. | ||
335 | * | ||
336 | * To fix this, we should send the frame through TX processing | ||
337 | * again. However, it's not that simple, since the frame will | ||
338 | * have been software-encrypted (if applicable) already, and | ||
339 | * encrypting it again doesn't do much good. So to properly do | ||
340 | * that, we not only have to skip the actual 'raw' encryption | ||
341 | * (key selection etc. still has to be done!) but also the | ||
342 | * sequence number assignment since that impacts the crypto | ||
343 | * encapsulation, of course. | ||
344 | * | ||
345 | * Hence, for now, fix the bug by just dropping the frame. | ||
346 | */ | ||
347 | goto drop; | ||
348 | |||
378 | sta->tx_filtered_count++; | 349 | sta->tx_filtered_count++; |
379 | 350 | ||
380 | /* | 351 | /* |
@@ -428,6 +399,7 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local, | |||
428 | return; | 399 | return; |
429 | } | 400 | } |
430 | 401 | ||
402 | drop: | ||
431 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 403 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
432 | if (net_ratelimit()) | 404 | if (net_ratelimit()) |
433 | printk(KERN_DEBUG "%s: dropped TX filtered frame, " | 405 | printk(KERN_DEBUG "%s: dropped TX filtered frame, " |
@@ -510,6 +482,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
510 | } | 482 | } |
511 | 483 | ||
512 | rate_control_tx_status(local, sband, sta, skb); | 484 | rate_control_tx_status(local, sband, sta, skb); |
485 | if (ieee80211_vif_is_mesh(&sta->sdata->vif)) | ||
486 | ieee80211s_update_metric(local, sta, skb); | ||
513 | } | 487 | } |
514 | 488 | ||
515 | rcu_read_unlock(); | 489 | rcu_read_unlock(); |
@@ -685,6 +659,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
685 | if (!wiphy) | 659 | if (!wiphy) |
686 | return NULL; | 660 | return NULL; |
687 | 661 | ||
662 | wiphy->netnsok = true; | ||
688 | wiphy->privid = mac80211_wiphy_privid; | 663 | wiphy->privid = mac80211_wiphy_privid; |
689 | 664 | ||
690 | /* Yes, putting cfg80211_bss into ieee80211_bss is a hack */ | 665 | /* Yes, putting cfg80211_bss into ieee80211_bss is a hack */ |
@@ -711,7 +686,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
711 | local->hw.max_rates = 1; | 686 | local->hw.max_rates = 1; |
712 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; | 687 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
713 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; | 688 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
714 | local->hw.conf.radio_enabled = true; | ||
715 | local->user_power_level = -1; | 689 | local->user_power_level = -1; |
716 | 690 | ||
717 | INIT_LIST_HEAD(&local->interfaces); | 691 | INIT_LIST_HEAD(&local->interfaces); |
@@ -719,13 +693,15 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
719 | mutex_init(&local->scan_mtx); | 693 | mutex_init(&local->scan_mtx); |
720 | 694 | ||
721 | spin_lock_init(&local->key_lock); | 695 | spin_lock_init(&local->key_lock); |
722 | 696 | spin_lock_init(&local->filter_lock); | |
723 | spin_lock_init(&local->queue_stop_reason_lock); | 697 | spin_lock_init(&local->queue_stop_reason_lock); |
724 | 698 | ||
725 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work); | 699 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work); |
726 | 700 | ||
727 | INIT_WORK(&local->restart_work, ieee80211_restart_work); | 701 | INIT_WORK(&local->restart_work, ieee80211_restart_work); |
728 | 702 | ||
703 | INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter); | ||
704 | |||
729 | INIT_WORK(&local->dynamic_ps_enable_work, | 705 | INIT_WORK(&local->dynamic_ps_enable_work, |
730 | ieee80211_dynamic_ps_enable_work); | 706 | ieee80211_dynamic_ps_enable_work); |
731 | INIT_WORK(&local->dynamic_ps_disable_work, | 707 | INIT_WORK(&local->dynamic_ps_disable_work, |
@@ -739,12 +715,10 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
739 | skb_queue_head_init(&local->pending[i]); | 715 | skb_queue_head_init(&local->pending[i]); |
740 | tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, | 716 | tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, |
741 | (unsigned long)local); | 717 | (unsigned long)local); |
742 | tasklet_disable(&local->tx_pending_tasklet); | ||
743 | 718 | ||
744 | tasklet_init(&local->tasklet, | 719 | tasklet_init(&local->tasklet, |
745 | ieee80211_tasklet_handler, | 720 | ieee80211_tasklet_handler, |
746 | (unsigned long) local); | 721 | (unsigned long) local); |
747 | tasklet_disable(&local->tasklet); | ||
748 | 722 | ||
749 | skb_queue_head_init(&local->skb_queue); | 723 | skb_queue_head_init(&local->skb_queue); |
750 | skb_queue_head_init(&local->skb_queue_unreliable); | 724 | skb_queue_head_init(&local->skb_queue_unreliable); |
@@ -755,30 +729,11 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
755 | } | 729 | } |
756 | EXPORT_SYMBOL(ieee80211_alloc_hw); | 730 | EXPORT_SYMBOL(ieee80211_alloc_hw); |
757 | 731 | ||
758 | static 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 | |||
766 | static 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 | |||
775 | int ieee80211_register_hw(struct ieee80211_hw *hw) | 732 | int ieee80211_register_hw(struct ieee80211_hw *hw) |
776 | { | 733 | { |
777 | struct ieee80211_local *local = hw_to_local(hw); | 734 | struct ieee80211_local *local = hw_to_local(hw); |
778 | int result; | 735 | int result; |
779 | enum ieee80211_band band; | 736 | enum ieee80211_band band; |
780 | struct net_device *mdev; | ||
781 | struct ieee80211_master_priv *mpriv; | ||
782 | int channels, i, j, max_bitrates; | 737 | int channels, i, j, max_bitrates; |
783 | bool supp_ht; | 738 | bool supp_ht; |
784 | static const u32 cipher_suites[] = { | 739 | static const u32 cipher_suites[] = { |
@@ -818,9 +773,9 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
818 | supp_ht = supp_ht || sband->ht_cap.ht_supported; | 773 | supp_ht = supp_ht || sband->ht_cap.ht_supported; |
819 | } | 774 | } |
820 | 775 | ||
821 | local->int_scan_req.n_channels = channels; | 776 | local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + |
822 | local->int_scan_req.channels = kzalloc(sizeof(void *) * channels, GFP_KERNEL); | 777 | sizeof(void *) * channels, GFP_KERNEL); |
823 | if (!local->int_scan_req.channels) | 778 | if (!local->int_scan_req) |
824 | return -ENOMEM; | 779 | return -ENOMEM; |
825 | 780 | ||
826 | /* if low-level driver supports AP, we also support VLAN */ | 781 | /* if low-level driver supports AP, we also support VLAN */ |
@@ -877,19 +832,9 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
877 | if (hw->queues > IEEE80211_MAX_QUEUES) | 832 | if (hw->queues > IEEE80211_MAX_QUEUES) |
878 | hw->queues = IEEE80211_MAX_QUEUES; | 833 | hw->queues = IEEE80211_MAX_QUEUES; |
879 | 834 | ||
880 | mdev = alloc_netdev_mq(sizeof(struct ieee80211_master_priv), | 835 | local->workqueue = |
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 = | ||
891 | create_singlethread_workqueue(wiphy_name(local->hw.wiphy)); | 836 | create_singlethread_workqueue(wiphy_name(local->hw.wiphy)); |
892 | if (!local->hw.workqueue) { | 837 | if (!local->workqueue) { |
893 | result = -ENOMEM; | 838 | result = -ENOMEM; |
894 | goto fail_workqueue; | 839 | goto fail_workqueue; |
895 | } | 840 | } |
@@ -921,17 +866,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
921 | } | 866 | } |
922 | 867 | ||
923 | rtnl_lock(); | 868 | 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 | 869 | ||
936 | result = ieee80211_init_rate_ctrl_alg(local, | 870 | result = ieee80211_init_rate_ctrl_alg(local, |
937 | hw->rate_control_algorithm); | 871 | hw->rate_control_algorithm); |
@@ -956,13 +890,13 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
956 | 890 | ||
957 | /* alloc internal scan request */ | 891 | /* alloc internal scan request */ |
958 | i = 0; | 892 | i = 0; |
959 | local->int_scan_req.ssids = &local->scan_ssid; | 893 | local->int_scan_req->ssids = &local->scan_ssid; |
960 | local->int_scan_req.n_ssids = 1; | 894 | local->int_scan_req->n_ssids = 1; |
961 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | 895 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
962 | if (!hw->wiphy->bands[band]) | 896 | if (!hw->wiphy->bands[band]) |
963 | continue; | 897 | continue; |
964 | for (j = 0; j < hw->wiphy->bands[band]->n_channels; j++) { | 898 | for (j = 0; j < hw->wiphy->bands[band]->n_channels; j++) { |
965 | local->int_scan_req.channels[i] = | 899 | local->int_scan_req->channels[i] = |
966 | &hw->wiphy->bands[band]->channels[j]; | 900 | &hw->wiphy->bands[band]->channels[j]; |
967 | i++; | 901 | i++; |
968 | } | 902 | } |
@@ -984,23 +918,17 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
984 | ieee80211_led_exit(local); | 918 | ieee80211_led_exit(local); |
985 | ieee80211_remove_interfaces(local); | 919 | ieee80211_remove_interfaces(local); |
986 | fail_rate: | 920 | fail_rate: |
987 | unregister_netdevice(local->mdev); | ||
988 | local->mdev = NULL; | ||
989 | fail_dev: | ||
990 | rtnl_unlock(); | 921 | rtnl_unlock(); |
991 | ieee80211_wep_free(local); | 922 | ieee80211_wep_free(local); |
992 | fail_wep: | 923 | fail_wep: |
993 | sta_info_stop(local); | 924 | sta_info_stop(local); |
994 | fail_sta_info: | 925 | fail_sta_info: |
995 | debugfs_hw_del(local); | 926 | debugfs_hw_del(local); |
996 | destroy_workqueue(local->hw.workqueue); | 927 | destroy_workqueue(local->workqueue); |
997 | fail_workqueue: | 928 | fail_workqueue: |
998 | if (local->mdev) | ||
999 | free_netdev(local->mdev); | ||
1000 | fail_mdev_alloc: | ||
1001 | wiphy_unregister(local->hw.wiphy); | 929 | wiphy_unregister(local->hw.wiphy); |
1002 | fail_wiphy_register: | 930 | fail_wiphy_register: |
1003 | kfree(local->int_scan_req.channels); | 931 | kfree(local->int_scan_req); |
1004 | return result; | 932 | return result; |
1005 | } | 933 | } |
1006 | EXPORT_SYMBOL(ieee80211_register_hw); | 934 | EXPORT_SYMBOL(ieee80211_register_hw); |
@@ -1022,15 +950,12 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw) | |||
1022 | * because the driver cannot be handing us frames any | 950 | * because the driver cannot be handing us frames any |
1023 | * more and the tasklet is killed. | 951 | * more and the tasklet is killed. |
1024 | */ | 952 | */ |
1025 | |||
1026 | /* First, we remove all virtual interfaces. */ | ||
1027 | ieee80211_remove_interfaces(local); | 953 | ieee80211_remove_interfaces(local); |
1028 | 954 | ||
1029 | /* then, finally, remove the master interface */ | ||
1030 | unregister_netdevice(local->mdev); | ||
1031 | |||
1032 | rtnl_unlock(); | 955 | rtnl_unlock(); |
1033 | 956 | ||
957 | cancel_work_sync(&local->reconfig_filter); | ||
958 | |||
1034 | ieee80211_clear_tx_pending(local); | 959 | ieee80211_clear_tx_pending(local); |
1035 | sta_info_stop(local); | 960 | sta_info_stop(local); |
1036 | rate_control_deinitialize(local); | 961 | rate_control_deinitialize(local); |
@@ -1043,12 +968,11 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw) | |||
1043 | skb_queue_purge(&local->skb_queue); | 968 | skb_queue_purge(&local->skb_queue); |
1044 | skb_queue_purge(&local->skb_queue_unreliable); | 969 | skb_queue_purge(&local->skb_queue_unreliable); |
1045 | 970 | ||
1046 | destroy_workqueue(local->hw.workqueue); | 971 | destroy_workqueue(local->workqueue); |
1047 | wiphy_unregister(local->hw.wiphy); | 972 | wiphy_unregister(local->hw.wiphy); |
1048 | ieee80211_wep_free(local); | 973 | ieee80211_wep_free(local); |
1049 | ieee80211_led_exit(local); | 974 | ieee80211_led_exit(local); |
1050 | free_netdev(local->mdev); | 975 | kfree(local->int_scan_req); |
1051 | kfree(local->int_scan_req.channels); | ||
1052 | } | 976 | } |
1053 | EXPORT_SYMBOL(ieee80211_unregister_hw); | 977 | EXPORT_SYMBOL(ieee80211_unregister_hw); |
1054 | 978 | ||
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 11cf45bce38a..f7364e56f1ee 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -18,8 +18,11 @@ | |||
18 | #define PP_OFFSET 1 /* Path Selection Protocol */ | 18 | #define PP_OFFSET 1 /* Path Selection Protocol */ |
19 | #define PM_OFFSET 5 /* Path Selection Metric */ | 19 | #define PM_OFFSET 5 /* Path Selection Metric */ |
20 | #define CC_OFFSET 9 /* Congestion Control Mode */ | 20 | #define CC_OFFSET 9 /* Congestion Control Mode */ |
21 | #define CAPAB_OFFSET 17 | 21 | #define SP_OFFSET 13 /* Synchronization Protocol */ |
22 | #define ACCEPT_PLINKS 0x80 | 22 | #define AUTH_OFFSET 17 /* Authentication Protocol */ |
23 | #define CAPAB_OFFSET 22 | ||
24 | #define CAPAB_ACCEPT_PLINKS 0x80 | ||
25 | #define CAPAB_FORWARDING 0x10 | ||
23 | 26 | ||
24 | #define TMR_RUNNING_HK 0 | 27 | #define TMR_RUNNING_HK 0 |
25 | #define TMR_RUNNING_MP 1 | 28 | #define TMR_RUNNING_MP 1 |
@@ -47,14 +50,14 @@ static void ieee80211_mesh_housekeeping_timer(unsigned long data) | |||
47 | struct ieee80211_local *local = sdata->local; | 50 | struct ieee80211_local *local = sdata->local; |
48 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 51 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
49 | 52 | ||
50 | ifmsh->housekeeping = true; | 53 | ifmsh->wrkq_flags |= MESH_WORK_HOUSEKEEPING; |
51 | 54 | ||
52 | if (local->quiescing) { | 55 | if (local->quiescing) { |
53 | set_bit(TMR_RUNNING_HK, &ifmsh->timers_running); | 56 | set_bit(TMR_RUNNING_HK, &ifmsh->timers_running); |
54 | return; | 57 | return; |
55 | } | 58 | } |
56 | 59 | ||
57 | queue_work(local->hw.workqueue, &ifmsh->work); | 60 | ieee80211_queue_work(&local->hw, &ifmsh->work); |
58 | } | 61 | } |
59 | 62 | ||
60 | /** | 63 | /** |
@@ -84,7 +87,9 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_dat | |||
84 | memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && | 87 | memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && |
85 | memcmp(ifmsh->mesh_pp_id, ie->mesh_config + PP_OFFSET, 4) == 0 && | 88 | memcmp(ifmsh->mesh_pp_id, ie->mesh_config + PP_OFFSET, 4) == 0 && |
86 | memcmp(ifmsh->mesh_pm_id, ie->mesh_config + PM_OFFSET, 4) == 0 && | 89 | memcmp(ifmsh->mesh_pm_id, ie->mesh_config + PM_OFFSET, 4) == 0 && |
87 | memcmp(ifmsh->mesh_cc_id, ie->mesh_config + CC_OFFSET, 4) == 0) | 90 | memcmp(ifmsh->mesh_cc_id, ie->mesh_config + CC_OFFSET, 4) == 0 && |
91 | memcmp(ifmsh->mesh_sp_id, ie->mesh_config + SP_OFFSET, 4) == 0 && | ||
92 | memcmp(ifmsh->mesh_auth_id, ie->mesh_config + AUTH_OFFSET, 4) == 0) | ||
88 | return true; | 93 | return true; |
89 | 94 | ||
90 | return false; | 95 | return false; |
@@ -97,7 +102,7 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_dat | |||
97 | */ | 102 | */ |
98 | bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie) | 103 | bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie) |
99 | { | 104 | { |
100 | return (*(ie->mesh_config + CAPAB_OFFSET) & ACCEPT_PLINKS) != 0; | 105 | return (*(ie->mesh_config + CAPAB_OFFSET) & CAPAB_ACCEPT_PLINKS) != 0; |
101 | } | 106 | } |
102 | 107 | ||
103 | /** | 108 | /** |
@@ -123,11 +128,18 @@ void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata) | |||
123 | 128 | ||
124 | void mesh_ids_set_default(struct ieee80211_if_mesh *sta) | 129 | void mesh_ids_set_default(struct ieee80211_if_mesh *sta) |
125 | { | 130 | { |
126 | u8 def_id[4] = {0x00, 0x0F, 0xAC, 0xff}; | 131 | u8 oui[3] = {0x00, 0x0F, 0xAC}; |
127 | 132 | ||
128 | memcpy(sta->mesh_pp_id, def_id, 4); | 133 | memcpy(sta->mesh_pp_id, oui, sizeof(oui)); |
129 | memcpy(sta->mesh_pm_id, def_id, 4); | 134 | memcpy(sta->mesh_pm_id, oui, sizeof(oui)); |
130 | memcpy(sta->mesh_cc_id, def_id, 4); | 135 | memcpy(sta->mesh_cc_id, oui, sizeof(oui)); |
136 | memcpy(sta->mesh_sp_id, oui, sizeof(oui)); | ||
137 | memcpy(sta->mesh_auth_id, oui, sizeof(oui)); | ||
138 | sta->mesh_pp_id[sizeof(oui)] = 0; | ||
139 | sta->mesh_pm_id[sizeof(oui)] = 0; | ||
140 | sta->mesh_cc_id[sizeof(oui)] = 0xff; | ||
141 | sta->mesh_sp_id[sizeof(oui)] = 0xff; | ||
142 | sta->mesh_auth_id[sizeof(oui)] = 0x0; | ||
131 | } | 143 | } |
132 | 144 | ||
133 | int mesh_rmc_init(struct ieee80211_sub_if_data *sdata) | 145 | int mesh_rmc_init(struct ieee80211_sub_if_data *sdata) |
@@ -245,7 +257,7 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) | |||
245 | if (sdata->u.mesh.mesh_id_len) | 257 | if (sdata->u.mesh.mesh_id_len) |
246 | memcpy(pos, sdata->u.mesh.mesh_id, sdata->u.mesh.mesh_id_len); | 258 | memcpy(pos, sdata->u.mesh.mesh_id, sdata->u.mesh.mesh_id_len); |
247 | 259 | ||
248 | pos = skb_put(skb, 21); | 260 | pos = skb_put(skb, 2 + IEEE80211_MESH_CONFIG_LEN); |
249 | *pos++ = WLAN_EID_MESH_CONFIG; | 261 | *pos++ = WLAN_EID_MESH_CONFIG; |
250 | *pos++ = IEEE80211_MESH_CONFIG_LEN; | 262 | *pos++ = IEEE80211_MESH_CONFIG_LEN; |
251 | /* Version */ | 263 | /* Version */ |
@@ -263,15 +275,22 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) | |||
263 | memcpy(pos, sdata->u.mesh.mesh_cc_id, 4); | 275 | memcpy(pos, sdata->u.mesh.mesh_cc_id, 4); |
264 | pos += 4; | 276 | pos += 4; |
265 | 277 | ||
266 | /* Channel precedence: | 278 | /* Synchronization protocol identifier */ |
267 | * Not running simple channel unification protocol | 279 | memcpy(pos, sdata->u.mesh.mesh_sp_id, 4); |
268 | */ | ||
269 | memset(pos, 0x00, 4); | ||
270 | pos += 4; | 280 | pos += 4; |
271 | 281 | ||
282 | /* Authentication Protocol identifier */ | ||
283 | memcpy(pos, sdata->u.mesh.mesh_auth_id, 4); | ||
284 | pos += 4; | ||
285 | |||
286 | /* Mesh Formation Info */ | ||
287 | memset(pos, 0x00, 1); | ||
288 | pos += 1; | ||
289 | |||
272 | /* Mesh capability */ | 290 | /* Mesh capability */ |
273 | sdata->u.mesh.accepting_plinks = mesh_plink_availables(sdata); | 291 | sdata->u.mesh.accepting_plinks = mesh_plink_availables(sdata); |
274 | *pos++ = sdata->u.mesh.accepting_plinks ? ACCEPT_PLINKS : 0x00; | 292 | *pos = CAPAB_FORWARDING; |
293 | *pos++ |= sdata->u.mesh.accepting_plinks ? CAPAB_ACCEPT_PLINKS : 0x00; | ||
275 | *pos++ = 0x00; | 294 | *pos++ = 0x00; |
276 | 295 | ||
277 | return; | 296 | return; |
@@ -320,30 +339,6 @@ struct mesh_table *mesh_table_alloc(int size_order) | |||
320 | return newtbl; | 339 | return newtbl; |
321 | } | 340 | } |
322 | 341 | ||
323 | static void __mesh_table_free(struct mesh_table *tbl) | ||
324 | { | ||
325 | kfree(tbl->hash_buckets); | ||
326 | kfree(tbl->hashwlock); | ||
327 | kfree(tbl); | ||
328 | } | ||
329 | |||
330 | void mesh_table_free(struct mesh_table *tbl, bool free_leafs) | ||
331 | { | ||
332 | struct hlist_head *mesh_hash; | ||
333 | struct hlist_node *p, *q; | ||
334 | int i; | ||
335 | |||
336 | mesh_hash = tbl->hash_buckets; | ||
337 | for (i = 0; i <= tbl->hash_mask; i++) { | ||
338 | spin_lock(&tbl->hashwlock[i]); | ||
339 | hlist_for_each_safe(p, q, &mesh_hash[i]) { | ||
340 | tbl->free_node(p, free_leafs); | ||
341 | atomic_dec(&tbl->entries); | ||
342 | } | ||
343 | spin_unlock(&tbl->hashwlock[i]); | ||
344 | } | ||
345 | __mesh_table_free(tbl); | ||
346 | } | ||
347 | 342 | ||
348 | static void ieee80211_mesh_path_timer(unsigned long data) | 343 | static void ieee80211_mesh_path_timer(unsigned long data) |
349 | { | 344 | { |
@@ -357,63 +352,79 @@ static void ieee80211_mesh_path_timer(unsigned long data) | |||
357 | return; | 352 | return; |
358 | } | 353 | } |
359 | 354 | ||
360 | queue_work(local->hw.workqueue, &ifmsh->work); | 355 | ieee80211_queue_work(&local->hw, &ifmsh->work); |
361 | } | 356 | } |
362 | 357 | ||
363 | struct mesh_table *mesh_table_grow(struct mesh_table *tbl) | 358 | /** |
364 | { | 359 | * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame |
365 | struct mesh_table *newtbl; | 360 | * @hdr: 802.11 frame header |
366 | struct hlist_head *oldhash; | 361 | * @fc: frame control field |
367 | struct hlist_node *p, *q; | 362 | * @meshda: destination address in the mesh |
368 | int i; | 363 | * @meshsa: source address address in the mesh. Same as TA, as frame is |
369 | 364 | * locally originated. | |
370 | if (atomic_read(&tbl->entries) | 365 | * |
371 | < tbl->mean_chain_len * (tbl->hash_mask + 1)) | 366 | * Return the length of the 802.11 (does not include a mesh control header) |
372 | goto endgrow; | 367 | */ |
373 | 368 | int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, char | |
374 | newtbl = mesh_table_alloc(tbl->size_order + 1); | 369 | *meshda, char *meshsa) { |
375 | if (!newtbl) | 370 | if (is_multicast_ether_addr(meshda)) { |
376 | goto endgrow; | 371 | *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS); |
377 | 372 | /* DA TA SA */ | |
378 | newtbl->free_node = tbl->free_node; | 373 | memcpy(hdr->addr1, meshda, ETH_ALEN); |
379 | newtbl->mean_chain_len = tbl->mean_chain_len; | 374 | memcpy(hdr->addr2, meshsa, ETH_ALEN); |
380 | newtbl->copy_node = tbl->copy_node; | 375 | memcpy(hdr->addr3, meshsa, ETH_ALEN); |
381 | atomic_set(&newtbl->entries, atomic_read(&tbl->entries)); | 376 | return 24; |
382 | 377 | } else { | |
383 | oldhash = tbl->hash_buckets; | 378 | *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | |
384 | for (i = 0; i <= tbl->hash_mask; i++) | 379 | IEEE80211_FCTL_TODS); |
385 | hlist_for_each(p, &oldhash[i]) | 380 | /* RA TA DA SA */ |
386 | if (tbl->copy_node(p, newtbl) < 0) | 381 | memset(hdr->addr1, 0, ETH_ALEN); /* RA is resolved later */ |
387 | goto errcopy; | 382 | memcpy(hdr->addr2, meshsa, ETH_ALEN); |
388 | 383 | memcpy(hdr->addr3, meshda, ETH_ALEN); | |
389 | return newtbl; | 384 | memcpy(hdr->addr4, meshsa, ETH_ALEN); |
390 | 385 | return 30; | |
391 | errcopy: | ||
392 | for (i = 0; i <= newtbl->hash_mask; i++) { | ||
393 | hlist_for_each_safe(p, q, &newtbl->hash_buckets[i]) | ||
394 | tbl->free_node(p, 0); | ||
395 | } | 386 | } |
396 | __mesh_table_free(newtbl); | ||
397 | endgrow: | ||
398 | return NULL; | ||
399 | } | 387 | } |
400 | 388 | ||
401 | /** | 389 | /** |
402 | * ieee80211_new_mesh_header - create a new mesh header | 390 | * ieee80211_new_mesh_header - create a new mesh header |
403 | * @meshhdr: uninitialized mesh header | 391 | * @meshhdr: uninitialized mesh header |
404 | * @sdata: mesh interface to be used | 392 | * @sdata: mesh interface to be used |
393 | * @addr4: addr4 of the mesh frame (1st in ae header) | ||
394 | * may be NULL | ||
395 | * @addr5: addr5 of the mesh frame (1st or 2nd in ae header) | ||
396 | * may be NULL unless addr6 is present | ||
397 | * @addr6: addr6 of the mesh frame (2nd or 3rd in ae header) | ||
398 | * may be NULL unless addr5 is present | ||
405 | * | 399 | * |
406 | * Return the header length. | 400 | * Return the header length. |
407 | */ | 401 | */ |
408 | int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, | 402 | int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, |
409 | struct ieee80211_sub_if_data *sdata) | 403 | struct ieee80211_sub_if_data *sdata, char *addr4, |
404 | char *addr5, char *addr6) | ||
410 | { | 405 | { |
411 | meshhdr->flags = 0; | 406 | int aelen = 0; |
407 | memset(meshhdr, 0, sizeof(meshhdr)); | ||
412 | meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; | 408 | meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; |
413 | put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum); | 409 | put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum); |
414 | sdata->u.mesh.mesh_seqnum++; | 410 | sdata->u.mesh.mesh_seqnum++; |
415 | 411 | if (addr4) { | |
416 | return 6; | 412 | meshhdr->flags |= MESH_FLAGS_AE_A4; |
413 | aelen += ETH_ALEN; | ||
414 | memcpy(meshhdr->eaddr1, addr4, ETH_ALEN); | ||
415 | } | ||
416 | if (addr5 && addr6) { | ||
417 | meshhdr->flags |= MESH_FLAGS_AE_A5_A6; | ||
418 | aelen += 2 * ETH_ALEN; | ||
419 | if (!addr4) { | ||
420 | memcpy(meshhdr->eaddr1, addr5, ETH_ALEN); | ||
421 | memcpy(meshhdr->eaddr2, addr6, ETH_ALEN); | ||
422 | } else { | ||
423 | memcpy(meshhdr->eaddr2, addr5, ETH_ALEN); | ||
424 | memcpy(meshhdr->eaddr3, addr6, ETH_ALEN); | ||
425 | } | ||
426 | } | ||
427 | return 6 + aelen; | ||
417 | } | 428 | } |
418 | 429 | ||
419 | static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata, | 430 | static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata, |
@@ -433,7 +444,6 @@ static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata, | |||
433 | if (free_plinks != sdata->u.mesh.accepting_plinks) | 444 | if (free_plinks != sdata->u.mesh.accepting_plinks) |
434 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON); | 445 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON); |
435 | 446 | ||
436 | ifmsh->housekeeping = false; | ||
437 | mod_timer(&ifmsh->housekeeping_timer, | 447 | mod_timer(&ifmsh->housekeeping_timer, |
438 | round_jiffies(jiffies + IEEE80211_MESH_HOUSEKEEPING_INTERVAL)); | 448 | round_jiffies(jiffies + IEEE80211_MESH_HOUSEKEEPING_INTERVAL)); |
439 | } | 449 | } |
@@ -470,10 +480,12 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata) | |||
470 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 480 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
471 | struct ieee80211_local *local = sdata->local; | 481 | struct ieee80211_local *local = sdata->local; |
472 | 482 | ||
473 | ifmsh->housekeeping = true; | 483 | ifmsh->wrkq_flags |= MESH_WORK_HOUSEKEEPING; |
474 | queue_work(local->hw.workqueue, &ifmsh->work); | 484 | ieee80211_queue_work(&local->hw, &ifmsh->work); |
485 | sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL; | ||
475 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON | | 486 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON | |
476 | BSS_CHANGED_BEACON_ENABLED); | 487 | BSS_CHANGED_BEACON_ENABLED | |
488 | BSS_CHANGED_BEACON_INT); | ||
477 | } | 489 | } |
478 | 490 | ||
479 | void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata) | 491 | void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata) |
@@ -568,7 +580,7 @@ static void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
568 | 580 | ||
569 | ifmsh = &sdata->u.mesh; | 581 | ifmsh = &sdata->u.mesh; |
570 | 582 | ||
571 | rx_status = (struct ieee80211_rx_status *) skb->cb; | 583 | rx_status = IEEE80211_SKB_RXCB(skb); |
572 | mgmt = (struct ieee80211_mgmt *) skb->data; | 584 | mgmt = (struct ieee80211_mgmt *) skb->data; |
573 | stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE; | 585 | stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE; |
574 | 586 | ||
@@ -597,7 +609,7 @@ static void ieee80211_mesh_work(struct work_struct *work) | |||
597 | if (!netif_running(sdata->dev)) | 609 | if (!netif_running(sdata->dev)) |
598 | return; | 610 | return; |
599 | 611 | ||
600 | if (local->sw_scanning || local->hw_scanning) | 612 | if (local->scanning) |
601 | return; | 613 | return; |
602 | 614 | ||
603 | while ((skb = skb_dequeue(&ifmsh->skb_queue))) | 615 | while ((skb = skb_dequeue(&ifmsh->skb_queue))) |
@@ -608,7 +620,13 @@ static void ieee80211_mesh_work(struct work_struct *work) | |||
608 | ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval))) | 620 | ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval))) |
609 | mesh_path_start_discovery(sdata); | 621 | mesh_path_start_discovery(sdata); |
610 | 622 | ||
611 | if (ifmsh->housekeeping) | 623 | if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags)) |
624 | mesh_mpath_table_grow(); | ||
625 | |||
626 | if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags)) | ||
627 | mesh_mpp_table_grow(); | ||
628 | |||
629 | if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags)) | ||
612 | ieee80211_mesh_housekeeping(sdata, ifmsh); | 630 | ieee80211_mesh_housekeeping(sdata, ifmsh); |
613 | } | 631 | } |
614 | 632 | ||
@@ -619,7 +637,7 @@ void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) | |||
619 | rcu_read_lock(); | 637 | rcu_read_lock(); |
620 | list_for_each_entry_rcu(sdata, &local->interfaces, list) | 638 | list_for_each_entry_rcu(sdata, &local->interfaces, list) |
621 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 639 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
622 | queue_work(local->hw.workqueue, &sdata->u.mesh.work); | 640 | ieee80211_queue_work(&local->hw, &sdata->u.mesh.work); |
623 | rcu_read_unlock(); | 641 | rcu_read_unlock(); |
624 | } | 642 | } |
625 | 643 | ||
@@ -671,8 +689,7 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) | |||
671 | } | 689 | } |
672 | 690 | ||
673 | ieee80211_rx_result | 691 | ieee80211_rx_result |
674 | ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | 692 | ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) |
675 | struct ieee80211_rx_status *rx_status) | ||
676 | { | 693 | { |
677 | struct ieee80211_local *local = sdata->local; | 694 | struct ieee80211_local *local = sdata->local; |
678 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 695 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
@@ -686,12 +703,14 @@ ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | |||
686 | fc = le16_to_cpu(mgmt->frame_control); | 703 | fc = le16_to_cpu(mgmt->frame_control); |
687 | 704 | ||
688 | switch (fc & IEEE80211_FCTL_STYPE) { | 705 | switch (fc & IEEE80211_FCTL_STYPE) { |
706 | case IEEE80211_STYPE_ACTION: | ||
707 | if (skb->len < IEEE80211_MIN_ACTION_SIZE) | ||
708 | return RX_DROP_MONITOR; | ||
709 | /* fall through */ | ||
689 | case IEEE80211_STYPE_PROBE_RESP: | 710 | case IEEE80211_STYPE_PROBE_RESP: |
690 | case IEEE80211_STYPE_BEACON: | 711 | 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); | 712 | skb_queue_tail(&ifmsh->skb_queue, skb); |
694 | queue_work(local->hw.workqueue, &ifmsh->work); | 713 | ieee80211_queue_work(&local->hw, &ifmsh->work); |
695 | return RX_QUEUED; | 714 | return RX_QUEUED; |
696 | } | 715 | } |
697 | 716 | ||
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index c7d72819cdd2..dd1c19319f0a 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h | |||
@@ -44,6 +44,23 @@ enum mesh_path_flags { | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks | ||
48 | * | ||
49 | * | ||
50 | * | ||
51 | * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks | ||
52 | * @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs | ||
53 | * to grow. | ||
54 | * @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to | ||
55 | * grow | ||
56 | */ | ||
57 | enum mesh_deferred_task_flags { | ||
58 | MESH_WORK_HOUSEKEEPING, | ||
59 | MESH_WORK_GROW_MPATH_TABLE, | ||
60 | MESH_WORK_GROW_MPP_TABLE, | ||
61 | }; | ||
62 | |||
63 | /** | ||
47 | * struct mesh_path - mac80211 mesh path structure | 64 | * struct mesh_path - mac80211 mesh path structure |
48 | * | 65 | * |
49 | * @dst: mesh path destination mac address | 66 | * @dst: mesh path destination mac address |
@@ -61,7 +78,7 @@ enum mesh_path_flags { | |||
61 | * retry | 78 | * retry |
62 | * @discovery_retries: number of discovery retries | 79 | * @discovery_retries: number of discovery retries |
63 | * @flags: mesh path flags, as specified on &enum mesh_path_flags | 80 | * @flags: mesh path flags, as specified on &enum mesh_path_flags |
64 | * @state_lock: mesh pat state lock | 81 | * @state_lock: mesh path state lock |
65 | * | 82 | * |
66 | * | 83 | * |
67 | * The combination of dst and sdata is unique in the mesh path table. Since the | 84 | * The combination of dst and sdata is unique in the mesh path table. Since the |
@@ -174,6 +191,7 @@ struct mesh_rmc { | |||
174 | */ | 191 | */ |
175 | #define MESH_PATH_REFRESH_TIME 1000 | 192 | #define MESH_PATH_REFRESH_TIME 1000 |
176 | #define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME) | 193 | #define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME) |
194 | #define MESH_DEFAULT_BEACON_INTERVAL 1000 /* in 1024 us units */ | ||
177 | 195 | ||
178 | #define MESH_MAX_PREQ_RETRIES 4 | 196 | #define MESH_MAX_PREQ_RETRIES 4 |
179 | #define MESH_PATH_EXPIRE (600 * HZ) | 197 | #define MESH_PATH_EXPIRE (600 * HZ) |
@@ -193,8 +211,11 @@ struct mesh_rmc { | |||
193 | 211 | ||
194 | /* Public interfaces */ | 212 | /* Public interfaces */ |
195 | /* Various */ | 213 | /* Various */ |
214 | int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, | ||
215 | char *da, char *sa); | ||
196 | int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, | 216 | int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, |
197 | struct ieee80211_sub_if_data *sdata); | 217 | struct ieee80211_sub_if_data *sdata, char *addr4, |
218 | char *addr5, char *addr6); | ||
198 | int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr, | 219 | int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr, |
199 | struct ieee80211_sub_if_data *sdata); | 220 | struct ieee80211_sub_if_data *sdata); |
200 | bool mesh_matches_local(struct ieee802_11_elems *ie, | 221 | bool mesh_matches_local(struct ieee802_11_elems *ie, |
@@ -205,11 +226,12 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, | |||
205 | void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); | 226 | void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); |
206 | int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); | 227 | int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); |
207 | void ieee80211s_init(void); | 228 | void ieee80211s_init(void); |
229 | void ieee80211s_update_metric(struct ieee80211_local *local, | ||
230 | struct sta_info *stainfo, struct sk_buff *skb); | ||
208 | void ieee80211s_stop(void); | 231 | void ieee80211s_stop(void); |
209 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); | 232 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); |
210 | ieee80211_rx_result | 233 | ieee80211_rx_result |
211 | ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | 234 | ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); |
212 | struct ieee80211_rx_status *rx_status); | ||
213 | void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); | 235 | void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); |
214 | void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); | 236 | void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); |
215 | 237 | ||
@@ -247,7 +269,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
247 | /* Mesh tables */ | 269 | /* Mesh tables */ |
248 | struct mesh_table *mesh_table_alloc(int size_order); | 270 | struct mesh_table *mesh_table_alloc(int size_order); |
249 | void mesh_table_free(struct mesh_table *tbl, bool free_leafs); | 271 | void mesh_table_free(struct mesh_table *tbl, bool free_leafs); |
250 | struct mesh_table *mesh_table_grow(struct mesh_table *tbl); | 272 | void mesh_mpath_table_grow(void); |
273 | void mesh_mpp_table_grow(void); | ||
251 | u32 mesh_table_hash(u8 *addr, struct ieee80211_sub_if_data *sdata, | 274 | u32 mesh_table_hash(u8 *addr, struct ieee80211_sub_if_data *sdata, |
252 | struct mesh_table *tbl); | 275 | struct mesh_table *tbl); |
253 | /* Mesh paths */ | 276 | /* Mesh paths */ |
@@ -266,6 +289,8 @@ void mesh_path_discard_frame(struct sk_buff *skb, | |||
266 | void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata); | 289 | void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata); |
267 | void mesh_path_restart(struct ieee80211_sub_if_data *sdata); | 290 | void mesh_path_restart(struct ieee80211_sub_if_data *sdata); |
268 | 291 | ||
292 | extern int mesh_paths_generation; | ||
293 | |||
269 | #ifdef CONFIG_MAC80211_MESH | 294 | #ifdef CONFIG_MAC80211_MESH |
270 | extern int mesh_allocated; | 295 | extern int mesh_allocated; |
271 | 296 | ||
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index f49ef288e2e2..e12a786e26b8 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -201,6 +201,24 @@ int mesh_path_error_tx(u8 *dst, __le32 dst_dsn, u8 *ra, | |||
201 | return 0; | 201 | return 0; |
202 | } | 202 | } |
203 | 203 | ||
204 | void ieee80211s_update_metric(struct ieee80211_local *local, | ||
205 | struct sta_info *stainfo, struct sk_buff *skb) | ||
206 | { | ||
207 | struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb); | ||
208 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
209 | int failed; | ||
210 | |||
211 | if (!ieee80211_is_data(hdr->frame_control)) | ||
212 | return; | ||
213 | |||
214 | failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK); | ||
215 | |||
216 | /* moving average, scaled to 100 */ | ||
217 | stainfo->fail_avg = ((80 * stainfo->fail_avg + 5) / 100 + 20 * failed); | ||
218 | if (stainfo->fail_avg > 95) | ||
219 | mesh_plink_broken(stainfo); | ||
220 | } | ||
221 | |||
204 | static u32 airtime_link_metric_get(struct ieee80211_local *local, | 222 | static u32 airtime_link_metric_get(struct ieee80211_local *local, |
205 | struct sta_info *sta) | 223 | struct sta_info *sta) |
206 | { | 224 | { |
@@ -397,7 +415,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
397 | 415 | ||
398 | static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | 416 | static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, |
399 | struct ieee80211_mgmt *mgmt, | 417 | struct ieee80211_mgmt *mgmt, |
400 | u8 *preq_elem, u32 metric) { | 418 | u8 *preq_elem, u32 metric) |
419 | { | ||
401 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 420 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
402 | struct mesh_path *mpath; | 421 | struct mesh_path *mpath; |
403 | u8 *dst_addr, *orig_addr; | 422 | u8 *dst_addr, *orig_addr; |
@@ -430,7 +449,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
430 | if ((!(mpath->flags & MESH_PATH_DSN_VALID)) || | 449 | if ((!(mpath->flags & MESH_PATH_DSN_VALID)) || |
431 | DSN_LT(mpath->dsn, dst_dsn)) { | 450 | DSN_LT(mpath->dsn, dst_dsn)) { |
432 | mpath->dsn = dst_dsn; | 451 | mpath->dsn = dst_dsn; |
433 | mpath->flags &= MESH_PATH_DSN_VALID; | 452 | mpath->flags |= MESH_PATH_DSN_VALID; |
434 | } else if ((!(dst_flags & MP_F_DO)) && | 453 | } else if ((!(dst_flags & MP_F_DO)) && |
435 | (mpath->flags & MESH_PATH_ACTIVE)) { | 454 | (mpath->flags & MESH_PATH_ACTIVE)) { |
436 | reply = true; | 455 | reply = true; |
@@ -478,6 +497,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
478 | hopcount, ttl, cpu_to_le32(lifetime), | 497 | hopcount, ttl, cpu_to_le32(lifetime), |
479 | cpu_to_le32(metric), cpu_to_le32(preq_id), | 498 | cpu_to_le32(metric), cpu_to_le32(preq_id), |
480 | sdata); | 499 | sdata); |
500 | ifmsh->mshstats.fwded_mcast++; | ||
481 | ifmsh->mshstats.fwded_frames++; | 501 | ifmsh->mshstats.fwded_frames++; |
482 | } | 502 | } |
483 | } | 503 | } |
@@ -536,6 +556,8 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
536 | cpu_to_le32(lifetime), cpu_to_le32(metric), | 556 | cpu_to_le32(lifetime), cpu_to_le32(metric), |
537 | 0, sdata); | 557 | 0, sdata); |
538 | rcu_read_unlock(); | 558 | rcu_read_unlock(); |
559 | |||
560 | sdata->u.mesh.mshstats.fwded_unicast++; | ||
539 | sdata->u.mesh.mshstats.fwded_frames++; | 561 | sdata->u.mesh.mshstats.fwded_frames++; |
540 | return; | 562 | return; |
541 | 563 | ||
@@ -660,14 +682,14 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) | |||
660 | spin_unlock(&ifmsh->mesh_preq_queue_lock); | 682 | spin_unlock(&ifmsh->mesh_preq_queue_lock); |
661 | 683 | ||
662 | if (time_after(jiffies, ifmsh->last_preq + min_preq_int_jiff(sdata))) | 684 | if (time_after(jiffies, ifmsh->last_preq + min_preq_int_jiff(sdata))) |
663 | queue_work(sdata->local->hw.workqueue, &ifmsh->work); | 685 | ieee80211_queue_work(&sdata->local->hw, &ifmsh->work); |
664 | 686 | ||
665 | else if (time_before(jiffies, ifmsh->last_preq)) { | 687 | else if (time_before(jiffies, ifmsh->last_preq)) { |
666 | /* avoid long wait if did not send preqs for a long time | 688 | /* avoid long wait if did not send preqs for a long time |
667 | * and jiffies wrapped around | 689 | * and jiffies wrapped around |
668 | */ | 690 | */ |
669 | ifmsh->last_preq = jiffies - min_preq_int_jiff(sdata) - 1; | 691 | ifmsh->last_preq = jiffies - min_preq_int_jiff(sdata) - 1; |
670 | queue_work(sdata->local->hw.workqueue, &ifmsh->work); | 692 | ieee80211_queue_work(&sdata->local->hw, &ifmsh->work); |
671 | } else | 693 | } else |
672 | mod_timer(&ifmsh->mesh_path_timer, ifmsh->last_preq + | 694 | mod_timer(&ifmsh->mesh_path_timer, ifmsh->last_preq + |
673 | min_preq_int_jiff(sdata)); | 695 | min_preq_int_jiff(sdata)); |
@@ -686,11 +708,11 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
686 | u8 ttl, dst_flags; | 708 | u8 ttl, dst_flags; |
687 | u32 lifetime; | 709 | u32 lifetime; |
688 | 710 | ||
689 | spin_lock(&ifmsh->mesh_preq_queue_lock); | 711 | spin_lock_bh(&ifmsh->mesh_preq_queue_lock); |
690 | if (!ifmsh->preq_queue_len || | 712 | if (!ifmsh->preq_queue_len || |
691 | time_before(jiffies, ifmsh->last_preq + | 713 | time_before(jiffies, ifmsh->last_preq + |
692 | min_preq_int_jiff(sdata))) { | 714 | min_preq_int_jiff(sdata))) { |
693 | spin_unlock(&ifmsh->mesh_preq_queue_lock); | 715 | spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); |
694 | return; | 716 | return; |
695 | } | 717 | } |
696 | 718 | ||
@@ -698,7 +720,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) | |||
698 | struct mesh_preq_queue, list); | 720 | struct mesh_preq_queue, list); |
699 | list_del(&preq_node->list); | 721 | list_del(&preq_node->list); |
700 | --ifmsh->preq_queue_len; | 722 | --ifmsh->preq_queue_len; |
701 | spin_unlock(&ifmsh->mesh_preq_queue_lock); | 723 | spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); |
702 | 724 | ||
703 | rcu_read_lock(); | 725 | rcu_read_lock(); |
704 | mpath = mesh_path_lookup(preq_node->dst, sdata); | 726 | mpath = mesh_path_lookup(preq_node->dst, sdata); |
@@ -784,7 +806,6 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
784 | mesh_path_add(dst_addr, sdata); | 806 | mesh_path_add(dst_addr, sdata); |
785 | mpath = mesh_path_lookup(dst_addr, sdata); | 807 | mpath = mesh_path_lookup(dst_addr, sdata); |
786 | if (!mpath) { | 808 | if (!mpath) { |
787 | dev_kfree_skb(skb); | ||
788 | sdata->u.mesh.mshstats.dropped_frames_no_route++; | 809 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
789 | err = -ENOSPC; | 810 | err = -ENOSPC; |
790 | goto endlookup; | 811 | goto endlookup; |
@@ -792,7 +813,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
792 | } | 813 | } |
793 | 814 | ||
794 | if (mpath->flags & MESH_PATH_ACTIVE) { | 815 | if (mpath->flags & MESH_PATH_ACTIVE) { |
795 | if (time_after(jiffies, mpath->exp_time - | 816 | if (time_after(jiffies, mpath->exp_time + |
796 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) | 817 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) |
797 | && !memcmp(sdata->dev->dev_addr, hdr->addr4, | 818 | && !memcmp(sdata->dev->dev_addr, hdr->addr4, |
798 | ETH_ALEN) | 819 | ETH_ALEN) |
@@ -804,17 +825,17 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
804 | memcpy(hdr->addr1, mpath->next_hop->sta.addr, | 825 | memcpy(hdr->addr1, mpath->next_hop->sta.addr, |
805 | ETH_ALEN); | 826 | ETH_ALEN); |
806 | } else { | 827 | } else { |
828 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
807 | if (!(mpath->flags & MESH_PATH_RESOLVING)) { | 829 | if (!(mpath->flags & MESH_PATH_RESOLVING)) { |
808 | /* Start discovery only if it is not running yet */ | 830 | /* Start discovery only if it is not running yet */ |
809 | mesh_queue_preq(mpath, PREQ_Q_F_START); | 831 | mesh_queue_preq(mpath, PREQ_Q_F_START); |
810 | } | 832 | } |
811 | 833 | ||
812 | if (skb_queue_len(&mpath->frame_queue) >= | 834 | if (skb_queue_len(&mpath->frame_queue) >= |
813 | MESH_FRAME_QUEUE_LEN) { | 835 | MESH_FRAME_QUEUE_LEN) |
814 | skb_to_free = mpath->frame_queue.next; | 836 | skb_to_free = skb_dequeue(&mpath->frame_queue); |
815 | skb_unlink(skb_to_free, &mpath->frame_queue); | ||
816 | } | ||
817 | 837 | ||
838 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | ||
818 | skb_queue_tail(&mpath->frame_queue, skb); | 839 | skb_queue_tail(&mpath->frame_queue, skb); |
819 | if (skb_to_free) | 840 | if (skb_to_free) |
820 | mesh_path_discard_frame(skb_to_free, sdata); | 841 | mesh_path_discard_frame(skb_to_free, sdata); |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 479597e88583..751c4d0e2b36 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -38,6 +38,71 @@ struct mpath_node { | |||
38 | static struct mesh_table *mesh_paths; | 38 | static struct mesh_table *mesh_paths; |
39 | static struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */ | 39 | static struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */ |
40 | 40 | ||
41 | int mesh_paths_generation; | ||
42 | static void __mesh_table_free(struct mesh_table *tbl) | ||
43 | { | ||
44 | kfree(tbl->hash_buckets); | ||
45 | kfree(tbl->hashwlock); | ||
46 | kfree(tbl); | ||
47 | } | ||
48 | |||
49 | void mesh_table_free(struct mesh_table *tbl, bool free_leafs) | ||
50 | { | ||
51 | struct hlist_head *mesh_hash; | ||
52 | struct hlist_node *p, *q; | ||
53 | int i; | ||
54 | |||
55 | mesh_hash = tbl->hash_buckets; | ||
56 | for (i = 0; i <= tbl->hash_mask; i++) { | ||
57 | spin_lock(&tbl->hashwlock[i]); | ||
58 | hlist_for_each_safe(p, q, &mesh_hash[i]) { | ||
59 | tbl->free_node(p, free_leafs); | ||
60 | atomic_dec(&tbl->entries); | ||
61 | } | ||
62 | spin_unlock(&tbl->hashwlock[i]); | ||
63 | } | ||
64 | __mesh_table_free(tbl); | ||
65 | } | ||
66 | |||
67 | static struct mesh_table *mesh_table_grow(struct mesh_table *tbl) | ||
68 | { | ||
69 | struct mesh_table *newtbl; | ||
70 | struct hlist_head *oldhash; | ||
71 | struct hlist_node *p, *q; | ||
72 | int i; | ||
73 | |||
74 | if (atomic_read(&tbl->entries) | ||
75 | < tbl->mean_chain_len * (tbl->hash_mask + 1)) | ||
76 | goto endgrow; | ||
77 | |||
78 | newtbl = mesh_table_alloc(tbl->size_order + 1); | ||
79 | if (!newtbl) | ||
80 | goto endgrow; | ||
81 | |||
82 | newtbl->free_node = tbl->free_node; | ||
83 | newtbl->mean_chain_len = tbl->mean_chain_len; | ||
84 | newtbl->copy_node = tbl->copy_node; | ||
85 | atomic_set(&newtbl->entries, atomic_read(&tbl->entries)); | ||
86 | |||
87 | oldhash = tbl->hash_buckets; | ||
88 | for (i = 0; i <= tbl->hash_mask; i++) | ||
89 | hlist_for_each(p, &oldhash[i]) | ||
90 | if (tbl->copy_node(p, newtbl) < 0) | ||
91 | goto errcopy; | ||
92 | |||
93 | return newtbl; | ||
94 | |||
95 | errcopy: | ||
96 | for (i = 0; i <= newtbl->hash_mask; i++) { | ||
97 | hlist_for_each_safe(p, q, &newtbl->hash_buckets[i]) | ||
98 | tbl->free_node(p, 0); | ||
99 | } | ||
100 | __mesh_table_free(newtbl); | ||
101 | endgrow: | ||
102 | return NULL; | ||
103 | } | ||
104 | |||
105 | |||
41 | /* This lock will have the grow table function as writer and add / delete nodes | 106 | /* This lock will have the grow table function as writer and add / delete nodes |
42 | * as readers. When reading the table (i.e. doing lookups) we are well protected | 107 | * as readers. When reading the table (i.e. doing lookups) we are well protected |
43 | * by RCU | 108 | * by RCU |
@@ -55,7 +120,25 @@ static DEFINE_RWLOCK(pathtbl_resize_lock); | |||
55 | */ | 120 | */ |
56 | void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) | 121 | void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) |
57 | { | 122 | { |
123 | struct sk_buff *skb; | ||
124 | struct ieee80211_hdr *hdr; | ||
125 | struct sk_buff_head tmpq; | ||
126 | unsigned long flags; | ||
127 | |||
58 | rcu_assign_pointer(mpath->next_hop, sta); | 128 | rcu_assign_pointer(mpath->next_hop, sta); |
129 | |||
130 | __skb_queue_head_init(&tmpq); | ||
131 | |||
132 | spin_lock_irqsave(&mpath->frame_queue.lock, flags); | ||
133 | |||
134 | while ((skb = __skb_dequeue(&mpath->frame_queue)) != NULL) { | ||
135 | hdr = (struct ieee80211_hdr *) skb->data; | ||
136 | memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); | ||
137 | __skb_queue_tail(&tmpq, skb); | ||
138 | } | ||
139 | |||
140 | skb_queue_splice(&tmpq, &mpath->frame_queue); | ||
141 | spin_unlock_irqrestore(&mpath->frame_queue.lock, flags); | ||
59 | } | 142 | } |
60 | 143 | ||
61 | 144 | ||
@@ -167,6 +250,8 @@ struct mesh_path *mesh_path_lookup_by_idx(int idx, struct ieee80211_sub_if_data | |||
167 | */ | 250 | */ |
168 | int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) | 251 | int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) |
169 | { | 252 | { |
253 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
254 | struct ieee80211_local *local = sdata->local; | ||
170 | struct mesh_path *mpath, *new_mpath; | 255 | struct mesh_path *mpath, *new_mpath; |
171 | struct mpath_node *node, *new_node; | 256 | struct mpath_node *node, *new_node; |
172 | struct hlist_head *bucket; | 257 | struct hlist_head *bucket; |
@@ -175,8 +260,6 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) | |||
175 | int err = 0; | 260 | int err = 0; |
176 | u32 hash_idx; | 261 | u32 hash_idx; |
177 | 262 | ||
178 | might_sleep(); | ||
179 | |||
180 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) | 263 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) |
181 | /* never add ourselves as neighbours */ | 264 | /* never add ourselves as neighbours */ |
182 | return -ENOTSUPP; | 265 | return -ENOTSUPP; |
@@ -188,11 +271,11 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) | |||
188 | return -ENOSPC; | 271 | return -ENOSPC; |
189 | 272 | ||
190 | err = -ENOMEM; | 273 | err = -ENOMEM; |
191 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL); | 274 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC); |
192 | if (!new_mpath) | 275 | if (!new_mpath) |
193 | goto err_path_alloc; | 276 | goto err_path_alloc; |
194 | 277 | ||
195 | new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL); | 278 | new_node = kmalloc(sizeof(struct mpath_node), GFP_ATOMIC); |
196 | if (!new_node) | 279 | if (!new_node) |
197 | goto err_node_alloc; | 280 | goto err_node_alloc; |
198 | 281 | ||
@@ -225,23 +308,13 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) | |||
225 | mesh_paths->mean_chain_len * (mesh_paths->hash_mask + 1)) | 308 | mesh_paths->mean_chain_len * (mesh_paths->hash_mask + 1)) |
226 | grow = 1; | 309 | grow = 1; |
227 | 310 | ||
311 | mesh_paths_generation++; | ||
312 | |||
228 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); | 313 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); |
229 | read_unlock(&pathtbl_resize_lock); | 314 | read_unlock(&pathtbl_resize_lock); |
230 | if (grow) { | 315 | if (grow) { |
231 | struct mesh_table *oldtbl, *newtbl; | 316 | set_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags); |
232 | 317 | ieee80211_queue_work(&local->hw, &ifmsh->work); | |
233 | write_lock(&pathtbl_resize_lock); | ||
234 | oldtbl = mesh_paths; | ||
235 | newtbl = mesh_table_grow(mesh_paths); | ||
236 | if (!newtbl) { | ||
237 | write_unlock(&pathtbl_resize_lock); | ||
238 | return 0; | ||
239 | } | ||
240 | rcu_assign_pointer(mesh_paths, newtbl); | ||
241 | write_unlock(&pathtbl_resize_lock); | ||
242 | |||
243 | synchronize_rcu(); | ||
244 | mesh_table_free(oldtbl, false); | ||
245 | } | 318 | } |
246 | return 0; | 319 | return 0; |
247 | 320 | ||
@@ -256,9 +329,46 @@ err_path_alloc: | |||
256 | return err; | 329 | return err; |
257 | } | 330 | } |
258 | 331 | ||
332 | void mesh_mpath_table_grow(void) | ||
333 | { | ||
334 | struct mesh_table *oldtbl, *newtbl; | ||
335 | |||
336 | write_lock(&pathtbl_resize_lock); | ||
337 | oldtbl = mesh_paths; | ||
338 | newtbl = mesh_table_grow(mesh_paths); | ||
339 | if (!newtbl) { | ||
340 | write_unlock(&pathtbl_resize_lock); | ||
341 | return; | ||
342 | } | ||
343 | rcu_assign_pointer(mesh_paths, newtbl); | ||
344 | write_unlock(&pathtbl_resize_lock); | ||
345 | |||
346 | synchronize_rcu(); | ||
347 | mesh_table_free(oldtbl, false); | ||
348 | } | ||
349 | |||
350 | void mesh_mpp_table_grow(void) | ||
351 | { | ||
352 | struct mesh_table *oldtbl, *newtbl; | ||
353 | |||
354 | write_lock(&pathtbl_resize_lock); | ||
355 | oldtbl = mpp_paths; | ||
356 | newtbl = mesh_table_grow(mpp_paths); | ||
357 | if (!newtbl) { | ||
358 | write_unlock(&pathtbl_resize_lock); | ||
359 | return; | ||
360 | } | ||
361 | rcu_assign_pointer(mpp_paths, newtbl); | ||
362 | write_unlock(&pathtbl_resize_lock); | ||
363 | |||
364 | synchronize_rcu(); | ||
365 | mesh_table_free(oldtbl, false); | ||
366 | } | ||
259 | 367 | ||
260 | int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) | 368 | int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) |
261 | { | 369 | { |
370 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
371 | struct ieee80211_local *local = sdata->local; | ||
262 | struct mesh_path *mpath, *new_mpath; | 372 | struct mesh_path *mpath, *new_mpath; |
263 | struct mpath_node *node, *new_node; | 373 | struct mpath_node *node, *new_node; |
264 | struct hlist_head *bucket; | 374 | struct hlist_head *bucket; |
@@ -267,8 +377,6 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) | |||
267 | int err = 0; | 377 | int err = 0; |
268 | u32 hash_idx; | 378 | u32 hash_idx; |
269 | 379 | ||
270 | might_sleep(); | ||
271 | |||
272 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) | 380 | if (memcmp(dst, sdata->dev->dev_addr, ETH_ALEN) == 0) |
273 | /* never add ourselves as neighbours */ | 381 | /* never add ourselves as neighbours */ |
274 | return -ENOTSUPP; | 382 | return -ENOTSUPP; |
@@ -277,11 +385,11 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) | |||
277 | return -ENOTSUPP; | 385 | return -ENOTSUPP; |
278 | 386 | ||
279 | err = -ENOMEM; | 387 | err = -ENOMEM; |
280 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL); | 388 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC); |
281 | if (!new_mpath) | 389 | if (!new_mpath) |
282 | goto err_path_alloc; | 390 | goto err_path_alloc; |
283 | 391 | ||
284 | new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL); | 392 | new_node = kmalloc(sizeof(struct mpath_node), GFP_ATOMIC); |
285 | if (!new_node) | 393 | if (!new_node) |
286 | goto err_node_alloc; | 394 | goto err_node_alloc; |
287 | 395 | ||
@@ -315,20 +423,8 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) | |||
315 | spin_unlock(&mpp_paths->hashwlock[hash_idx]); | 423 | spin_unlock(&mpp_paths->hashwlock[hash_idx]); |
316 | read_unlock(&pathtbl_resize_lock); | 424 | read_unlock(&pathtbl_resize_lock); |
317 | if (grow) { | 425 | if (grow) { |
318 | struct mesh_table *oldtbl, *newtbl; | 426 | set_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags); |
319 | 427 | ieee80211_queue_work(&local->hw, &ifmsh->work); | |
320 | write_lock(&pathtbl_resize_lock); | ||
321 | oldtbl = mpp_paths; | ||
322 | newtbl = mesh_table_grow(mpp_paths); | ||
323 | if (!newtbl) { | ||
324 | write_unlock(&pathtbl_resize_lock); | ||
325 | return 0; | ||
326 | } | ||
327 | rcu_assign_pointer(mpp_paths, newtbl); | ||
328 | write_unlock(&pathtbl_resize_lock); | ||
329 | |||
330 | synchronize_rcu(); | ||
331 | mesh_table_free(oldtbl, false); | ||
332 | } | 428 | } |
333 | return 0; | 429 | return 0; |
334 | 430 | ||
@@ -466,6 +562,7 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) | |||
466 | 562 | ||
467 | err = -ENXIO; | 563 | err = -ENXIO; |
468 | enddel: | 564 | enddel: |
565 | mesh_paths_generation++; | ||
469 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); | 566 | spin_unlock(&mesh_paths->hashwlock[hash_idx]); |
470 | read_unlock(&pathtbl_resize_lock); | 567 | read_unlock(&pathtbl_resize_lock); |
471 | return err; | 568 | return err; |
@@ -481,11 +578,9 @@ enddel: | |||
481 | */ | 578 | */ |
482 | void mesh_path_tx_pending(struct mesh_path *mpath) | 579 | void mesh_path_tx_pending(struct mesh_path *mpath) |
483 | { | 580 | { |
484 | struct sk_buff *skb; | 581 | if (mpath->flags & MESH_PATH_ACTIVE) |
485 | 582 | ieee80211_add_pending_skbs(mpath->sdata->local, | |
486 | while ((skb = skb_dequeue(&mpath->frame_queue)) && | 583 | &mpath->frame_queue); |
487 | (mpath->flags & MESH_PATH_ACTIVE)) | ||
488 | dev_queue_xmit(skb); | ||
489 | } | 584 | } |
490 | 585 | ||
491 | /** | 586 | /** |
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index cb14253587f1..ffcbad75e09b 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -409,7 +409,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m | |||
409 | baselen = (u8 *) mgmt->u.action.u.plink_action.variable - (u8 *) mgmt; | 409 | baselen = (u8 *) mgmt->u.action.u.plink_action.variable - (u8 *) mgmt; |
410 | if (mgmt->u.action.u.plink_action.action_code == PLINK_CONFIRM) { | 410 | if (mgmt->u.action.u.plink_action.action_code == PLINK_CONFIRM) { |
411 | baseaddr += 4; | 411 | baseaddr += 4; |
412 | baselen -= 4; | 412 | baselen += 4; |
413 | } | 413 | } |
414 | ieee802_11_parse_elems(baseaddr, len - baselen, &elems); | 414 | ieee802_11_parse_elems(baseaddr, len - baselen, &elems); |
415 | if (!elems.peer_link) { | 415 | if (!elems.peer_link) { |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 07e7e41816be..97a278a2f48e 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -27,43 +27,99 @@ | |||
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 | #define IEEE80211_MAX_PROBE_TRIES 5 |
36 | #define IEEE80211_PROBE_WAIT (HZ / 5) | 35 | |
37 | #define IEEE80211_PROBE_IDLE_TIME (60 * HZ) | 36 | /* |
38 | #define IEEE80211_RETRY_AUTH_INTERVAL (1 * HZ) | 37 | * beacon loss detection timeout |
38 | * XXX: should depend on beacon interval | ||
39 | */ | ||
40 | #define IEEE80211_BEACON_LOSS_TIME (2 * HZ) | ||
41 | /* | ||
42 | * Time the connection can be idle before we probe | ||
43 | * it to see if we can still talk to the AP. | ||
44 | */ | ||
45 | #define IEEE80211_CONNECTION_IDLE_TIME (30 * HZ) | ||
46 | /* | ||
47 | * Time we wait for a probe response after sending | ||
48 | * a probe request because of beacon loss or for | ||
49 | * checking the connection still works. | ||
50 | */ | ||
51 | #define IEEE80211_PROBE_WAIT (HZ / 2) | ||
39 | 52 | ||
40 | #define TMR_RUNNING_TIMER 0 | 53 | #define TMR_RUNNING_TIMER 0 |
41 | #define TMR_RUNNING_CHANSW 1 | 54 | #define TMR_RUNNING_CHANSW 1 |
42 | 55 | ||
56 | /* | ||
57 | * All cfg80211 functions have to be called outside a locked | ||
58 | * section so that they can acquire a lock themselves... This | ||
59 | * is much simpler than queuing up things in cfg80211, but we | ||
60 | * do need some indirection for that here. | ||
61 | */ | ||
62 | enum rx_mgmt_action { | ||
63 | /* no action required */ | ||
64 | RX_MGMT_NONE, | ||
65 | |||
66 | /* caller must call cfg80211_send_rx_auth() */ | ||
67 | RX_MGMT_CFG80211_AUTH, | ||
68 | |||
69 | /* caller must call cfg80211_send_rx_assoc() */ | ||
70 | RX_MGMT_CFG80211_ASSOC, | ||
71 | |||
72 | /* caller must call cfg80211_send_deauth() */ | ||
73 | RX_MGMT_CFG80211_DEAUTH, | ||
74 | |||
75 | /* caller must call cfg80211_send_disassoc() */ | ||
76 | RX_MGMT_CFG80211_DISASSOC, | ||
77 | |||
78 | /* caller must call cfg80211_auth_timeout() & free work */ | ||
79 | RX_MGMT_CFG80211_AUTH_TO, | ||
80 | |||
81 | /* caller must call cfg80211_assoc_timeout() & free work */ | ||
82 | RX_MGMT_CFG80211_ASSOC_TO, | ||
83 | }; | ||
84 | |||
43 | /* utils */ | 85 | /* utils */ |
44 | static int ecw2cw(int ecw) | 86 | static inline void ASSERT_MGD_MTX(struct ieee80211_if_managed *ifmgd) |
45 | { | 87 | { |
46 | return (1 << ecw) - 1; | 88 | WARN_ON(!mutex_is_locked(&ifmgd->mtx)); |
47 | } | 89 | } |
48 | 90 | ||
49 | static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie) | 91 | /* |
92 | * We can have multiple work items (and connection probing) | ||
93 | * scheduling this timer, but we need to take care to only | ||
94 | * reschedule it when it should fire _earlier_ than it was | ||
95 | * asked for before, or if it's not pending right now. This | ||
96 | * function ensures that. Note that it then is required to | ||
97 | * run this function for all timeouts after the first one | ||
98 | * has happened -- the work that runs from this timer will | ||
99 | * do that. | ||
100 | */ | ||
101 | static void run_again(struct ieee80211_if_managed *ifmgd, | ||
102 | unsigned long timeout) | ||
50 | { | 103 | { |
51 | u8 *end, *pos; | 104 | ASSERT_MGD_MTX(ifmgd); |
52 | 105 | ||
53 | pos = bss->cbss.information_elements; | 106 | if (!timer_pending(&ifmgd->timer) || |
54 | if (pos == NULL) | 107 | time_before(timeout, ifmgd->timer.expires)) |
55 | return NULL; | 108 | mod_timer(&ifmgd->timer, timeout); |
56 | end = pos + bss->cbss.len_information_elements; | 109 | } |
57 | 110 | ||
58 | while (pos + 1 < end) { | 111 | static void mod_beacon_timer(struct ieee80211_sub_if_data *sdata) |
59 | if (pos + 2 + pos[1] > end) | 112 | { |
60 | break; | 113 | if (sdata->local->hw.flags & IEEE80211_HW_BEACON_FILTER) |
61 | if (pos[0] == ie) | 114 | return; |
62 | return pos; | 115 | |
63 | pos += 2 + pos[1]; | 116 | mod_timer(&sdata->u.mgd.bcn_mon_timer, |
64 | } | 117 | round_jiffies_up(jiffies + IEEE80211_BEACON_LOSS_TIME)); |
118 | } | ||
65 | 119 | ||
66 | return NULL; | 120 | static int ecw2cw(int ecw) |
121 | { | ||
122 | return (1 << ecw) - 1; | ||
67 | } | 123 | } |
68 | 124 | ||
69 | static int ieee80211_compatible_rates(struct ieee80211_bss *bss, | 125 | static int ieee80211_compatible_rates(struct ieee80211_bss *bss, |
@@ -94,11 +150,10 @@ static int ieee80211_compatible_rates(struct ieee80211_bss *bss, | |||
94 | */ | 150 | */ |
95 | static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, | 151 | static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, |
96 | struct ieee80211_ht_info *hti, | 152 | struct ieee80211_ht_info *hti, |
97 | u16 ap_ht_cap_flags) | 153 | const u8 *bssid, u16 ap_ht_cap_flags) |
98 | { | 154 | { |
99 | struct ieee80211_local *local = sdata->local; | 155 | struct ieee80211_local *local = sdata->local; |
100 | struct ieee80211_supported_band *sband; | 156 | struct ieee80211_supported_band *sband; |
101 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
102 | struct sta_info *sta; | 157 | struct sta_info *sta; |
103 | u32 changed = 0; | 158 | u32 changed = 0; |
104 | u16 ht_opmode; | 159 | u16 ht_opmode; |
@@ -147,12 +202,10 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, | |||
147 | ieee80211_hw_config(local, 0); | 202 | ieee80211_hw_config(local, 0); |
148 | 203 | ||
149 | rcu_read_lock(); | 204 | rcu_read_lock(); |
150 | 205 | sta = sta_info_get(local, bssid); | |
151 | sta = sta_info_get(local, ifmgd->bssid); | ||
152 | if (sta) | 206 | if (sta) |
153 | rate_control_rate_update(local, sband, sta, | 207 | rate_control_rate_update(local, sband, sta, |
154 | IEEE80211_RC_HT_CHANGED); | 208 | IEEE80211_RC_HT_CHANGED); |
155 | |||
156 | rcu_read_unlock(); | 209 | rcu_read_unlock(); |
157 | } | 210 | } |
158 | 211 | ||
@@ -175,23 +228,24 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, | |||
175 | 228 | ||
176 | /* frame sending functions */ | 229 | /* frame sending functions */ |
177 | 230 | ||
178 | static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | 231 | static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, |
232 | struct ieee80211_mgd_work *wk) | ||
179 | { | 233 | { |
180 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 234 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
181 | struct ieee80211_local *local = sdata->local; | 235 | struct ieee80211_local *local = sdata->local; |
182 | struct sk_buff *skb; | 236 | struct sk_buff *skb; |
183 | struct ieee80211_mgmt *mgmt; | 237 | struct ieee80211_mgmt *mgmt; |
184 | u8 *pos, *ies, *ht_ie; | 238 | u8 *pos; |
239 | const u8 *ies, *ht_ie; | ||
185 | int i, len, count, rates_len, supp_rates_len; | 240 | int i, len, count, rates_len, supp_rates_len; |
186 | u16 capab; | 241 | u16 capab; |
187 | struct ieee80211_bss *bss; | ||
188 | int wmm = 0; | 242 | int wmm = 0; |
189 | struct ieee80211_supported_band *sband; | 243 | struct ieee80211_supported_band *sband; |
190 | u32 rates = 0; | 244 | u32 rates = 0; |
191 | 245 | ||
192 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | 246 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
193 | sizeof(*mgmt) + 200 + ifmgd->extra_ie_len + | 247 | sizeof(*mgmt) + 200 + wk->ie_len + |
194 | ifmgd->ssid_len); | 248 | wk->ssid_len); |
195 | if (!skb) { | 249 | if (!skb) { |
196 | printk(KERN_DEBUG "%s: failed to allocate buffer for assoc " | 250 | printk(KERN_DEBUG "%s: failed to allocate buffer for assoc " |
197 | "frame\n", sdata->dev->name); | 251 | "frame\n", sdata->dev->name); |
@@ -210,45 +264,35 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
210 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; | 264 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; |
211 | } | 265 | } |
212 | 266 | ||
213 | bss = ieee80211_rx_bss_get(local, ifmgd->bssid, | 267 | if (wk->bss->cbss.capability & WLAN_CAPABILITY_PRIVACY) |
214 | local->hw.conf.channel->center_freq, | 268 | capab |= WLAN_CAPABILITY_PRIVACY; |
215 | ifmgd->ssid, ifmgd->ssid_len); | 269 | if (wk->bss->wmm_used) |
216 | if (bss) { | 270 | wmm = 1; |
217 | if (bss->cbss.capability & WLAN_CAPABILITY_PRIVACY) | ||
218 | capab |= WLAN_CAPABILITY_PRIVACY; | ||
219 | if (bss->wmm_used) | ||
220 | wmm = 1; | ||
221 | 271 | ||
222 | /* get all rates supported by the device and the AP as | 272 | /* get all rates supported by the device and the AP as |
223 | * some APs don't like getting a superset of their rates | 273 | * some APs don't like getting a superset of their rates |
224 | * in the association request (e.g. D-Link DAP 1353 in | 274 | * in the association request (e.g. D-Link DAP 1353 in |
225 | * b-only mode) */ | 275 | * b-only mode) */ |
226 | rates_len = ieee80211_compatible_rates(bss, sband, &rates); | 276 | rates_len = ieee80211_compatible_rates(wk->bss, sband, &rates); |
227 | 277 | ||
228 | if ((bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && | 278 | if ((wk->bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && |
229 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) | 279 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) |
230 | capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; | 280 | 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 | 281 | ||
238 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | 282 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
239 | memset(mgmt, 0, 24); | 283 | memset(mgmt, 0, 24); |
240 | memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN); | 284 | memcpy(mgmt->da, wk->bss->cbss.bssid, ETH_ALEN); |
241 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 285 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
242 | memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN); | 286 | memcpy(mgmt->bssid, wk->bss->cbss.bssid, ETH_ALEN); |
243 | 287 | ||
244 | if (ifmgd->flags & IEEE80211_STA_PREV_BSSID_SET) { | 288 | if (!is_zero_ether_addr(wk->prev_bssid)) { |
245 | skb_put(skb, 10); | 289 | skb_put(skb, 10); |
246 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 290 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
247 | IEEE80211_STYPE_REASSOC_REQ); | 291 | IEEE80211_STYPE_REASSOC_REQ); |
248 | mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); | 292 | mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); |
249 | mgmt->u.reassoc_req.listen_interval = | 293 | mgmt->u.reassoc_req.listen_interval = |
250 | cpu_to_le16(local->hw.conf.listen_interval); | 294 | cpu_to_le16(local->hw.conf.listen_interval); |
251 | memcpy(mgmt->u.reassoc_req.current_ap, ifmgd->prev_bssid, | 295 | memcpy(mgmt->u.reassoc_req.current_ap, wk->prev_bssid, |
252 | ETH_ALEN); | 296 | ETH_ALEN); |
253 | } else { | 297 | } else { |
254 | skb_put(skb, 4); | 298 | skb_put(skb, 4); |
@@ -260,10 +304,10 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
260 | } | 304 | } |
261 | 305 | ||
262 | /* SSID */ | 306 | /* SSID */ |
263 | ies = pos = skb_put(skb, 2 + ifmgd->ssid_len); | 307 | ies = pos = skb_put(skb, 2 + wk->ssid_len); |
264 | *pos++ = WLAN_EID_SSID; | 308 | *pos++ = WLAN_EID_SSID; |
265 | *pos++ = ifmgd->ssid_len; | 309 | *pos++ = wk->ssid_len; |
266 | memcpy(pos, ifmgd->ssid, ifmgd->ssid_len); | 310 | memcpy(pos, wk->ssid, wk->ssid_len); |
267 | 311 | ||
268 | /* add all rates which were marked to be used above */ | 312 | /* add all rates which were marked to be used above */ |
269 | supp_rates_len = rates_len; | 313 | supp_rates_len = rates_len; |
@@ -318,9 +362,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
318 | } | 362 | } |
319 | } | 363 | } |
320 | 364 | ||
321 | if (ifmgd->extra_ie) { | 365 | if (wk->ie_len && wk->ie) { |
322 | pos = skb_put(skb, ifmgd->extra_ie_len); | 366 | pos = skb_put(skb, wk->ie_len); |
323 | memcpy(pos, ifmgd->extra_ie, ifmgd->extra_ie_len); | 367 | memcpy(pos, wk->ie, wk->ie_len); |
324 | } | 368 | } |
325 | 369 | ||
326 | if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) { | 370 | if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) { |
@@ -345,9 +389,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
345 | */ | 389 | */ |
346 | if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && | 390 | if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && |
347 | sband->ht_cap.ht_supported && | 391 | sband->ht_cap.ht_supported && |
348 | (ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) && | 392 | (ht_ie = ieee80211_bss_get_ie(&wk->bss->cbss, WLAN_EID_HT_INFORMATION)) && |
349 | ht_ie[1] >= sizeof(struct ieee80211_ht_info) && | 393 | ht_ie[1] >= sizeof(struct ieee80211_ht_info) && |
350 | (!(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED))) { | 394 | (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N))) { |
351 | struct ieee80211_ht_info *ht_info = | 395 | struct ieee80211_ht_info *ht_info = |
352 | (struct ieee80211_ht_info *)(ht_ie + 2); | 396 | (struct ieee80211_ht_info *)(ht_ie + 2); |
353 | u16 cap = sband->ht_cap.cap; | 397 | u16 cap = sband->ht_cap.cap; |
@@ -382,18 +426,13 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
382 | memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); | 426 | memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); |
383 | } | 427 | } |
384 | 428 | ||
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); | 429 | ieee80211_tx_skb(sdata, skb, 0); |
392 | } | 430 | } |
393 | 431 | ||
394 | 432 | ||
395 | static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | 433 | static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, |
396 | u16 stype, u16 reason) | 434 | const u8 *bssid, u16 stype, u16 reason, |
435 | void *cookie) | ||
397 | { | 436 | { |
398 | struct ieee80211_local *local = sdata->local; | 437 | struct ieee80211_local *local = sdata->local; |
399 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 438 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
@@ -410,18 +449,18 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
410 | 449 | ||
411 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | 450 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
412 | memset(mgmt, 0, 24); | 451 | memset(mgmt, 0, 24); |
413 | memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN); | 452 | memcpy(mgmt->da, bssid, ETH_ALEN); |
414 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 453 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
415 | memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN); | 454 | memcpy(mgmt->bssid, bssid, ETH_ALEN); |
416 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); | 455 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); |
417 | skb_put(skb, 2); | 456 | skb_put(skb, 2); |
418 | /* u.deauth.reason_code == u.disassoc.reason_code */ | 457 | /* u.deauth.reason_code == u.disassoc.reason_code */ |
419 | mgmt->u.deauth.reason_code = cpu_to_le16(reason); | 458 | mgmt->u.deauth.reason_code = cpu_to_le16(reason); |
420 | 459 | ||
421 | if (stype == IEEE80211_STYPE_DEAUTH) | 460 | if (stype == IEEE80211_STYPE_DEAUTH) |
422 | cfg80211_send_deauth(sdata->dev, (u8 *) mgmt, skb->len); | 461 | cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len, cookie); |
423 | else | 462 | else |
424 | cfg80211_send_disassoc(sdata->dev, (u8 *) mgmt, skb->len); | 463 | cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len, cookie); |
425 | ieee80211_tx_skb(sdata, skb, ifmgd->flags & IEEE80211_STA_MFP_ENABLED); | 464 | ieee80211_tx_skb(sdata, skb, ifmgd->flags & IEEE80211_STA_MFP_ENABLED); |
426 | } | 465 | } |
427 | 466 | ||
@@ -494,28 +533,26 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
494 | { | 533 | { |
495 | struct ieee80211_sub_if_data *sdata = | 534 | struct ieee80211_sub_if_data *sdata = |
496 | container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); | 535 | 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; | 536 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
499 | 537 | ||
500 | if (!netif_running(sdata->dev)) | 538 | if (!netif_running(sdata->dev)) |
501 | return; | 539 | return; |
502 | 540 | ||
503 | bss = ieee80211_rx_bss_get(sdata->local, ifmgd->bssid, | 541 | mutex_lock(&ifmgd->mtx); |
504 | sdata->local->hw.conf.channel->center_freq, | 542 | if (!ifmgd->associated) |
505 | ifmgd->ssid, ifmgd->ssid_len); | 543 | goto out; |
506 | if (!bss) | ||
507 | goto exit; | ||
508 | 544 | ||
509 | sdata->local->oper_channel = sdata->local->csa_channel; | 545 | sdata->local->oper_channel = sdata->local->csa_channel; |
546 | ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL); | ||
547 | |||
510 | /* XXX: shouldn't really modify cfg80211-owned data! */ | 548 | /* XXX: shouldn't really modify cfg80211-owned data! */ |
511 | if (!ieee80211_hw_config(sdata->local, IEEE80211_CONF_CHANGE_CHANNEL)) | 549 | ifmgd->associated->cbss.channel = sdata->local->oper_channel; |
512 | bss->cbss.channel = sdata->local->oper_channel; | ||
513 | 550 | ||
514 | ieee80211_rx_bss_put(sdata->local, bss); | ||
515 | exit: | ||
516 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; | ||
517 | ieee80211_wake_queues_by_reason(&sdata->local->hw, | 551 | ieee80211_wake_queues_by_reason(&sdata->local->hw, |
518 | IEEE80211_QUEUE_STOP_REASON_CSA); | 552 | IEEE80211_QUEUE_STOP_REASON_CSA); |
553 | out: | ||
554 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; | ||
555 | mutex_unlock(&ifmgd->mtx); | ||
519 | } | 556 | } |
520 | 557 | ||
521 | static void ieee80211_chswitch_timer(unsigned long data) | 558 | static void ieee80211_chswitch_timer(unsigned long data) |
@@ -529,7 +566,7 @@ static void ieee80211_chswitch_timer(unsigned long data) | |||
529 | return; | 566 | return; |
530 | } | 567 | } |
531 | 568 | ||
532 | queue_work(sdata->local->hw.workqueue, &ifmgd->chswitch_work); | 569 | ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); |
533 | } | 570 | } |
534 | 571 | ||
535 | void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | 572 | void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, |
@@ -540,10 +577,12 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
540 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 577 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
541 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num); | 578 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num); |
542 | 579 | ||
543 | if (ifmgd->state != IEEE80211_STA_MLME_ASSOCIATED) | 580 | ASSERT_MGD_MTX(ifmgd); |
581 | |||
582 | if (!ifmgd->associated) | ||
544 | return; | 583 | return; |
545 | 584 | ||
546 | if (sdata->local->sw_scanning || sdata->local->hw_scanning) | 585 | if (sdata->local->scanning) |
547 | return; | 586 | return; |
548 | 587 | ||
549 | /* Disregard subsequent beacons if we are already running a timer | 588 | /* Disregard subsequent beacons if we are already running a timer |
@@ -559,7 +598,7 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
559 | sdata->local->csa_channel = new_ch; | 598 | sdata->local->csa_channel = new_ch; |
560 | 599 | ||
561 | if (sw_elem->count <= 1) { | 600 | if (sw_elem->count <= 1) { |
562 | queue_work(sdata->local->hw.workqueue, &ifmgd->chswitch_work); | 601 | ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); |
563 | } else { | 602 | } else { |
564 | ieee80211_stop_queues_by_reason(&sdata->local->hw, | 603 | ieee80211_stop_queues_by_reason(&sdata->local->hw, |
565 | IEEE80211_QUEUE_STOP_REASON_CSA); | 604 | IEEE80211_QUEUE_STOP_REASON_CSA); |
@@ -601,7 +640,7 @@ static void ieee80211_enable_ps(struct ieee80211_local *local, | |||
601 | * If we are scanning right now then the parameters will | 640 | * If we are scanning right now then the parameters will |
602 | * take effect when scan finishes. | 641 | * take effect when scan finishes. |
603 | */ | 642 | */ |
604 | if (local->hw_scanning || local->sw_scanning) | 643 | if (local->scanning) |
605 | return; | 644 | return; |
606 | 645 | ||
607 | if (conf->dynamic_ps_timeout > 0 && | 646 | if (conf->dynamic_ps_timeout > 0 && |
@@ -651,8 +690,9 @@ void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency) | |||
651 | } | 690 | } |
652 | 691 | ||
653 | if (count == 1 && found->u.mgd.powersave && | 692 | if (count == 1 && found->u.mgd.powersave && |
654 | (found->u.mgd.flags & IEEE80211_STA_ASSOCIATED) && | 693 | found->u.mgd.associated && list_empty(&found->u.mgd.work_list) && |
655 | !(found->u.mgd.flags & IEEE80211_STA_PROBEREQ_POLL)) { | 694 | !(found->u.mgd.flags & (IEEE80211_STA_BEACON_POLL | |
695 | IEEE80211_STA_CONNECTION_POLL))) { | ||
656 | s32 beaconint_us; | 696 | s32 beaconint_us; |
657 | 697 | ||
658 | if (latency < 0) | 698 | if (latency < 0) |
@@ -724,7 +764,7 @@ void ieee80211_dynamic_ps_timer(unsigned long data) | |||
724 | if (local->quiescing || local->suspended) | 764 | if (local->quiescing || local->suspended) |
725 | return; | 765 | return; |
726 | 766 | ||
727 | queue_work(local->hw.workqueue, &local->dynamic_ps_enable_work); | 767 | ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work); |
728 | } | 768 | } |
729 | 769 | ||
730 | /* MLME */ | 770 | /* MLME */ |
@@ -806,9 +846,6 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, | |||
806 | u16 capab, bool erp_valid, u8 erp) | 846 | u16 capab, bool erp_valid, u8 erp) |
807 | { | 847 | { |
808 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; | 848 | 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; | 849 | u32 changed = 0; |
813 | bool use_protection; | 850 | bool use_protection; |
814 | bool use_short_preamble; | 851 | bool use_short_preamble; |
@@ -825,42 +862,16 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, | |||
825 | use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); | 862 | use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); |
826 | 863 | ||
827 | if (use_protection != bss_conf->use_cts_prot) { | 864 | 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; | 865 | bss_conf->use_cts_prot = use_protection; |
837 | changed |= BSS_CHANGED_ERP_CTS_PROT; | 866 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
838 | } | 867 | } |
839 | 868 | ||
840 | if (use_short_preamble != bss_conf->use_short_preamble) { | 869 | 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; | 870 | bss_conf->use_short_preamble = use_short_preamble; |
851 | changed |= BSS_CHANGED_ERP_PREAMBLE; | 871 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
852 | } | 872 | } |
853 | 873 | ||
854 | if (use_short_slot != bss_conf->use_short_slot) { | 874 | 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; | 875 | bss_conf->use_short_slot = use_short_slot; |
865 | changed |= BSS_CHANGED_ERP_SLOT; | 876 | changed |= BSS_CHANGED_ERP_SLOT; |
866 | } | 877 | } |
@@ -868,105 +879,31 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, | |||
868 | return changed; | 879 | return changed; |
869 | } | 880 | } |
870 | 881 | ||
871 | static 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 | |||
882 | static 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 | |||
935 | static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | 882 | static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, |
883 | struct ieee80211_mgd_work *wk, | ||
936 | u32 bss_info_changed) | 884 | u32 bss_info_changed) |
937 | { | 885 | { |
938 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
939 | struct ieee80211_local *local = sdata->local; | 886 | struct ieee80211_local *local = sdata->local; |
940 | struct ieee80211_conf *conf = &local_to_hw(local)->conf; | 887 | struct ieee80211_bss *bss = wk->bss; |
941 | |||
942 | struct ieee80211_bss *bss; | ||
943 | 888 | ||
944 | bss_info_changed |= BSS_CHANGED_ASSOC; | 889 | bss_info_changed |= BSS_CHANGED_ASSOC; |
945 | ifmgd->flags |= IEEE80211_STA_ASSOCIATED; | 890 | /* set timing information */ |
891 | sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval; | ||
892 | sdata->vif.bss_conf.timestamp = bss->cbss.tsf; | ||
893 | sdata->vif.bss_conf.dtim_period = bss->dtim_period; | ||
946 | 894 | ||
947 | bss = ieee80211_rx_bss_get(local, ifmgd->bssid, | 895 | bss_info_changed |= BSS_CHANGED_BEACON_INT; |
948 | conf->channel->center_freq, | 896 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, |
949 | ifmgd->ssid, ifmgd->ssid_len); | 897 | bss->cbss.capability, bss->has_erp_value, bss->erp_value); |
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 | 898 | ||
956 | bss_info_changed |= BSS_CHANGED_BEACON_INT; | 899 | sdata->u.mgd.associated = bss; |
957 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, | 900 | sdata->u.mgd.old_associate_work = wk; |
958 | bss->cbss.capability, bss->has_erp_value, bss->erp_value); | 901 | memcpy(sdata->u.mgd.bssid, bss->cbss.bssid, ETH_ALEN); |
959 | |||
960 | cfg80211_hold_bss(&bss->cbss); | ||
961 | |||
962 | ieee80211_rx_bss_put(local, bss); | ||
963 | } | ||
964 | 902 | ||
965 | ifmgd->flags |= IEEE80211_STA_PREV_BSSID_SET; | 903 | /* just to be sure */ |
966 | memcpy(ifmgd->prev_bssid, sdata->u.mgd.bssid, ETH_ALEN); | 904 | sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | |
967 | ieee80211_sta_send_associnfo(sdata); | 905 | IEEE80211_STA_BEACON_POLL); |
968 | 906 | ||
969 | ifmgd->last_probe = jiffies; | ||
970 | ieee80211_led_assoc(local, 1); | 907 | ieee80211_led_assoc(local, 1); |
971 | 908 | ||
972 | sdata->vif.bss_conf.assoc = 1; | 909 | sdata->vif.bss_conf.assoc = 1; |
@@ -982,176 +919,157 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
982 | 919 | ||
983 | ieee80211_bss_info_change_notify(sdata, bss_info_changed); | 920 | ieee80211_bss_info_change_notify(sdata, bss_info_changed); |
984 | 921 | ||
985 | /* will be same as sdata */ | 922 | mutex_lock(&local->iflist_mtx); |
986 | if (local->ps_sdata) { | 923 | ieee80211_recalc_ps(local, -1); |
987 | mutex_lock(&local->iflist_mtx); | 924 | mutex_unlock(&local->iflist_mtx); |
988 | ieee80211_recalc_ps(local, -1); | ||
989 | mutex_unlock(&local->iflist_mtx); | ||
990 | } | ||
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 | ||
998 | static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata) | 930 | static enum rx_mgmt_action __must_check |
931 | ieee80211_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 | ieee80211_queue_work(&local->hw, &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); | 966 | |
967 | wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; | ||
968 | run_again(ifmgd, wk->timeout); | ||
1039 | 969 | ||
1040 | mod_timer(&ifmgd->timer, jiffies + IEEE80211_AUTH_TIMEOUT); | 970 | return RX_MGMT_NONE; |
1041 | } | 971 | } |
1042 | 972 | ||
1043 | 973 | ||
1044 | static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata) | 974 | static enum rx_mgmt_action __must_check |
975 | ieee80211_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 | ieee80211_queue_work(&local->hw, &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 | /* | ||
1091 | * The disassoc 'reason' argument can be either our own reason | ||
1092 | * if self disconnected or a reason code from the AP. | ||
1093 | */ | ||
1094 | static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | 1015 | static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, |
1095 | bool deauth, bool self_disconnected, | 1016 | bool deauth) |
1096 | u16 reason) | ||
1097 | { | 1017 | { |
1098 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1018 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1099 | struct ieee80211_local *local = sdata->local; | 1019 | 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; | 1020 | struct sta_info *sta; |
1103 | u32 changed = 0, config_changed = 0; | 1021 | u32 changed = 0, config_changed = 0; |
1022 | u8 bssid[ETH_ALEN]; | ||
1023 | |||
1024 | ASSERT_MGD_MTX(ifmgd); | ||
1025 | |||
1026 | if (WARN_ON(!ifmgd->associated)) | ||
1027 | return; | ||
1028 | |||
1029 | memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); | ||
1030 | |||
1031 | ifmgd->associated = NULL; | ||
1032 | memset(ifmgd->bssid, 0, ETH_ALEN); | ||
1104 | 1033 | ||
1105 | if (deauth) { | 1034 | if (deauth) { |
1106 | ifmgd->direct_probe_tries = 0; | 1035 | kfree(ifmgd->old_associate_work); |
1107 | ifmgd->auth_tries = 0; | 1036 | ifmgd->old_associate_work = NULL; |
1037 | } else { | ||
1038 | struct ieee80211_mgd_work *wk = ifmgd->old_associate_work; | ||
1039 | |||
1040 | wk->state = IEEE80211_MGD_STATE_IDLE; | ||
1041 | list_add(&wk->list, &ifmgd->work_list); | ||
1108 | } | 1042 | } |
1109 | ifmgd->assoc_scan_tries = 0; | 1043 | |
1110 | ifmgd->assoc_tries = 0; | 1044 | /* |
1045 | * we need to commit the associated = NULL change because the | ||
1046 | * scan code uses that to determine whether this iface should | ||
1047 | * go to/wake up from powersave or not -- and could otherwise | ||
1048 | * wake the queues erroneously. | ||
1049 | */ | ||
1050 | smp_mb(); | ||
1051 | |||
1052 | /* | ||
1053 | * Thus, we can only afterwards stop the queues -- to account | ||
1054 | * for the case where another CPU is finishing a scan at this | ||
1055 | * time -- we don't want the scan code to enable queues. | ||
1056 | */ | ||
1111 | 1057 | ||
1112 | netif_tx_stop_all_queues(sdata->dev); | 1058 | netif_tx_stop_all_queues(sdata->dev); |
1113 | netif_carrier_off(sdata->dev); | 1059 | netif_carrier_off(sdata->dev); |
1114 | 1060 | ||
1115 | rcu_read_lock(); | 1061 | rcu_read_lock(); |
1116 | sta = sta_info_get(local, ifmgd->bssid); | 1062 | sta = sta_info_get(local, bssid); |
1117 | if (sta) | 1063 | if (sta) |
1118 | ieee80211_sta_tear_down_BA_sessions(sta); | 1064 | ieee80211_sta_tear_down_BA_sessions(sta); |
1119 | rcu_read_unlock(); | 1065 | rcu_read_unlock(); |
1120 | 1066 | ||
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); | 1067 | changed |= ieee80211_reset_erp_info(sdata); |
1141 | 1068 | ||
1142 | ieee80211_led_assoc(local, 0); | 1069 | ieee80211_led_assoc(local, 0); |
1143 | changed |= BSS_CHANGED_ASSOC; | 1070 | changed |= BSS_CHANGED_ASSOC; |
1144 | sdata->vif.bss_conf.assoc = false; | 1071 | sdata->vif.bss_conf.assoc = false; |
1145 | 1072 | ||
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); | 1073 | ieee80211_set_wmm_default(sdata); |
1156 | 1074 | ||
1157 | ieee80211_recalc_idle(local); | 1075 | ieee80211_recalc_idle(local); |
@@ -1180,7 +1098,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1180 | 1098 | ||
1181 | rcu_read_lock(); | 1099 | rcu_read_lock(); |
1182 | 1100 | ||
1183 | sta = sta_info_get(local, ifmgd->bssid); | 1101 | sta = sta_info_get(local, bssid); |
1184 | if (!sta) { | 1102 | if (!sta) { |
1185 | rcu_read_unlock(); | 1103 | rcu_read_unlock(); |
1186 | return; | 1104 | return; |
@@ -1193,83 +1111,42 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1193 | sta_info_destroy(sta); | 1111 | sta_info_destroy(sta); |
1194 | } | 1112 | } |
1195 | 1113 | ||
1196 | static int ieee80211_sta_wep_configured(struct ieee80211_sub_if_data *sdata) | 1114 | static enum rx_mgmt_action __must_check |
1197 | { | 1115 | ieee80211_associate(struct ieee80211_sub_if_data *sdata, |
1198 | if (!sdata || !sdata->default_key || | 1116 | struct ieee80211_mgd_work *wk) |
1199 | sdata->default_key->conf.alg != ALG_WEP) | ||
1200 | return 0; | ||
1201 | return 1; | ||
1202 | } | ||
1203 | |||
1204 | static 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 | |||
1234 | static void ieee80211_associate(struct ieee80211_sub_if_data *sdata) | ||
1235 | { | 1117 | { |
1236 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1118 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1237 | struct ieee80211_local *local = sdata->local; | 1119 | struct ieee80211_local *local = sdata->local; |
1238 | 1120 | ||
1239 | ifmgd->assoc_tries++; | 1121 | wk->tries++; |
1240 | if (ifmgd->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) { | 1122 | if (wk->tries > IEEE80211_ASSOC_MAX_TRIES) { |
1241 | printk(KERN_DEBUG "%s: association with AP %pM" | 1123 | printk(KERN_DEBUG "%s: association with AP %pM" |
1242 | " timed out\n", | 1124 | " timed out\n", |
1243 | sdata->dev->name, ifmgd->bssid); | 1125 | sdata->dev->name, wk->bss->cbss.bssid); |
1244 | ifmgd->state = IEEE80211_STA_MLME_DISABLED; | 1126 | |
1245 | ieee80211_recalc_idle(local); | 1127 | /* |
1246 | cfg80211_send_assoc_timeout(sdata->dev, ifmgd->bssid); | 1128 | * Most likely AP is not in the range so remove the |
1247 | ieee80211_rx_bss_remove(sdata, ifmgd->bssid, | 1129 | * bss struct for that AP. |
1248 | sdata->local->hw.conf.channel->center_freq, | 1130 | */ |
1249 | ifmgd->ssid, ifmgd->ssid_len); | 1131 | cfg80211_unlink_bss(local->hw.wiphy, &wk->bss->cbss); |
1132 | |||
1250 | /* | 1133 | /* |
1251 | * We might have a pending scan which had no chance to run yet | 1134 | * We might have a pending scan which had no chance to run yet |
1252 | * due to state == IEEE80211_STA_MLME_ASSOCIATE. | 1135 | * due to work needing to be done. Hence, queue the STAs work |
1253 | * Hence, queue the STAs work again | 1136 | * again for that. |
1254 | */ | 1137 | */ |
1255 | queue_work(local->hw.workqueue, &ifmgd->work); | 1138 | ieee80211_queue_work(&local->hw, &ifmgd->work); |
1256 | return; | 1139 | return RX_MGMT_CFG80211_ASSOC_TO; |
1257 | } | 1140 | } |
1258 | 1141 | ||
1259 | ifmgd->state = IEEE80211_STA_MLME_ASSOCIATE; | 1142 | printk(KERN_DEBUG "%s: associate with AP %pM (try %d)\n", |
1260 | printk(KERN_DEBUG "%s: associate with AP %pM\n", | 1143 | sdata->dev->name, wk->bss->cbss.bssid, wk->tries); |
1261 | sdata->dev->name, ifmgd->bssid); | 1144 | 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 | 1145 | ||
1270 | ieee80211_send_assoc(sdata); | 1146 | wk->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; |
1147 | run_again(ifmgd, wk->timeout); | ||
1271 | 1148 | ||
1272 | mod_timer(&ifmgd->timer, jiffies + IEEE80211_ASSOC_TIMEOUT); | 1149 | return RX_MGMT_NONE; |
1273 | } | 1150 | } |
1274 | 1151 | ||
1275 | void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, | 1152 | void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, |
@@ -1280,160 +1157,113 @@ void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, | |||
1280 | * from AP because we know that the connection is working both ways | 1157 | * from AP because we know that the connection is working both ways |
1281 | * at that time. But multicast frames (and hence also beacons) must | 1158 | * at that time. But multicast frames (and hence also beacons) must |
1282 | * be ignored here, because we need to trigger the timer during | 1159 | * be ignored here, because we need to trigger the timer during |
1283 | * data idle periods for sending the periodical probe request to | 1160 | * data idle periods for sending the periodic probe request to the |
1284 | * the AP. | 1161 | * AP we're connected to. |
1285 | */ | 1162 | */ |
1286 | if (!is_multicast_ether_addr(hdr->addr1)) | 1163 | if (is_multicast_ether_addr(hdr->addr1)) |
1287 | mod_timer(&sdata->u.mgd.timer, | ||
1288 | jiffies + IEEE80211_MONITORING_INTERVAL); | ||
1289 | } | ||
1290 | |||
1291 | void ieee80211_beacon_loss_work(struct work_struct *work) | ||
1292 | { | ||
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; | ||
1297 | |||
1298 | /* | ||
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; | 1164 | return; |
1308 | 1165 | ||
1309 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 1166 | mod_timer(&sdata->u.mgd.conn_mon_timer, |
1310 | if (net_ratelimit()) { | 1167 | round_jiffies_up(jiffies + IEEE80211_CONNECTION_IDLE_TIME)); |
1311 | printk(KERN_DEBUG "%s: driver reports beacon loss from AP %pM " | ||
1312 | "- sending probe request\n", sdata->dev->name, | ||
1313 | sdata->u.mgd.bssid); | ||
1314 | } | ||
1315 | #endif | ||
1316 | |||
1317 | ifmgd->flags |= IEEE80211_STA_PROBEREQ_POLL; | ||
1318 | |||
1319 | mutex_lock(&sdata->local->iflist_mtx); | ||
1320 | ieee80211_recalc_ps(sdata->local, -1); | ||
1321 | mutex_unlock(&sdata->local->iflist_mtx); | ||
1322 | |||
1323 | ieee80211_send_probe_req(sdata, ifmgd->bssid, ifmgd->ssid, | ||
1324 | ifmgd->ssid_len, NULL, 0); | ||
1325 | |||
1326 | mod_timer(&ifmgd->timer, jiffies + IEEE80211_PROBE_WAIT); | ||
1327 | } | 1168 | } |
1328 | 1169 | ||
1329 | void ieee80211_beacon_loss(struct ieee80211_vif *vif) | 1170 | static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) |
1330 | { | 1171 | { |
1331 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | 1172 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1173 | const u8 *ssid; | ||
1174 | |||
1175 | ssid = ieee80211_bss_get_ie(&ifmgd->associated->cbss, WLAN_EID_SSID); | ||
1176 | ieee80211_send_probe_req(sdata, ifmgd->associated->cbss.bssid, | ||
1177 | ssid + 2, ssid[1], NULL, 0); | ||
1332 | 1178 | ||
1333 | queue_work(sdata->local->hw.workqueue, | 1179 | ifmgd->probe_send_count++; |
1334 | &sdata->u.mgd.beacon_loss_work); | 1180 | ifmgd->probe_timeout = jiffies + IEEE80211_PROBE_WAIT; |
1181 | run_again(ifmgd, ifmgd->probe_timeout); | ||
1335 | } | 1182 | } |
1336 | EXPORT_SYMBOL(ieee80211_beacon_loss); | ||
1337 | 1183 | ||
1338 | static void ieee80211_associated(struct ieee80211_sub_if_data *sdata) | 1184 | static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata, |
1185 | bool beacon) | ||
1339 | { | 1186 | { |
1340 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1187 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1341 | struct ieee80211_local *local = sdata->local; | 1188 | bool already = false; |
1342 | struct sta_info *sta; | ||
1343 | unsigned long last_rx; | ||
1344 | bool disassoc = false; | ||
1345 | 1189 | ||
1346 | /* TODO: start monitoring current AP signal quality and number of | 1190 | if (!netif_running(sdata->dev)) |
1347 | * missed beacons. Scan other channels every now and then and search | 1191 | return; |
1348 | * for better APs. */ | ||
1349 | /* TODO: remove expired BSSes */ | ||
1350 | 1192 | ||
1351 | ifmgd->state = IEEE80211_STA_MLME_ASSOCIATED; | 1193 | if (sdata->local->scanning) |
1194 | return; | ||
1352 | 1195 | ||
1353 | rcu_read_lock(); | 1196 | mutex_lock(&ifmgd->mtx); |
1354 | 1197 | ||
1355 | sta = sta_info_get(local, ifmgd->bssid); | 1198 | if (!ifmgd->associated) |
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; | 1199 | goto out; |
1362 | } | ||
1363 | 1200 | ||
1364 | last_rx = sta->last_rx; | 1201 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
1365 | rcu_read_unlock(); | 1202 | if (beacon && net_ratelimit()) |
1366 | 1203 | printk(KERN_DEBUG "%s: detected beacon loss from AP " | |
1367 | if ((ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) && | 1204 | "- sending probe request\n", sdata->dev->name); |
1368 | time_after(jiffies, last_rx + IEEE80211_PROBE_WAIT)) { | 1205 | #endif |
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 | 1206 | ||
1377 | /* | 1207 | /* |
1378 | * Beacon filtering is only enabled with power save and then the | 1208 | * The driver/our work has already reported this event or the |
1379 | * stack should not check for beacon loss. | 1209 | * connection monitoring has kicked in and we have already sent |
1210 | * a probe request. Or maybe the AP died and the driver keeps | ||
1211 | * reporting until we disassociate... | ||
1212 | * | ||
1213 | * In either case we have to ignore the current call to this | ||
1214 | * function (except for setting the correct probe reason bit) | ||
1215 | * because otherwise we would reset the timer every time and | ||
1216 | * never check whether we received a probe response! | ||
1380 | */ | 1217 | */ |
1381 | if (!((local->hw.flags & IEEE80211_HW_BEACON_FILTER) && | 1218 | if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | |
1382 | (local->hw.conf.flags & IEEE80211_CONF_PS)) && | 1219 | IEEE80211_STA_CONNECTION_POLL)) |
1383 | time_after(jiffies, | 1220 | already = true; |
1384 | ifmgd->last_beacon + IEEE80211_MONITORING_INTERVAL)) { | 1221 | |
1385 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 1222 | if (beacon) |
1386 | if (net_ratelimit()) { | 1223 | ifmgd->flags |= IEEE80211_STA_BEACON_POLL; |
1387 | printk(KERN_DEBUG "%s: beacon loss from AP %pM " | 1224 | else |
1388 | "- sending probe request\n", | 1225 | ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL; |
1389 | sdata->dev->name, ifmgd->bssid); | 1226 | |
1390 | } | 1227 | if (already) |
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; | 1228 | goto out; |
1400 | } | ||
1401 | 1229 | ||
1402 | if (time_after(jiffies, last_rx + IEEE80211_PROBE_IDLE_TIME)) { | 1230 | mutex_lock(&sdata->local->iflist_mtx); |
1403 | ifmgd->flags |= IEEE80211_STA_PROBEREQ_POLL; | 1231 | ieee80211_recalc_ps(sdata->local, -1); |
1404 | mutex_lock(&local->iflist_mtx); | 1232 | mutex_unlock(&sdata->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 | 1233 | ||
1234 | ifmgd->probe_send_count = 0; | ||
1235 | ieee80211_mgd_probe_ap_send(sdata); | ||
1411 | out: | 1236 | out: |
1412 | if (!disassoc) | 1237 | mutex_unlock(&ifmgd->mtx); |
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 | } | 1238 | } |
1419 | 1239 | ||
1240 | void ieee80211_beacon_loss_work(struct work_struct *work) | ||
1241 | { | ||
1242 | struct ieee80211_sub_if_data *sdata = | ||
1243 | container_of(work, struct ieee80211_sub_if_data, | ||
1244 | u.mgd.beacon_loss_work); | ||
1245 | |||
1246 | ieee80211_mgd_probe_ap(sdata, true); | ||
1247 | } | ||
1420 | 1248 | ||
1421 | static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata) | 1249 | void ieee80211_beacon_loss(struct ieee80211_vif *vif) |
1422 | { | 1250 | { |
1423 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1251 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
1424 | 1252 | ||
1253 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.beacon_loss_work); | ||
1254 | } | ||
1255 | EXPORT_SYMBOL(ieee80211_beacon_loss); | ||
1256 | |||
1257 | static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata, | ||
1258 | struct ieee80211_mgd_work *wk) | ||
1259 | { | ||
1260 | wk->state = IEEE80211_MGD_STATE_IDLE; | ||
1425 | printk(KERN_DEBUG "%s: authenticated\n", sdata->dev->name); | 1261 | 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 | } | 1262 | } |
1434 | 1263 | ||
1435 | 1264 | ||
1436 | static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | 1265 | static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, |
1266 | struct ieee80211_mgd_work *wk, | ||
1437 | struct ieee80211_mgmt *mgmt, | 1267 | struct ieee80211_mgmt *mgmt, |
1438 | size_t len) | 1268 | size_t len) |
1439 | { | 1269 | { |
@@ -1444,161 +1274,133 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | |||
1444 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | 1274 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); |
1445 | if (!elems.challenge) | 1275 | if (!elems.challenge) |
1446 | return; | 1276 | return; |
1447 | ieee80211_send_auth(sdata, 3, sdata->u.mgd.auth_alg, | 1277 | ieee80211_send_auth(sdata, 3, wk->auth_alg, |
1448 | elems.challenge - 2, elems.challenge_len + 2, | 1278 | elems.challenge - 2, elems.challenge_len + 2, |
1449 | sdata->u.mgd.bssid, 1); | 1279 | wk->bss->cbss.bssid, |
1450 | sdata->u.mgd.auth_transaction = 4; | 1280 | wk->key, wk->key_len, wk->key_idx); |
1281 | wk->auth_transaction = 4; | ||
1451 | } | 1282 | } |
1452 | 1283 | ||
1453 | static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | 1284 | static enum rx_mgmt_action __must_check |
1454 | struct ieee80211_mgmt *mgmt, | 1285 | ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, |
1455 | size_t len) | 1286 | struct ieee80211_mgd_work *wk, |
1287 | struct ieee80211_mgmt *mgmt, size_t len) | ||
1456 | { | 1288 | { |
1457 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
1458 | u16 auth_alg, auth_transaction, status_code; | 1289 | u16 auth_alg, auth_transaction, status_code; |
1459 | 1290 | ||
1460 | if (ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE) | 1291 | if (wk->state != IEEE80211_MGD_STATE_AUTH) |
1461 | return; | 1292 | return RX_MGMT_NONE; |
1462 | 1293 | ||
1463 | if (len < 24 + 6) | 1294 | if (len < 24 + 6) |
1464 | return; | 1295 | return RX_MGMT_NONE; |
1465 | 1296 | ||
1466 | if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0) | 1297 | if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0) |
1467 | return; | 1298 | return RX_MGMT_NONE; |
1468 | 1299 | ||
1469 | if (memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0) | 1300 | if (memcmp(wk->bss->cbss.bssid, mgmt->bssid, ETH_ALEN) != 0) |
1470 | return; | 1301 | return RX_MGMT_NONE; |
1471 | 1302 | ||
1472 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); | 1303 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); |
1473 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); | 1304 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); |
1474 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | 1305 | status_code = le16_to_cpu(mgmt->u.auth.status_code); |
1475 | 1306 | ||
1476 | if (auth_alg != ifmgd->auth_alg || | 1307 | if (auth_alg != wk->auth_alg || |
1477 | auth_transaction != ifmgd->auth_transaction) | 1308 | auth_transaction != wk->auth_transaction) |
1478 | return; | 1309 | return RX_MGMT_NONE; |
1479 | 1310 | ||
1480 | if (status_code != WLAN_STATUS_SUCCESS) { | 1311 | if (status_code != WLAN_STATUS_SUCCESS) { |
1481 | if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { | 1312 | list_del(&wk->list); |
1482 | u8 algs[3]; | 1313 | kfree(wk); |
1483 | const int num_algs = ARRAY_SIZE(algs); | 1314 | 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 | } | 1315 | } |
1514 | 1316 | ||
1515 | switch (ifmgd->auth_alg) { | 1317 | switch (wk->auth_alg) { |
1516 | case WLAN_AUTH_OPEN: | 1318 | case WLAN_AUTH_OPEN: |
1517 | case WLAN_AUTH_LEAP: | 1319 | case WLAN_AUTH_LEAP: |
1518 | case WLAN_AUTH_FT: | 1320 | case WLAN_AUTH_FT: |
1519 | ieee80211_auth_completed(sdata); | 1321 | ieee80211_auth_completed(sdata, wk); |
1520 | cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, len); | 1322 | return RX_MGMT_CFG80211_AUTH; |
1521 | break; | ||
1522 | case WLAN_AUTH_SHARED_KEY: | 1323 | case WLAN_AUTH_SHARED_KEY: |
1523 | if (ifmgd->auth_transaction == 4) { | 1324 | if (wk->auth_transaction == 4) { |
1524 | ieee80211_auth_completed(sdata); | 1325 | ieee80211_auth_completed(sdata, wk); |
1525 | cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, len); | 1326 | return RX_MGMT_CFG80211_AUTH; |
1526 | } else | 1327 | } else |
1527 | ieee80211_auth_challenge(sdata, mgmt, len); | 1328 | ieee80211_auth_challenge(sdata, wk, mgmt, len); |
1528 | break; | 1329 | break; |
1529 | } | 1330 | } |
1331 | |||
1332 | return RX_MGMT_NONE; | ||
1530 | } | 1333 | } |
1531 | 1334 | ||
1532 | 1335 | ||
1533 | static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, | 1336 | static enum rx_mgmt_action __must_check |
1534 | struct ieee80211_mgmt *mgmt, | 1337 | ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, |
1535 | size_t len) | 1338 | struct ieee80211_mgd_work *wk, |
1339 | struct ieee80211_mgmt *mgmt, size_t len) | ||
1536 | { | 1340 | { |
1537 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1341 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1342 | const u8 *bssid = NULL; | ||
1538 | u16 reason_code; | 1343 | u16 reason_code; |
1539 | 1344 | ||
1540 | if (len < 24 + 2) | 1345 | if (len < 24 + 2) |
1541 | return; | 1346 | return RX_MGMT_NONE; |
1542 | 1347 | ||
1543 | if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN)) | 1348 | ASSERT_MGD_MTX(ifmgd); |
1544 | return; | 1349 | |
1350 | if (wk) | ||
1351 | bssid = wk->bss->cbss.bssid; | ||
1352 | else | ||
1353 | bssid = ifmgd->associated->cbss.bssid; | ||
1545 | 1354 | ||
1546 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); | 1355 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); |
1547 | 1356 | ||
1548 | if (ifmgd->flags & IEEE80211_STA_AUTHENTICATED) | 1357 | printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n", |
1549 | printk(KERN_DEBUG "%s: deauthenticated (Reason: %u)\n", | 1358 | sdata->dev->name, bssid, reason_code); |
1550 | sdata->dev->name, reason_code); | ||
1551 | 1359 | ||
1552 | if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) && | 1360 | if (!wk) { |
1553 | (ifmgd->state == IEEE80211_STA_MLME_AUTHENTICATE || | 1361 | ieee80211_set_disassoc(sdata, true); |
1554 | ifmgd->state == IEEE80211_STA_MLME_ASSOCIATE || | 1362 | } else { |
1555 | ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)) { | 1363 | list_del(&wk->list); |
1556 | ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE; | 1364 | kfree(wk); |
1557 | mod_timer(&ifmgd->timer, jiffies + | ||
1558 | IEEE80211_RETRY_AUTH_INTERVAL); | ||
1559 | } | 1365 | } |
1560 | 1366 | ||
1561 | ieee80211_set_disassoc(sdata, true, false, 0); | 1367 | return RX_MGMT_CFG80211_DEAUTH; |
1562 | ifmgd->flags &= ~IEEE80211_STA_AUTHENTICATED; | ||
1563 | cfg80211_send_deauth(sdata->dev, (u8 *) mgmt, len); | ||
1564 | } | 1368 | } |
1565 | 1369 | ||
1566 | 1370 | ||
1567 | static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, | 1371 | static enum rx_mgmt_action __must_check |
1568 | struct ieee80211_mgmt *mgmt, | 1372 | ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, |
1569 | size_t len) | 1373 | struct ieee80211_mgmt *mgmt, size_t len) |
1570 | { | 1374 | { |
1571 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1375 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1572 | u16 reason_code; | 1376 | u16 reason_code; |
1573 | 1377 | ||
1574 | if (len < 24 + 2) | 1378 | if (len < 24 + 2) |
1575 | return; | 1379 | return RX_MGMT_NONE; |
1576 | 1380 | ||
1577 | if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN)) | 1381 | ASSERT_MGD_MTX(ifmgd); |
1578 | return; | ||
1579 | 1382 | ||
1580 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); | 1383 | if (WARN_ON(!ifmgd->associated)) |
1384 | return RX_MGMT_NONE; | ||
1581 | 1385 | ||
1582 | if (ifmgd->flags & IEEE80211_STA_ASSOCIATED) | 1386 | if (WARN_ON(memcmp(ifmgd->associated->cbss.bssid, mgmt->sa, ETH_ALEN))) |
1583 | printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n", | 1387 | return RX_MGMT_NONE; |
1584 | sdata->dev->name, reason_code); | ||
1585 | 1388 | ||
1586 | if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) && | 1389 | 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 | 1390 | ||
1593 | ieee80211_set_disassoc(sdata, false, false, reason_code); | 1391 | printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n", |
1594 | cfg80211_send_disassoc(sdata->dev, (u8 *) mgmt, len); | 1392 | sdata->dev->name, reason_code); |
1393 | |||
1394 | ieee80211_set_disassoc(sdata, false); | ||
1395 | return RX_MGMT_CFG80211_DISASSOC; | ||
1595 | } | 1396 | } |
1596 | 1397 | ||
1597 | 1398 | ||
1598 | static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | 1399 | static enum rx_mgmt_action __must_check |
1599 | struct ieee80211_mgmt *mgmt, | 1400 | ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, |
1600 | size_t len, | 1401 | struct ieee80211_mgd_work *wk, |
1601 | int reassoc) | 1402 | struct ieee80211_mgmt *mgmt, size_t len, |
1403 | bool reassoc) | ||
1602 | { | 1404 | { |
1603 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1405 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1604 | struct ieee80211_local *local = sdata->local; | 1406 | struct ieee80211_local *local = sdata->local; |
@@ -1614,17 +1416,16 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1614 | bool have_higher_than_11mbit = false, newsta = false; | 1416 | bool have_higher_than_11mbit = false, newsta = false; |
1615 | u16 ap_ht_cap_flags; | 1417 | u16 ap_ht_cap_flags; |
1616 | 1418 | ||
1617 | /* AssocResp and ReassocResp have identical structure, so process both | 1419 | /* |
1618 | * of them in this function. */ | 1420 | * AssocResp and ReassocResp have identical structure, so process both |
1619 | 1421 | * of them in this function. | |
1620 | if (ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE) | 1422 | */ |
1621 | return; | ||
1622 | 1423 | ||
1623 | if (len < 24 + 6) | 1424 | if (len < 24 + 6) |
1624 | return; | 1425 | return RX_MGMT_NONE; |
1625 | 1426 | ||
1626 | if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0) | 1427 | if (memcmp(wk->bss->cbss.bssid, mgmt->sa, ETH_ALEN) != 0) |
1627 | return; | 1428 | return RX_MGMT_NONE; |
1628 | 1429 | ||
1629 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); | 1430 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); |
1630 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); | 1431 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); |
@@ -1647,26 +1448,18 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1647 | printk(KERN_DEBUG "%s: AP rejected association temporarily; " | 1448 | printk(KERN_DEBUG "%s: AP rejected association temporarily; " |
1648 | "comeback duration %u TU (%u ms)\n", | 1449 | "comeback duration %u TU (%u ms)\n", |
1649 | sdata->dev->name, tu, ms); | 1450 | sdata->dev->name, tu, ms); |
1451 | wk->timeout = jiffies + msecs_to_jiffies(ms); | ||
1650 | if (ms > IEEE80211_ASSOC_TIMEOUT) | 1452 | if (ms > IEEE80211_ASSOC_TIMEOUT) |
1651 | mod_timer(&ifmgd->timer, | 1453 | run_again(ifmgd, jiffies + msecs_to_jiffies(ms)); |
1652 | jiffies + msecs_to_jiffies(ms)); | 1454 | return RX_MGMT_NONE; |
1653 | return; | ||
1654 | } | 1455 | } |
1655 | 1456 | ||
1656 | if (status_code != WLAN_STATUS_SUCCESS) { | 1457 | if (status_code != WLAN_STATUS_SUCCESS) { |
1657 | printk(KERN_DEBUG "%s: AP denied association (code=%d)\n", | 1458 | printk(KERN_DEBUG "%s: AP denied association (code=%d)\n", |
1658 | sdata->dev->name, status_code); | 1459 | sdata->dev->name, status_code); |
1659 | /* if this was a reassociation, ensure we try a "full" | 1460 | list_del(&wk->list); |
1660 | * association next time. This works around some broken APs | 1461 | kfree(wk); |
1661 | * which do not correctly reject reassociation requests. */ | 1462 | 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 | } | 1463 | } |
1671 | 1464 | ||
1672 | if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) | 1465 | if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) |
@@ -1677,51 +1470,35 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1677 | if (!elems.supp_rates) { | 1470 | if (!elems.supp_rates) { |
1678 | printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n", | 1471 | printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n", |
1679 | sdata->dev->name); | 1472 | sdata->dev->name); |
1680 | return; | 1473 | return RX_MGMT_NONE; |
1681 | } | 1474 | } |
1682 | 1475 | ||
1683 | printk(KERN_DEBUG "%s: associated\n", sdata->dev->name); | 1476 | printk(KERN_DEBUG "%s: associated\n", sdata->dev->name); |
1684 | ifmgd->aid = aid; | 1477 | 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 | 1478 | ||
1693 | rcu_read_lock(); | 1479 | rcu_read_lock(); |
1694 | 1480 | ||
1695 | /* Add STA entry for the AP */ | 1481 | /* Add STA entry for the AP */ |
1696 | sta = sta_info_get(local, ifmgd->bssid); | 1482 | sta = sta_info_get(local, wk->bss->cbss.bssid); |
1697 | if (!sta) { | 1483 | if (!sta) { |
1698 | newsta = true; | 1484 | newsta = true; |
1699 | 1485 | ||
1700 | sta = sta_info_alloc(sdata, ifmgd->bssid, GFP_ATOMIC); | 1486 | rcu_read_unlock(); |
1487 | |||
1488 | sta = sta_info_alloc(sdata, wk->bss->cbss.bssid, GFP_KERNEL); | ||
1701 | if (!sta) { | 1489 | if (!sta) { |
1702 | printk(KERN_DEBUG "%s: failed to alloc STA entry for" | 1490 | printk(KERN_DEBUG "%s: failed to alloc STA entry for" |
1703 | " the AP\n", sdata->dev->name); | 1491 | " the AP\n", sdata->dev->name); |
1704 | rcu_read_unlock(); | 1492 | return RX_MGMT_NONE; |
1705 | return; | ||
1706 | } | 1493 | } |
1707 | 1494 | ||
1708 | /* update new sta with its last rx activity */ | 1495 | set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC | |
1709 | sta->last_rx = jiffies; | 1496 | WLAN_STA_ASSOC_AP); |
1710 | } | 1497 | if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) |
1498 | set_sta_flags(sta, WLAN_STA_AUTHORIZED); | ||
1711 | 1499 | ||
1712 | /* | 1500 | rcu_read_lock(); |
1713 | * FIXME: Do we really need to update the sta_info's information here? | 1501 | } |
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 | |||
1722 | set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP); | ||
1723 | if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) | ||
1724 | set_sta_flags(sta, WLAN_STA_AUTHORIZED); | ||
1725 | 1502 | ||
1726 | rates = 0; | 1503 | rates = 0; |
1727 | basic_rates = 0; | 1504 | basic_rates = 0; |
@@ -1771,8 +1548,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1771 | else | 1548 | else |
1772 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; | 1549 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; |
1773 | 1550 | ||
1774 | /* If TKIP/WEP is used, no need to parse AP's HT capabilities */ | 1551 | 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, | 1552 | ieee80211_ht_cap_ie_to_sta_ht_cap(sband, |
1777 | elems.ht_cap_elem, &sta->sta.ht_cap); | 1553 | elems.ht_cap_elem, &sta->sta.ht_cap); |
1778 | 1554 | ||
@@ -1792,7 +1568,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" | 1568 | printk(KERN_DEBUG "%s: failed to insert STA entry for" |
1793 | " the AP (error %d)\n", sdata->dev->name, err); | 1569 | " the AP (error %d)\n", sdata->dev->name, err); |
1794 | rcu_read_unlock(); | 1570 | rcu_read_unlock(); |
1795 | return; | 1571 | return RX_MGMT_NONE; |
1796 | } | 1572 | } |
1797 | } | 1573 | } |
1798 | 1574 | ||
@@ -1806,24 +1582,29 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1806 | 1582 | ||
1807 | if (elems.ht_info_elem && elems.wmm_param && | 1583 | if (elems.ht_info_elem && elems.wmm_param && |
1808 | (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && | 1584 | (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && |
1809 | !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED)) | 1585 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
1810 | changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, | 1586 | changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, |
1587 | wk->bss->cbss.bssid, | ||
1811 | ap_ht_cap_flags); | 1588 | ap_ht_cap_flags); |
1812 | 1589 | ||
1590 | /* delete work item -- must be before set_associated for PS */ | ||
1591 | list_del(&wk->list); | ||
1592 | |||
1813 | /* set AID and assoc capability, | 1593 | /* set AID and assoc capability, |
1814 | * ieee80211_set_associated() will tell the driver */ | 1594 | * ieee80211_set_associated() will tell the driver */ |
1815 | bss_conf->aid = aid; | 1595 | bss_conf->aid = aid; |
1816 | bss_conf->assoc_capability = capab_info; | 1596 | bss_conf->assoc_capability = capab_info; |
1817 | ieee80211_set_associated(sdata, changed); | 1597 | /* this will take ownership of wk */ |
1598 | ieee80211_set_associated(sdata, wk, changed); | ||
1818 | 1599 | ||
1819 | /* | 1600 | /* |
1820 | * initialise the time of last beacon to be the association time, | 1601 | * Start timer to probe the connection to the AP now. |
1821 | * otherwise beacon loss check will trigger immediately | 1602 | * Also start the timer that will detect beacon loss. |
1822 | */ | 1603 | */ |
1823 | ifmgd->last_beacon = jiffies; | 1604 | ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt); |
1605 | mod_beacon_timer(sdata); | ||
1824 | 1606 | ||
1825 | ieee80211_associated(sdata); | 1607 | return RX_MGMT_CFG80211_ASSOC; |
1826 | cfg80211_send_rx_assoc(sdata->dev, (u8 *) mgmt, len); | ||
1827 | } | 1608 | } |
1828 | 1609 | ||
1829 | 1610 | ||
@@ -1851,23 +1632,25 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
1851 | 1632 | ||
1852 | bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, | 1633 | bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, |
1853 | channel, beacon); | 1634 | channel, beacon); |
1854 | if (!bss) | 1635 | if (bss) |
1636 | ieee80211_rx_bss_put(local, bss); | ||
1637 | |||
1638 | if (!sdata->u.mgd.associated) | ||
1855 | return; | 1639 | return; |
1856 | 1640 | ||
1857 | if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) && | 1641 | if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) && |
1858 | (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN) == 0)) { | 1642 | (memcmp(mgmt->bssid, sdata->u.mgd.associated->cbss.bssid, |
1643 | ETH_ALEN) == 0)) { | ||
1859 | struct ieee80211_channel_sw_ie *sw_elem = | 1644 | struct ieee80211_channel_sw_ie *sw_elem = |
1860 | (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem; | 1645 | (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem; |
1861 | ieee80211_sta_process_chanswitch(sdata, sw_elem, bss); | 1646 | ieee80211_sta_process_chanswitch(sdata, sw_elem, bss); |
1862 | } | 1647 | } |
1863 | |||
1864 | ieee80211_rx_bss_put(local, bss); | ||
1865 | } | 1648 | } |
1866 | 1649 | ||
1867 | 1650 | ||
1868 | static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | 1651 | static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, |
1869 | struct ieee80211_mgmt *mgmt, | 1652 | struct ieee80211_mgd_work *wk, |
1870 | size_t len, | 1653 | struct ieee80211_mgmt *mgmt, size_t len, |
1871 | struct ieee80211_rx_status *rx_status) | 1654 | struct ieee80211_rx_status *rx_status) |
1872 | { | 1655 | { |
1873 | struct ieee80211_if_managed *ifmgd; | 1656 | struct ieee80211_if_managed *ifmgd; |
@@ -1876,6 +1659,8 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | |||
1876 | 1659 | ||
1877 | ifmgd = &sdata->u.mgd; | 1660 | ifmgd = &sdata->u.mgd; |
1878 | 1661 | ||
1662 | ASSERT_MGD_MTX(ifmgd); | ||
1663 | |||
1879 | if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) | 1664 | if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) |
1880 | return; /* ignore ProbeResp to foreign address */ | 1665 | return; /* ignore ProbeResp to foreign address */ |
1881 | 1666 | ||
@@ -1889,17 +1674,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); | 1674 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); |
1890 | 1675 | ||
1891 | /* direct probe may be part of the association flow */ | 1676 | /* direct probe may be part of the association flow */ |
1892 | if (ifmgd->state == IEEE80211_STA_MLME_DIRECT_PROBE) { | 1677 | if (wk && wk->state == IEEE80211_MGD_STATE_PROBE) { |
1893 | printk(KERN_DEBUG "%s direct probe responded\n", | 1678 | printk(KERN_DEBUG "%s direct probe responded\n", |
1894 | sdata->dev->name); | 1679 | sdata->dev->name); |
1895 | ieee80211_authenticate(sdata); | 1680 | wk->tries = 0; |
1681 | wk->state = IEEE80211_MGD_STATE_AUTH; | ||
1682 | WARN_ON(ieee80211_authenticate(sdata, wk) != RX_MGMT_NONE); | ||
1896 | } | 1683 | } |
1897 | 1684 | ||
1898 | if (ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) { | 1685 | if (ifmgd->associated && |
1899 | ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL; | 1686 | memcmp(mgmt->bssid, ifmgd->associated->cbss.bssid, ETH_ALEN) == 0 && |
1687 | ifmgd->flags & (IEEE80211_STA_BEACON_POLL | | ||
1688 | IEEE80211_STA_CONNECTION_POLL)) { | ||
1689 | ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | | ||
1690 | IEEE80211_STA_BEACON_POLL); | ||
1900 | mutex_lock(&sdata->local->iflist_mtx); | 1691 | mutex_lock(&sdata->local->iflist_mtx); |
1901 | ieee80211_recalc_ps(sdata->local, -1); | 1692 | ieee80211_recalc_ps(sdata->local, -1); |
1902 | mutex_unlock(&sdata->local->iflist_mtx); | 1693 | mutex_unlock(&sdata->local->iflist_mtx); |
1694 | /* | ||
1695 | * We've received a probe response, but are not sure whether | ||
1696 | * we have or will be receiving any beacons or data, so let's | ||
1697 | * schedule the timers again, just in case. | ||
1698 | */ | ||
1699 | mod_beacon_timer(sdata); | ||
1700 | mod_timer(&ifmgd->conn_mon_timer, | ||
1701 | round_jiffies_up(jiffies + | ||
1702 | IEEE80211_CONNECTION_IDLE_TIME)); | ||
1903 | } | 1703 | } |
1904 | } | 1704 | } |
1905 | 1705 | ||
@@ -1937,6 +1737,9 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
1937 | bool erp_valid, directed_tim = false; | 1737 | bool erp_valid, directed_tim = false; |
1938 | u8 erp_value = 0; | 1738 | u8 erp_value = 0; |
1939 | u32 ncrc; | 1739 | u32 ncrc; |
1740 | u8 *bssid; | ||
1741 | |||
1742 | ASSERT_MGD_MTX(ifmgd); | ||
1940 | 1743 | ||
1941 | /* Process beacon from the current BSS */ | 1744 | /* Process beacon from the current BSS */ |
1942 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; | 1745 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; |
@@ -1946,23 +1749,41 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
1946 | if (rx_status->freq != local->hw.conf.channel->center_freq) | 1749 | if (rx_status->freq != local->hw.conf.channel->center_freq) |
1947 | return; | 1750 | return; |
1948 | 1751 | ||
1949 | if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED) || | 1752 | /* |
1950 | memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0) | 1753 | * We might have received a number of frames, among them a |
1754 | * disassoc frame and a beacon... | ||
1755 | */ | ||
1756 | if (!ifmgd->associated) | ||
1757 | return; | ||
1758 | |||
1759 | bssid = ifmgd->associated->cbss.bssid; | ||
1760 | |||
1761 | /* | ||
1762 | * And in theory even frames from a different AP we were just | ||
1763 | * associated to a split-second ago! | ||
1764 | */ | ||
1765 | if (memcmp(bssid, mgmt->bssid, ETH_ALEN) != 0) | ||
1951 | return; | 1766 | return; |
1952 | 1767 | ||
1953 | if (ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) { | 1768 | if (ifmgd->flags & IEEE80211_STA_BEACON_POLL) { |
1954 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 1769 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
1955 | if (net_ratelimit()) { | 1770 | if (net_ratelimit()) { |
1956 | printk(KERN_DEBUG "%s: cancelling probereq poll due " | 1771 | printk(KERN_DEBUG "%s: cancelling probereq poll due " |
1957 | "to a received beacon\n", sdata->dev->name); | 1772 | "to a received beacon\n", sdata->dev->name); |
1958 | } | 1773 | } |
1959 | #endif | 1774 | #endif |
1960 | ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL; | 1775 | ifmgd->flags &= ~IEEE80211_STA_BEACON_POLL; |
1961 | mutex_lock(&local->iflist_mtx); | 1776 | mutex_lock(&local->iflist_mtx); |
1962 | ieee80211_recalc_ps(local, -1); | 1777 | ieee80211_recalc_ps(local, -1); |
1963 | mutex_unlock(&local->iflist_mtx); | 1778 | mutex_unlock(&local->iflist_mtx); |
1964 | } | 1779 | } |
1965 | 1780 | ||
1781 | /* | ||
1782 | * Push the beacon loss detection into the future since | ||
1783 | * we are processing a beacon from the AP just now. | ||
1784 | */ | ||
1785 | mod_beacon_timer(sdata); | ||
1786 | |||
1966 | ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); | 1787 | ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); |
1967 | ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable, | 1788 | ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable, |
1968 | len - baselen, &elems, | 1789 | len - baselen, &elems, |
@@ -2019,15 +1840,15 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2019 | 1840 | ||
2020 | 1841 | ||
2021 | if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && | 1842 | if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && |
2022 | !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED)) { | 1843 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) { |
2023 | struct sta_info *sta; | 1844 | struct sta_info *sta; |
2024 | struct ieee80211_supported_band *sband; | 1845 | struct ieee80211_supported_band *sband; |
2025 | u16 ap_ht_cap_flags; | 1846 | u16 ap_ht_cap_flags; |
2026 | 1847 | ||
2027 | rcu_read_lock(); | 1848 | rcu_read_lock(); |
2028 | 1849 | ||
2029 | sta = sta_info_get(local, ifmgd->bssid); | 1850 | sta = sta_info_get(local, bssid); |
2030 | if (!sta) { | 1851 | if (WARN_ON(!sta)) { |
2031 | rcu_read_unlock(); | 1852 | rcu_read_unlock(); |
2032 | return; | 1853 | return; |
2033 | } | 1854 | } |
@@ -2042,15 +1863,11 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2042 | rcu_read_unlock(); | 1863 | rcu_read_unlock(); |
2043 | 1864 | ||
2044 | changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, | 1865 | changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, |
2045 | ap_ht_cap_flags); | 1866 | bssid, ap_ht_cap_flags); |
2046 | } | 1867 | } |
2047 | 1868 | ||
1869 | /* Note: country IE parsing is done for us by cfg80211 */ | ||
2048 | if (elems.country_elem) { | 1870 | if (elems.country_elem) { |
2049 | /* Note we are only reviewing this on beacons | ||
2050 | * for the BSSID we are associated to */ | ||
2051 | regulatory_hint_11d(local->hw.wiphy, | ||
2052 | elems.country_elem, elems.country_elem_len); | ||
2053 | |||
2054 | /* TODO: IBSS also needs this */ | 1871 | /* TODO: IBSS also needs this */ |
2055 | if (elems.pwr_constr_elem) | 1872 | if (elems.pwr_constr_elem) |
2056 | ieee80211_handle_pwr_constr(sdata, | 1873 | ieee80211_handle_pwr_constr(sdata, |
@@ -2063,8 +1880,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2063 | } | 1880 | } |
2064 | 1881 | ||
2065 | ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, | 1882 | ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, |
2066 | struct sk_buff *skb, | 1883 | struct sk_buff *skb) |
2067 | struct ieee80211_rx_status *rx_status) | ||
2068 | { | 1884 | { |
2069 | struct ieee80211_local *local = sdata->local; | 1885 | struct ieee80211_local *local = sdata->local; |
2070 | struct ieee80211_mgmt *mgmt; | 1886 | struct ieee80211_mgmt *mgmt; |
@@ -2080,14 +1896,14 @@ ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, | |||
2080 | case IEEE80211_STYPE_PROBE_REQ: | 1896 | case IEEE80211_STYPE_PROBE_REQ: |
2081 | case IEEE80211_STYPE_PROBE_RESP: | 1897 | case IEEE80211_STYPE_PROBE_RESP: |
2082 | case IEEE80211_STYPE_BEACON: | 1898 | case IEEE80211_STYPE_BEACON: |
2083 | memcpy(skb->cb, rx_status, sizeof(*rx_status)); | ||
2084 | case IEEE80211_STYPE_AUTH: | 1899 | case IEEE80211_STYPE_AUTH: |
2085 | case IEEE80211_STYPE_ASSOC_RESP: | 1900 | case IEEE80211_STYPE_ASSOC_RESP: |
2086 | case IEEE80211_STYPE_REASSOC_RESP: | 1901 | case IEEE80211_STYPE_REASSOC_RESP: |
2087 | case IEEE80211_STYPE_DEAUTH: | 1902 | case IEEE80211_STYPE_DEAUTH: |
2088 | case IEEE80211_STYPE_DISASSOC: | 1903 | case IEEE80211_STYPE_DISASSOC: |
1904 | case IEEE80211_STYPE_ACTION: | ||
2089 | skb_queue_tail(&sdata->u.mgd.skb_queue, skb); | 1905 | skb_queue_tail(&sdata->u.mgd.skb_queue, skb); |
2090 | queue_work(local->hw.workqueue, &sdata->u.mgd.work); | 1906 | ieee80211_queue_work(&local->hw, &sdata->u.mgd.work); |
2091 | return RX_QUEUED; | 1907 | return RX_QUEUED; |
2092 | } | 1908 | } |
2093 | 1909 | ||
@@ -2097,40 +1913,119 @@ ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, | |||
2097 | static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | 1913 | static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, |
2098 | struct sk_buff *skb) | 1914 | struct sk_buff *skb) |
2099 | { | 1915 | { |
1916 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
2100 | struct ieee80211_rx_status *rx_status; | 1917 | struct ieee80211_rx_status *rx_status; |
2101 | struct ieee80211_mgmt *mgmt; | 1918 | struct ieee80211_mgmt *mgmt; |
1919 | struct ieee80211_mgd_work *wk; | ||
1920 | enum rx_mgmt_action rma = RX_MGMT_NONE; | ||
2102 | u16 fc; | 1921 | u16 fc; |
2103 | 1922 | ||
2104 | rx_status = (struct ieee80211_rx_status *) skb->cb; | 1923 | rx_status = (struct ieee80211_rx_status *) skb->cb; |
2105 | mgmt = (struct ieee80211_mgmt *) skb->data; | 1924 | mgmt = (struct ieee80211_mgmt *) skb->data; |
2106 | fc = le16_to_cpu(mgmt->frame_control); | 1925 | fc = le16_to_cpu(mgmt->frame_control); |
2107 | 1926 | ||
2108 | switch (fc & IEEE80211_FCTL_STYPE) { | 1927 | mutex_lock(&ifmgd->mtx); |
2109 | case IEEE80211_STYPE_PROBE_RESP: | 1928 | |
2110 | ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, | 1929 | if (ifmgd->associated && |
2111 | rx_status); | 1930 | memcmp(ifmgd->associated->cbss.bssid, mgmt->bssid, |
2112 | break; | 1931 | ETH_ALEN) == 0) { |
2113 | case IEEE80211_STYPE_BEACON: | 1932 | switch (fc & IEEE80211_FCTL_STYPE) { |
2114 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, | 1933 | case IEEE80211_STYPE_BEACON: |
2115 | rx_status); | 1934 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, |
2116 | break; | 1935 | rx_status); |
2117 | case IEEE80211_STYPE_AUTH: | 1936 | break; |
2118 | ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len); | 1937 | case IEEE80211_STYPE_PROBE_RESP: |
1938 | ieee80211_rx_mgmt_probe_resp(sdata, NULL, mgmt, | ||
1939 | skb->len, rx_status); | ||
1940 | break; | ||
1941 | case IEEE80211_STYPE_DEAUTH: | ||
1942 | rma = ieee80211_rx_mgmt_deauth(sdata, NULL, | ||
1943 | mgmt, skb->len); | ||
1944 | break; | ||
1945 | case IEEE80211_STYPE_DISASSOC: | ||
1946 | rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); | ||
1947 | break; | ||
1948 | case IEEE80211_STYPE_ACTION: | ||
1949 | /* XXX: differentiate, can only happen for CSA now! */ | ||
1950 | ieee80211_sta_process_chanswitch(sdata, | ||
1951 | &mgmt->u.action.u.chan_switch.sw_elem, | ||
1952 | ifmgd->associated); | ||
1953 | break; | ||
1954 | } | ||
1955 | mutex_unlock(&ifmgd->mtx); | ||
1956 | |||
1957 | switch (rma) { | ||
1958 | case RX_MGMT_NONE: | ||
1959 | /* no action */ | ||
1960 | break; | ||
1961 | case RX_MGMT_CFG80211_DEAUTH: | ||
1962 | cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len, | ||
1963 | NULL); | ||
1964 | break; | ||
1965 | case RX_MGMT_CFG80211_DISASSOC: | ||
1966 | cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len, | ||
1967 | NULL); | ||
1968 | break; | ||
1969 | default: | ||
1970 | WARN(1, "unexpected: %d", rma); | ||
1971 | } | ||
1972 | goto out; | ||
1973 | } | ||
1974 | |||
1975 | list_for_each_entry(wk, &ifmgd->work_list, list) { | ||
1976 | if (memcmp(wk->bss->cbss.bssid, mgmt->bssid, ETH_ALEN) != 0) | ||
1977 | continue; | ||
1978 | |||
1979 | switch (fc & IEEE80211_FCTL_STYPE) { | ||
1980 | case IEEE80211_STYPE_PROBE_RESP: | ||
1981 | ieee80211_rx_mgmt_probe_resp(sdata, wk, mgmt, skb->len, | ||
1982 | rx_status); | ||
1983 | break; | ||
1984 | case IEEE80211_STYPE_AUTH: | ||
1985 | rma = ieee80211_rx_mgmt_auth(sdata, wk, mgmt, skb->len); | ||
1986 | break; | ||
1987 | case IEEE80211_STYPE_ASSOC_RESP: | ||
1988 | rma = ieee80211_rx_mgmt_assoc_resp(sdata, wk, mgmt, | ||
1989 | skb->len, false); | ||
1990 | break; | ||
1991 | case IEEE80211_STYPE_REASSOC_RESP: | ||
1992 | rma = ieee80211_rx_mgmt_assoc_resp(sdata, wk, mgmt, | ||
1993 | skb->len, true); | ||
1994 | break; | ||
1995 | case IEEE80211_STYPE_DEAUTH: | ||
1996 | rma = ieee80211_rx_mgmt_deauth(sdata, wk, mgmt, | ||
1997 | skb->len); | ||
1998 | break; | ||
1999 | } | ||
2000 | /* | ||
2001 | * We've processed this frame for that work, so it can't | ||
2002 | * belong to another work struct. | ||
2003 | * NB: this is also required for correctness because the | ||
2004 | * called functions can free 'wk', and for 'rma'! | ||
2005 | */ | ||
2119 | break; | 2006 | break; |
2120 | case IEEE80211_STYPE_ASSOC_RESP: | 2007 | } |
2121 | ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 0); | 2008 | |
2009 | mutex_unlock(&ifmgd->mtx); | ||
2010 | |||
2011 | switch (rma) { | ||
2012 | case RX_MGMT_NONE: | ||
2013 | /* no action */ | ||
2122 | break; | 2014 | break; |
2123 | case IEEE80211_STYPE_REASSOC_RESP: | 2015 | case RX_MGMT_CFG80211_AUTH: |
2124 | ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 1); | 2016 | cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, skb->len); |
2125 | break; | 2017 | break; |
2126 | case IEEE80211_STYPE_DEAUTH: | 2018 | case RX_MGMT_CFG80211_ASSOC: |
2127 | ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); | 2019 | cfg80211_send_rx_assoc(sdata->dev, (u8 *) mgmt, skb->len); |
2128 | break; | 2020 | break; |
2129 | case IEEE80211_STYPE_DISASSOC: | 2021 | case RX_MGMT_CFG80211_DEAUTH: |
2130 | ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); | 2022 | cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len, NULL); |
2131 | break; | 2023 | break; |
2024 | default: | ||
2025 | WARN(1, "unexpected: %d", rma); | ||
2132 | } | 2026 | } |
2133 | 2027 | ||
2028 | out: | ||
2134 | kfree_skb(skb); | 2029 | kfree_skb(skb); |
2135 | } | 2030 | } |
2136 | 2031 | ||
@@ -2146,215 +2041,216 @@ static void ieee80211_sta_timer(unsigned long data) | |||
2146 | return; | 2041 | return; |
2147 | } | 2042 | } |
2148 | 2043 | ||
2149 | set_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request); | 2044 | ieee80211_queue_work(&local->hw, &ifmgd->work); |
2150 | queue_work(local->hw.workqueue, &ifmgd->work); | ||
2151 | } | 2045 | } |
2152 | 2046 | ||
2153 | static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata) | 2047 | static void ieee80211_sta_work(struct work_struct *work) |
2154 | { | 2048 | { |
2155 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 2049 | struct ieee80211_sub_if_data *sdata = |
2050 | container_of(work, struct ieee80211_sub_if_data, u.mgd.work); | ||
2156 | struct ieee80211_local *local = sdata->local; | 2051 | struct ieee80211_local *local = sdata->local; |
2052 | struct ieee80211_if_managed *ifmgd; | ||
2053 | struct sk_buff *skb; | ||
2054 | struct ieee80211_mgd_work *wk, *tmp; | ||
2055 | LIST_HEAD(free_work); | ||
2056 | enum rx_mgmt_action rma; | ||
2057 | bool anybusy = false; | ||
2157 | 2058 | ||
2158 | /* Reset own TSF to allow time synchronization work. */ | 2059 | if (!netif_running(sdata->dev)) |
2159 | drv_reset_tsf(local); | 2060 | return; |
2160 | 2061 | ||
2161 | ifmgd->wmm_last_param_set = -1; /* allow any WMM update */ | 2062 | if (local->scanning) |
2063 | return; | ||
2162 | 2064 | ||
2065 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) | ||
2066 | return; | ||
2163 | 2067 | ||
2164 | if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_OPEN) | 2068 | /* |
2165 | ifmgd->auth_alg = WLAN_AUTH_OPEN; | 2069 | * ieee80211_queue_work() should have picked up most cases, |
2166 | else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY) | 2070 | * here we'll pick the the rest. |
2167 | ifmgd->auth_alg = WLAN_AUTH_SHARED_KEY; | 2071 | */ |
2168 | else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_LEAP) | 2072 | if (WARN(local->suspended, "STA MLME work scheduled while " |
2169 | ifmgd->auth_alg = WLAN_AUTH_LEAP; | 2073 | "going to suspend\n")) |
2170 | else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_FT) | 2074 | return; |
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 | 2075 | ||
2184 | static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata) | 2076 | ifmgd = &sdata->u.mgd; |
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 | 2077 | ||
2195 | if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) && | 2078 | /* first process frames to avoid timing out while a frame is pending */ |
2196 | ifmgd->flags & (IEEE80211_STA_AUTO_SSID_SEL | | 2079 | while ((skb = skb_dequeue(&ifmgd->skb_queue))) |
2197 | IEEE80211_STA_AUTO_BSSID_SEL | | 2080 | ieee80211_sta_rx_queued_mgmt(sdata, skb); |
2198 | IEEE80211_STA_AUTO_CHANNEL_SEL)) { | 2081 | |
2199 | capa_mask |= WLAN_CAPABILITY_PRIVACY; | 2082 | /* then process the rest of the work */ |
2200 | if (sdata->default_key) | 2083 | mutex_lock(&ifmgd->mtx); |
2201 | capa_val |= WLAN_CAPABILITY_PRIVACY; | ||
2202 | } | ||
2203 | 2084 | ||
2204 | if (ifmgd->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) | 2085 | if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | |
2205 | chan = NULL; | 2086 | IEEE80211_STA_CONNECTION_POLL) && |
2087 | ifmgd->associated) { | ||
2088 | u8 bssid[ETH_ALEN]; | ||
2206 | 2089 | ||
2207 | if (ifmgd->flags & IEEE80211_STA_AUTO_BSSID_SEL) | 2090 | memcpy(bssid, ifmgd->associated->cbss.bssid, ETH_ALEN); |
2208 | bssid = NULL; | 2091 | if (time_is_after_jiffies(ifmgd->probe_timeout)) |
2092 | run_again(ifmgd, ifmgd->probe_timeout); | ||
2209 | 2093 | ||
2210 | if (ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL) { | 2094 | else if (ifmgd->probe_send_count < IEEE80211_MAX_PROBE_TRIES) { |
2211 | ssid = NULL; | 2095 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
2212 | ssid_len = 0; | 2096 | printk(KERN_DEBUG "No probe response from AP %pM" |
2097 | " after %dms, try %d\n", bssid, | ||
2098 | (1000 * IEEE80211_PROBE_WAIT)/HZ, | ||
2099 | ifmgd->probe_send_count); | ||
2100 | #endif | ||
2101 | ieee80211_mgd_probe_ap_send(sdata); | ||
2102 | } else { | ||
2103 | /* | ||
2104 | * We actually lost the connection ... or did we? | ||
2105 | * Let's make sure! | ||
2106 | */ | ||
2107 | ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | | ||
2108 | IEEE80211_STA_BEACON_POLL); | ||
2109 | printk(KERN_DEBUG "No probe response from AP %pM" | ||
2110 | " after %dms, disconnecting.\n", | ||
2111 | bssid, (1000 * IEEE80211_PROBE_WAIT)/HZ); | ||
2112 | ieee80211_set_disassoc(sdata, true); | ||
2113 | mutex_unlock(&ifmgd->mtx); | ||
2114 | /* | ||
2115 | * must be outside lock due to cfg80211, | ||
2116 | * but that's not a problem. | ||
2117 | */ | ||
2118 | ieee80211_send_deauth_disassoc(sdata, bssid, | ||
2119 | IEEE80211_STYPE_DEAUTH, | ||
2120 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, | ||
2121 | NULL); | ||
2122 | mutex_lock(&ifmgd->mtx); | ||
2123 | } | ||
2213 | } | 2124 | } |
2214 | 2125 | ||
2215 | bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan, | ||
2216 | bssid, ssid, ssid_len, | ||
2217 | capa_mask, capa_val); | ||
2218 | 2126 | ||
2219 | if (bss) { | 2127 | ieee80211_recalc_idle(local); |
2220 | local->oper_channel = bss->cbss.channel; | ||
2221 | local->oper_channel_type = NL80211_CHAN_NO_HT; | ||
2222 | ieee80211_hw_config(local, 0); | ||
2223 | 2128 | ||
2224 | if (!(ifmgd->flags & IEEE80211_STA_SSID_SET)) | 2129 | list_for_each_entry_safe(wk, tmp, &ifmgd->work_list, list) { |
2225 | ieee80211_sta_set_ssid(sdata, bss->ssid, | 2130 | if (time_is_after_jiffies(wk->timeout)) { |
2226 | bss->ssid_len); | 2131 | /* |
2227 | ieee80211_sta_set_bssid(sdata, bss->cbss.bssid); | 2132 | * This work item isn't supposed to be worked on |
2228 | ieee80211_sta_def_wmm_params(sdata, bss->supp_rates_len, | 2133 | * right now, but take care to adjust the timer |
2229 | bss->supp_rates); | 2134 | * properly. |
2230 | if (sdata->u.mgd.mfp == IEEE80211_MFP_REQUIRED) | 2135 | */ |
2231 | sdata->u.mgd.flags |= IEEE80211_STA_MFP_ENABLED; | 2136 | run_again(ifmgd, wk->timeout); |
2232 | else | 2137 | continue; |
2233 | sdata->u.mgd.flags &= ~IEEE80211_STA_MFP_ENABLED; | 2138 | } |
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 | 2139 | ||
2245 | ieee80211_rx_bss_put(local, bss); | 2140 | switch (wk->state) { |
2246 | ieee80211_sta_reset_auth(sdata); | 2141 | default: |
2247 | return 0; | 2142 | WARN_ON(1); |
2248 | } else { | 2143 | /* fall through */ |
2249 | if (ifmgd->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) { | 2144 | case IEEE80211_MGD_STATE_IDLE: |
2145 | /* nothing */ | ||
2146 | rma = RX_MGMT_NONE; | ||
2147 | break; | ||
2148 | case IEEE80211_MGD_STATE_PROBE: | ||
2149 | rma = ieee80211_direct_probe(sdata, wk); | ||
2150 | break; | ||
2151 | case IEEE80211_MGD_STATE_AUTH: | ||
2152 | rma = ieee80211_authenticate(sdata, wk); | ||
2153 | break; | ||
2154 | case IEEE80211_MGD_STATE_ASSOC: | ||
2155 | rma = ieee80211_associate(sdata, wk); | ||
2156 | break; | ||
2157 | } | ||
2158 | |||
2159 | switch (rma) { | ||
2160 | case RX_MGMT_NONE: | ||
2161 | /* no action required */ | ||
2162 | break; | ||
2163 | case RX_MGMT_CFG80211_AUTH_TO: | ||
2164 | case RX_MGMT_CFG80211_ASSOC_TO: | ||
2165 | list_del(&wk->list); | ||
2166 | list_add(&wk->list, &free_work); | ||
2167 | wk->tries = rma; /* small abuse but only local */ | ||
2168 | break; | ||
2169 | default: | ||
2170 | WARN(1, "unexpected: %d", rma); | ||
2171 | } | ||
2172 | } | ||
2250 | 2173 | ||
2251 | ifmgd->assoc_scan_tries++; | 2174 | list_for_each_entry(wk, &ifmgd->work_list, list) { |
2175 | if (wk->state != IEEE80211_MGD_STATE_IDLE) { | ||
2176 | anybusy = true; | ||
2177 | break; | ||
2178 | } | ||
2179 | } | ||
2180 | if (!anybusy && | ||
2181 | test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) | ||
2182 | ieee80211_queue_delayed_work(&local->hw, | ||
2183 | &local->scan_work, | ||
2184 | round_jiffies_relative(0)); | ||
2252 | 2185 | ||
2253 | ieee80211_request_internal_scan(sdata, ifmgd->ssid, | 2186 | mutex_unlock(&ifmgd->mtx); |
2254 | ssid_len); | ||
2255 | 2187 | ||
2256 | ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE; | 2188 | list_for_each_entry_safe(wk, tmp, &free_work, list) { |
2257 | set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request); | 2189 | switch (wk->tries) { |
2258 | } else { | 2190 | case RX_MGMT_CFG80211_AUTH_TO: |
2259 | ifmgd->assoc_scan_tries = 0; | 2191 | cfg80211_send_auth_timeout(sdata->dev, |
2260 | ifmgd->state = IEEE80211_STA_MLME_DISABLED; | 2192 | wk->bss->cbss.bssid); |
2261 | ieee80211_recalc_idle(local); | 2193 | break; |
2194 | case RX_MGMT_CFG80211_ASSOC_TO: | ||
2195 | cfg80211_send_assoc_timeout(sdata->dev, | ||
2196 | wk->bss->cbss.bssid); | ||
2197 | break; | ||
2198 | default: | ||
2199 | WARN(1, "unexpected: %d", wk->tries); | ||
2262 | } | 2200 | } |
2201 | |||
2202 | list_del(&wk->list); | ||
2203 | kfree(wk); | ||
2263 | } | 2204 | } |
2264 | return -1; | ||
2265 | } | ||
2266 | 2205 | ||
2206 | ieee80211_recalc_idle(local); | ||
2207 | } | ||
2267 | 2208 | ||
2268 | static void ieee80211_sta_work(struct work_struct *work) | 2209 | static void ieee80211_sta_bcn_mon_timer(unsigned long data) |
2269 | { | 2210 | { |
2270 | struct ieee80211_sub_if_data *sdata = | 2211 | struct ieee80211_sub_if_data *sdata = |
2271 | container_of(work, struct ieee80211_sub_if_data, u.mgd.work); | 2212 | (struct ieee80211_sub_if_data *) data; |
2272 | struct ieee80211_local *local = sdata->local; | 2213 | struct ieee80211_local *local = sdata->local; |
2273 | struct ieee80211_if_managed *ifmgd; | ||
2274 | struct sk_buff *skb; | ||
2275 | |||
2276 | if (!netif_running(sdata->dev)) | ||
2277 | return; | ||
2278 | 2214 | ||
2279 | if (local->sw_scanning || local->hw_scanning) | 2215 | if (local->quiescing) |
2280 | return; | 2216 | return; |
2281 | 2217 | ||
2282 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) | 2218 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.beacon_loss_work); |
2283 | return; | 2219 | } |
2284 | |||
2285 | /* | ||
2286 | * Nothing should have been stuffed into the workqueue during | ||
2287 | * the suspend->resume cycle. If this WARN is seen then there | ||
2288 | * is a bug with either the driver suspend or something in | ||
2289 | * mac80211 stuffing into the workqueue which we haven't yet | ||
2290 | * cleared during mac80211's suspend cycle. | ||
2291 | */ | ||
2292 | if (WARN_ON(local->suspended)) | ||
2293 | return; | ||
2294 | |||
2295 | ifmgd = &sdata->u.mgd; | ||
2296 | |||
2297 | while ((skb = skb_dequeue(&ifmgd->skb_queue))) | ||
2298 | ieee80211_sta_rx_queued_mgmt(sdata, skb); | ||
2299 | 2220 | ||
2300 | if (ifmgd->state != IEEE80211_STA_MLME_DIRECT_PROBE && | 2221 | static void ieee80211_sta_conn_mon_timer(unsigned long data) |
2301 | ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE && | 2222 | { |
2302 | ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE && | 2223 | struct ieee80211_sub_if_data *sdata = |
2303 | test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) { | 2224 | (struct ieee80211_sub_if_data *) data; |
2304 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | 2225 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
2305 | round_jiffies_relative(0)); | 2226 | struct ieee80211_local *local = sdata->local; |
2306 | return; | ||
2307 | } | ||
2308 | 2227 | ||
2309 | if (test_and_clear_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request)) { | 2228 | if (local->quiescing) |
2310 | if (ieee80211_sta_config_auth(sdata)) | ||
2311 | return; | ||
2312 | clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request); | ||
2313 | } else if (!test_and_clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request)) | ||
2314 | return; | 2229 | return; |
2315 | 2230 | ||
2316 | ieee80211_recalc_idle(local); | 2231 | ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); |
2317 | 2232 | } | |
2318 | switch (ifmgd->state) { | ||
2319 | case IEEE80211_STA_MLME_DISABLED: | ||
2320 | break; | ||
2321 | case IEEE80211_STA_MLME_DIRECT_PROBE: | ||
2322 | ieee80211_direct_probe(sdata); | ||
2323 | break; | ||
2324 | case IEEE80211_STA_MLME_AUTHENTICATE: | ||
2325 | ieee80211_authenticate(sdata); | ||
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 | } | ||
2337 | 2233 | ||
2338 | if (ieee80211_privacy_mismatch(sdata)) { | 2234 | static void ieee80211_sta_monitor_work(struct work_struct *work) |
2339 | printk(KERN_DEBUG "%s: privacy configuration mismatch and " | 2235 | { |
2340 | "mixed-cell disabled - disassociate\n", sdata->dev->name); | 2236 | struct ieee80211_sub_if_data *sdata = |
2237 | container_of(work, struct ieee80211_sub_if_data, | ||
2238 | u.mgd.monitor_work); | ||
2341 | 2239 | ||
2342 | ieee80211_set_disassoc(sdata, false, true, | 2240 | ieee80211_mgd_probe_ap(sdata, false); |
2343 | WLAN_REASON_UNSPECIFIED); | ||
2344 | } | ||
2345 | } | 2241 | } |
2346 | 2242 | ||
2347 | static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata) | 2243 | static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata) |
2348 | { | 2244 | { |
2349 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 2245 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
2350 | /* | 2246 | sdata->u.mgd.flags &= ~(IEEE80211_STA_BEACON_POLL | |
2351 | * Need to update last_beacon to avoid beacon loss | 2247 | IEEE80211_STA_CONNECTION_POLL); |
2352 | * test to trigger. | 2248 | |
2353 | */ | 2249 | /* let's probe the connection once */ |
2354 | sdata->u.mgd.last_beacon = jiffies; | 2250 | ieee80211_queue_work(&sdata->local->hw, |
2355 | 2251 | &sdata->u.mgd.monitor_work); | |
2356 | 2252 | /* and do all the other regular work too */ | |
2357 | queue_work(sdata->local->hw.workqueue, | 2253 | ieee80211_queue_work(&sdata->local->hw, |
2358 | &sdata->u.mgd.work); | 2254 | &sdata->u.mgd.work); |
2359 | } | 2255 | } |
2360 | } | 2256 | } |
@@ -2378,6 +2274,11 @@ void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata) | |||
2378 | cancel_work_sync(&ifmgd->chswitch_work); | 2274 | cancel_work_sync(&ifmgd->chswitch_work); |
2379 | if (del_timer_sync(&ifmgd->chswitch_timer)) | 2275 | if (del_timer_sync(&ifmgd->chswitch_timer)) |
2380 | set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running); | 2276 | set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running); |
2277 | |||
2278 | cancel_work_sync(&ifmgd->monitor_work); | ||
2279 | /* these will just be re-established on connection */ | ||
2280 | del_timer_sync(&ifmgd->conn_mon_timer); | ||
2281 | del_timer_sync(&ifmgd->bcn_mon_timer); | ||
2381 | } | 2282 | } |
2382 | 2283 | ||
2383 | void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) | 2284 | void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) |
@@ -2395,210 +2296,277 @@ void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) | |||
2395 | void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) | 2296 | void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) |
2396 | { | 2297 | { |
2397 | struct ieee80211_if_managed *ifmgd; | 2298 | struct ieee80211_if_managed *ifmgd; |
2398 | u32 hw_flags; | ||
2399 | 2299 | ||
2400 | ifmgd = &sdata->u.mgd; | 2300 | ifmgd = &sdata->u.mgd; |
2401 | INIT_WORK(&ifmgd->work, ieee80211_sta_work); | 2301 | INIT_WORK(&ifmgd->work, ieee80211_sta_work); |
2302 | INIT_WORK(&ifmgd->monitor_work, ieee80211_sta_monitor_work); | ||
2402 | INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work); | 2303 | INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work); |
2403 | INIT_WORK(&ifmgd->beacon_loss_work, ieee80211_beacon_loss_work); | 2304 | INIT_WORK(&ifmgd->beacon_loss_work, ieee80211_beacon_loss_work); |
2404 | setup_timer(&ifmgd->timer, ieee80211_sta_timer, | 2305 | setup_timer(&ifmgd->timer, ieee80211_sta_timer, |
2405 | (unsigned long) sdata); | 2306 | (unsigned long) sdata); |
2307 | setup_timer(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, | ||
2308 | (unsigned long) sdata); | ||
2309 | setup_timer(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, | ||
2310 | (unsigned long) sdata); | ||
2406 | setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, | 2311 | setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, |
2407 | (unsigned long) sdata); | 2312 | (unsigned long) sdata); |
2408 | skb_queue_head_init(&ifmgd->skb_queue); | 2313 | skb_queue_head_init(&ifmgd->skb_queue); |
2409 | 2314 | ||
2315 | INIT_LIST_HEAD(&ifmgd->work_list); | ||
2316 | |||
2410 | ifmgd->capab = WLAN_CAPABILITY_ESS; | 2317 | ifmgd->capab = WLAN_CAPABILITY_ESS; |
2411 | ifmgd->auth_algs = IEEE80211_AUTH_ALG_OPEN | | 2318 | 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) | 2319 | if (sdata->local->hw.queues >= 4) |
2417 | ifmgd->flags |= IEEE80211_STA_WMM_ENABLED; | 2320 | ifmgd->flags |= IEEE80211_STA_WMM_ENABLED; |
2418 | 2321 | ||
2419 | hw_flags = sdata->local->hw.flags; | 2322 | 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 | } | 2323 | } |
2426 | 2324 | ||
2427 | /* configuration hooks */ | 2325 | /* scan finished notification */ |
2428 | void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata) | 2326 | void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) |
2429 | { | 2327 | { |
2430 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 2328 | 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 | 2329 | ||
2453 | if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) || | 2330 | /* Restart STA timers */ |
2454 | ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE) | 2331 | rcu_read_lock(); |
2455 | set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request); | 2332 | list_for_each_entry_rcu(sdata, &local->interfaces, list) |
2456 | else if (ifmgd->flags & IEEE80211_STA_EXT_SME) | 2333 | ieee80211_restart_sta_timer(sdata); |
2457 | set_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request); | 2334 | rcu_read_unlock(); |
2458 | queue_work(local->hw.workqueue, &ifmgd->work); | ||
2459 | } | ||
2460 | } | 2335 | } |
2461 | 2336 | ||
2462 | int ieee80211_sta_commit(struct ieee80211_sub_if_data *sdata) | 2337 | int ieee80211_max_network_latency(struct notifier_block *nb, |
2338 | unsigned long data, void *dummy) | ||
2463 | { | 2339 | { |
2464 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 2340 | s32 latency_usec = (s32) data; |
2341 | struct ieee80211_local *local = | ||
2342 | container_of(nb, struct ieee80211_local, | ||
2343 | network_latency_notifier); | ||
2465 | 2344 | ||
2466 | if (ifmgd->ssid_len) | 2345 | mutex_lock(&local->iflist_mtx); |
2467 | ifmgd->flags |= IEEE80211_STA_SSID_SET; | 2346 | ieee80211_recalc_ps(local, latency_usec); |
2468 | else | 2347 | mutex_unlock(&local->iflist_mtx); |
2469 | ifmgd->flags &= ~IEEE80211_STA_SSID_SET; | ||
2470 | 2348 | ||
2471 | return 0; | 2349 | return 0; |
2472 | } | 2350 | } |
2473 | 2351 | ||
2474 | int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len) | 2352 | /* config hooks */ |
2353 | int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, | ||
2354 | struct cfg80211_auth_request *req) | ||
2475 | { | 2355 | { |
2476 | struct ieee80211_if_managed *ifmgd; | 2356 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
2357 | const u8 *ssid; | ||
2358 | struct ieee80211_mgd_work *wk; | ||
2359 | u16 auth_alg; | ||
2477 | 2360 | ||
2478 | if (len > IEEE80211_MAX_SSID_LEN) | 2361 | switch (req->auth_type) { |
2479 | return -EINVAL; | 2362 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
2363 | auth_alg = WLAN_AUTH_OPEN; | ||
2364 | break; | ||
2365 | case NL80211_AUTHTYPE_SHARED_KEY: | ||
2366 | auth_alg = WLAN_AUTH_SHARED_KEY; | ||
2367 | break; | ||
2368 | case NL80211_AUTHTYPE_FT: | ||
2369 | auth_alg = WLAN_AUTH_FT; | ||
2370 | break; | ||
2371 | case NL80211_AUTHTYPE_NETWORK_EAP: | ||
2372 | auth_alg = WLAN_AUTH_LEAP; | ||
2373 | break; | ||
2374 | default: | ||
2375 | return -EOPNOTSUPP; | ||
2376 | } | ||
2480 | 2377 | ||
2481 | ifmgd = &sdata->u.mgd; | 2378 | wk = kzalloc(sizeof(*wk) + req->ie_len, GFP_KERNEL); |
2379 | if (!wk) | ||
2380 | return -ENOMEM; | ||
2482 | 2381 | ||
2483 | if (ifmgd->ssid_len != len || memcmp(ifmgd->ssid, ssid, len) != 0) { | 2382 | 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 | 2383 | ||
2488 | /* | 2384 | if (req->ie && req->ie_len) { |
2489 | * Do not use reassociation if SSID is changed (different ESS). | 2385 | memcpy(wk->ie, req->ie, req->ie_len); |
2490 | */ | 2386 | 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 | } | 2387 | } |
2496 | 2388 | ||
2497 | return ieee80211_sta_commit(sdata); | 2389 | if (req->key && req->key_len) { |
2498 | } | 2390 | wk->key_len = req->key_len; |
2391 | wk->key_idx = req->key_idx; | ||
2392 | memcpy(wk->key, req->key, req->key_len); | ||
2393 | } | ||
2499 | 2394 | ||
2500 | int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len) | 2395 | ssid = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); |
2501 | { | 2396 | memcpy(wk->ssid, ssid + 2, ssid[1]); |
2502 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 2397 | wk->ssid_len = ssid[1]; |
2503 | memcpy(ssid, ifmgd->ssid, ifmgd->ssid_len); | 2398 | |
2504 | *len = ifmgd->ssid_len; | 2399 | wk->state = IEEE80211_MGD_STATE_PROBE; |
2400 | wk->auth_alg = auth_alg; | ||
2401 | wk->timeout = jiffies; /* run right away */ | ||
2402 | |||
2403 | /* | ||
2404 | * XXX: if still associated need to tell AP that we're going | ||
2405 | * to sleep and then change channel etc. | ||
2406 | */ | ||
2407 | sdata->local->oper_channel = req->bss->channel; | ||
2408 | ieee80211_hw_config(sdata->local, 0); | ||
2409 | |||
2410 | mutex_lock(&ifmgd->mtx); | ||
2411 | list_add(&wk->list, &sdata->u.mgd.work_list); | ||
2412 | mutex_unlock(&ifmgd->mtx); | ||
2413 | |||
2414 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.work); | ||
2505 | return 0; | 2415 | return 0; |
2506 | } | 2416 | } |
2507 | 2417 | ||
2508 | int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid) | 2418 | int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, |
2419 | struct cfg80211_assoc_request *req) | ||
2509 | { | 2420 | { |
2510 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 2421 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
2422 | struct ieee80211_mgd_work *wk, *found = NULL; | ||
2423 | int i, err; | ||
2511 | 2424 | ||
2512 | if (compare_ether_addr(bssid, ifmgd->bssid) != 0 && | 2425 | mutex_lock(&ifmgd->mtx); |
2513 | ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) | ||
2514 | ieee80211_set_disassoc(sdata, true, true, | ||
2515 | WLAN_REASON_DEAUTH_LEAVING); | ||
2516 | 2426 | ||
2517 | if (is_valid_ether_addr(bssid)) { | 2427 | list_for_each_entry(wk, &ifmgd->work_list, list) { |
2518 | memcpy(ifmgd->bssid, bssid, ETH_ALEN); | 2428 | if (&wk->bss->cbss == req->bss && |
2519 | ifmgd->flags |= IEEE80211_STA_BSSID_SET; | 2429 | wk->state == IEEE80211_MGD_STATE_IDLE) { |
2520 | } else { | 2430 | found = wk; |
2521 | memset(ifmgd->bssid, 0, ETH_ALEN); | 2431 | break; |
2522 | ifmgd->flags &= ~IEEE80211_STA_BSSID_SET; | 2432 | } |
2523 | } | 2433 | } |
2524 | 2434 | ||
2525 | return ieee80211_sta_commit(sdata); | 2435 | if (!found) { |
2526 | } | 2436 | err = -ENOLINK; |
2437 | goto out; | ||
2438 | } | ||
2527 | 2439 | ||
2528 | int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, | 2440 | list_del(&found->list); |
2529 | const char *ie, size_t len) | ||
2530 | { | ||
2531 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
2532 | 2441 | ||
2533 | if (len == 0 && ifmgd->extra_ie_len == 0) | 2442 | wk = krealloc(found, sizeof(*wk) + req->ie_len, GFP_KERNEL); |
2534 | return -EALREADY; | 2443 | if (!wk) { |
2444 | list_add(&found->list, &ifmgd->work_list); | ||
2445 | err = -ENOMEM; | ||
2446 | goto out; | ||
2447 | } | ||
2535 | 2448 | ||
2536 | if (len == ifmgd->extra_ie_len && ifmgd->extra_ie && | 2449 | list_add(&wk->list, &ifmgd->work_list); |
2537 | memcmp(ifmgd->extra_ie, ie, len) == 0) | ||
2538 | return -EALREADY; | ||
2539 | 2450 | ||
2540 | kfree(ifmgd->extra_ie); | 2451 | ifmgd->flags &= ~IEEE80211_STA_DISABLE_11N; |
2541 | if (len == 0) { | 2452 | |
2542 | ifmgd->extra_ie = NULL; | 2453 | for (i = 0; i < req->crypto.n_ciphers_pairwise; i++) |
2543 | ifmgd->extra_ie_len = 0; | 2454 | if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 || |
2544 | return 0; | 2455 | req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP || |
2545 | } | 2456 | req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) |
2546 | ifmgd->extra_ie = kmalloc(len, GFP_KERNEL); | 2457 | ifmgd->flags |= IEEE80211_STA_DISABLE_11N; |
2547 | if (!ifmgd->extra_ie) { | 2458 | |
2548 | ifmgd->extra_ie_len = 0; | 2459 | sdata->local->oper_channel = req->bss->channel; |
2549 | return -ENOMEM; | 2460 | ieee80211_hw_config(sdata->local, 0); |
2461 | |||
2462 | if (req->ie && req->ie_len) { | ||
2463 | memcpy(wk->ie, req->ie, req->ie_len); | ||
2464 | wk->ie_len = req->ie_len; | ||
2465 | } else | ||
2466 | wk->ie_len = 0; | ||
2467 | |||
2468 | if (req->prev_bssid) | ||
2469 | memcpy(wk->prev_bssid, req->prev_bssid, ETH_ALEN); | ||
2470 | |||
2471 | wk->state = IEEE80211_MGD_STATE_ASSOC; | ||
2472 | wk->tries = 0; | ||
2473 | wk->timeout = jiffies; /* run right away */ | ||
2474 | |||
2475 | if (req->use_mfp) { | ||
2476 | ifmgd->mfp = IEEE80211_MFP_REQUIRED; | ||
2477 | ifmgd->flags |= IEEE80211_STA_MFP_ENABLED; | ||
2478 | } else { | ||
2479 | ifmgd->mfp = IEEE80211_MFP_DISABLED; | ||
2480 | ifmgd->flags &= ~IEEE80211_STA_MFP_ENABLED; | ||
2550 | } | 2481 | } |
2551 | memcpy(ifmgd->extra_ie, ie, len); | ||
2552 | ifmgd->extra_ie_len = len; | ||
2553 | return 0; | ||
2554 | } | ||
2555 | 2482 | ||
2556 | int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason) | 2483 | if (req->crypto.control_port) |
2557 | { | 2484 | ifmgd->flags |= IEEE80211_STA_CONTROL_PORT; |
2558 | printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n", | 2485 | else |
2559 | sdata->dev->name, reason); | 2486 | ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT; |
2560 | 2487 | ||
2561 | ieee80211_set_disassoc(sdata, true, true, reason); | 2488 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.work); |
2562 | return 0; | 2489 | |
2490 | err = 0; | ||
2491 | |||
2492 | out: | ||
2493 | mutex_unlock(&ifmgd->mtx); | ||
2494 | return err; | ||
2563 | } | 2495 | } |
2564 | 2496 | ||
2565 | int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason) | 2497 | int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, |
2498 | struct cfg80211_deauth_request *req, | ||
2499 | void *cookie) | ||
2566 | { | 2500 | { |
2567 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 2501 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
2502 | struct ieee80211_mgd_work *wk; | ||
2503 | const u8 *bssid = NULL; | ||
2568 | 2504 | ||
2569 | printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n", | 2505 | printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n", |
2570 | sdata->dev->name, reason); | 2506 | sdata->dev->name, req->reason_code); |
2507 | |||
2508 | mutex_lock(&ifmgd->mtx); | ||
2509 | |||
2510 | if (ifmgd->associated && &ifmgd->associated->cbss == req->bss) { | ||
2511 | bssid = req->bss->bssid; | ||
2512 | ieee80211_set_disassoc(sdata, true); | ||
2513 | } else list_for_each_entry(wk, &ifmgd->work_list, list) { | ||
2514 | if (&wk->bss->cbss == req->bss) { | ||
2515 | bssid = req->bss->bssid; | ||
2516 | list_del(&wk->list); | ||
2517 | kfree(wk); | ||
2518 | break; | ||
2519 | } | ||
2520 | } | ||
2571 | 2521 | ||
2572 | if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED)) | 2522 | /* |
2523 | * cfg80211 should catch this ... but it's racy since | ||
2524 | * we can receive a deauth frame, process it, hand it | ||
2525 | * to cfg80211 while that's in a locked section already | ||
2526 | * trying to tell us that the user wants to disconnect. | ||
2527 | */ | ||
2528 | if (!bssid) { | ||
2529 | mutex_unlock(&ifmgd->mtx); | ||
2573 | return -ENOLINK; | 2530 | return -ENOLINK; |
2531 | } | ||
2532 | |||
2533 | mutex_unlock(&ifmgd->mtx); | ||
2534 | |||
2535 | ieee80211_send_deauth_disassoc(sdata, bssid, | ||
2536 | IEEE80211_STYPE_DEAUTH, req->reason_code, | ||
2537 | cookie); | ||
2574 | 2538 | ||
2575 | ieee80211_set_disassoc(sdata, false, true, reason); | ||
2576 | return 0; | 2539 | return 0; |
2577 | } | 2540 | } |
2578 | 2541 | ||
2579 | /* scan finished notification */ | 2542 | int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, |
2580 | void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) | 2543 | struct cfg80211_disassoc_request *req, |
2544 | void *cookie) | ||
2581 | { | 2545 | { |
2582 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | 2546 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
2583 | 2547 | ||
2584 | /* Restart STA timers */ | 2548 | printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n", |
2585 | rcu_read_lock(); | 2549 | 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 | 2550 | ||
2591 | int ieee80211_max_network_latency(struct notifier_block *nb, | 2551 | 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 | 2552 | ||
2599 | mutex_lock(&local->iflist_mtx); | 2553 | /* |
2600 | ieee80211_recalc_ps(local, latency_usec); | 2554 | * cfg80211 should catch this ... but it's racy since |
2601 | mutex_unlock(&local->iflist_mtx); | 2555 | * we can receive a disassoc frame, process it, hand it |
2556 | * to cfg80211 while that's in a locked section already | ||
2557 | * trying to tell us that the user wants to disconnect. | ||
2558 | */ | ||
2559 | if (&ifmgd->associated->cbss != req->bss) { | ||
2560 | mutex_unlock(&ifmgd->mtx); | ||
2561 | return -ENOLINK; | ||
2562 | } | ||
2563 | |||
2564 | ieee80211_set_disassoc(sdata, false); | ||
2565 | |||
2566 | mutex_unlock(&ifmgd->mtx); | ||
2602 | 2567 | ||
2568 | ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, | ||
2569 | IEEE80211_STYPE_DISASSOC, req->reason_code, | ||
2570 | cookie); | ||
2603 | return 0; | 2571 | return 0; |
2604 | } | 2572 | } |
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 5e3d476972f9..e535f1c988fe 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c | |||
@@ -26,7 +26,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
26 | /* make quiescing visible to timers everywhere */ | 26 | /* make quiescing visible to timers everywhere */ |
27 | mb(); | 27 | mb(); |
28 | 28 | ||
29 | flush_workqueue(local->hw.workqueue); | 29 | flush_workqueue(local->workqueue); |
30 | 30 | ||
31 | /* Don't try to run timers while suspended. */ | 31 | /* Don't try to run timers while suspended. */ |
32 | del_timer_sync(&local->sta_cleanup); | 32 | del_timer_sync(&local->sta_cleanup); |
@@ -96,6 +96,10 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
96 | if (!netif_running(sdata->dev)) | 96 | if (!netif_running(sdata->dev)) |
97 | continue; | 97 | continue; |
98 | 98 | ||
99 | /* disable beaconing */ | ||
100 | ieee80211_bss_info_change_notify(sdata, | ||
101 | BSS_CHANGED_BEACON_ENABLED); | ||
102 | |||
99 | conf.vif = &sdata->vif; | 103 | conf.vif = &sdata->vif; |
100 | conf.type = sdata->vif.type; | 104 | conf.type = sdata->vif.type; |
101 | conf.mac_addr = sdata->dev->dev_addr; | 105 | conf.mac_addr = sdata->dev->dev_addr; |
@@ -103,17 +107,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) | |||
103 | } | 107 | } |
104 | 108 | ||
105 | /* stop hardware - this must stop RX */ | 109 | /* stop hardware - this must stop RX */ |
106 | if (local->open_count) { | 110 | if (local->open_count) |
107 | ieee80211_led_radio(local, false); | 111 | ieee80211_stop_device(local); |
108 | drv_stop(local); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * flush again, in case driver queued work -- it | ||
113 | * shouldn't be doing (or cancel everything in the | ||
114 | * stop callback) that but better safe than sorry. | ||
115 | */ | ||
116 | flush_workqueue(local->hw.workqueue); | ||
117 | 112 | ||
118 | local->suspended = true; | 113 | local->suspended = true; |
119 | /* need suspended to be visible before quiescing is false */ | 114 | /* need suspended to be visible before quiescing is false */ |
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 | ||
201 | static 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 | |||
213 | bool 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 | } | ||
228 | EXPORT_SYMBOL(rate_control_send_low); | ||
229 | |||
201 | void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | 230 | void 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 | ||
73 | static inline bool | ||
74 | use_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 | |||
87 | static void | 73 | static void |
88 | minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) | 74 | minstrel_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_minstrel.h b/net/mac80211/rc80211_minstrel.h index 869fe0ef951d..38bf4168fc3a 100644 --- a/net/mac80211/rc80211_minstrel.h +++ b/net/mac80211/rc80211_minstrel.h | |||
@@ -33,7 +33,6 @@ struct minstrel_rate { | |||
33 | 33 | ||
34 | /* per-rate throughput */ | 34 | /* per-rate throughput */ |
35 | u32 cur_tp; | 35 | u32 cur_tp; |
36 | u32 throughput; | ||
37 | 36 | ||
38 | u64 succ_hist; | 37 | u64 succ_hist; |
39 | u64 att_hist; | 38 | u64 att_hist; |
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c index 98f480708050..a715d9454f64 100644 --- a/net/mac80211/rc80211_minstrel_debugfs.c +++ b/net/mac80211/rc80211_minstrel_debugfs.c | |||
@@ -83,7 +83,7 @@ minstrel_stats_open(struct inode *inode, struct file *file) | |||
83 | p += sprintf(p, "%3u%s", mr->bitrate / 2, | 83 | p += sprintf(p, "%3u%s", mr->bitrate / 2, |
84 | (mr->bitrate & 1 ? ".5" : " ")); | 84 | (mr->bitrate & 1 ? ".5" : " ")); |
85 | 85 | ||
86 | tp = ((mr->cur_tp * 96) / 18000) >> 10; | 86 | tp = mr->cur_tp / ((18000 << 10) / 96); |
87 | prob = mr->cur_prob / 18; | 87 | prob = mr->cur_prob / 18; |
88 | eprob = mr->probability / 18; | 88 | eprob = mr->probability / 18; |
89 | 89 | ||
@@ -139,7 +139,7 @@ minstrel_stats_release(struct inode *inode, struct file *file) | |||
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | static struct file_operations minstrel_stat_fops = { | 142 | static const struct file_operations minstrel_stat_fops = { |
143 | .owner = THIS_MODULE, | 143 | .owner = THIS_MODULE, |
144 | .open = minstrel_stats_open, | 144 | .open = minstrel_stats_open, |
145 | .read = minstrel_stats_read, | 145 | .read = minstrel_stats_read, |
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c index a0bef767ceb5..699d3ed869c4 100644 --- a/net/mac80211/rc80211_pid_algo.c +++ b/net/mac80211/rc80211_pid_algo.c | |||
@@ -169,19 +169,9 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
169 | * still a good measurement and copy it. */ | 169 | * still a good measurement and copy it. */ |
170 | if (unlikely(spinfo->tx_num_xmit == 0)) | 170 | if (unlikely(spinfo->tx_num_xmit == 0)) |
171 | pf = spinfo->last_pf; | 171 | pf = spinfo->last_pf; |
172 | else { | 172 | else |
173 | /* XXX: BAD HACK!!! */ | ||
174 | struct sta_info *si = container_of(sta, struct sta_info, sta); | ||
175 | |||
176 | pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit; | 173 | pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit; |
177 | 174 | ||
178 | if (ieee80211_vif_is_mesh(&si->sdata->vif) && pf == 100) | ||
179 | mesh_plink_broken(si); | ||
180 | pf <<= RC_PID_ARITH_SHIFT; | ||
181 | si->fail_avg = ((pf + (spinfo->last_pf << 3)) / 9) | ||
182 | >> RC_PID_ARITH_SHIFT; | ||
183 | } | ||
184 | |||
185 | spinfo->tx_num_xmit = 0; | 175 | spinfo->tx_num_xmit = 0; |
186 | spinfo->tx_num_failed = 0; | 176 | spinfo->tx_num_failed = 0; |
187 | 177 | ||
@@ -276,11 +266,9 @@ rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta, | |||
276 | { | 266 | { |
277 | struct sk_buff *skb = txrc->skb; | 267 | struct sk_buff *skb = txrc->skb; |
278 | struct ieee80211_supported_band *sband = txrc->sband; | 268 | 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); | 269 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
281 | struct rc_pid_sta_info *spinfo = priv_sta; | 270 | struct rc_pid_sta_info *spinfo = priv_sta; |
282 | int rateidx; | 271 | int rateidx; |
283 | u16 fc; | ||
284 | 272 | ||
285 | if (txrc->rts) | 273 | if (txrc->rts) |
286 | info->control.rates[0].count = | 274 | info->control.rates[0].count = |
@@ -290,16 +278,8 @@ rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta, | |||
290 | txrc->hw->conf.short_frame_max_tx_count; | 278 | txrc->hw->conf.short_frame_max_tx_count; |
291 | 279 | ||
292 | /* Send management frames and NO_ACK data using lowest rate. */ | 280 | /* Send management frames and NO_ACK data using lowest rate. */ |
293 | fc = le16_to_cpu(hdr->frame_control); | 281 | 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; | 282 | return; |
302 | } | ||
303 | 283 | ||
304 | rateidx = spinfo->txrate_idx; | 284 | rateidx = spinfo->txrate_idx; |
305 | 285 | ||
@@ -321,7 +301,6 @@ rate_control_pid_rate_init(void *priv, struct ieee80211_supported_band *sband, | |||
321 | struct rc_pid_sta_info *spinfo = priv_sta; | 301 | struct rc_pid_sta_info *spinfo = priv_sta; |
322 | struct rc_pid_info *pinfo = priv; | 302 | struct rc_pid_info *pinfo = priv; |
323 | struct rc_pid_rateinfo *rinfo = pinfo->rinfo; | 303 | struct rc_pid_rateinfo *rinfo = pinfo->rinfo; |
324 | struct sta_info *si; | ||
325 | int i, j, tmp; | 304 | int i, j, tmp; |
326 | bool s; | 305 | bool s; |
327 | 306 | ||
@@ -358,9 +337,6 @@ rate_control_pid_rate_init(void *priv, struct ieee80211_supported_band *sband, | |||
358 | } | 337 | } |
359 | 338 | ||
360 | spinfo->txrate_idx = rate_lowest_index(sband, sta); | 339 | spinfo->txrate_idx = rate_lowest_index(sband, sta); |
361 | /* HACK */ | ||
362 | si = container_of(sta, struct sta_info, sta); | ||
363 | si->fail_avg = 0; | ||
364 | } | 340 | } |
365 | 341 | ||
366 | static void *rate_control_pid_alloc(struct ieee80211_hw *hw, | 342 | static void *rate_control_pid_alloc(struct ieee80211_hw *hw, |
diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c index a08a9b530347..a59043fbb0ff 100644 --- a/net/mac80211/rc80211_pid_debugfs.c +++ b/net/mac80211/rc80211_pid_debugfs.c | |||
@@ -198,7 +198,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf, | |||
198 | 198 | ||
199 | #undef RC_PID_PRINT_BUF_SIZE | 199 | #undef RC_PID_PRINT_BUF_SIZE |
200 | 200 | ||
201 | static struct file_operations rc_pid_fop_events = { | 201 | static const struct file_operations rc_pid_fop_events = { |
202 | .owner = THIS_MODULE, | 202 | .owner = THIS_MODULE, |
203 | .read = rate_control_pid_events_read, | 203 | .read = rate_control_pid_events_read, |
204 | .poll = rate_control_pid_events_poll, | 204 | .poll = rate_control_pid_events_poll, |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 0936fc24942d..c01588f9d453 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -30,7 +30,6 @@ | |||
30 | static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | 30 | static 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 | ||
62 | static inline int should_drop_frame(struct ieee80211_rx_status *status, | 61 | static 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, | |||
111 | static void | 110 | static void |
112 | ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, | 111 | ieee80211_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 | */ |
221 | static struct sk_buff * | 220 | static struct sk_buff * |
222 | ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | 221 | ieee80211_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); |
@@ -420,13 +418,13 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx) | |||
420 | struct ieee80211_local *local = rx->local; | 418 | struct ieee80211_local *local = rx->local; |
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(test_bit(SCAN_HW_SCANNING, &local->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(test_bit(SCAN_SW_SCANNING, &local->scanning) && |
425 | (rx->flags & IEEE80211_RX_IN_SCAN))) { | ||
427 | /* drop all the other packets during a software scan anyway */ | 426 | /* drop all the other packets during a software scan anyway */ |
428 | if (ieee80211_scan_rx(rx->sdata, skb, rx->status) | 427 | if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED) |
429 | != RX_QUEUED) | ||
430 | dev_kfree_skb(skb); | 428 | dev_kfree_skb(skb); |
431 | return RX_QUEUED; | 429 | return RX_QUEUED; |
432 | } | 430 | } |
@@ -491,12 +489,21 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
491 | { | 489 | { |
492 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 490 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
493 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); | 491 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); |
492 | char *dev_addr = rx->dev->dev_addr; | ||
494 | 493 | ||
495 | if (ieee80211_is_data(hdr->frame_control)) { | 494 | if (ieee80211_is_data(hdr->frame_control)) { |
496 | if (!ieee80211_has_a4(hdr->frame_control)) | 495 | if (is_multicast_ether_addr(hdr->addr1)) { |
497 | return RX_DROP_MONITOR; | 496 | if (ieee80211_has_tods(hdr->frame_control) || |
498 | if (memcmp(hdr->addr4, rx->dev->dev_addr, ETH_ALEN) == 0) | 497 | !ieee80211_has_fromds(hdr->frame_control)) |
499 | return RX_DROP_MONITOR; | 498 | return RX_DROP_MONITOR; |
499 | if (memcmp(hdr->addr3, dev_addr, ETH_ALEN) == 0) | ||
500 | return RX_DROP_MONITOR; | ||
501 | } else { | ||
502 | if (!ieee80211_has_a4(hdr->frame_control)) | ||
503 | return RX_DROP_MONITOR; | ||
504 | if (memcmp(hdr->addr4, dev_addr, ETH_ALEN) == 0) | ||
505 | return RX_DROP_MONITOR; | ||
506 | } | ||
500 | } | 507 | } |
501 | 508 | ||
502 | /* If there is not an established peer link and this is not a peer link | 509 | /* If there is not an established peer link and this is not a peer link |
@@ -529,7 +536,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
529 | 536 | ||
530 | if (ieee80211_is_data(hdr->frame_control) && | 537 | if (ieee80211_is_data(hdr->frame_control) && |
531 | is_multicast_ether_addr(hdr->addr1) && | 538 | is_multicast_ether_addr(hdr->addr1) && |
532 | mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->sdata)) | 539 | mesh_rmc_check(hdr->addr3, msh_h_get(hdr, hdrlen), rx->sdata)) |
533 | return RX_DROP_MONITOR; | 540 | return RX_DROP_MONITOR; |
534 | #undef msh_h_get | 541 | #undef msh_h_get |
535 | 542 | ||
@@ -785,7 +792,7 @@ static void ap_sta_ps_start(struct sta_info *sta) | |||
785 | struct ieee80211_local *local = sdata->local; | 792 | struct ieee80211_local *local = sdata->local; |
786 | 793 | ||
787 | atomic_inc(&sdata->bss->num_sta_ps); | 794 | atomic_inc(&sdata->bss->num_sta_ps); |
788 | set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL); | 795 | set_sta_flags(sta, WLAN_STA_PS); |
789 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta); | 796 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta); |
790 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 797 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
791 | printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", | 798 | printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", |
@@ -801,7 +808,7 @@ static int ap_sta_ps_end(struct sta_info *sta) | |||
801 | 808 | ||
802 | atomic_dec(&sdata->bss->num_sta_ps); | 809 | atomic_dec(&sdata->bss->num_sta_ps); |
803 | 810 | ||
804 | clear_sta_flags(sta, WLAN_STA_PS | WLAN_STA_PSPOLL); | 811 | clear_sta_flags(sta, WLAN_STA_PS); |
805 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_AWAKE, &sta->sta); | 812 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_AWAKE, &sta->sta); |
806 | 813 | ||
807 | if (!skb_queue_empty(&sta->ps_tx_buf)) | 814 | if (!skb_queue_empty(&sta->ps_tx_buf)) |
@@ -836,28 +843,22 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
836 | if (!sta) | 843 | if (!sta) |
837 | return RX_CONTINUE; | 844 | return RX_CONTINUE; |
838 | 845 | ||
839 | /* Update last_rx only for IBSS packets which are for the current | 846 | /* |
840 | * BSSID to avoid keeping the current IBSS network alive in cases where | 847 | * Update last_rx only for IBSS packets which are for the current |
841 | * other STAs are using different BSSID. */ | 848 | * BSSID to avoid keeping the current IBSS network alive in cases |
849 | * where other STAs start using different BSSID. | ||
850 | */ | ||
842 | if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { | 851 | if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
843 | u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, | 852 | u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, |
844 | NL80211_IFTYPE_ADHOC); | 853 | NL80211_IFTYPE_ADHOC); |
845 | if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) | 854 | if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) |
846 | sta->last_rx = jiffies; | 855 | sta->last_rx = jiffies; |
847 | } else | 856 | } else if (!is_multicast_ether_addr(hdr->addr1)) { |
848 | if (!is_multicast_ether_addr(hdr->addr1) || | 857 | /* |
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 | 858 | * Mesh beacons will update last_rx when if they are found to |
854 | * match the current local configuration when processed. | 859 | * match the current local configuration when processed. |
855 | */ | 860 | */ |
856 | if (rx->sdata->vif.type == NL80211_IFTYPE_STATION && | 861 | 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 | } | 862 | } |
862 | 863 | ||
863 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | 864 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) |
@@ -1125,14 +1126,15 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
1125 | skb_queue_empty(&rx->sta->ps_tx_buf); | 1126 | skb_queue_empty(&rx->sta->ps_tx_buf); |
1126 | 1127 | ||
1127 | if (skb) { | 1128 | if (skb) { |
1129 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1128 | struct ieee80211_hdr *hdr = | 1130 | struct ieee80211_hdr *hdr = |
1129 | (struct ieee80211_hdr *) skb->data; | 1131 | (struct ieee80211_hdr *) skb->data; |
1130 | 1132 | ||
1131 | /* | 1133 | /* |
1132 | * Tell TX path to send one frame even though the STA may | 1134 | * Tell TX path to send this frame even though the STA may |
1133 | * still remain is PS mode after this frame exchange. | 1135 | * still remain is PS mode after this frame exchange. |
1134 | */ | 1136 | */ |
1135 | set_sta_flags(rx->sta, WLAN_STA_PSPOLL); | 1137 | info->flags |= IEEE80211_TX_CTL_PSPOLL_RESPONSE; |
1136 | 1138 | ||
1137 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1139 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
1138 | printk(KERN_DEBUG "STA %pM aid %d: PS Poll (entries after %d)\n", | 1140 | printk(KERN_DEBUG "STA %pM aid %d: PS Poll (entries after %d)\n", |
@@ -1147,7 +1149,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
1147 | else | 1149 | else |
1148 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); | 1150 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
1149 | 1151 | ||
1150 | dev_queue_xmit(skb); | 1152 | ieee80211_add_pending_skb(rx->local, skb); |
1151 | 1153 | ||
1152 | if (no_pending_pkts) | 1154 | if (no_pending_pkts) |
1153 | sta_info_clear_tim_bit(rx->sta); | 1155 | sta_info_clear_tim_bit(rx->sta); |
@@ -1487,10 +1489,13 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1487 | struct ieee80211s_hdr *mesh_hdr; | 1489 | struct ieee80211s_hdr *mesh_hdr; |
1488 | unsigned int hdrlen; | 1490 | unsigned int hdrlen; |
1489 | struct sk_buff *skb = rx->skb, *fwd_skb; | 1491 | struct sk_buff *skb = rx->skb, *fwd_skb; |
1492 | struct ieee80211_local *local = rx->local; | ||
1493 | struct ieee80211_sub_if_data *sdata; | ||
1490 | 1494 | ||
1491 | hdr = (struct ieee80211_hdr *) skb->data; | 1495 | hdr = (struct ieee80211_hdr *) skb->data; |
1492 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 1496 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
1493 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); | 1497 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); |
1498 | sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | ||
1494 | 1499 | ||
1495 | if (!ieee80211_is_data(hdr->frame_control)) | 1500 | if (!ieee80211_is_data(hdr->frame_control)) |
1496 | return RX_CONTINUE; | 1501 | return RX_CONTINUE; |
@@ -1499,11 +1504,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1499 | /* illegal frame */ | 1504 | /* illegal frame */ |
1500 | return RX_DROP_MONITOR; | 1505 | return RX_DROP_MONITOR; |
1501 | 1506 | ||
1502 | if (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6){ | 1507 | if (!is_multicast_ether_addr(hdr->addr1) && |
1503 | struct ieee80211_sub_if_data *sdata; | 1508 | (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6)) { |
1504 | struct mesh_path *mppath; | 1509 | struct mesh_path *mppath; |
1505 | 1510 | ||
1506 | sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | ||
1507 | rcu_read_lock(); | 1511 | rcu_read_lock(); |
1508 | mppath = mpp_path_lookup(mesh_hdr->eaddr2, sdata); | 1512 | mppath = mpp_path_lookup(mesh_hdr->eaddr2, sdata); |
1509 | if (!mppath) { | 1513 | if (!mppath) { |
@@ -1518,7 +1522,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1518 | rcu_read_unlock(); | 1522 | rcu_read_unlock(); |
1519 | } | 1523 | } |
1520 | 1524 | ||
1521 | if (compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) | 1525 | /* Frame has reached destination. Don't forward */ |
1526 | if (!is_multicast_ether_addr(hdr->addr1) && | ||
1527 | compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) | ||
1522 | return RX_CONTINUE; | 1528 | return RX_CONTINUE; |
1523 | 1529 | ||
1524 | mesh_hdr->ttl--; | 1530 | mesh_hdr->ttl--; |
@@ -1529,6 +1535,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1529 | dropped_frames_ttl); | 1535 | dropped_frames_ttl); |
1530 | else { | 1536 | else { |
1531 | struct ieee80211_hdr *fwd_hdr; | 1537 | struct ieee80211_hdr *fwd_hdr; |
1538 | struct ieee80211_tx_info *info; | ||
1539 | |||
1532 | fwd_skb = skb_copy(skb, GFP_ATOMIC); | 1540 | fwd_skb = skb_copy(skb, GFP_ATOMIC); |
1533 | 1541 | ||
1534 | if (!fwd_skb && net_ratelimit()) | 1542 | if (!fwd_skb && net_ratelimit()) |
@@ -1536,19 +1544,40 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1536 | rx->dev->name); | 1544 | rx->dev->name); |
1537 | 1545 | ||
1538 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; | 1546 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; |
1539 | /* | ||
1540 | * Save TA to addr1 to send TA a path error if a | ||
1541 | * suitable next hop is not found | ||
1542 | */ | ||
1543 | memcpy(fwd_hdr->addr1, fwd_hdr->addr2, ETH_ALEN); | ||
1544 | memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN); | 1547 | memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN); |
1545 | fwd_skb->dev = rx->local->mdev; | 1548 | info = IEEE80211_SKB_CB(fwd_skb); |
1546 | fwd_skb->iif = rx->dev->ifindex; | 1549 | memset(info, 0, sizeof(*info)); |
1547 | dev_queue_xmit(fwd_skb); | 1550 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
1551 | info->control.vif = &rx->sdata->vif; | ||
1552 | ieee80211_select_queue(local, fwd_skb); | ||
1553 | if (is_multicast_ether_addr(fwd_hdr->addr1)) | ||
1554 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, | ||
1555 | fwded_mcast); | ||
1556 | else { | ||
1557 | int err; | ||
1558 | /* | ||
1559 | * Save TA to addr1 to send TA a path error if a | ||
1560 | * suitable next hop is not found | ||
1561 | */ | ||
1562 | memcpy(fwd_hdr->addr1, fwd_hdr->addr2, | ||
1563 | ETH_ALEN); | ||
1564 | err = mesh_nexthop_lookup(fwd_skb, sdata); | ||
1565 | /* Failed to immediately resolve next hop: | ||
1566 | * fwded frame was dropped or will be added | ||
1567 | * later to the pending skb queue. */ | ||
1568 | if (err) | ||
1569 | return RX_DROP_MONITOR; | ||
1570 | |||
1571 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, | ||
1572 | fwded_unicast); | ||
1573 | } | ||
1574 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, | ||
1575 | fwded_frames); | ||
1576 | ieee80211_add_pending_skb(local, fwd_skb); | ||
1548 | } | 1577 | } |
1549 | } | 1578 | } |
1550 | 1579 | ||
1551 | if (is_multicast_ether_addr(hdr->addr3) || | 1580 | if (is_multicast_ether_addr(hdr->addr1) || |
1552 | rx->dev->flags & IFF_PROMISC) | 1581 | rx->dev->flags & IFF_PROMISC) |
1553 | return RX_CONTINUE; | 1582 | return RX_CONTINUE; |
1554 | else | 1583 | else |
@@ -1620,7 +1649,7 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) | |||
1620 | /* manage reordering buffer according to requested */ | 1649 | /* manage reordering buffer according to requested */ |
1621 | /* sequence number */ | 1650 | /* sequence number */ |
1622 | rcu_read_lock(); | 1651 | rcu_read_lock(); |
1623 | ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, NULL, | 1652 | ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, |
1624 | start_seq_num, 1); | 1653 | start_seq_num, 1); |
1625 | rcu_read_unlock(); | 1654 | rcu_read_unlock(); |
1626 | return RX_DROP_UNUSABLE; | 1655 | return RX_DROP_UNUSABLE; |
@@ -1644,12 +1673,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, | |||
1644 | 1673 | ||
1645 | if (compare_ether_addr(mgmt->sa, sdata->u.mgd.bssid) != 0 || | 1674 | if (compare_ether_addr(mgmt->sa, sdata->u.mgd.bssid) != 0 || |
1646 | compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid) != 0) { | 1675 | compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid) != 0) { |
1647 | /* Not from the current AP. */ | 1676 | /* 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; | 1677 | return; |
1654 | } | 1678 | } |
1655 | 1679 | ||
@@ -1686,7 +1710,6 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
1686 | struct ieee80211_local *local = rx->local; | 1710 | struct ieee80211_local *local = rx->local; |
1687 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | 1711 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); |
1688 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | 1712 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; |
1689 | struct ieee80211_bss *bss; | ||
1690 | int len = rx->skb->len; | 1713 | int len = rx->skb->len; |
1691 | 1714 | ||
1692 | if (!ieee80211_is_action(mgmt->frame_control)) | 1715 | if (!ieee80211_is_action(mgmt->frame_control)) |
@@ -1764,17 +1787,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
1764 | if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN)) | 1787 | if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN)) |
1765 | return RX_DROP_MONITOR; | 1788 | return RX_DROP_MONITOR; |
1766 | 1789 | ||
1767 | bss = ieee80211_rx_bss_get(local, sdata->u.mgd.bssid, | 1790 | 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 | } | 1791 | } |
1779 | break; | 1792 | break; |
1780 | case WLAN_CATEGORY_SA_QUERY: | 1793 | case WLAN_CATEGORY_SA_QUERY: |
@@ -1817,19 +1830,18 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | |||
1817 | return RX_DROP_MONITOR; | 1830 | return RX_DROP_MONITOR; |
1818 | 1831 | ||
1819 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 1832 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
1820 | return ieee80211_mesh_rx_mgmt(sdata, rx->skb, rx->status); | 1833 | return ieee80211_mesh_rx_mgmt(sdata, rx->skb); |
1821 | 1834 | ||
1822 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | 1835 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) |
1823 | return ieee80211_ibss_rx_mgmt(sdata, rx->skb, rx->status); | 1836 | return ieee80211_ibss_rx_mgmt(sdata, rx->skb); |
1824 | 1837 | ||
1825 | if (sdata->vif.type == NL80211_IFTYPE_STATION) | 1838 | if (sdata->vif.type == NL80211_IFTYPE_STATION) |
1826 | return ieee80211_sta_rx_mgmt(sdata, rx->skb, rx->status); | 1839 | return ieee80211_sta_rx_mgmt(sdata, rx->skb); |
1827 | 1840 | ||
1828 | return RX_DROP_MONITOR; | 1841 | return RX_DROP_MONITOR; |
1829 | } | 1842 | } |
1830 | 1843 | ||
1831 | static void ieee80211_rx_michael_mic_report(struct net_device *dev, | 1844 | static void ieee80211_rx_michael_mic_report(struct ieee80211_hdr *hdr, |
1832 | struct ieee80211_hdr *hdr, | ||
1833 | struct ieee80211_rx_data *rx) | 1845 | struct ieee80211_rx_data *rx) |
1834 | { | 1846 | { |
1835 | int keyidx; | 1847 | int keyidx; |
@@ -1866,7 +1878,8 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev, | |||
1866 | !ieee80211_is_auth(hdr->frame_control)) | 1878 | !ieee80211_is_auth(hdr->frame_control)) |
1867 | goto ignore; | 1879 | goto ignore; |
1868 | 1880 | ||
1869 | mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL); | 1881 | mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL, |
1882 | GFP_ATOMIC); | ||
1870 | ignore: | 1883 | ignore: |
1871 | dev_kfree_skb(rx->skb); | 1884 | dev_kfree_skb(rx->skb); |
1872 | rx->skb = NULL; | 1885 | rx->skb = NULL; |
@@ -2028,13 +2041,8 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2028 | case NL80211_IFTYPE_STATION: | 2041 | case NL80211_IFTYPE_STATION: |
2029 | if (!bssid) | 2042 | if (!bssid) |
2030 | return 0; | 2043 | return 0; |
2031 | if (!ieee80211_bssid_match(bssid, sdata->u.mgd.bssid)) { | 2044 | if (!multicast && |
2032 | if (!(rx->flags & IEEE80211_RX_IN_SCAN)) | 2045 | 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)) | 2046 | if (!(sdata->dev->flags & IFF_PROMISC)) |
2039 | return 0; | 2047 | return 0; |
2040 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2048 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
@@ -2114,9 +2122,9 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2114 | */ | 2122 | */ |
2115 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | 2123 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, |
2116 | struct sk_buff *skb, | 2124 | struct sk_buff *skb, |
2117 | struct ieee80211_rx_status *status, | ||
2118 | struct ieee80211_rate *rate) | 2125 | struct ieee80211_rate *rate) |
2119 | { | 2126 | { |
2127 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | ||
2120 | struct ieee80211_local *local = hw_to_local(hw); | 2128 | struct ieee80211_local *local = hw_to_local(hw); |
2121 | struct ieee80211_sub_if_data *sdata; | 2129 | struct ieee80211_sub_if_data *sdata; |
2122 | struct ieee80211_hdr *hdr; | 2130 | struct ieee80211_hdr *hdr; |
@@ -2143,11 +2151,12 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2143 | } | 2151 | } |
2144 | 2152 | ||
2145 | if ((status->flag & RX_FLAG_MMIC_ERROR)) { | 2153 | if ((status->flag & RX_FLAG_MMIC_ERROR)) { |
2146 | ieee80211_rx_michael_mic_report(local->mdev, hdr, &rx); | 2154 | ieee80211_rx_michael_mic_report(hdr, &rx); |
2147 | return; | 2155 | return; |
2148 | } | 2156 | } |
2149 | 2157 | ||
2150 | if (unlikely(local->sw_scanning || local->hw_scanning)) | 2158 | if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) || |
2159 | test_bit(SCAN_OFF_CHANNEL, &local->scanning))) | ||
2151 | rx.flags |= IEEE80211_RX_IN_SCAN; | 2160 | rx.flags |= IEEE80211_RX_IN_SCAN; |
2152 | 2161 | ||
2153 | ieee80211_parse_qos(&rx); | 2162 | ieee80211_parse_qos(&rx); |
@@ -2227,20 +2236,21 @@ static void ieee80211_release_reorder_frame(struct ieee80211_hw *hw, | |||
2227 | { | 2236 | { |
2228 | struct ieee80211_supported_band *sband; | 2237 | struct ieee80211_supported_band *sband; |
2229 | struct ieee80211_rate *rate; | 2238 | struct ieee80211_rate *rate; |
2230 | struct ieee80211_rx_status status; | 2239 | struct sk_buff *skb = tid_agg_rx->reorder_buf[index]; |
2240 | struct ieee80211_rx_status *status; | ||
2231 | 2241 | ||
2232 | if (!tid_agg_rx->reorder_buf[index]) | 2242 | if (!skb) |
2233 | goto no_frame; | 2243 | goto no_frame; |
2234 | 2244 | ||
2245 | status = IEEE80211_SKB_RXCB(skb); | ||
2246 | |||
2235 | /* release the reordered frames to stack */ | 2247 | /* release the reordered frames to stack */ |
2236 | memcpy(&status, tid_agg_rx->reorder_buf[index]->cb, sizeof(status)); | 2248 | sband = hw->wiphy->bands[status->band]; |
2237 | sband = hw->wiphy->bands[status.band]; | 2249 | if (status->flag & RX_FLAG_HT) |
2238 | if (status.flag & RX_FLAG_HT) | ||
2239 | rate = sband->bitrates; /* TODO: HT rates */ | 2250 | rate = sband->bitrates; /* TODO: HT rates */ |
2240 | else | 2251 | else |
2241 | rate = &sband->bitrates[status.rate_idx]; | 2252 | rate = &sband->bitrates[status->rate_idx]; |
2242 | __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], | 2253 | __ieee80211_rx_handle_packet(hw, skb, rate); |
2243 | &status, rate); | ||
2244 | tid_agg_rx->stored_mpdu_num--; | 2254 | tid_agg_rx->stored_mpdu_num--; |
2245 | tid_agg_rx->reorder_buf[index] = NULL; | 2255 | tid_agg_rx->reorder_buf[index] = NULL; |
2246 | 2256 | ||
@@ -2265,7 +2275,6 @@ no_frame: | |||
2265 | static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | 2275 | static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, |
2266 | struct tid_ampdu_rx *tid_agg_rx, | 2276 | struct tid_ampdu_rx *tid_agg_rx, |
2267 | struct sk_buff *skb, | 2277 | struct sk_buff *skb, |
2268 | struct ieee80211_rx_status *rxstatus, | ||
2269 | u16 mpdu_seq_num, | 2278 | u16 mpdu_seq_num, |
2270 | int bar_req) | 2279 | int bar_req) |
2271 | { | 2280 | { |
@@ -2324,8 +2333,6 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2324 | /* put the frame in the reordering buffer */ | 2333 | /* put the frame in the reordering buffer */ |
2325 | tid_agg_rx->reorder_buf[index] = skb; | 2334 | tid_agg_rx->reorder_buf[index] = skb; |
2326 | tid_agg_rx->reorder_time[index] = jiffies; | 2335 | 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++; | 2336 | tid_agg_rx->stored_mpdu_num++; |
2330 | /* release the buffer until next missing frame */ | 2337 | /* release the buffer until next missing frame */ |
2331 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) | 2338 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) |
@@ -2374,8 +2381,7 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
2374 | } | 2381 | } |
2375 | 2382 | ||
2376 | static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, | 2383 | static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, |
2377 | struct sk_buff *skb, | 2384 | struct sk_buff *skb) |
2378 | struct ieee80211_rx_status *status) | ||
2379 | { | 2385 | { |
2380 | struct ieee80211_hw *hw = &local->hw; | 2386 | struct ieee80211_hw *hw = &local->hw; |
2381 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 2387 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
@@ -2424,7 +2430,7 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, | |||
2424 | 2430 | ||
2425 | /* according to mpdu sequence number deal with reordering buffer */ | 2431 | /* according to mpdu sequence number deal with reordering buffer */ |
2426 | mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; | 2432 | mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; |
2427 | ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb, status, | 2433 | ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb, |
2428 | mpdu_seq_num, 0); | 2434 | mpdu_seq_num, 0); |
2429 | end_reorder: | 2435 | end_reorder: |
2430 | return ret; | 2436 | return ret; |
@@ -2434,24 +2440,20 @@ 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 | 2440 | * 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. | 2441 | * 802.11 MPDU is received from the hardware. |
2436 | */ | 2442 | */ |
2437 | void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | 2443 | void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) |
2438 | struct ieee80211_rx_status *status) | ||
2439 | { | 2444 | { |
2440 | struct ieee80211_local *local = hw_to_local(hw); | 2445 | struct ieee80211_local *local = hw_to_local(hw); |
2441 | struct ieee80211_rate *rate = NULL; | 2446 | struct ieee80211_rate *rate = NULL; |
2442 | struct ieee80211_supported_band *sband; | 2447 | struct ieee80211_supported_band *sband; |
2448 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | ||
2443 | 2449 | ||
2444 | if (status->band < 0 || | 2450 | if (WARN_ON(status->band < 0 || |
2445 | status->band >= IEEE80211_NUM_BANDS) { | 2451 | status->band >= IEEE80211_NUM_BANDS)) |
2446 | WARN_ON(1); | 2452 | goto drop; |
2447 | return; | ||
2448 | } | ||
2449 | 2453 | ||
2450 | sband = local->hw.wiphy->bands[status->band]; | 2454 | sband = local->hw.wiphy->bands[status->band]; |
2451 | if (!sband) { | 2455 | if (WARN_ON(!sband)) |
2452 | WARN_ON(1); | 2456 | goto drop; |
2453 | return; | ||
2454 | } | ||
2455 | 2457 | ||
2456 | /* | 2458 | /* |
2457 | * If we're suspending, it is possible although not too likely | 2459 | * If we're suspending, it is possible although not too likely |
@@ -2460,16 +2462,21 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2460 | * that might, for example, cause stations to be added or other | 2462 | * that might, for example, cause stations to be added or other |
2461 | * driver callbacks be invoked. | 2463 | * driver callbacks be invoked. |
2462 | */ | 2464 | */ |
2463 | if (unlikely(local->quiescing || local->suspended)) { | 2465 | if (unlikely(local->quiescing || local->suspended)) |
2464 | kfree_skb(skb); | 2466 | goto drop; |
2465 | return; | 2467 | |
2466 | } | 2468 | /* |
2469 | * The same happens when we're not even started, | ||
2470 | * but that's worth a warning. | ||
2471 | */ | ||
2472 | if (WARN_ON(!local->started)) | ||
2473 | goto drop; | ||
2467 | 2474 | ||
2468 | if (status->flag & RX_FLAG_HT) { | 2475 | if (status->flag & RX_FLAG_HT) { |
2469 | /* rate_idx is MCS index */ | 2476 | /* rate_idx is MCS index */ |
2470 | if (WARN_ON(status->rate_idx < 0 || | 2477 | if (WARN_ON(status->rate_idx < 0 || |
2471 | status->rate_idx >= 76)) | 2478 | status->rate_idx >= 76)) |
2472 | return; | 2479 | goto drop; |
2473 | /* HT rates are not in the table - use the highest legacy rate | 2480 | /* HT rates are not in the table - use the highest legacy rate |
2474 | * for now since other parts of mac80211 may not yet be fully | 2481 | * for now since other parts of mac80211 may not yet be fully |
2475 | * MCS aware. */ | 2482 | * MCS aware. */ |
@@ -2477,7 +2484,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2477 | } else { | 2484 | } else { |
2478 | if (WARN_ON(status->rate_idx < 0 || | 2485 | if (WARN_ON(status->rate_idx < 0 || |
2479 | status->rate_idx >= sband->n_bitrates)) | 2486 | status->rate_idx >= sband->n_bitrates)) |
2480 | return; | 2487 | goto drop; |
2481 | rate = &sband->bitrates[status->rate_idx]; | 2488 | rate = &sband->bitrates[status->rate_idx]; |
2482 | } | 2489 | } |
2483 | 2490 | ||
@@ -2494,7 +2501,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2494 | * if it was previously present. | 2501 | * if it was previously present. |
2495 | * Also, frames with less than 16 bytes are dropped. | 2502 | * Also, frames with less than 16 bytes are dropped. |
2496 | */ | 2503 | */ |
2497 | skb = ieee80211_rx_monitor(local, skb, status, rate); | 2504 | skb = ieee80211_rx_monitor(local, skb, rate); |
2498 | if (!skb) { | 2505 | if (!skb) { |
2499 | rcu_read_unlock(); | 2506 | rcu_read_unlock(); |
2500 | return; | 2507 | return; |
@@ -2512,25 +2519,25 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2512 | * frames from other than operational channel), but that should not | 2519 | * frames from other than operational channel), but that should not |
2513 | * happen in normal networks. | 2520 | * happen in normal networks. |
2514 | */ | 2521 | */ |
2515 | if (!ieee80211_rx_reorder_ampdu(local, skb, status)) | 2522 | if (!ieee80211_rx_reorder_ampdu(local, skb)) |
2516 | __ieee80211_rx_handle_packet(hw, skb, status, rate); | 2523 | __ieee80211_rx_handle_packet(hw, skb, rate); |
2517 | 2524 | ||
2518 | rcu_read_unlock(); | 2525 | rcu_read_unlock(); |
2526 | |||
2527 | return; | ||
2528 | drop: | ||
2529 | kfree_skb(skb); | ||
2519 | } | 2530 | } |
2520 | EXPORT_SYMBOL(__ieee80211_rx); | 2531 | EXPORT_SYMBOL(ieee80211_rx); |
2521 | 2532 | ||
2522 | /* This is a version of the rx handler that can be called from hard irq | 2533 | /* 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 */ | 2534 | * context. Post the skb on the queue and schedule the tasklet */ |
2524 | void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb, | 2535 | void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb) |
2525 | struct ieee80211_rx_status *status) | ||
2526 | { | 2536 | { |
2527 | struct ieee80211_local *local = hw_to_local(hw); | 2537 | struct ieee80211_local *local = hw_to_local(hw); |
2528 | 2538 | ||
2529 | BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb)); | 2539 | BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb)); |
2530 | 2540 | ||
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; | 2541 | skb->pkt_type = IEEE80211_RX_MSG; |
2535 | skb_queue_tail(&local->skb_queue, skb); | 2542 | skb_queue_tail(&local->skb_queue, skb); |
2536 | tasklet_schedule(&local->tasklet); | 2543 | tasklet_schedule(&local->tasklet); |
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 2a8d09ad17ff..039901109fa1 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/if_arp.h> | 18 | #include <linux/if_arp.h> |
19 | #include <linux/rtnetlink.h> | 19 | #include <linux/rtnetlink.h> |
20 | #include <net/mac80211.h> | 20 | #include <net/mac80211.h> |
21 | #include <net/iw_handler.h> | ||
22 | 21 | ||
23 | #include "ieee80211_i.h" | 22 | #include "ieee80211_i.h" |
24 | #include "driver-ops.h" | 23 | #include "driver-ops.h" |
@@ -26,7 +25,7 @@ | |||
26 | 25 | ||
27 | #define IEEE80211_PROBE_DELAY (HZ / 33) | 26 | #define IEEE80211_PROBE_DELAY (HZ / 33) |
28 | #define IEEE80211_CHANNEL_TIME (HZ / 33) | 27 | #define IEEE80211_CHANNEL_TIME (HZ / 33) |
29 | #define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 5) | 28 | #define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 8) |
30 | 29 | ||
31 | struct ieee80211_bss * | 30 | struct ieee80211_bss * |
32 | ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, | 31 | ieee80211_rx_bss_get(struct ieee80211_local *local, u8 *bssid, int freq, |
@@ -121,23 +120,10 @@ ieee80211_bss_info_update(struct ieee80211_local *local, | |||
121 | return bss; | 120 | return bss; |
122 | } | 121 | } |
123 | 122 | ||
124 | void 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 | |||
137 | ieee80211_rx_result | 123 | ieee80211_rx_result |
138 | ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | 124 | ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) |
139 | struct ieee80211_rx_status *rx_status) | ||
140 | { | 125 | { |
126 | struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); | ||
141 | struct ieee80211_mgmt *mgmt; | 127 | struct ieee80211_mgmt *mgmt; |
142 | struct ieee80211_bss *bss; | 128 | struct ieee80211_bss *bss; |
143 | u8 *elements; | 129 | u8 *elements; |
@@ -278,7 +264,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
278 | 264 | ||
279 | mutex_lock(&local->scan_mtx); | 265 | mutex_lock(&local->scan_mtx); |
280 | 266 | ||
281 | if (WARN_ON(!local->hw_scanning && !local->sw_scanning)) { | 267 | if (WARN_ON(!local->scanning)) { |
282 | mutex_unlock(&local->scan_mtx); | 268 | mutex_unlock(&local->scan_mtx); |
283 | return; | 269 | return; |
284 | } | 270 | } |
@@ -288,16 +274,16 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
288 | return; | 274 | return; |
289 | } | 275 | } |
290 | 276 | ||
291 | if (local->hw_scanning) | 277 | if (test_bit(SCAN_HW_SCANNING, &local->scanning)) |
292 | ieee80211_restore_scan_ies(local); | 278 | ieee80211_restore_scan_ies(local); |
293 | 279 | ||
294 | if (local->scan_req != &local->int_scan_req) | 280 | if (local->scan_req != local->int_scan_req) |
295 | cfg80211_scan_done(local->scan_req, aborted); | 281 | cfg80211_scan_done(local->scan_req, aborted); |
296 | local->scan_req = NULL; | 282 | local->scan_req = NULL; |
283 | local->scan_sdata = NULL; | ||
297 | 284 | ||
298 | was_hw_scan = local->hw_scanning; | 285 | was_hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning); |
299 | local->hw_scanning = false; | 286 | local->scanning = 0; |
300 | local->sw_scanning = false; | ||
301 | local->scan_channel = NULL; | 287 | local->scan_channel = NULL; |
302 | 288 | ||
303 | /* we only have to protect scan_req and hw/sw scan */ | 289 | /* we only have to protect scan_req and hw/sw scan */ |
@@ -307,16 +293,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
307 | if (was_hw_scan) | 293 | if (was_hw_scan) |
308 | goto done; | 294 | goto done; |
309 | 295 | ||
310 | netif_tx_lock_bh(local->mdev); | 296 | ieee80211_configure_filter(local); |
311 | netif_addr_lock(local->mdev); | ||
312 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; | ||
313 | drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC, | ||
314 | &local->filter_flags, | ||
315 | local->mdev->mc_count, | ||
316 | local->mdev->mc_list); | ||
317 | |||
318 | netif_addr_unlock(local->mdev); | ||
319 | netif_tx_unlock_bh(local->mdev); | ||
320 | 297 | ||
321 | drv_sw_scan_complete(local); | 298 | drv_sw_scan_complete(local); |
322 | 299 | ||
@@ -327,7 +304,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
327 | 304 | ||
328 | /* Tell AP we're back */ | 305 | /* Tell AP we're back */ |
329 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 306 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
330 | if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { | 307 | if (sdata->u.mgd.associated) { |
331 | ieee80211_scan_ps_disable(sdata); | 308 | ieee80211_scan_ps_disable(sdata); |
332 | netif_tx_wake_all_queues(sdata->dev); | 309 | netif_tx_wake_all_queues(sdata->dev); |
333 | } | 310 | } |
@@ -382,30 +359,24 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) | |||
382 | ieee80211_bss_info_change_notify( | 359 | ieee80211_bss_info_change_notify( |
383 | sdata, BSS_CHANGED_BEACON_ENABLED); | 360 | sdata, BSS_CHANGED_BEACON_ENABLED); |
384 | 361 | ||
385 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 362 | /* |
386 | if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { | 363 | * only handle non-STA interfaces here, STA interfaces |
387 | netif_tx_stop_all_queues(sdata->dev); | 364 | * are handled in the scan state machine |
388 | ieee80211_scan_ps_enable(sdata); | 365 | */ |
389 | } | 366 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
390 | } else | ||
391 | netif_tx_stop_all_queues(sdata->dev); | 367 | netif_tx_stop_all_queues(sdata->dev); |
392 | } | 368 | } |
393 | mutex_unlock(&local->iflist_mtx); | 369 | mutex_unlock(&local->iflist_mtx); |
394 | 370 | ||
395 | local->scan_state = SCAN_SET_CHANNEL; | 371 | local->next_scan_state = SCAN_DECISION; |
396 | local->scan_channel_idx = 0; | 372 | local->scan_channel_idx = 0; |
397 | 373 | ||
398 | netif_addr_lock_bh(local->mdev); | 374 | ieee80211_configure_filter(local); |
399 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; | ||
400 | drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC, | ||
401 | &local->filter_flags, | ||
402 | local->mdev->mc_count, | ||
403 | local->mdev->mc_list); | ||
404 | netif_addr_unlock_bh(local->mdev); | ||
405 | 375 | ||
406 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ | 376 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ |
407 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | 377 | ieee80211_queue_delayed_work(&local->hw, |
408 | IEEE80211_CHANNEL_TIME); | 378 | &local->scan_work, |
379 | IEEE80211_CHANNEL_TIME); | ||
409 | 380 | ||
410 | return 0; | 381 | return 0; |
411 | } | 382 | } |
@@ -441,20 +412,18 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
441 | local->scan_req = req; | 412 | local->scan_req = req; |
442 | local->scan_sdata = sdata; | 413 | local->scan_sdata = sdata; |
443 | 414 | ||
444 | if (req != &local->int_scan_req && | 415 | if (req != local->int_scan_req && |
445 | sdata->vif.type == NL80211_IFTYPE_STATION && | 416 | sdata->vif.type == NL80211_IFTYPE_STATION && |
446 | (ifmgd->state == IEEE80211_STA_MLME_DIRECT_PROBE || | 417 | !list_empty(&ifmgd->work_list)) { |
447 | ifmgd->state == IEEE80211_STA_MLME_AUTHENTICATE || | 418 | /* 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); | 419 | set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); |
451 | return 0; | 420 | return 0; |
452 | } | 421 | } |
453 | 422 | ||
454 | if (local->ops->hw_scan) | 423 | if (local->ops->hw_scan) |
455 | local->hw_scanning = true; | 424 | __set_bit(SCAN_HW_SCANNING, &local->scanning); |
456 | else | 425 | else |
457 | local->sw_scanning = true; | 426 | __set_bit(SCAN_SW_SCANNING, &local->scanning); |
458 | /* | 427 | /* |
459 | * Kicking off the scan need not be protected, | 428 | * Kicking off the scan need not be protected, |
460 | * only the scan variable stuff, since now | 429 | * only the scan variable stuff, since now |
@@ -477,11 +446,9 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
477 | mutex_lock(&local->scan_mtx); | 446 | mutex_lock(&local->scan_mtx); |
478 | 447 | ||
479 | if (rc) { | 448 | if (rc) { |
480 | if (local->ops->hw_scan) { | 449 | if (local->ops->hw_scan) |
481 | local->hw_scanning = false; | ||
482 | ieee80211_restore_scan_ies(local); | 450 | ieee80211_restore_scan_ies(local); |
483 | } else | 451 | local->scanning = 0; |
484 | local->sw_scanning = false; | ||
485 | 452 | ||
486 | ieee80211_recalc_idle(local); | 453 | ieee80211_recalc_idle(local); |
487 | 454 | ||
@@ -492,13 +459,195 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
492 | return rc; | 459 | return rc; |
493 | } | 460 | } |
494 | 461 | ||
462 | static int ieee80211_scan_state_decision(struct ieee80211_local *local, | ||
463 | unsigned long *next_delay) | ||
464 | { | ||
465 | bool associated = false; | ||
466 | struct ieee80211_sub_if_data *sdata; | ||
467 | |||
468 | /* if no more bands/channels left, complete scan and advance to the idle state */ | ||
469 | if (local->scan_channel_idx >= local->scan_req->n_channels) { | ||
470 | ieee80211_scan_completed(&local->hw, false); | ||
471 | return 1; | ||
472 | } | ||
473 | |||
474 | /* check if at least one STA interface is associated */ | ||
475 | mutex_lock(&local->iflist_mtx); | ||
476 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
477 | if (!netif_running(sdata->dev)) | ||
478 | continue; | ||
479 | |||
480 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
481 | if (sdata->u.mgd.associated) { | ||
482 | associated = true; | ||
483 | break; | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | mutex_unlock(&local->iflist_mtx); | ||
488 | |||
489 | if (local->scan_channel) { | ||
490 | /* | ||
491 | * we're currently scanning a different channel, let's | ||
492 | * switch back to the operating channel now if at least | ||
493 | * one interface is associated. Otherwise just scan the | ||
494 | * next channel | ||
495 | */ | ||
496 | if (associated) | ||
497 | local->next_scan_state = SCAN_ENTER_OPER_CHANNEL; | ||
498 | else | ||
499 | local->next_scan_state = SCAN_SET_CHANNEL; | ||
500 | } else { | ||
501 | /* | ||
502 | * we're on the operating channel currently, let's | ||
503 | * leave that channel now to scan another one | ||
504 | */ | ||
505 | local->next_scan_state = SCAN_LEAVE_OPER_CHANNEL; | ||
506 | } | ||
507 | |||
508 | *next_delay = 0; | ||
509 | return 0; | ||
510 | } | ||
511 | |||
512 | static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *local, | ||
513 | unsigned long *next_delay) | ||
514 | { | ||
515 | struct ieee80211_sub_if_data *sdata; | ||
516 | |||
517 | /* | ||
518 | * notify the AP about us leaving the channel and stop all STA interfaces | ||
519 | */ | ||
520 | mutex_lock(&local->iflist_mtx); | ||
521 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
522 | if (!netif_running(sdata->dev)) | ||
523 | continue; | ||
524 | |||
525 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
526 | netif_tx_stop_all_queues(sdata->dev); | ||
527 | if (sdata->u.mgd.associated) | ||
528 | ieee80211_scan_ps_enable(sdata); | ||
529 | } | ||
530 | } | ||
531 | mutex_unlock(&local->iflist_mtx); | ||
532 | |||
533 | __set_bit(SCAN_OFF_CHANNEL, &local->scanning); | ||
534 | |||
535 | /* advance to the next channel to be scanned */ | ||
536 | *next_delay = HZ / 10; | ||
537 | local->next_scan_state = SCAN_SET_CHANNEL; | ||
538 | } | ||
539 | |||
540 | static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *local, | ||
541 | unsigned long *next_delay) | ||
542 | { | ||
543 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | ||
544 | |||
545 | /* switch back to the operating channel */ | ||
546 | local->scan_channel = NULL; | ||
547 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); | ||
548 | |||
549 | /* | ||
550 | * notify the AP about us being back and restart all STA interfaces | ||
551 | */ | ||
552 | mutex_lock(&local->iflist_mtx); | ||
553 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
554 | if (!netif_running(sdata->dev)) | ||
555 | continue; | ||
556 | |||
557 | /* Tell AP we're back */ | ||
558 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
559 | if (sdata->u.mgd.associated) | ||
560 | ieee80211_scan_ps_disable(sdata); | ||
561 | netif_tx_wake_all_queues(sdata->dev); | ||
562 | } | ||
563 | } | ||
564 | mutex_unlock(&local->iflist_mtx); | ||
565 | |||
566 | __clear_bit(SCAN_OFF_CHANNEL, &local->scanning); | ||
567 | |||
568 | *next_delay = HZ / 5; | ||
569 | local->next_scan_state = SCAN_DECISION; | ||
570 | } | ||
571 | |||
572 | static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, | ||
573 | unsigned long *next_delay) | ||
574 | { | ||
575 | int skip; | ||
576 | struct ieee80211_channel *chan; | ||
577 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | ||
578 | |||
579 | skip = 0; | ||
580 | chan = local->scan_req->channels[local->scan_channel_idx]; | ||
581 | |||
582 | if (chan->flags & IEEE80211_CHAN_DISABLED || | ||
583 | (sdata->vif.type == NL80211_IFTYPE_ADHOC && | ||
584 | chan->flags & IEEE80211_CHAN_NO_IBSS)) | ||
585 | skip = 1; | ||
586 | |||
587 | if (!skip) { | ||
588 | local->scan_channel = chan; | ||
589 | if (ieee80211_hw_config(local, | ||
590 | IEEE80211_CONF_CHANGE_CHANNEL)) | ||
591 | skip = 1; | ||
592 | } | ||
593 | |||
594 | /* advance state machine to next channel/band */ | ||
595 | local->scan_channel_idx++; | ||
596 | |||
597 | if (skip) { | ||
598 | /* if we skip this channel return to the decision state */ | ||
599 | local->next_scan_state = SCAN_DECISION; | ||
600 | return; | ||
601 | } | ||
602 | |||
603 | /* | ||
604 | * Probe delay is used to update the NAV, cf. 11.1.3.2.2 | ||
605 | * (which unfortunately doesn't say _why_ step a) is done, | ||
606 | * but it waits for the probe delay or until a frame is | ||
607 | * received - and the received frame would update the NAV). | ||
608 | * For now, we do not support waiting until a frame is | ||
609 | * received. | ||
610 | * | ||
611 | * In any case, it is not necessary for a passive scan. | ||
612 | */ | ||
613 | if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN || | ||
614 | !local->scan_req->n_ssids) { | ||
615 | *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; | ||
616 | local->next_scan_state = SCAN_DECISION; | ||
617 | return; | ||
618 | } | ||
619 | |||
620 | /* active scan, send probes */ | ||
621 | *next_delay = IEEE80211_PROBE_DELAY; | ||
622 | local->next_scan_state = SCAN_SEND_PROBE; | ||
623 | } | ||
624 | |||
625 | static void ieee80211_scan_state_send_probe(struct ieee80211_local *local, | ||
626 | unsigned long *next_delay) | ||
627 | { | ||
628 | int i; | ||
629 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | ||
630 | |||
631 | for (i = 0; i < local->scan_req->n_ssids; i++) | ||
632 | ieee80211_send_probe_req( | ||
633 | sdata, NULL, | ||
634 | local->scan_req->ssids[i].ssid, | ||
635 | local->scan_req->ssids[i].ssid_len, | ||
636 | local->scan_req->ie, local->scan_req->ie_len); | ||
637 | |||
638 | /* | ||
639 | * After sending probe requests, wait for probe responses | ||
640 | * on the channel. | ||
641 | */ | ||
642 | *next_delay = IEEE80211_CHANNEL_TIME; | ||
643 | local->next_scan_state = SCAN_DECISION; | ||
644 | } | ||
645 | |||
495 | void ieee80211_scan_work(struct work_struct *work) | 646 | void ieee80211_scan_work(struct work_struct *work) |
496 | { | 647 | { |
497 | struct ieee80211_local *local = | 648 | struct ieee80211_local *local = |
498 | container_of(work, struct ieee80211_local, scan_work.work); | 649 | container_of(work, struct ieee80211_local, scan_work.work); |
499 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; | 650 | struct ieee80211_sub_if_data *sdata = local->scan_sdata; |
500 | struct ieee80211_channel *chan; | ||
501 | int skip, i; | ||
502 | unsigned long next_delay = 0; | 651 | unsigned long next_delay = 0; |
503 | 652 | ||
504 | mutex_lock(&local->scan_mtx); | 653 | mutex_lock(&local->scan_mtx); |
@@ -507,11 +656,12 @@ void ieee80211_scan_work(struct work_struct *work) | |||
507 | return; | 656 | return; |
508 | } | 657 | } |
509 | 658 | ||
510 | if (local->scan_req && !(local->sw_scanning || local->hw_scanning)) { | 659 | if (local->scan_req && !local->scanning) { |
511 | struct cfg80211_scan_request *req = local->scan_req; | 660 | struct cfg80211_scan_request *req = local->scan_req; |
512 | int rc; | 661 | int rc; |
513 | 662 | ||
514 | local->scan_req = NULL; | 663 | local->scan_req = NULL; |
664 | local->scan_sdata = NULL; | ||
515 | 665 | ||
516 | rc = __ieee80211_start_scan(sdata, req); | 666 | rc = __ieee80211_start_scan(sdata, req); |
517 | mutex_unlock(&local->scan_mtx); | 667 | mutex_unlock(&local->scan_mtx); |
@@ -531,72 +681,32 @@ void ieee80211_scan_work(struct work_struct *work) | |||
531 | return; | 681 | return; |
532 | } | 682 | } |
533 | 683 | ||
534 | switch (local->scan_state) { | 684 | /* |
535 | case SCAN_SET_CHANNEL: | 685 | * as long as no delay is required advance immediately |
536 | /* if no more bands/channels left, complete scan */ | 686 | * without scheduling a new work |
537 | if (local->scan_channel_idx >= local->scan_req->n_channels) { | 687 | */ |
538 | ieee80211_scan_completed(&local->hw, false); | 688 | do { |
539 | return; | 689 | switch (local->next_scan_state) { |
540 | } | 690 | case SCAN_DECISION: |
541 | skip = 0; | 691 | if (ieee80211_scan_state_decision(local, &next_delay)) |
542 | chan = local->scan_req->channels[local->scan_channel_idx]; | 692 | return; |
543 | |||
544 | if (chan->flags & IEEE80211_CHAN_DISABLED || | ||
545 | (sdata->vif.type == NL80211_IFTYPE_ADHOC && | ||
546 | chan->flags & IEEE80211_CHAN_NO_IBSS)) | ||
547 | skip = 1; | ||
548 | |||
549 | if (!skip) { | ||
550 | local->scan_channel = chan; | ||
551 | if (ieee80211_hw_config(local, | ||
552 | IEEE80211_CONF_CHANGE_CHANNEL)) | ||
553 | skip = 1; | ||
554 | } | ||
555 | |||
556 | /* advance state machine to next channel/band */ | ||
557 | local->scan_channel_idx++; | ||
558 | |||
559 | if (skip) | ||
560 | break; | 693 | break; |
561 | 694 | case SCAN_SET_CHANNEL: | |
562 | /* | 695 | ieee80211_scan_state_set_channel(local, &next_delay); |
563 | * Probe delay is used to update the NAV, cf. 11.1.3.2.2 | 696 | break; |
564 | * (which unfortunately doesn't say _why_ step a) is done, | 697 | case SCAN_SEND_PROBE: |
565 | * but it waits for the probe delay or until a frame is | 698 | ieee80211_scan_state_send_probe(local, &next_delay); |
566 | * received - and the received frame would update the NAV). | 699 | break; |
567 | * For now, we do not support waiting until a frame is | 700 | case SCAN_LEAVE_OPER_CHANNEL: |
568 | * received. | 701 | ieee80211_scan_state_leave_oper_channel(local, &next_delay); |
569 | * | 702 | break; |
570 | * In any case, it is not necessary for a passive scan. | 703 | case SCAN_ENTER_OPER_CHANNEL: |
571 | */ | 704 | ieee80211_scan_state_enter_oper_channel(local, &next_delay); |
572 | if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN || | ||
573 | !local->scan_req->n_ssids) { | ||
574 | next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; | ||
575 | break; | 705 | break; |
576 | } | 706 | } |
707 | } while (next_delay == 0); | ||
577 | 708 | ||
578 | next_delay = IEEE80211_PROBE_DELAY; | 709 | ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay); |
579 | local->scan_state = SCAN_SEND_PROBE; | ||
580 | break; | ||
581 | case SCAN_SEND_PROBE: | ||
582 | for (i = 0; i < local->scan_req->n_ssids; i++) | ||
583 | ieee80211_send_probe_req( | ||
584 | sdata, NULL, | ||
585 | local->scan_req->ssids[i].ssid, | ||
586 | local->scan_req->ssids[i].ssid_len, | ||
587 | local->scan_req->ie, local->scan_req->ie_len); | ||
588 | |||
589 | /* | ||
590 | * After sending probe requests, wait for probe responses | ||
591 | * on the channel. | ||
592 | */ | ||
593 | next_delay = IEEE80211_CHANNEL_TIME; | ||
594 | local->scan_state = SCAN_SET_CHANNEL; | ||
595 | break; | ||
596 | } | ||
597 | |||
598 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | ||
599 | next_delay); | ||
600 | } | 710 | } |
601 | 711 | ||
602 | int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, | 712 | int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, |
@@ -623,10 +733,10 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata, | |||
623 | if (local->scan_req) | 733 | if (local->scan_req) |
624 | goto unlock; | 734 | goto unlock; |
625 | 735 | ||
626 | memcpy(local->int_scan_req.ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN); | 736 | memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN); |
627 | local->int_scan_req.ssids[0].ssid_len = ssid_len; | 737 | local->int_scan_req->ssids[0].ssid_len = ssid_len; |
628 | 738 | ||
629 | ret = __ieee80211_start_scan(sdata, &sdata->local->int_scan_req); | 739 | ret = __ieee80211_start_scan(sdata, sdata->local->int_scan_req); |
630 | unlock: | 740 | unlock: |
631 | mutex_unlock(&local->scan_mtx); | 741 | mutex_unlock(&local->scan_mtx); |
632 | return ret; | 742 | return ret; |
@@ -634,7 +744,7 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata, | |||
634 | 744 | ||
635 | void ieee80211_scan_cancel(struct ieee80211_local *local) | 745 | void ieee80211_scan_cancel(struct ieee80211_local *local) |
636 | { | 746 | { |
637 | bool swscan; | 747 | bool abortscan; |
638 | 748 | ||
639 | cancel_delayed_work_sync(&local->scan_work); | 749 | cancel_delayed_work_sync(&local->scan_work); |
640 | 750 | ||
@@ -643,9 +753,10 @@ void ieee80211_scan_cancel(struct ieee80211_local *local) | |||
643 | * queued -- mostly at suspend under RTNL. | 753 | * queued -- mostly at suspend under RTNL. |
644 | */ | 754 | */ |
645 | mutex_lock(&local->scan_mtx); | 755 | mutex_lock(&local->scan_mtx); |
646 | swscan = local->sw_scanning; | 756 | abortscan = test_bit(SCAN_SW_SCANNING, &local->scanning) || |
757 | (!local->scanning && local->scan_req); | ||
647 | mutex_unlock(&local->scan_mtx); | 758 | mutex_unlock(&local->scan_mtx); |
648 | 759 | ||
649 | if (swscan) | 760 | if (abortscan) |
650 | ieee80211_scan_completed(&local->hw, true); | 761 | ieee80211_scan_completed(&local->hw, true); |
651 | } | 762 | } |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index a360bceeba59..eec001491e66 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -349,6 +349,7 @@ int sta_info_insert(struct sta_info *sta) | |||
349 | goto out_free; | 349 | goto out_free; |
350 | } | 350 | } |
351 | list_add(&sta->list, &local->sta_list); | 351 | list_add(&sta->list, &local->sta_list); |
352 | local->sta_generation++; | ||
352 | local->num_sta++; | 353 | local->num_sta++; |
353 | sta_info_hash_add(local, sta); | 354 | sta_info_hash_add(local, sta); |
354 | 355 | ||
@@ -485,6 +486,7 @@ static void __sta_info_unlink(struct sta_info **sta) | |||
485 | } | 486 | } |
486 | 487 | ||
487 | local->num_sta--; | 488 | local->num_sta--; |
489 | local->sta_generation++; | ||
488 | 490 | ||
489 | if (local->ops->sta_notify) { | 491 | if (local->ops->sta_notify) { |
490 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 492 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 49a1a1f76511..ccc3adf962c7 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h | |||
@@ -30,7 +30,6 @@ | |||
30 | * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP. | 30 | * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP. |
31 | * @WLAN_STA_WME: Station is a QoS-STA. | 31 | * @WLAN_STA_WME: Station is a QoS-STA. |
32 | * @WLAN_STA_WDS: Station is one of our WDS peers. | 32 | * @WLAN_STA_WDS: Station is one of our WDS peers. |
33 | * @WLAN_STA_PSPOLL: Station has just PS-polled us. | ||
34 | * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the | 33 | * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the |
35 | * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next | 34 | * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next |
36 | * frame to this station is transmitted. | 35 | * frame to this station is transmitted. |
@@ -47,7 +46,6 @@ enum ieee80211_sta_info_flags { | |||
47 | WLAN_STA_ASSOC_AP = 1<<5, | 46 | WLAN_STA_ASSOC_AP = 1<<5, |
48 | WLAN_STA_WME = 1<<6, | 47 | WLAN_STA_WME = 1<<6, |
49 | WLAN_STA_WDS = 1<<7, | 48 | WLAN_STA_WDS = 1<<7, |
50 | WLAN_STA_PSPOLL = 1<<8, | ||
51 | WLAN_STA_CLEAR_PS_FILT = 1<<9, | 49 | WLAN_STA_CLEAR_PS_FILT = 1<<9, |
52 | WLAN_STA_MFP = 1<<10, | 50 | WLAN_STA_MFP = 1<<10, |
53 | WLAN_STA_SUSPEND = 1<<11 | 51 | WLAN_STA_SUSPEND = 1<<11 |
@@ -308,6 +306,23 @@ struct sta_info { | |||
308 | struct dentry *inactive_ms; | 306 | struct dentry *inactive_ms; |
309 | struct dentry *last_seq_ctrl; | 307 | struct dentry *last_seq_ctrl; |
310 | struct dentry *agg_status; | 308 | struct dentry *agg_status; |
309 | struct dentry *aid; | ||
310 | struct dentry *dev; | ||
311 | struct dentry *rx_packets; | ||
312 | struct dentry *tx_packets; | ||
313 | struct dentry *rx_bytes; | ||
314 | struct dentry *tx_bytes; | ||
315 | struct dentry *rx_duplicates; | ||
316 | struct dentry *rx_fragments; | ||
317 | struct dentry *rx_dropped; | ||
318 | struct dentry *tx_fragments; | ||
319 | struct dentry *tx_filtered; | ||
320 | struct dentry *tx_retry_failed; | ||
321 | struct dentry *tx_retry_count; | ||
322 | struct dentry *last_signal; | ||
323 | struct dentry *last_qual; | ||
324 | struct dentry *last_noise; | ||
325 | struct dentry *wep_weak_iv_count; | ||
311 | bool add_has_run; | 326 | bool add_has_run; |
312 | } debugfs; | 327 | } debugfs; |
313 | #endif | 328 | #endif |
@@ -342,17 +357,6 @@ static inline void clear_sta_flags(struct sta_info *sta, const u32 flags) | |||
342 | spin_unlock_irqrestore(&sta->flaglock, irqfl); | 357 | spin_unlock_irqrestore(&sta->flaglock, irqfl); |
343 | } | 358 | } |
344 | 359 | ||
345 | static inline void set_and_clear_sta_flags(struct sta_info *sta, | ||
346 | const u32 set, const u32 clear) | ||
347 | { | ||
348 | unsigned long irqfl; | ||
349 | |||
350 | spin_lock_irqsave(&sta->flaglock, irqfl); | ||
351 | sta->flags |= set; | ||
352 | sta->flags &= ~clear; | ||
353 | spin_unlock_irqrestore(&sta->flaglock, irqfl); | ||
354 | } | ||
355 | |||
356 | static inline u32 test_sta_flags(struct sta_info *sta, const u32 flags) | 360 | static inline u32 test_sta_flags(struct sta_info *sta, const u32 flags) |
357 | { | 361 | { |
358 | u32 ret; | 362 | u32 ret; |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 3a8922cd1038..5143d203256b 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -192,7 +192,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) | |||
192 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) | 192 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) |
193 | return TX_CONTINUE; | 193 | return TX_CONTINUE; |
194 | 194 | ||
195 | if (unlikely(tx->local->sw_scanning) && | 195 | if (unlikely(test_bit(SCAN_OFF_CHANNEL, &tx->local->scanning)) && |
196 | !ieee80211_is_probe_req(hdr->frame_control) && | 196 | !ieee80211_is_probe_req(hdr->frame_control) && |
197 | !ieee80211_is_nullfunc(hdr->frame_control)) | 197 | !ieee80211_is_nullfunc(hdr->frame_control)) |
198 | /* | 198 | /* |
@@ -317,30 +317,30 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
317 | if (!atomic_read(&tx->sdata->bss->num_sta_ps)) | 317 | if (!atomic_read(&tx->sdata->bss->num_sta_ps)) |
318 | return TX_CONTINUE; | 318 | return TX_CONTINUE; |
319 | 319 | ||
320 | /* buffered in hardware */ | ||
321 | if (!(tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING)) { | ||
322 | info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; | ||
323 | |||
324 | return TX_CONTINUE; | ||
325 | } | ||
326 | |||
320 | /* buffered in mac80211 */ | 327 | /* buffered in mac80211 */ |
321 | if (tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) { | 328 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) |
322 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) | 329 | purge_old_ps_buffers(tx->local); |
323 | purge_old_ps_buffers(tx->local); | 330 | |
324 | if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= | 331 | if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= AP_MAX_BC_BUFFER) { |
325 | AP_MAX_BC_BUFFER) { | ||
326 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 332 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
327 | if (net_ratelimit()) { | 333 | if (net_ratelimit()) |
328 | printk(KERN_DEBUG "%s: BC TX buffer full - " | 334 | printk(KERN_DEBUG "%s: BC TX buffer full - dropping the oldest frame\n", |
329 | "dropping the oldest frame\n", | 335 | tx->dev->name); |
330 | tx->dev->name); | ||
331 | } | ||
332 | #endif | 336 | #endif |
333 | dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf)); | 337 | dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf)); |
334 | } else | 338 | } else |
335 | tx->local->total_ps_buffered++; | 339 | tx->local->total_ps_buffered++; |
336 | skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb); | ||
337 | return TX_QUEUED; | ||
338 | } | ||
339 | 340 | ||
340 | /* buffered in hardware */ | 341 | skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb); |
341 | info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; | ||
342 | 342 | ||
343 | return TX_CONTINUE; | 343 | return TX_QUEUED; |
344 | } | 344 | } |
345 | 345 | ||
346 | static int ieee80211_use_mfp(__le16 fc, struct sta_info *sta, | 346 | static int ieee80211_use_mfp(__le16 fc, struct sta_info *sta, |
@@ -373,7 +373,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
373 | staflags = get_sta_flags(sta); | 373 | staflags = get_sta_flags(sta); |
374 | 374 | ||
375 | if (unlikely((staflags & WLAN_STA_PS) && | 375 | if (unlikely((staflags & WLAN_STA_PS) && |
376 | !(staflags & WLAN_STA_PSPOLL))) { | 376 | !(info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE))) { |
377 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 377 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
378 | printk(KERN_DEBUG "STA %pM aid %d: PS buffer (entries " | 378 | printk(KERN_DEBUG "STA %pM aid %d: PS buffer (entries " |
379 | "before %d)\n", | 379 | "before %d)\n", |
@@ -400,6 +400,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
400 | sta_info_set_tim_bit(sta); | 400 | sta_info_set_tim_bit(sta); |
401 | 401 | ||
402 | info->control.jiffies = jiffies; | 402 | info->control.jiffies = jiffies; |
403 | info->control.vif = &tx->sdata->vif; | ||
403 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 404 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
404 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); | 405 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); |
405 | return TX_QUEUED; | 406 | return TX_QUEUED; |
@@ -411,24 +412,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
411 | sta->sta.addr); | 412 | sta->sta.addr); |
412 | } | 413 | } |
413 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 414 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
414 | if (test_and_clear_sta_flags(sta, WLAN_STA_PSPOLL)) { | ||
415 | /* | ||
416 | * The sleeping station with pending data is now snoozing. | ||
417 | * It queried us for its buffered frames and will go back | ||
418 | * to deep sleep once it got everything. | ||
419 | * | ||
420 | * inform the driver, in case the hardware does powersave | ||
421 | * frame filtering and keeps a station blacklist on its own | ||
422 | * (e.g: p54), so that frames can be delivered unimpeded. | ||
423 | * | ||
424 | * Note: It should be safe to disable the filter now. | ||
425 | * As, it is really unlikely that we still have any pending | ||
426 | * frame for this station in the hw's buffers/fifos left, | ||
427 | * that is not rejected with a unsuccessful tx_status yet. | ||
428 | */ | ||
429 | 415 | ||
430 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | ||
431 | } | ||
432 | return TX_CONTINUE; | 416 | return TX_CONTINUE; |
433 | } | 417 | } |
434 | 418 | ||
@@ -451,7 +435,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
451 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 435 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
452 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | 436 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; |
453 | 437 | ||
454 | if (unlikely(tx->skb->do_not_encrypt)) | 438 | if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) |
455 | tx->key = NULL; | 439 | tx->key = NULL; |
456 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) | 440 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) |
457 | tx->key = key; | 441 | tx->key = key; |
@@ -497,7 +481,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
497 | } | 481 | } |
498 | 482 | ||
499 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) | 483 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
500 | tx->skb->do_not_encrypt = 1; | 484 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
501 | 485 | ||
502 | return TX_CONTINUE; | 486 | return TX_CONTINUE; |
503 | } | 487 | } |
@@ -512,6 +496,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
512 | int i, len; | 496 | int i, len; |
513 | bool inval = false, rts = false, short_preamble = false; | 497 | bool inval = false, rts = false, short_preamble = false; |
514 | struct ieee80211_tx_rate_control txrc; | 498 | struct ieee80211_tx_rate_control txrc; |
499 | u32 sta_flags; | ||
515 | 500 | ||
516 | memset(&txrc, 0, sizeof(txrc)); | 501 | memset(&txrc, 0, sizeof(txrc)); |
517 | 502 | ||
@@ -544,7 +529,26 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
544 | (tx->sta && test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) | 529 | (tx->sta && test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) |
545 | txrc.short_preamble = short_preamble = true; | 530 | txrc.short_preamble = short_preamble = true; |
546 | 531 | ||
532 | sta_flags = tx->sta ? get_sta_flags(tx->sta) : 0; | ||
533 | |||
534 | /* | ||
535 | * Lets not bother rate control if we're associated and cannot | ||
536 | * talk to the sta. This should not happen. | ||
537 | */ | ||
538 | if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && | ||
539 | (sta_flags & WLAN_STA_ASSOC) && | ||
540 | !rate_usable_index_exists(sband, &tx->sta->sta), | ||
541 | "%s: Dropped data frame as no usable bitrate found while " | ||
542 | "scanning and associated. Target station: " | ||
543 | "%pM on %d GHz band\n", | ||
544 | tx->dev->name, hdr->addr1, | ||
545 | tx->channel->band ? 5 : 2)) | ||
546 | return TX_DROP; | ||
547 | 547 | ||
548 | /* | ||
549 | * If we're associated with the sta at this point we know we can at | ||
550 | * least send the frame at the lowest bit rate. | ||
551 | */ | ||
548 | rate_control_get_rate(tx->sdata, tx->sta, &txrc); | 552 | rate_control_get_rate(tx->sdata, tx->sta, &txrc); |
549 | 553 | ||
550 | if (unlikely(info->control.rates[0].idx < 0)) | 554 | if (unlikely(info->control.rates[0].idx < 0)) |
@@ -676,7 +680,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) | |||
676 | * number, if we have no matching interface then we | 680 | * number, if we have no matching interface then we |
677 | * neither assign one ourselves nor ask the driver to. | 681 | * neither assign one ourselves nor ask the driver to. |
678 | */ | 682 | */ |
679 | if (unlikely(!info->control.vif)) | 683 | if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) |
680 | return TX_CONTINUE; | 684 | return TX_CONTINUE; |
681 | 685 | ||
682 | if (unlikely(ieee80211_is_ctl(hdr->frame_control))) | 686 | if (unlikely(ieee80211_is_ctl(hdr->frame_control))) |
@@ -696,7 +700,6 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) | |||
696 | /* for pure STA mode without beacons, we can do it */ | 700 | /* for pure STA mode without beacons, we can do it */ |
697 | hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); | 701 | hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); |
698 | tx->sdata->sequence_number += 0x10; | 702 | tx->sdata->sequence_number += 0x10; |
699 | tx->sdata->sequence_number &= IEEE80211_SCTL_SEQ; | ||
700 | return TX_CONTINUE; | 703 | return TX_CONTINUE; |
701 | } | 704 | } |
702 | 705 | ||
@@ -754,9 +757,7 @@ static int ieee80211_fragment(struct ieee80211_local *local, | |||
754 | memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); | 757 | memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); |
755 | skb_copy_queue_mapping(tmp, skb); | 758 | skb_copy_queue_mapping(tmp, skb); |
756 | tmp->priority = skb->priority; | 759 | tmp->priority = skb->priority; |
757 | tmp->do_not_encrypt = skb->do_not_encrypt; | ||
758 | tmp->dev = skb->dev; | 760 | tmp->dev = skb->dev; |
759 | tmp->iif = skb->iif; | ||
760 | 761 | ||
761 | /* copy header and data */ | 762 | /* copy header and data */ |
762 | memcpy(skb_put(tmp, hdrlen), skb->data, hdrlen); | 763 | memcpy(skb_put(tmp, hdrlen), skb->data, hdrlen); |
@@ -784,7 +785,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
784 | 785 | ||
785 | /* | 786 | /* |
786 | * Warn when submitting a fragmented A-MPDU frame and drop it. | 787 | * Warn when submitting a fragmented A-MPDU frame and drop it. |
787 | * This scenario is handled in __ieee80211_tx_prepare but extra | 788 | * This scenario is handled in ieee80211_tx_prepare but extra |
788 | * caution taken here as fragmented ampdu may cause Tx stop. | 789 | * caution taken here as fragmented ampdu may cause Tx stop. |
789 | */ | 790 | */ |
790 | if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) | 791 | if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) |
@@ -842,6 +843,23 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
842 | } | 843 | } |
843 | 844 | ||
844 | static ieee80211_tx_result debug_noinline | 845 | static ieee80211_tx_result debug_noinline |
846 | ieee80211_tx_h_stats(struct ieee80211_tx_data *tx) | ||
847 | { | ||
848 | struct sk_buff *skb = tx->skb; | ||
849 | |||
850 | if (!tx->sta) | ||
851 | return TX_CONTINUE; | ||
852 | |||
853 | tx->sta->tx_packets++; | ||
854 | do { | ||
855 | tx->sta->tx_fragments++; | ||
856 | tx->sta->tx_bytes += skb->len; | ||
857 | } while ((skb = skb->next)); | ||
858 | |||
859 | return TX_CONTINUE; | ||
860 | } | ||
861 | |||
862 | static ieee80211_tx_result debug_noinline | ||
845 | ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx) | 863 | ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx) |
846 | { | 864 | { |
847 | if (!tx->key) | 865 | if (!tx->key) |
@@ -885,23 +903,6 @@ ieee80211_tx_h_calculate_duration(struct ieee80211_tx_data *tx) | |||
885 | return TX_CONTINUE; | 903 | return TX_CONTINUE; |
886 | } | 904 | } |
887 | 905 | ||
888 | static ieee80211_tx_result debug_noinline | ||
889 | ieee80211_tx_h_stats(struct ieee80211_tx_data *tx) | ||
890 | { | ||
891 | struct sk_buff *skb = tx->skb; | ||
892 | |||
893 | if (!tx->sta) | ||
894 | return TX_CONTINUE; | ||
895 | |||
896 | tx->sta->tx_packets++; | ||
897 | do { | ||
898 | tx->sta->tx_fragments++; | ||
899 | tx->sta->tx_bytes += skb->len; | ||
900 | } while ((skb = skb->next)); | ||
901 | |||
902 | return TX_CONTINUE; | ||
903 | } | ||
904 | |||
905 | /* actual transmit path */ | 906 | /* actual transmit path */ |
906 | 907 | ||
907 | /* | 908 | /* |
@@ -923,11 +924,12 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
923 | struct ieee80211_radiotap_header *rthdr = | 924 | struct ieee80211_radiotap_header *rthdr = |
924 | (struct ieee80211_radiotap_header *) skb->data; | 925 | (struct ieee80211_radiotap_header *) skb->data; |
925 | struct ieee80211_supported_band *sband; | 926 | struct ieee80211_supported_band *sband; |
927 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
926 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); | 928 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); |
927 | 929 | ||
928 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; | 930 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; |
929 | 931 | ||
930 | skb->do_not_encrypt = 1; | 932 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
931 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; | 933 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; |
932 | 934 | ||
933 | /* | 935 | /* |
@@ -965,7 +967,7 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
965 | skb_trim(skb, skb->len - FCS_LEN); | 967 | skb_trim(skb, skb->len - FCS_LEN); |
966 | } | 968 | } |
967 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) | 969 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) |
968 | tx->skb->do_not_encrypt = 0; | 970 | info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; |
969 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) | 971 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) |
970 | tx->flags |= IEEE80211_TX_FRAGMENTED; | 972 | tx->flags |= IEEE80211_TX_FRAGMENTED; |
971 | break; | 973 | break; |
@@ -998,13 +1000,12 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
998 | * initialises @tx | 1000 | * initialises @tx |
999 | */ | 1001 | */ |
1000 | static ieee80211_tx_result | 1002 | static ieee80211_tx_result |
1001 | __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | 1003 | ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, |
1002 | struct sk_buff *skb, | 1004 | struct ieee80211_tx_data *tx, |
1003 | struct net_device *dev) | 1005 | struct sk_buff *skb) |
1004 | { | 1006 | { |
1005 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1007 | struct ieee80211_local *local = sdata->local; |
1006 | struct ieee80211_hdr *hdr; | 1008 | struct ieee80211_hdr *hdr; |
1007 | struct ieee80211_sub_if_data *sdata; | ||
1008 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1009 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1009 | int hdrlen, tid; | 1010 | int hdrlen, tid; |
1010 | u8 *qc, *state; | 1011 | u8 *qc, *state; |
@@ -1012,9 +1013,9 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1012 | 1013 | ||
1013 | memset(tx, 0, sizeof(*tx)); | 1014 | memset(tx, 0, sizeof(*tx)); |
1014 | tx->skb = skb; | 1015 | tx->skb = skb; |
1015 | tx->dev = dev; /* use original interface */ | 1016 | tx->dev = sdata->dev; /* use original interface */ |
1016 | tx->local = local; | 1017 | tx->local = local; |
1017 | tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1018 | tx->sdata = sdata; |
1018 | tx->channel = local->hw.conf.channel; | 1019 | tx->channel = local->hw.conf.channel; |
1019 | /* | 1020 | /* |
1020 | * Set this flag (used below to indicate "automatic fragmentation"), | 1021 | * Set this flag (used below to indicate "automatic fragmentation"), |
@@ -1023,7 +1024,6 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1023 | tx->flags |= IEEE80211_TX_FRAGMENTED; | 1024 | tx->flags |= IEEE80211_TX_FRAGMENTED; |
1024 | 1025 | ||
1025 | /* process and remove the injection radiotap header */ | 1026 | /* process and remove the injection radiotap header */ |
1026 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1027 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) { | 1027 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) { |
1028 | if (!__ieee80211_parse_tx_radiotap(tx, skb)) | 1028 | if (!__ieee80211_parse_tx_radiotap(tx, skb)) |
1029 | return TX_DROP; | 1029 | return TX_DROP; |
@@ -1075,6 +1075,7 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1075 | } else if (*state != HT_AGG_STATE_IDLE) { | 1075 | } else if (*state != HT_AGG_STATE_IDLE) { |
1076 | /* in progress */ | 1076 | /* in progress */ |
1077 | queued = true; | 1077 | queued = true; |
1078 | info->control.vif = &sdata->vif; | ||
1078 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 1079 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
1079 | __skb_queue_tail(&tid_tx->pending, skb); | 1080 | __skb_queue_tail(&tid_tx->pending, skb); |
1080 | } | 1081 | } |
@@ -1119,50 +1120,29 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1119 | return TX_CONTINUE; | 1120 | return TX_CONTINUE; |
1120 | } | 1121 | } |
1121 | 1122 | ||
1122 | /* | ||
1123 | * NB: @tx is uninitialised when passed in here | ||
1124 | */ | ||
1125 | static 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 | |||
1151 | static int __ieee80211_tx(struct ieee80211_local *local, | 1123 | static int __ieee80211_tx(struct ieee80211_local *local, |
1152 | struct sk_buff **skbp, | 1124 | struct sk_buff **skbp, |
1153 | struct sta_info *sta) | 1125 | struct sta_info *sta, |
1126 | bool txpending) | ||
1154 | { | 1127 | { |
1155 | struct sk_buff *skb = *skbp, *next; | 1128 | struct sk_buff *skb = *skbp, *next; |
1156 | struct ieee80211_tx_info *info; | 1129 | struct ieee80211_tx_info *info; |
1130 | struct ieee80211_sub_if_data *sdata; | ||
1131 | unsigned long flags; | ||
1157 | int ret, len; | 1132 | int ret, len; |
1158 | bool fragm = false; | 1133 | bool fragm = false; |
1159 | 1134 | ||
1160 | local->mdev->trans_start = jiffies; | ||
1161 | |||
1162 | while (skb) { | 1135 | while (skb) { |
1163 | if (ieee80211_queue_stopped(&local->hw, | 1136 | int q = skb_get_queue_mapping(skb); |
1164 | skb_get_queue_mapping(skb))) | 1137 | |
1165 | return IEEE80211_TX_PENDING; | 1138 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
1139 | ret = IEEE80211_TX_OK; | ||
1140 | if (local->queue_stop_reasons[q] || | ||
1141 | (!txpending && !skb_queue_empty(&local->pending[q]))) | ||
1142 | ret = IEEE80211_TX_PENDING; | ||
1143 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
1144 | if (ret != IEEE80211_TX_OK) | ||
1145 | return ret; | ||
1166 | 1146 | ||
1167 | info = IEEE80211_SKB_CB(skb); | 1147 | info = IEEE80211_SKB_CB(skb); |
1168 | 1148 | ||
@@ -1172,13 +1152,35 @@ static int __ieee80211_tx(struct ieee80211_local *local, | |||
1172 | 1152 | ||
1173 | next = skb->next; | 1153 | next = skb->next; |
1174 | len = skb->len; | 1154 | len = skb->len; |
1155 | |||
1156 | if (next) | ||
1157 | info->flags |= IEEE80211_TX_CTL_MORE_FRAMES; | ||
1158 | |||
1159 | sdata = vif_to_sdata(info->control.vif); | ||
1160 | |||
1161 | switch (sdata->vif.type) { | ||
1162 | case NL80211_IFTYPE_MONITOR: | ||
1163 | info->control.vif = NULL; | ||
1164 | break; | ||
1165 | case NL80211_IFTYPE_AP_VLAN: | ||
1166 | info->control.vif = &container_of(sdata->bss, | ||
1167 | struct ieee80211_sub_if_data, u.ap)->vif; | ||
1168 | break; | ||
1169 | default: | ||
1170 | /* keep */ | ||
1171 | break; | ||
1172 | } | ||
1173 | |||
1175 | ret = drv_tx(local, skb); | 1174 | ret = drv_tx(local, skb); |
1176 | if (WARN_ON(ret != NETDEV_TX_OK && skb->len != len)) { | 1175 | if (WARN_ON(ret != NETDEV_TX_OK && skb->len != len)) { |
1177 | dev_kfree_skb(skb); | 1176 | dev_kfree_skb(skb); |
1178 | ret = NETDEV_TX_OK; | 1177 | ret = NETDEV_TX_OK; |
1179 | } | 1178 | } |
1180 | if (ret != NETDEV_TX_OK) | 1179 | if (ret != NETDEV_TX_OK) { |
1180 | info->control.vif = &sdata->vif; | ||
1181 | return IEEE80211_TX_AGAIN; | 1181 | return IEEE80211_TX_AGAIN; |
1182 | } | ||
1183 | |||
1182 | *skbp = skb = next; | 1184 | *skbp = skb = next; |
1183 | ieee80211_led_tx(local, 1); | 1185 | ieee80211_led_tx(local, 1); |
1184 | fragm = true; | 1186 | fragm = true; |
@@ -1210,9 +1212,9 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) | |||
1210 | CALL_TXH(ieee80211_tx_h_sequence) | 1212 | CALL_TXH(ieee80211_tx_h_sequence) |
1211 | CALL_TXH(ieee80211_tx_h_fragment) | 1213 | CALL_TXH(ieee80211_tx_h_fragment) |
1212 | /* handlers after fragment must be aware of tx info fragmentation! */ | 1214 | /* handlers after fragment must be aware of tx info fragmentation! */ |
1215 | CALL_TXH(ieee80211_tx_h_stats) | ||
1213 | CALL_TXH(ieee80211_tx_h_encrypt) | 1216 | CALL_TXH(ieee80211_tx_h_encrypt) |
1214 | CALL_TXH(ieee80211_tx_h_calculate_duration) | 1217 | CALL_TXH(ieee80211_tx_h_calculate_duration) |
1215 | CALL_TXH(ieee80211_tx_h_stats) | ||
1216 | #undef CALL_TXH | 1218 | #undef CALL_TXH |
1217 | 1219 | ||
1218 | txh_done: | 1220 | txh_done: |
@@ -1234,10 +1236,10 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) | |||
1234 | return 0; | 1236 | return 0; |
1235 | } | 1237 | } |
1236 | 1238 | ||
1237 | static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | 1239 | static void ieee80211_tx(struct ieee80211_sub_if_data *sdata, |
1238 | bool txpending) | 1240 | struct sk_buff *skb, bool txpending) |
1239 | { | 1241 | { |
1240 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1242 | struct ieee80211_local *local = sdata->local; |
1241 | struct ieee80211_tx_data tx; | 1243 | struct ieee80211_tx_data tx; |
1242 | ieee80211_tx_result res_prepare; | 1244 | ieee80211_tx_result res_prepare; |
1243 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1245 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
@@ -1248,8 +1250,6 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1248 | 1250 | ||
1249 | queue = skb_get_queue_mapping(skb); | 1251 | queue = skb_get_queue_mapping(skb); |
1250 | 1252 | ||
1251 | WARN_ON(!txpending && !skb_queue_empty(&local->pending[queue])); | ||
1252 | |||
1253 | if (unlikely(skb->len < 10)) { | 1253 | if (unlikely(skb->len < 10)) { |
1254 | dev_kfree_skb(skb); | 1254 | dev_kfree_skb(skb); |
1255 | return; | 1255 | return; |
@@ -1258,7 +1258,7 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1258 | rcu_read_lock(); | 1258 | rcu_read_lock(); |
1259 | 1259 | ||
1260 | /* initialises tx */ | 1260 | /* initialises tx */ |
1261 | res_prepare = __ieee80211_tx_prepare(&tx, skb, dev); | 1261 | res_prepare = ieee80211_tx_prepare(sdata, &tx, skb); |
1262 | 1262 | ||
1263 | if (unlikely(res_prepare == TX_DROP)) { | 1263 | if (unlikely(res_prepare == TX_DROP)) { |
1264 | dev_kfree_skb(skb); | 1264 | dev_kfree_skb(skb); |
@@ -1277,7 +1277,7 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1277 | 1277 | ||
1278 | retries = 0; | 1278 | retries = 0; |
1279 | retry: | 1279 | retry: |
1280 | ret = __ieee80211_tx(local, &tx.skb, tx.sta); | 1280 | ret = __ieee80211_tx(local, &tx.skb, tx.sta, txpending); |
1281 | switch (ret) { | 1281 | switch (ret) { |
1282 | case IEEE80211_TX_OK: | 1282 | case IEEE80211_TX_OK: |
1283 | break; | 1283 | break; |
@@ -1295,34 +1295,35 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1295 | 1295 | ||
1296 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 1296 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
1297 | 1297 | ||
1298 | if (__netif_subqueue_stopped(local->mdev, queue)) { | 1298 | if (local->queue_stop_reasons[queue] || |
1299 | !skb_queue_empty(&local->pending[queue])) { | ||
1300 | /* | ||
1301 | * if queue is stopped, queue up frames for later | ||
1302 | * transmission from the tasklet | ||
1303 | */ | ||
1299 | do { | 1304 | do { |
1300 | next = skb->next; | 1305 | next = skb->next; |
1301 | skb->next = NULL; | 1306 | skb->next = NULL; |
1302 | if (unlikely(txpending)) | 1307 | if (unlikely(txpending)) |
1303 | skb_queue_head(&local->pending[queue], | 1308 | __skb_queue_head(&local->pending[queue], |
1304 | skb); | 1309 | skb); |
1305 | else | 1310 | else |
1306 | skb_queue_tail(&local->pending[queue], | 1311 | __skb_queue_tail(&local->pending[queue], |
1307 | skb); | 1312 | skb); |
1308 | } while ((skb = next)); | 1313 | } while ((skb = next)); |
1309 | 1314 | ||
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, | 1315 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, |
1319 | flags); | 1316 | flags); |
1320 | } else { | 1317 | } else { |
1318 | /* | ||
1319 | * otherwise retry, but this is a race condition or | ||
1320 | * a driver bug (which we warn about if it persists) | ||
1321 | */ | ||
1321 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, | 1322 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, |
1322 | flags); | 1323 | flags); |
1323 | 1324 | ||
1324 | retries++; | 1325 | retries++; |
1325 | if (WARN(retries > 10, "tx refused but queue active")) | 1326 | if (WARN(retries > 10, "tx refused but queue active\n")) |
1326 | goto drop; | 1327 | goto drop; |
1327 | goto retry; | 1328 | goto retry; |
1328 | } | 1329 | } |
@@ -1383,44 +1384,25 @@ static int ieee80211_skb_resize(struct ieee80211_local *local, | |||
1383 | return 0; | 1384 | return 0; |
1384 | } | 1385 | } |
1385 | 1386 | ||
1386 | int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | 1387 | static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, |
1388 | struct sk_buff *skb) | ||
1387 | { | 1389 | { |
1388 | struct ieee80211_master_priv *mpriv = netdev_priv(dev); | 1390 | struct ieee80211_local *local = sdata->local; |
1389 | struct ieee80211_local *local = mpriv->local; | ||
1390 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1391 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1391 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 1392 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
1392 | struct net_device *odev = NULL; | 1393 | struct ieee80211_sub_if_data *tmp_sdata; |
1393 | struct ieee80211_sub_if_data *osdata; | ||
1394 | int headroom; | 1394 | int headroom; |
1395 | bool may_encrypt; | 1395 | bool may_encrypt; |
1396 | enum { | 1396 | |
1397 | NOT_MONITOR, | 1397 | dev_hold(sdata->dev); |
1398 | FOUND_SDATA, | ||
1399 | UNKNOWN_ADDRESS, | ||
1400 | } monitor_iface = NOT_MONITOR; | ||
1401 | |||
1402 | if (skb->iif) | ||
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 | 1398 | ||
1417 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && | 1399 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && |
1418 | local->hw.conf.dynamic_ps_timeout > 0 && | 1400 | local->hw.conf.dynamic_ps_timeout > 0 && |
1419 | !local->sw_scanning && !local->hw_scanning && local->ps_sdata) { | 1401 | !(local->scanning) && local->ps_sdata) { |
1420 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { | 1402 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { |
1421 | ieee80211_stop_queues_by_reason(&local->hw, | 1403 | ieee80211_stop_queues_by_reason(&local->hw, |
1422 | IEEE80211_QUEUE_STOP_REASON_PS); | 1404 | IEEE80211_QUEUE_STOP_REASON_PS); |
1423 | queue_work(local->hw.workqueue, | 1405 | ieee80211_queue_work(&local->hw, |
1424 | &local->dynamic_ps_disable_work); | 1406 | &local->dynamic_ps_disable_work); |
1425 | } | 1407 | } |
1426 | 1408 | ||
@@ -1428,31 +1410,13 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1428 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | 1410 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); |
1429 | } | 1411 | } |
1430 | 1412 | ||
1431 | memset(info, 0, sizeof(*info)); | ||
1432 | |||
1433 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; | 1413 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; |
1434 | 1414 | ||
1435 | osdata = IEEE80211_DEV_TO_SUB_IF(odev); | 1415 | if (unlikely(sdata->vif.type == NL80211_IFTYPE_MONITOR)) { |
1436 | |||
1437 | if (ieee80211_vif_is_mesh(&osdata->vif) && | ||
1438 | ieee80211_is_data(hdr->frame_control)) { | ||
1439 | if (is_multicast_ether_addr(hdr->addr3)) | ||
1440 | memcpy(hdr->addr1, hdr->addr3, ETH_ALEN); | ||
1441 | else | ||
1442 | if (mesh_nexthop_lookup(skb, osdata)) { | ||
1443 | dev_put(odev); | ||
1444 | return NETDEV_TX_OK; | ||
1445 | } | ||
1446 | if (memcmp(odev->dev_addr, hdr->addr4, ETH_ALEN) != 0) | ||
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; | 1416 | int hdrlen; |
1452 | u16 len_rthdr; | 1417 | u16 len_rthdr; |
1453 | 1418 | ||
1454 | info->flags |= IEEE80211_TX_CTL_INJECTED; | 1419 | info->flags |= IEEE80211_TX_CTL_INJECTED; |
1455 | monitor_iface = UNKNOWN_ADDRESS; | ||
1456 | 1420 | ||
1457 | len_rthdr = ieee80211_get_radiotap_len(skb->data); | 1421 | len_rthdr = ieee80211_get_radiotap_len(skb->data); |
1458 | hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); | 1422 | hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); |
@@ -1471,20 +1435,17 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1471 | */ | 1435 | */ |
1472 | 1436 | ||
1473 | rcu_read_lock(); | 1437 | rcu_read_lock(); |
1474 | list_for_each_entry_rcu(sdata, &local->interfaces, | 1438 | list_for_each_entry_rcu(tmp_sdata, &local->interfaces, |
1475 | list) { | 1439 | list) { |
1476 | if (!netif_running(sdata->dev)) | 1440 | if (!netif_running(tmp_sdata->dev)) |
1477 | continue; | 1441 | continue; |
1478 | if (sdata->vif.type != NL80211_IFTYPE_AP) | 1442 | if (tmp_sdata->vif.type != NL80211_IFTYPE_AP) |
1479 | continue; | 1443 | continue; |
1480 | if (compare_ether_addr(sdata->dev->dev_addr, | 1444 | if (compare_ether_addr(tmp_sdata->dev->dev_addr, |
1481 | hdr->addr2)) { | 1445 | hdr->addr2)) { |
1482 | dev_hold(sdata->dev); | 1446 | dev_hold(tmp_sdata->dev); |
1483 | dev_put(odev); | 1447 | dev_put(sdata->dev); |
1484 | osdata = sdata; | 1448 | sdata = tmp_sdata; |
1485 | odev = osdata->dev; | ||
1486 | skb->iif = sdata->dev->ifindex; | ||
1487 | monitor_iface = FOUND_SDATA; | ||
1488 | break; | 1449 | break; |
1489 | } | 1450 | } |
1490 | } | 1451 | } |
@@ -1492,40 +1453,44 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1492 | } | 1453 | } |
1493 | } | 1454 | } |
1494 | 1455 | ||
1495 | may_encrypt = !skb->do_not_encrypt; | 1456 | may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); |
1496 | 1457 | ||
1497 | headroom = osdata->local->tx_headroom; | 1458 | headroom = local->tx_headroom; |
1498 | if (may_encrypt) | 1459 | if (may_encrypt) |
1499 | headroom += IEEE80211_ENCRYPT_HEADROOM; | 1460 | headroom += IEEE80211_ENCRYPT_HEADROOM; |
1500 | headroom -= skb_headroom(skb); | 1461 | headroom -= skb_headroom(skb); |
1501 | headroom = max_t(int, 0, headroom); | 1462 | headroom = max_t(int, 0, headroom); |
1502 | 1463 | ||
1503 | if (ieee80211_skb_resize(osdata->local, skb, headroom, may_encrypt)) { | 1464 | if (ieee80211_skb_resize(local, skb, headroom, may_encrypt)) { |
1504 | dev_kfree_skb(skb); | 1465 | dev_kfree_skb(skb); |
1505 | dev_put(odev); | 1466 | dev_put(sdata->dev); |
1506 | return NETDEV_TX_OK; | 1467 | return; |
1507 | } | 1468 | } |
1508 | 1469 | ||
1509 | if (osdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 1470 | info->control.vif = &sdata->vif; |
1510 | osdata = container_of(osdata->bss, | ||
1511 | struct ieee80211_sub_if_data, | ||
1512 | u.ap); | ||
1513 | if (likely(monitor_iface != UNKNOWN_ADDRESS)) | ||
1514 | info->control.vif = &osdata->vif; | ||
1515 | 1471 | ||
1516 | ieee80211_tx(odev, skb, false); | 1472 | if (ieee80211_vif_is_mesh(&sdata->vif) && |
1517 | dev_put(odev); | 1473 | ieee80211_is_data(hdr->frame_control) && |
1474 | !is_multicast_ether_addr(hdr->addr1)) | ||
1475 | if (mesh_nexthop_lookup(skb, sdata)) { | ||
1476 | /* skb queued: don't free */ | ||
1477 | dev_put(sdata->dev); | ||
1478 | return; | ||
1479 | } | ||
1518 | 1480 | ||
1519 | return NETDEV_TX_OK; | 1481 | ieee80211_select_queue(local, skb); |
1482 | ieee80211_tx(sdata, skb, false); | ||
1483 | dev_put(sdata->dev); | ||
1520 | } | 1484 | } |
1521 | 1485 | ||
1522 | int ieee80211_monitor_start_xmit(struct sk_buff *skb, | 1486 | netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, |
1523 | struct net_device *dev) | 1487 | struct net_device *dev) |
1524 | { | 1488 | { |
1525 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1489 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1526 | struct ieee80211_channel *chan = local->hw.conf.channel; | 1490 | struct ieee80211_channel *chan = local->hw.conf.channel; |
1527 | struct ieee80211_radiotap_header *prthdr = | 1491 | struct ieee80211_radiotap_header *prthdr = |
1528 | (struct ieee80211_radiotap_header *)skb->data; | 1492 | (struct ieee80211_radiotap_header *)skb->data; |
1493 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1529 | u16 len_rthdr; | 1494 | u16 len_rthdr; |
1530 | 1495 | ||
1531 | /* | 1496 | /* |
@@ -1563,15 +1528,6 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1563 | if (unlikely(skb->len < len_rthdr)) | 1528 | if (unlikely(skb->len < len_rthdr)) |
1564 | goto fail; /* skb too short for claimed rt header extent */ | 1529 | goto fail; /* skb too short for claimed rt header extent */ |
1565 | 1530 | ||
1566 | skb->dev = local->mdev; | ||
1567 | |||
1568 | /* needed because we set skb device to master */ | ||
1569 | skb->iif = dev->ifindex; | ||
1570 | |||
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 | /* | 1531 | /* |
1576 | * fix up the pointers accounting for the radiotap | 1532 | * fix up the pointers accounting for the radiotap |
1577 | * header still being in there. We are being given | 1533 | * header still being in there. We are being given |
@@ -1586,8 +1542,10 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1586 | skb_set_network_header(skb, len_rthdr); | 1542 | skb_set_network_header(skb, len_rthdr); |
1587 | skb_set_transport_header(skb, len_rthdr); | 1543 | skb_set_transport_header(skb, len_rthdr); |
1588 | 1544 | ||
1589 | /* pass the radiotap header up to the next stage intact */ | 1545 | memset(info, 0, sizeof(*info)); |
1590 | dev_queue_xmit(skb); | 1546 | |
1547 | /* pass the radiotap header up to xmit */ | ||
1548 | ieee80211_xmit(IEEE80211_DEV_TO_SUB_IF(dev), skb); | ||
1591 | return NETDEV_TX_OK; | 1549 | return NETDEV_TX_OK; |
1592 | 1550 | ||
1593 | fail: | 1551 | fail: |
@@ -1610,11 +1568,12 @@ fail: | |||
1610 | * encapsulated packet will then be passed to master interface, wlan#.11, for | 1568 | * encapsulated packet will then be passed to master interface, wlan#.11, for |
1611 | * transmission (through low-level driver). | 1569 | * transmission (through low-level driver). |
1612 | */ | 1570 | */ |
1613 | int ieee80211_subif_start_xmit(struct sk_buff *skb, | 1571 | netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, |
1614 | struct net_device *dev) | 1572 | struct net_device *dev) |
1615 | { | 1573 | { |
1616 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1574 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1617 | struct ieee80211_local *local = sdata->local; | 1575 | struct ieee80211_local *local = sdata->local; |
1576 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1618 | int ret = NETDEV_TX_BUSY, head_need; | 1577 | int ret = NETDEV_TX_BUSY, head_need; |
1619 | u16 ethertype, hdrlen, meshhdrlen = 0; | 1578 | u16 ethertype, hdrlen, meshhdrlen = 0; |
1620 | __le16 fc; | 1579 | __le16 fc; |
@@ -1627,7 +1586,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1627 | u32 sta_flags = 0; | 1586 | u32 sta_flags = 0; |
1628 | 1587 | ||
1629 | if (unlikely(skb->len < ETH_HLEN)) { | 1588 | if (unlikely(skb->len < ETH_HLEN)) { |
1630 | ret = 0; | 1589 | ret = NETDEV_TX_OK; |
1631 | goto fail; | 1590 | goto fail; |
1632 | } | 1591 | } |
1633 | 1592 | ||
@@ -1660,52 +1619,58 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1660 | break; | 1619 | break; |
1661 | #ifdef CONFIG_MAC80211_MESH | 1620 | #ifdef CONFIG_MAC80211_MESH |
1662 | case NL80211_IFTYPE_MESH_POINT: | 1621 | case NL80211_IFTYPE_MESH_POINT: |
1663 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | ||
1664 | if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { | 1622 | if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { |
1665 | /* Do not send frames with mesh_ttl == 0 */ | 1623 | /* Do not send frames with mesh_ttl == 0 */ |
1666 | sdata->u.mesh.mshstats.dropped_frames_ttl++; | 1624 | sdata->u.mesh.mshstats.dropped_frames_ttl++; |
1667 | ret = 0; | 1625 | ret = NETDEV_TX_OK; |
1668 | goto fail; | 1626 | goto fail; |
1669 | } | 1627 | } |
1670 | memset(&mesh_hdr, 0, sizeof(mesh_hdr)); | ||
1671 | 1628 | ||
1672 | if (compare_ether_addr(dev->dev_addr, | 1629 | if (compare_ether_addr(dev->dev_addr, |
1673 | skb->data + ETH_ALEN) == 0) { | 1630 | skb->data + ETH_ALEN) == 0) { |
1674 | /* RA TA DA SA */ | 1631 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, |
1675 | memset(hdr.addr1, 0, ETH_ALEN); | 1632 | skb->data, skb->data + ETH_ALEN); |
1676 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | 1633 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, |
1677 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1634 | sdata, NULL, NULL, NULL); |
1678 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | ||
1679 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, sdata); | ||
1680 | } else { | 1635 | } else { |
1681 | /* packet from other interface */ | 1636 | /* packet from other interface */ |
1682 | struct mesh_path *mppath; | 1637 | struct mesh_path *mppath; |
1638 | int is_mesh_mcast = 1; | ||
1639 | char *mesh_da; | ||
1683 | 1640 | ||
1684 | memset(hdr.addr1, 0, ETH_ALEN); | 1641 | rcu_read_lock(); |
1685 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | ||
1686 | memcpy(hdr.addr4, dev->dev_addr, ETH_ALEN); | ||
1687 | |||
1688 | if (is_multicast_ether_addr(skb->data)) | 1642 | if (is_multicast_ether_addr(skb->data)) |
1689 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1643 | /* DA TA mSA AE:SA */ |
1644 | mesh_da = skb->data; | ||
1690 | else { | 1645 | else { |
1691 | rcu_read_lock(); | ||
1692 | mppath = mpp_path_lookup(skb->data, sdata); | 1646 | mppath = mpp_path_lookup(skb->data, sdata); |
1693 | if (mppath) | 1647 | if (mppath) { |
1694 | memcpy(hdr.addr3, mppath->mpp, ETH_ALEN); | 1648 | /* RA TA mDA mSA AE:DA SA */ |
1695 | else | 1649 | mesh_da = mppath->mpp; |
1696 | memset(hdr.addr3, 0xff, ETH_ALEN); | 1650 | is_mesh_mcast = 0; |
1697 | rcu_read_unlock(); | 1651 | } else |
1652 | /* DA TA mSA AE:SA */ | ||
1653 | mesh_da = dev->broadcast; | ||
1698 | } | 1654 | } |
1655 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, | ||
1656 | mesh_da, dev->dev_addr); | ||
1657 | rcu_read_unlock(); | ||
1658 | if (is_mesh_mcast) | ||
1659 | meshhdrlen = | ||
1660 | ieee80211_new_mesh_header(&mesh_hdr, | ||
1661 | sdata, | ||
1662 | skb->data + ETH_ALEN, | ||
1663 | NULL, | ||
1664 | NULL); | ||
1665 | else | ||
1666 | meshhdrlen = | ||
1667 | ieee80211_new_mesh_header(&mesh_hdr, | ||
1668 | sdata, | ||
1669 | NULL, | ||
1670 | skb->data, | ||
1671 | skb->data + ETH_ALEN); | ||
1699 | 1672 | ||
1700 | mesh_hdr.flags |= MESH_FLAGS_AE_A5_A6; | ||
1701 | mesh_hdr.ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; | ||
1702 | put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &mesh_hdr.seqnum); | ||
1703 | memcpy(mesh_hdr.eaddr1, skb->data, ETH_ALEN); | ||
1704 | memcpy(mesh_hdr.eaddr2, skb->data + ETH_ALEN, ETH_ALEN); | ||
1705 | sdata->u.mesh.mesh_seqnum++; | ||
1706 | meshhdrlen = 18; | ||
1707 | } | 1673 | } |
1708 | hdrlen = 30; | ||
1709 | break; | 1674 | break; |
1710 | #endif | 1675 | #endif |
1711 | case NL80211_IFTYPE_STATION: | 1676 | case NL80211_IFTYPE_STATION: |
@@ -1724,7 +1689,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1724 | hdrlen = 24; | 1689 | hdrlen = 24; |
1725 | break; | 1690 | break; |
1726 | default: | 1691 | default: |
1727 | ret = 0; | 1692 | ret = NETDEV_TX_OK; |
1728 | goto fail; | 1693 | goto fail; |
1729 | } | 1694 | } |
1730 | 1695 | ||
@@ -1766,7 +1731,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1766 | 1731 | ||
1767 | I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); | 1732 | I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); |
1768 | 1733 | ||
1769 | ret = 0; | 1734 | ret = NETDEV_TX_OK; |
1770 | goto fail; | 1735 | goto fail; |
1771 | } | 1736 | } |
1772 | 1737 | ||
@@ -1842,9 +1807,6 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1842 | nh_pos += hdrlen; | 1807 | nh_pos += hdrlen; |
1843 | h_pos += hdrlen; | 1808 | h_pos += hdrlen; |
1844 | 1809 | ||
1845 | skb->iif = dev->ifindex; | ||
1846 | |||
1847 | skb->dev = local->mdev; | ||
1848 | dev->stats.tx_packets++; | 1810 | dev->stats.tx_packets++; |
1849 | dev->stats.tx_bytes += skb->len; | 1811 | dev->stats.tx_bytes += skb->len; |
1850 | 1812 | ||
@@ -1855,13 +1817,15 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1855 | skb_set_network_header(skb, nh_pos); | 1817 | skb_set_network_header(skb, nh_pos); |
1856 | skb_set_transport_header(skb, h_pos); | 1818 | skb_set_transport_header(skb, h_pos); |
1857 | 1819 | ||
1820 | memset(info, 0, sizeof(*info)); | ||
1821 | |||
1858 | dev->trans_start = jiffies; | 1822 | dev->trans_start = jiffies; |
1859 | dev_queue_xmit(skb); | 1823 | ieee80211_xmit(sdata, skb); |
1860 | 1824 | ||
1861 | return 0; | 1825 | return NETDEV_TX_OK; |
1862 | 1826 | ||
1863 | fail: | 1827 | fail: |
1864 | if (!ret) | 1828 | if (ret == NETDEV_TX_OK) |
1865 | dev_kfree_skb(skb); | 1829 | dev_kfree_skb(skb); |
1866 | 1830 | ||
1867 | return ret; | 1831 | return ret; |
@@ -1887,101 +1851,74 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local, | |||
1887 | struct ieee80211_sub_if_data *sdata; | 1851 | struct ieee80211_sub_if_data *sdata; |
1888 | struct sta_info *sta; | 1852 | struct sta_info *sta; |
1889 | struct ieee80211_hdr *hdr; | 1853 | struct ieee80211_hdr *hdr; |
1890 | struct net_device *dev; | ||
1891 | int ret; | 1854 | int ret; |
1892 | bool result = true; | 1855 | bool result = true; |
1893 | 1856 | ||
1894 | /* does interface still exist? */ | 1857 | sdata = vif_to_sdata(info->control.vif); |
1895 | dev = dev_get_by_index(&init_net, skb->iif); | ||
1896 | if (!dev) { | ||
1897 | dev_kfree_skb(skb); | ||
1898 | return true; | ||
1899 | } | ||
1900 | |||
1901 | /* validate info->control.vif against skb->iif */ | ||
1902 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1903 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | ||
1904 | sdata = container_of(sdata->bss, | ||
1905 | struct ieee80211_sub_if_data, | ||
1906 | u.ap); | ||
1907 | |||
1908 | if (unlikely(info->control.vif && info->control.vif != &sdata->vif)) { | ||
1909 | dev_kfree_skb(skb); | ||
1910 | result = true; | ||
1911 | goto out; | ||
1912 | } | ||
1913 | 1858 | ||
1914 | if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { | 1859 | if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { |
1915 | ieee80211_tx(dev, skb, true); | 1860 | ieee80211_tx(sdata, skb, true); |
1916 | } else { | 1861 | } else { |
1917 | hdr = (struct ieee80211_hdr *)skb->data; | 1862 | hdr = (struct ieee80211_hdr *)skb->data; |
1918 | sta = sta_info_get(local, hdr->addr1); | 1863 | sta = sta_info_get(local, hdr->addr1); |
1919 | 1864 | ||
1920 | ret = __ieee80211_tx(local, &skb, sta); | 1865 | ret = __ieee80211_tx(local, &skb, sta, true); |
1921 | if (ret != IEEE80211_TX_OK) | 1866 | if (ret != IEEE80211_TX_OK) |
1922 | result = false; | 1867 | result = false; |
1923 | } | 1868 | } |
1924 | 1869 | ||
1925 | out: | ||
1926 | dev_put(dev); | ||
1927 | |||
1928 | return result; | 1870 | return result; |
1929 | } | 1871 | } |
1930 | 1872 | ||
1931 | /* | 1873 | /* |
1932 | * Transmit all pending packets. Called from tasklet, locks master device | 1874 | * Transmit all pending packets. Called from tasklet. |
1933 | * TX lock so that no new packets can come in. | ||
1934 | */ | 1875 | */ |
1935 | void ieee80211_tx_pending(unsigned long data) | 1876 | void ieee80211_tx_pending(unsigned long data) |
1936 | { | 1877 | { |
1937 | struct ieee80211_local *local = (struct ieee80211_local *)data; | 1878 | struct ieee80211_local *local = (struct ieee80211_local *)data; |
1938 | struct net_device *dev = local->mdev; | ||
1939 | unsigned long flags; | 1879 | unsigned long flags; |
1940 | int i; | 1880 | int i; |
1941 | bool next; | 1881 | bool txok; |
1942 | 1882 | ||
1943 | rcu_read_lock(); | 1883 | rcu_read_lock(); |
1944 | netif_tx_lock_bh(dev); | ||
1945 | 1884 | ||
1885 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | ||
1946 | for (i = 0; i < local->hw.queues; i++) { | 1886 | for (i = 0; i < local->hw.queues; i++) { |
1947 | /* | 1887 | /* |
1948 | * If queue is stopped by something other than due to pending | 1888 | * If queue is stopped by something other than due to pending |
1949 | * frames, or we have no pending frames, proceed to next queue. | 1889 | * frames, or we have no pending frames, proceed to next queue. |
1950 | */ | 1890 | */ |
1951 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 1891 | 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])) | 1892 | 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; | 1893 | continue; |
1961 | 1894 | ||
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])) { | 1895 | while (!skb_queue_empty(&local->pending[i])) { |
1970 | struct sk_buff *skb = skb_dequeue(&local->pending[i]); | 1896 | struct sk_buff *skb = __skb_dequeue(&local->pending[i]); |
1897 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1898 | struct ieee80211_sub_if_data *sdata; | ||
1971 | 1899 | ||
1972 | if (!ieee80211_tx_pending_skb(local, skb)) { | 1900 | if (WARN_ON(!info->control.vif)) { |
1973 | skb_queue_head(&local->pending[i], skb); | 1901 | kfree_skb(skb); |
1974 | break; | 1902 | continue; |
1975 | } | 1903 | } |
1976 | } | ||
1977 | 1904 | ||
1978 | /* Start regular packet processing again. */ | 1905 | sdata = vif_to_sdata(info->control.vif); |
1979 | if (skb_queue_empty(&local->pending[i])) | 1906 | dev_hold(sdata->dev); |
1980 | ieee80211_wake_queue_by_reason(&local->hw, i, | 1907 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, |
1981 | IEEE80211_QUEUE_STOP_REASON_PENDING); | 1908 | flags); |
1909 | |||
1910 | txok = ieee80211_tx_pending_skb(local, skb); | ||
1911 | dev_put(sdata->dev); | ||
1912 | if (!txok) | ||
1913 | __skb_queue_head(&local->pending[i], skb); | ||
1914 | spin_lock_irqsave(&local->queue_stop_reason_lock, | ||
1915 | flags); | ||
1916 | if (!txok) | ||
1917 | break; | ||
1918 | } | ||
1982 | } | 1919 | } |
1920 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
1983 | 1921 | ||
1984 | netif_tx_unlock_bh(dev); | ||
1985 | rcu_read_unlock(); | 1922 | rcu_read_unlock(); |
1986 | } | 1923 | } |
1987 | 1924 | ||
@@ -2156,8 +2093,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
2156 | 2093 | ||
2157 | info = IEEE80211_SKB_CB(skb); | 2094 | info = IEEE80211_SKB_CB(skb); |
2158 | 2095 | ||
2159 | skb->do_not_encrypt = 1; | 2096 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
2160 | |||
2161 | info->band = band; | 2097 | info->band = band; |
2162 | /* | 2098 | /* |
2163 | * XXX: For now, always use the lowest rate | 2099 | * XXX: For now, always use the lowest rate |
@@ -2228,9 +2164,6 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2228 | sdata = vif_to_sdata(vif); | 2164 | sdata = vif_to_sdata(vif); |
2229 | bss = &sdata->u.ap; | 2165 | bss = &sdata->u.ap; |
2230 | 2166 | ||
2231 | if (!bss) | ||
2232 | return NULL; | ||
2233 | |||
2234 | rcu_read_lock(); | 2167 | rcu_read_lock(); |
2235 | beacon = rcu_dereference(bss->beacon); | 2168 | beacon = rcu_dereference(bss->beacon); |
2236 | 2169 | ||
@@ -2256,7 +2189,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2256 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); | 2189 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
2257 | } | 2190 | } |
2258 | 2191 | ||
2259 | if (!ieee80211_tx_prepare(local, &tx, skb)) | 2192 | if (!ieee80211_tx_prepare(sdata, &tx, skb)) |
2260 | break; | 2193 | break; |
2261 | dev_kfree_skb_any(skb); | 2194 | dev_kfree_skb_any(skb); |
2262 | } | 2195 | } |
@@ -2276,3 +2209,24 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2276 | return skb; | 2209 | return skb; |
2277 | } | 2210 | } |
2278 | EXPORT_SYMBOL(ieee80211_get_buffered_bc); | 2211 | EXPORT_SYMBOL(ieee80211_get_buffered_bc); |
2212 | |||
2213 | void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | ||
2214 | int encrypt) | ||
2215 | { | ||
2216 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
2217 | skb_set_mac_header(skb, 0); | ||
2218 | skb_set_network_header(skb, 0); | ||
2219 | skb_set_transport_header(skb, 0); | ||
2220 | |||
2221 | if (!encrypt) | ||
2222 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
2223 | |||
2224 | /* | ||
2225 | * The other path calling ieee80211_xmit is from the tasklet, | ||
2226 | * and while we can handle concurrent transmissions locking | ||
2227 | * requirements are that we do not come into tx with bhs on. | ||
2228 | */ | ||
2229 | local_bh_disable(); | ||
2230 | ieee80211_xmit(sdata, skb); | ||
2231 | local_bh_enable(); | ||
2232 | } | ||
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 915e77769312..dd6564321369 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 */ |
36 | void *mac80211_wiphy_privid = &mac80211_wiphy_privid; | 37 | void *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 | ||
289 | void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, | 286 | void 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 | ||
@@ -347,11 +336,16 @@ void ieee80211_add_pending_skb(struct ieee80211_local *local, | |||
347 | struct ieee80211_hw *hw = &local->hw; | 336 | struct ieee80211_hw *hw = &local->hw; |
348 | unsigned long flags; | 337 | unsigned long flags; |
349 | int queue = skb_get_queue_mapping(skb); | 338 | int queue = skb_get_queue_mapping(skb); |
339 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
340 | |||
341 | if (WARN_ON(!info->control.vif)) { | ||
342 | kfree(skb); | ||
343 | return; | ||
344 | } | ||
350 | 345 | ||
351 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 346 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
352 | __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); | 347 | __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); |
353 | __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_PENDING); | 348 | __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); | 349 | __ieee80211_wake_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); |
356 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | 350 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); |
357 | } | 351 | } |
@@ -370,18 +364,21 @@ int ieee80211_add_pending_skbs(struct ieee80211_local *local, | |||
370 | IEEE80211_QUEUE_STOP_REASON_SKB_ADD); | 364 | IEEE80211_QUEUE_STOP_REASON_SKB_ADD); |
371 | 365 | ||
372 | while ((skb = skb_dequeue(skbs))) { | 366 | while ((skb = skb_dequeue(skbs))) { |
367 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
368 | |||
369 | if (WARN_ON(!info->control.vif)) { | ||
370 | kfree(skb); | ||
371 | continue; | ||
372 | } | ||
373 | |||
373 | ret++; | 374 | ret++; |
374 | queue = skb_get_queue_mapping(skb); | 375 | queue = skb_get_queue_mapping(skb); |
375 | skb_queue_tail(&local->pending[queue], skb); | 376 | __skb_queue_tail(&local->pending[queue], skb); |
376 | } | 377 | } |
377 | 378 | ||
378 | for (i = 0; i < hw->queues; i++) { | 379 | 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, | 380 | __ieee80211_wake_queue(hw, i, |
383 | IEEE80211_QUEUE_STOP_REASON_SKB_ADD); | 381 | IEEE80211_QUEUE_STOP_REASON_SKB_ADD); |
384 | } | ||
385 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | 382 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); |
386 | 383 | ||
387 | return ret; | 384 | return ret; |
@@ -412,11 +409,16 @@ EXPORT_SYMBOL(ieee80211_stop_queues); | |||
412 | int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue) | 409 | int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue) |
413 | { | 410 | { |
414 | struct ieee80211_local *local = hw_to_local(hw); | 411 | struct ieee80211_local *local = hw_to_local(hw); |
412 | unsigned long flags; | ||
413 | int ret; | ||
415 | 414 | ||
416 | if (WARN_ON(queue >= hw->queues)) | 415 | if (WARN_ON(queue >= hw->queues)) |
417 | return true; | 416 | return true; |
418 | 417 | ||
419 | return __netif_subqueue_stopped(local->mdev, queue); | 418 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
419 | ret = !!local->queue_stop_reasons[queue]; | ||
420 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
421 | return ret; | ||
420 | } | 422 | } |
421 | EXPORT_SYMBOL(ieee80211_queue_stopped); | 423 | EXPORT_SYMBOL(ieee80211_queue_stopped); |
422 | 424 | ||
@@ -509,6 +511,46 @@ void ieee80211_iterate_active_interfaces_atomic( | |||
509 | } | 511 | } |
510 | EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic); | 512 | EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic); |
511 | 513 | ||
514 | /* | ||
515 | * Nothing should have been stuffed into the workqueue during | ||
516 | * the suspend->resume cycle. If this WARN is seen then there | ||
517 | * is a bug with either the driver suspend or something in | ||
518 | * mac80211 stuffing into the workqueue which we haven't yet | ||
519 | * cleared during mac80211's suspend cycle. | ||
520 | */ | ||
521 | static bool ieee80211_can_queue_work(struct ieee80211_local *local) | ||
522 | { | ||
523 | if (WARN(local->suspended, "queueing ieee80211 work while " | ||
524 | "going to suspend\n")) | ||
525 | return false; | ||
526 | |||
527 | return true; | ||
528 | } | ||
529 | |||
530 | void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work) | ||
531 | { | ||
532 | struct ieee80211_local *local = hw_to_local(hw); | ||
533 | |||
534 | if (!ieee80211_can_queue_work(local)) | ||
535 | return; | ||
536 | |||
537 | queue_work(local->workqueue, work); | ||
538 | } | ||
539 | EXPORT_SYMBOL(ieee80211_queue_work); | ||
540 | |||
541 | void ieee80211_queue_delayed_work(struct ieee80211_hw *hw, | ||
542 | struct delayed_work *dwork, | ||
543 | unsigned long delay) | ||
544 | { | ||
545 | struct ieee80211_local *local = hw_to_local(hw); | ||
546 | |||
547 | if (!ieee80211_can_queue_work(local)) | ||
548 | return; | ||
549 | |||
550 | queue_delayed_work(local->workqueue, dwork, delay); | ||
551 | } | ||
552 | EXPORT_SYMBOL(ieee80211_queue_delayed_work); | ||
553 | |||
512 | void ieee802_11_parse_elems(u8 *start, size_t len, | 554 | void ieee802_11_parse_elems(u8 *start, size_t len, |
513 | struct ieee802_11_elems *elems) | 555 | struct ieee802_11_elems *elems) |
514 | { | 556 | { |
@@ -760,20 +802,6 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, | |||
760 | ieee80211_set_wmm_default(sdata); | 802 | ieee80211_set_wmm_default(sdata); |
761 | } | 803 | } |
762 | 804 | ||
763 | void 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 | |||
777 | u32 ieee80211_mandatory_rates(struct ieee80211_local *local, | 805 | u32 ieee80211_mandatory_rates(struct ieee80211_local *local, |
778 | enum ieee80211_band band) | 806 | enum ieee80211_band band) |
779 | { | 807 | { |
@@ -804,12 +832,13 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local, | |||
804 | 832 | ||
805 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | 833 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, |
806 | u16 transaction, u16 auth_alg, | 834 | u16 transaction, u16 auth_alg, |
807 | u8 *extra, size_t extra_len, | 835 | u8 *extra, size_t extra_len, const u8 *bssid, |
808 | const u8 *bssid, int encrypt) | 836 | const u8 *key, u8 key_len, u8 key_idx) |
809 | { | 837 | { |
810 | struct ieee80211_local *local = sdata->local; | 838 | struct ieee80211_local *local = sdata->local; |
811 | struct sk_buff *skb; | 839 | struct sk_buff *skb; |
812 | struct ieee80211_mgmt *mgmt; | 840 | struct ieee80211_mgmt *mgmt; |
841 | int err; | ||
813 | 842 | ||
814 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | 843 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
815 | sizeof(*mgmt) + 6 + extra_len); | 844 | sizeof(*mgmt) + 6 + extra_len); |
@@ -824,8 +853,6 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | |||
824 | memset(mgmt, 0, 24 + 6); | 853 | memset(mgmt, 0, 24 + 6); |
825 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 854 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
826 | IEEE80211_STYPE_AUTH); | 855 | IEEE80211_STYPE_AUTH); |
827 | if (encrypt) | ||
828 | mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); | ||
829 | memcpy(mgmt->da, bssid, ETH_ALEN); | 856 | memcpy(mgmt->da, bssid, ETH_ALEN); |
830 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 857 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
831 | memcpy(mgmt->bssid, bssid, ETH_ALEN); | 858 | memcpy(mgmt->bssid, bssid, ETH_ALEN); |
@@ -835,7 +862,13 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | |||
835 | if (extra) | 862 | if (extra) |
836 | memcpy(skb_put(skb, extra_len), extra, extra_len); | 863 | memcpy(skb_put(skb, extra_len), extra, extra_len); |
837 | 864 | ||
838 | ieee80211_tx_skb(sdata, skb, encrypt); | 865 | if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) { |
866 | mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); | ||
867 | err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx); | ||
868 | WARN_ON(err); | ||
869 | } | ||
870 | |||
871 | ieee80211_tx_skb(sdata, skb, 0); | ||
839 | } | 872 | } |
840 | 873 | ||
841 | int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, | 874 | int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, |
@@ -974,6 +1007,16 @@ u32 ieee80211_sta_get_rates(struct ieee80211_local *local, | |||
974 | return supp_rates; | 1007 | return supp_rates; |
975 | } | 1008 | } |
976 | 1009 | ||
1010 | void ieee80211_stop_device(struct ieee80211_local *local) | ||
1011 | { | ||
1012 | ieee80211_led_radio(local, false); | ||
1013 | |||
1014 | cancel_work_sync(&local->reconfig_filter); | ||
1015 | drv_stop(local); | ||
1016 | |||
1017 | flush_workqueue(local->workqueue); | ||
1018 | } | ||
1019 | |||
977 | int ieee80211_reconfig(struct ieee80211_local *local) | 1020 | int ieee80211_reconfig(struct ieee80211_local *local) |
978 | { | 1021 | { |
979 | struct ieee80211_hw *hw = &local->hw; | 1022 | struct ieee80211_hw *hw = &local->hw; |
@@ -1043,9 +1086,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1043 | /* reconfigure hardware */ | 1086 | /* reconfigure hardware */ |
1044 | ieee80211_hw_config(local, ~0); | 1087 | ieee80211_hw_config(local, ~0); |
1045 | 1088 | ||
1046 | netif_addr_lock_bh(local->mdev); | ||
1047 | ieee80211_configure_filter(local); | 1089 | ieee80211_configure_filter(local); |
1048 | netif_addr_unlock_bh(local->mdev); | ||
1049 | 1090 | ||
1050 | /* Finally also reconfigure all the BSS information */ | 1091 | /* Finally also reconfigure all the BSS information */ |
1051 | list_for_each_entry(sdata, &local->interfaces, list) { | 1092 | list_for_each_entry(sdata, &local->interfaces, list) { |
@@ -1121,3 +1162,4 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1121 | #endif | 1162 | #endif |
1122 | return 0; | 1163 | return 0; |
1123 | } | 1164 | } |
1165 | |||
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 | ||
69 | static void ieee80211_wep_get_iv(struct ieee80211_local *local, | 69 | static 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 | ||
86 | static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, | 86 | static 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 | */ |
147 | int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb, | 147 | int 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 | */ |
219 | int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, | 208 | static 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); | |||
20 | void ieee80211_wep_free(struct ieee80211_local *local); | 20 | void ieee80211_wep_free(struct ieee80211_local *local); |
21 | void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key, | 21 | void 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); |
23 | int ieee80211_wep_encrypt(struct ieee80211_local *local, | ||
24 | struct sk_buff *skb, | ||
25 | const u8 *key, int keylen, int keyidx); | ||
23 | int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key, | 26 | int 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); |
25 | int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb, | ||
26 | struct ieee80211_key *key); | ||
27 | int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, | ||
28 | struct ieee80211_key *key); | ||
29 | bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); | 28 | bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); |
30 | 29 | ||
31 | ieee80211_rx_result | 30 | ieee80211_rx_result |
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c deleted file mode 100644 index 1da81f456744..000000000000 --- a/net/mac80211/wext.c +++ /dev/null | |||
@@ -1,633 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | ||
3 | * Copyright 2005-2006, Devicescape Software, Inc. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/netdevice.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/skbuff.h> | ||
16 | #include <linux/etherdevice.h> | ||
17 | #include <linux/if_arp.h> | ||
18 | #include <linux/wireless.h> | ||
19 | #include <net/iw_handler.h> | ||
20 | #include <asm/uaccess.h> | ||
21 | |||
22 | #include <net/mac80211.h> | ||
23 | #include "ieee80211_i.h" | ||
24 | #include "led.h" | ||
25 | #include "rate.h" | ||
26 | #include "wpa.h" | ||
27 | #include "aes_ccm.h" | ||
28 | |||
29 | |||
30 | static 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 | |||
53 | static int ieee80211_ioctl_siwfreq(struct net_device *dev, | ||
54 | struct iw_request_info *info, | ||
55 | struct iw_freq *freq, char *extra) | ||
56 | { | ||
57 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
58 | struct ieee80211_local *local = sdata->local; | ||
59 | struct ieee80211_channel *chan; | ||
60 | |||
61 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | ||
62 | return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra); | ||
63 | else if (sdata->vif.type == NL80211_IFTYPE_STATION) | ||
64 | sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL; | ||
65 | |||
66 | /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */ | ||
67 | if (freq->e == 0) { | ||
68 | if (freq->m < 0) { | ||
69 | if (sdata->vif.type == NL80211_IFTYPE_STATION) | ||
70 | sdata->u.mgd.flags |= | ||
71 | IEEE80211_STA_AUTO_CHANNEL_SEL; | ||
72 | return 0; | ||
73 | } else | ||
74 | chan = ieee80211_get_channel(local->hw.wiphy, | ||
75 | ieee80211_channel_to_frequency(freq->m)); | ||
76 | } else { | ||
77 | int i, div = 1000000; | ||
78 | for (i = 0; i < freq->e; i++) | ||
79 | div /= 10; | ||
80 | if (div <= 0) | ||
81 | return -EINVAL; | ||
82 | chan = ieee80211_get_channel(local->hw.wiphy, freq->m / div); | ||
83 | } | ||
84 | |||
85 | if (!chan) | ||
86 | return -EINVAL; | ||
87 | |||
88 | if (chan->flags & IEEE80211_CHAN_DISABLED) | ||
89 | return -EINVAL; | ||
90 | |||
91 | /* | ||
92 | * no change except maybe auto -> fixed, ignore the HT | ||
93 | * setting so you can fix a channel you're on already | ||
94 | */ | ||
95 | if (local->oper_channel == chan) | ||
96 | return 0; | ||
97 | |||
98 | if (sdata->vif.type == NL80211_IFTYPE_STATION) | ||
99 | ieee80211_sta_req_auth(sdata); | ||
100 | |||
101 | local->oper_channel = chan; | ||
102 | local->oper_channel_type = NL80211_CHAN_NO_HT; | ||
103 | ieee80211_hw_config(local, 0); | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | |||
109 | static int ieee80211_ioctl_giwfreq(struct net_device *dev, | ||
110 | struct iw_request_info *info, | ||
111 | struct iw_freq *freq, char *extra) | ||
112 | { | ||
113 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
114 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
115 | |||
116 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | ||
117 | return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); | ||
118 | |||
119 | freq->m = local->oper_channel->center_freq; | ||
120 | freq->e = 6; | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | |||
126 | static int ieee80211_ioctl_siwessid(struct net_device *dev, | ||
127 | struct iw_request_info *info, | ||
128 | struct iw_point *data, char *ssid) | ||
129 | { | ||
130 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
131 | size_t len = data->length; | ||
132 | int ret; | ||
133 | |||
134 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | ||
135 | return cfg80211_ibss_wext_siwessid(dev, info, data, ssid); | ||
136 | |||
137 | /* iwconfig uses nul termination in 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 | |||
157 | return -EOPNOTSUPP; | ||
158 | } | ||
159 | |||
160 | |||
161 | static int ieee80211_ioctl_giwessid(struct net_device *dev, | ||
162 | struct iw_request_info *info, | ||
163 | struct iw_point *data, char *ssid) | ||
164 | { | ||
165 | size_t len; | ||
166 | struct ieee80211_sub_if_data *sdata; | ||
167 | |||
168 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
169 | |||
170 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | ||
171 | return cfg80211_ibss_wext_giwessid(dev, info, data, ssid); | ||
172 | |||
173 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
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 | |||
183 | return -EOPNOTSUPP; | ||
184 | } | ||
185 | |||
186 | |||
187 | static int ieee80211_ioctl_siwap(struct net_device *dev, | ||
188 | struct iw_request_info *info, | ||
189 | struct sockaddr *ap_addr, char *extra) | ||
190 | { | ||
191 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
192 | |||
193 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | ||
194 | return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra); | ||
195 | |||
196 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
197 | int ret; | ||
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 | |||
230 | return -EOPNOTSUPP; | ||
231 | } | ||
232 | |||
233 | |||
234 | static int ieee80211_ioctl_giwap(struct net_device *dev, | ||
235 | struct iw_request_info *info, | ||
236 | struct sockaddr *ap_addr, char *extra) | ||
237 | { | ||
238 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
239 | |||
240 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) | ||
241 | return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra); | ||
242 | |||
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 | |||
260 | static 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 | |||
297 | static 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 | |||
332 | static 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 | |||
386 | static 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 | |||
398 | static 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 */ | ||
478 | static 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) | ||
488 | sta = sta_info_get(local, sdata->u.mgd.bssid); | ||
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 | |||
539 | rcu_read_unlock(); | ||
540 | |||
541 | return wstats; | ||
542 | } | ||
543 | |||
544 | static int ieee80211_ioctl_giwauth(struct net_device *dev, | ||
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 | } | ||
564 | |||
565 | |||
566 | /* Structures to export the Wireless Handlers */ | ||
567 | |||
568 | static const iw_handler ieee80211_handler[] = | ||
569 | { | ||
570 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ | ||
571 | (iw_handler) cfg80211_wext_giwname, /* SIOCGIWNAME */ | ||
572 | (iw_handler) NULL, /* SIOCSIWNWID */ | ||
573 | (iw_handler) NULL, /* SIOCGIWNWID */ | ||
574 | (iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */ | ||
575 | (iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */ | ||
576 | (iw_handler) cfg80211_wext_siwmode, /* SIOCSIWMODE */ | ||
577 | (iw_handler) cfg80211_wext_giwmode, /* SIOCGIWMODE */ | ||
578 | (iw_handler) NULL, /* SIOCSIWSENS */ | ||
579 | (iw_handler) NULL, /* SIOCGIWSENS */ | ||
580 | (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */ | ||
581 | (iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */ | ||
582 | (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */ | ||
583 | (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */ | ||
584 | (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */ | ||
585 | (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */ | ||
586 | (iw_handler) NULL, /* SIOCSIWSPY */ | ||
587 | (iw_handler) NULL, /* SIOCGIWSPY */ | ||
588 | (iw_handler) NULL, /* SIOCSIWTHRSPY */ | ||
589 | (iw_handler) NULL, /* SIOCGIWTHRSPY */ | ||
590 | (iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */ | ||
591 | (iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */ | ||
592 | (iw_handler) cfg80211_wext_siwmlme, /* SIOCSIWMLME */ | ||
593 | (iw_handler) NULL, /* SIOCGIWAPLIST */ | ||
594 | (iw_handler) cfg80211_wext_siwscan, /* SIOCSIWSCAN */ | ||
595 | (iw_handler) cfg80211_wext_giwscan, /* SIOCGIWSCAN */ | ||
596 | (iw_handler) ieee80211_ioctl_siwessid, /* SIOCSIWESSID */ | ||
597 | (iw_handler) ieee80211_ioctl_giwessid, /* SIOCGIWESSID */ | ||
598 | (iw_handler) NULL, /* SIOCSIWNICKN */ | ||
599 | (iw_handler) NULL, /* SIOCGIWNICKN */ | ||
600 | (iw_handler) NULL, /* -- hole -- */ | ||
601 | (iw_handler) NULL, /* -- hole -- */ | ||
602 | (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */ | ||
603 | (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */ | ||
604 | (iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */ | ||
605 | (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */ | ||
606 | (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */ | ||
607 | (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */ | ||
608 | (iw_handler) cfg80211_wext_siwtxpower, /* SIOCSIWTXPOW */ | ||
609 | (iw_handler) cfg80211_wext_giwtxpower, /* SIOCGIWTXPOW */ | ||
610 | (iw_handler) cfg80211_wext_siwretry, /* SIOCSIWRETRY */ | ||
611 | (iw_handler) cfg80211_wext_giwretry, /* SIOCGIWRETRY */ | ||
612 | (iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */ | ||
613 | (iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */ | ||
614 | (iw_handler) ieee80211_ioctl_siwpower, /* SIOCSIWPOWER */ | ||
615 | (iw_handler) ieee80211_ioctl_giwpower, /* SIOCGIWPOWER */ | ||
616 | (iw_handler) NULL, /* -- hole -- */ | ||
617 | (iw_handler) NULL, /* -- hole -- */ | ||
618 | (iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */ | ||
619 | (iw_handler) NULL, /* SIOCGIWGENIE */ | ||
620 | (iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */ | ||
621 | (iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */ | ||
622 | (iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */ | ||
623 | (iw_handler) NULL, /* SIOCGIWENCODEEXT */ | ||
624 | (iw_handler) NULL, /* SIOCSIWPMKSA */ | ||
625 | (iw_handler) NULL, /* -- hole -- */ | ||
626 | }; | ||
627 | |||
628 | const struct iw_handler_def ieee80211_iw_handler_def = | ||
629 | { | ||
630 | .num_standard = ARRAY_SIZE(ieee80211_handler), | ||
631 | .standard = (iw_handler *) ieee80211_handler, | ||
632 | .get_wireless_stats = ieee80211_get_wireless_stats, | ||
633 | }; | ||
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 | ||
88 | u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb) | 88 | void 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 | ||
21 | extern const int ieee802_1d_to_ac[8]; | 21 | extern const int ieee802_1d_to_ac[8]; |
22 | 22 | ||
23 | u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb); | 23 | void 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 | ||