diff options
author | David S. Miller <davem@davemloft.net> | 2008-02-29 16:41:25 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-29 16:41:25 -0500 |
commit | 4a80f2788952055a627f2093a0174537d70aec1b (patch) | |
tree | 411c8ec555fe85cf9faa9da90e62ab781b33661c /net | |
parent | 03a64c93b68e1eff299b9bbbb0d13105171cddc4 (diff) | |
parent | e4861829072c61883114c64a3af61f305a789ff0 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.26
Diffstat (limited to 'net')
34 files changed, 3201 insertions, 1946 deletions
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index 54f46bc80cfe..9d7a19581a29 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile | |||
@@ -19,7 +19,6 @@ mac80211-y := \ | |||
19 | ieee80211_iface.o \ | 19 | ieee80211_iface.o \ |
20 | ieee80211_rate.o \ | 20 | ieee80211_rate.o \ |
21 | michael.o \ | 21 | michael.o \ |
22 | regdomain.o \ | ||
23 | tkip.o \ | 22 | tkip.o \ |
24 | aes_ccm.o \ | 23 | aes_ccm.o \ |
25 | cfg.o \ | 24 | cfg.o \ |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 22c9619ba776..e7535ffc8e1c 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -34,10 +34,13 @@ nl80211_type_to_mac80211_type(enum nl80211_iftype type) | |||
34 | } | 34 | } |
35 | 35 | ||
36 | static int ieee80211_add_iface(struct wiphy *wiphy, char *name, | 36 | static int ieee80211_add_iface(struct wiphy *wiphy, char *name, |
37 | enum nl80211_iftype type) | 37 | enum nl80211_iftype type, u32 *flags) |
38 | { | 38 | { |
39 | struct ieee80211_local *local = wiphy_priv(wiphy); | 39 | struct ieee80211_local *local = wiphy_priv(wiphy); |
40 | enum ieee80211_if_types itype; | 40 | enum ieee80211_if_types itype; |
41 | struct net_device *dev; | ||
42 | struct ieee80211_sub_if_data *sdata; | ||
43 | int err; | ||
41 | 44 | ||
42 | if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) | 45 | if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) |
43 | return -ENODEV; | 46 | return -ENODEV; |
@@ -46,7 +49,13 @@ static int ieee80211_add_iface(struct wiphy *wiphy, char *name, | |||
46 | if (itype == IEEE80211_IF_TYPE_INVALID) | 49 | if (itype == IEEE80211_IF_TYPE_INVALID) |
47 | return -EINVAL; | 50 | return -EINVAL; |
48 | 51 | ||
49 | return ieee80211_if_add(local->mdev, name, NULL, itype); | 52 | err = ieee80211_if_add(local->mdev, name, &dev, itype); |
53 | if (err || itype != IEEE80211_IF_TYPE_MNTR || !flags) | ||
54 | return err; | ||
55 | |||
56 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
57 | sdata->u.mntr_flags = *flags; | ||
58 | return 0; | ||
50 | } | 59 | } |
51 | 60 | ||
52 | static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) | 61 | static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) |
@@ -69,7 +78,7 @@ static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) | |||
69 | } | 78 | } |
70 | 79 | ||
71 | static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, | 80 | static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, |
72 | enum nl80211_iftype type) | 81 | enum nl80211_iftype type, u32 *flags) |
73 | { | 82 | { |
74 | struct ieee80211_local *local = wiphy_priv(wiphy); | 83 | struct ieee80211_local *local = wiphy_priv(wiphy); |
75 | struct net_device *dev; | 84 | struct net_device *dev; |
@@ -99,6 +108,10 @@ static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, | |||
99 | ieee80211_if_reinit(dev); | 108 | ieee80211_if_reinit(dev); |
100 | ieee80211_if_set_type(dev, itype); | 109 | ieee80211_if_set_type(dev, itype); |
101 | 110 | ||
111 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || !flags) | ||
112 | return 0; | ||
113 | |||
114 | sdata->u.mntr_flags = *flags; | ||
102 | return 0; | 115 | return 0; |
103 | } | 116 | } |
104 | 117 | ||
@@ -110,6 +123,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
110 | struct sta_info *sta = NULL; | 123 | struct sta_info *sta = NULL; |
111 | enum ieee80211_key_alg alg; | 124 | enum ieee80211_key_alg alg; |
112 | int ret; | 125 | int ret; |
126 | struct ieee80211_key *key; | ||
113 | 127 | ||
114 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 128 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
115 | 129 | ||
@@ -128,16 +142,21 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
128 | return -EINVAL; | 142 | return -EINVAL; |
129 | } | 143 | } |
130 | 144 | ||
145 | key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key); | ||
146 | if (!key) | ||
147 | return -ENOMEM; | ||
148 | |||
131 | if (mac_addr) { | 149 | if (mac_addr) { |
132 | sta = sta_info_get(sdata->local, mac_addr); | 150 | sta = sta_info_get(sdata->local, mac_addr); |
133 | if (!sta) | 151 | if (!sta) { |
152 | ieee80211_key_free(key); | ||
134 | return -ENOENT; | 153 | return -ENOENT; |
154 | } | ||
135 | } | 155 | } |
136 | 156 | ||
157 | ieee80211_key_link(key, sdata, sta); | ||
158 | |||
137 | ret = 0; | 159 | ret = 0; |
138 | if (!ieee80211_key_alloc(sdata, sta, alg, key_idx, | ||
139 | params->key_len, params->key)) | ||
140 | ret = -ENOMEM; | ||
141 | 160 | ||
142 | if (sta) | 161 | if (sta) |
143 | sta_info_put(sta); | 162 | sta_info_put(sta); |
@@ -151,6 +170,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |||
151 | struct ieee80211_sub_if_data *sdata; | 170 | struct ieee80211_sub_if_data *sdata; |
152 | struct sta_info *sta; | 171 | struct sta_info *sta; |
153 | int ret; | 172 | int ret; |
173 | struct ieee80211_key *key; | ||
154 | 174 | ||
155 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 175 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
156 | 176 | ||
@@ -160,9 +180,11 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |||
160 | return -ENOENT; | 180 | return -ENOENT; |
161 | 181 | ||
162 | ret = 0; | 182 | ret = 0; |
163 | if (sta->key) | 183 | if (sta->key) { |
164 | ieee80211_key_free(sta->key); | 184 | key = sta->key; |
165 | else | 185 | ieee80211_key_free(key); |
186 | WARN_ON(sta->key); | ||
187 | } else | ||
166 | ret = -ENOENT; | 188 | ret = -ENOENT; |
167 | 189 | ||
168 | sta_info_put(sta); | 190 | sta_info_put(sta); |
@@ -172,7 +194,9 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |||
172 | if (!sdata->keys[key_idx]) | 194 | if (!sdata->keys[key_idx]) |
173 | return -ENOENT; | 195 | return -ENOENT; |
174 | 196 | ||
175 | ieee80211_key_free(sdata->keys[key_idx]); | 197 | key = sdata->keys[key_idx]; |
198 | ieee80211_key_free(key); | ||
199 | WARN_ON(sdata->keys[key_idx]); | ||
176 | 200 | ||
177 | return 0; | 201 | return 0; |
178 | } | 202 | } |
@@ -498,7 +522,7 @@ static void sta_apply_parameters(struct ieee80211_local *local, | |||
498 | { | 522 | { |
499 | u32 rates; | 523 | u32 rates; |
500 | int i, j; | 524 | int i, j; |
501 | struct ieee80211_hw_mode *mode; | 525 | struct ieee80211_supported_band *sband; |
502 | 526 | ||
503 | if (params->station_flags & STATION_FLAG_CHANGED) { | 527 | if (params->station_flags & STATION_FLAG_CHANGED) { |
504 | sta->flags &= ~WLAN_STA_AUTHORIZED; | 528 | sta->flags &= ~WLAN_STA_AUTHORIZED; |
@@ -525,15 +549,16 @@ static void sta_apply_parameters(struct ieee80211_local *local, | |||
525 | 549 | ||
526 | if (params->supported_rates) { | 550 | if (params->supported_rates) { |
527 | rates = 0; | 551 | rates = 0; |
528 | mode = local->oper_hw_mode; | 552 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
553 | |||
529 | for (i = 0; i < params->supported_rates_len; i++) { | 554 | for (i = 0; i < params->supported_rates_len; i++) { |
530 | int rate = (params->supported_rates[i] & 0x7f) * 5; | 555 | int rate = (params->supported_rates[i] & 0x7f) * 5; |
531 | for (j = 0; j < mode->num_rates; j++) { | 556 | for (j = 0; j < sband->n_bitrates; j++) { |
532 | if (mode->rates[j].rate == rate) | 557 | if (sband->bitrates[j].bitrate == rate) |
533 | rates |= BIT(j); | 558 | rates |= BIT(j); |
534 | } | 559 | } |
535 | } | 560 | } |
536 | sta->supp_rates = rates; | 561 | sta->supp_rates[local->oper_channel->band] = rates; |
537 | } | 562 | } |
538 | } | 563 | } |
539 | 564 | ||
@@ -548,13 +573,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |||
548 | if (!netif_running(dev)) | 573 | if (!netif_running(dev)) |
549 | return -ENETDOWN; | 574 | return -ENETDOWN; |
550 | 575 | ||
551 | /* XXX: get sta belonging to dev */ | ||
552 | sta = sta_info_get(local, mac); | ||
553 | if (sta) { | ||
554 | sta_info_put(sta); | ||
555 | return -EEXIST; | ||
556 | } | ||
557 | |||
558 | if (params->vlan) { | 576 | if (params->vlan) { |
559 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); | 577 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
560 | 578 | ||
@@ -565,8 +583,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |||
565 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 583 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
566 | 584 | ||
567 | sta = sta_info_add(local, dev, mac, GFP_KERNEL); | 585 | sta = sta_info_add(local, dev, mac, GFP_KERNEL); |
568 | if (!sta) | 586 | if (IS_ERR(sta)) |
569 | return -ENOMEM; | 587 | return PTR_ERR(sta); |
570 | 588 | ||
571 | sta->dev = sdata->dev; | 589 | sta->dev = sdata->dev; |
572 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN || | 590 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN || |
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 60514b2c97b9..4736c64937b4 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c | |||
@@ -19,41 +19,6 @@ int mac80211_open_file_generic(struct inode *inode, struct file *file) | |||
19 | return 0; | 19 | return 0; |
20 | } | 20 | } |
21 | 21 | ||
22 | static const char *ieee80211_mode_str(int mode) | ||
23 | { | ||
24 | switch (mode) { | ||
25 | case MODE_IEEE80211A: | ||
26 | return "IEEE 802.11a"; | ||
27 | case MODE_IEEE80211B: | ||
28 | return "IEEE 802.11b"; | ||
29 | case MODE_IEEE80211G: | ||
30 | return "IEEE 802.11g"; | ||
31 | default: | ||
32 | return "UNKNOWN"; | ||
33 | } | ||
34 | } | ||
35 | |||
36 | static ssize_t modes_read(struct file *file, char __user *userbuf, | ||
37 | size_t count, loff_t *ppos) | ||
38 | { | ||
39 | struct ieee80211_local *local = file->private_data; | ||
40 | struct ieee80211_hw_mode *mode; | ||
41 | char buf[150], *p = buf; | ||
42 | |||
43 | /* FIXME: locking! */ | ||
44 | list_for_each_entry(mode, &local->modes_list, list) { | ||
45 | p += scnprintf(p, sizeof(buf)+buf-p, | ||
46 | "%s\n", ieee80211_mode_str(mode->mode)); | ||
47 | } | ||
48 | |||
49 | return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf); | ||
50 | } | ||
51 | |||
52 | static const struct file_operations modes_ops = { | ||
53 | .read = modes_read, | ||
54 | .open = mac80211_open_file_generic, | ||
55 | }; | ||
56 | |||
57 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ | 22 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ |
58 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ | 23 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
59 | size_t count, loff_t *ppos) \ | 24 | size_t count, loff_t *ppos) \ |
@@ -80,10 +45,8 @@ static const struct file_operations name## _ops = { \ | |||
80 | local->debugfs.name = NULL; | 45 | local->debugfs.name = NULL; |
81 | 46 | ||
82 | 47 | ||
83 | DEBUGFS_READONLY_FILE(channel, 20, "%d", | ||
84 | local->hw.conf.channel); | ||
85 | DEBUGFS_READONLY_FILE(frequency, 20, "%d", | 48 | DEBUGFS_READONLY_FILE(frequency, 20, "%d", |
86 | local->hw.conf.freq); | 49 | local->hw.conf.channel->center_freq); |
87 | DEBUGFS_READONLY_FILE(antenna_sel_tx, 20, "%d", | 50 | DEBUGFS_READONLY_FILE(antenna_sel_tx, 20, "%d", |
88 | local->hw.conf.antenna_sel_tx); | 51 | local->hw.conf.antenna_sel_tx); |
89 | DEBUGFS_READONLY_FILE(antenna_sel_rx, 20, "%d", | 52 | DEBUGFS_READONLY_FILE(antenna_sel_rx, 20, "%d", |
@@ -100,8 +63,6 @@ DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d", | |||
100 | local->long_retry_limit); | 63 | local->long_retry_limit); |
101 | DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d", | 64 | DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d", |
102 | local->total_ps_buffered); | 65 | local->total_ps_buffered); |
103 | DEBUGFS_READONLY_FILE(mode, 20, "%s", | ||
104 | ieee80211_mode_str(local->hw.conf.phymode)); | ||
105 | DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x", | 66 | DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x", |
106 | local->wep_iv & 0xffffff); | 67 | local->wep_iv & 0xffffff); |
107 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s", | 68 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s", |
@@ -294,7 +255,6 @@ void debugfs_hw_add(struct ieee80211_local *local) | |||
294 | local->debugfs.stations = debugfs_create_dir("stations", phyd); | 255 | local->debugfs.stations = debugfs_create_dir("stations", phyd); |
295 | local->debugfs.keys = debugfs_create_dir("keys", phyd); | 256 | local->debugfs.keys = debugfs_create_dir("keys", phyd); |
296 | 257 | ||
297 | DEBUGFS_ADD(channel); | ||
298 | DEBUGFS_ADD(frequency); | 258 | DEBUGFS_ADD(frequency); |
299 | DEBUGFS_ADD(antenna_sel_tx); | 259 | DEBUGFS_ADD(antenna_sel_tx); |
300 | DEBUGFS_ADD(antenna_sel_rx); | 260 | DEBUGFS_ADD(antenna_sel_rx); |
@@ -304,9 +264,7 @@ void debugfs_hw_add(struct ieee80211_local *local) | |||
304 | DEBUGFS_ADD(short_retry_limit); | 264 | DEBUGFS_ADD(short_retry_limit); |
305 | DEBUGFS_ADD(long_retry_limit); | 265 | DEBUGFS_ADD(long_retry_limit); |
306 | DEBUGFS_ADD(total_ps_buffered); | 266 | DEBUGFS_ADD(total_ps_buffered); |
307 | DEBUGFS_ADD(mode); | ||
308 | DEBUGFS_ADD(wep_iv); | 267 | DEBUGFS_ADD(wep_iv); |
309 | DEBUGFS_ADD(modes); | ||
310 | 268 | ||
311 | statsd = debugfs_create_dir("statistics", phyd); | 269 | statsd = debugfs_create_dir("statistics", phyd); |
312 | local->debugfs.statistics = statsd; | 270 | local->debugfs.statistics = statsd; |
@@ -356,7 +314,6 @@ void debugfs_hw_add(struct ieee80211_local *local) | |||
356 | 314 | ||
357 | void debugfs_hw_del(struct ieee80211_local *local) | 315 | void debugfs_hw_del(struct ieee80211_local *local) |
358 | { | 316 | { |
359 | DEBUGFS_DEL(channel); | ||
360 | DEBUGFS_DEL(frequency); | 317 | DEBUGFS_DEL(frequency); |
361 | DEBUGFS_DEL(antenna_sel_tx); | 318 | DEBUGFS_DEL(antenna_sel_tx); |
362 | DEBUGFS_DEL(antenna_sel_rx); | 319 | DEBUGFS_DEL(antenna_sel_rx); |
@@ -366,9 +323,7 @@ void debugfs_hw_del(struct ieee80211_local *local) | |||
366 | DEBUGFS_DEL(short_retry_limit); | 323 | DEBUGFS_DEL(short_retry_limit); |
367 | DEBUGFS_DEL(long_retry_limit); | 324 | DEBUGFS_DEL(long_retry_limit); |
368 | DEBUGFS_DEL(total_ps_buffered); | 325 | DEBUGFS_DEL(total_ps_buffered); |
369 | DEBUGFS_DEL(mode); | ||
370 | DEBUGFS_DEL(wep_iv); | 326 | DEBUGFS_DEL(wep_iv); |
371 | DEBUGFS_DEL(modes); | ||
372 | 327 | ||
373 | DEBUGFS_STATS_DEL(transmitted_fragment_count); | 328 | DEBUGFS_STATS_DEL(transmitted_fragment_count); |
374 | DEBUGFS_STATS_DEL(multicast_transmitted_frame_count); | 329 | DEBUGFS_STATS_DEL(multicast_transmitted_frame_count); |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 829872a3ae81..29f7b98ba1fb 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -91,7 +91,6 @@ static const struct file_operations name##_ops = { \ | |||
91 | /* common attributes */ | 91 | /* common attributes */ |
92 | IEEE80211_IF_FILE(channel_use, channel_use, DEC); | 92 | IEEE80211_IF_FILE(channel_use, channel_use, DEC); |
93 | IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); | 93 | IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); |
94 | IEEE80211_IF_FILE(ieee802_1x_pac, ieee802_1x_pac, DEC); | ||
95 | 94 | ||
96 | /* STA/IBSS attributes */ | 95 | /* STA/IBSS attributes */ |
97 | IEEE80211_IF_FILE(state, u.sta.state, DEC); | 96 | IEEE80211_IF_FILE(state, u.sta.state, DEC); |
@@ -148,7 +147,6 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata) | |||
148 | { | 147 | { |
149 | DEBUGFS_ADD(channel_use, sta); | 148 | DEBUGFS_ADD(channel_use, sta); |
150 | DEBUGFS_ADD(drop_unencrypted, sta); | 149 | DEBUGFS_ADD(drop_unencrypted, sta); |
151 | DEBUGFS_ADD(ieee802_1x_pac, sta); | ||
152 | DEBUGFS_ADD(state, sta); | 150 | DEBUGFS_ADD(state, sta); |
153 | DEBUGFS_ADD(bssid, sta); | 151 | DEBUGFS_ADD(bssid, sta); |
154 | DEBUGFS_ADD(prev_bssid, sta); | 152 | DEBUGFS_ADD(prev_bssid, sta); |
@@ -169,7 +167,6 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata) | |||
169 | { | 167 | { |
170 | DEBUGFS_ADD(channel_use, ap); | 168 | DEBUGFS_ADD(channel_use, ap); |
171 | DEBUGFS_ADD(drop_unencrypted, ap); | 169 | DEBUGFS_ADD(drop_unencrypted, ap); |
172 | DEBUGFS_ADD(ieee802_1x_pac, ap); | ||
173 | DEBUGFS_ADD(num_sta_ps, ap); | 170 | DEBUGFS_ADD(num_sta_ps, ap); |
174 | DEBUGFS_ADD(dtim_count, ap); | 171 | DEBUGFS_ADD(dtim_count, ap); |
175 | DEBUGFS_ADD(num_beacons, ap); | 172 | DEBUGFS_ADD(num_beacons, ap); |
@@ -182,7 +179,6 @@ static void add_wds_files(struct ieee80211_sub_if_data *sdata) | |||
182 | { | 179 | { |
183 | DEBUGFS_ADD(channel_use, wds); | 180 | DEBUGFS_ADD(channel_use, wds); |
184 | DEBUGFS_ADD(drop_unencrypted, wds); | 181 | DEBUGFS_ADD(drop_unencrypted, wds); |
185 | DEBUGFS_ADD(ieee802_1x_pac, wds); | ||
186 | DEBUGFS_ADD(peer, wds); | 182 | DEBUGFS_ADD(peer, wds); |
187 | } | 183 | } |
188 | 184 | ||
@@ -190,7 +186,6 @@ static void add_vlan_files(struct ieee80211_sub_if_data *sdata) | |||
190 | { | 186 | { |
191 | DEBUGFS_ADD(channel_use, vlan); | 187 | DEBUGFS_ADD(channel_use, vlan); |
192 | DEBUGFS_ADD(drop_unencrypted, vlan); | 188 | DEBUGFS_ADD(drop_unencrypted, vlan); |
193 | DEBUGFS_ADD(ieee802_1x_pac, vlan); | ||
194 | } | 189 | } |
195 | 190 | ||
196 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) | 191 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) |
@@ -234,7 +229,6 @@ static void del_sta_files(struct ieee80211_sub_if_data *sdata) | |||
234 | { | 229 | { |
235 | DEBUGFS_DEL(channel_use, sta); | 230 | DEBUGFS_DEL(channel_use, sta); |
236 | DEBUGFS_DEL(drop_unencrypted, sta); | 231 | DEBUGFS_DEL(drop_unencrypted, sta); |
237 | DEBUGFS_DEL(ieee802_1x_pac, sta); | ||
238 | DEBUGFS_DEL(state, sta); | 232 | DEBUGFS_DEL(state, sta); |
239 | DEBUGFS_DEL(bssid, sta); | 233 | DEBUGFS_DEL(bssid, sta); |
240 | DEBUGFS_DEL(prev_bssid, sta); | 234 | DEBUGFS_DEL(prev_bssid, sta); |
@@ -255,7 +249,6 @@ static void del_ap_files(struct ieee80211_sub_if_data *sdata) | |||
255 | { | 249 | { |
256 | DEBUGFS_DEL(channel_use, ap); | 250 | DEBUGFS_DEL(channel_use, ap); |
257 | DEBUGFS_DEL(drop_unencrypted, ap); | 251 | DEBUGFS_DEL(drop_unencrypted, ap); |
258 | DEBUGFS_DEL(ieee802_1x_pac, ap); | ||
259 | DEBUGFS_DEL(num_sta_ps, ap); | 252 | DEBUGFS_DEL(num_sta_ps, ap); |
260 | DEBUGFS_DEL(dtim_count, ap); | 253 | DEBUGFS_DEL(dtim_count, ap); |
261 | DEBUGFS_DEL(num_beacons, ap); | 254 | DEBUGFS_DEL(num_beacons, ap); |
@@ -268,7 +261,6 @@ static void del_wds_files(struct ieee80211_sub_if_data *sdata) | |||
268 | { | 261 | { |
269 | DEBUGFS_DEL(channel_use, wds); | 262 | DEBUGFS_DEL(channel_use, wds); |
270 | DEBUGFS_DEL(drop_unencrypted, wds); | 263 | DEBUGFS_DEL(drop_unencrypted, wds); |
271 | DEBUGFS_DEL(ieee802_1x_pac, wds); | ||
272 | DEBUGFS_DEL(peer, wds); | 264 | DEBUGFS_DEL(peer, wds); |
273 | } | 265 | } |
274 | 266 | ||
@@ -276,7 +268,6 @@ static void del_vlan_files(struct ieee80211_sub_if_data *sdata) | |||
276 | { | 268 | { |
277 | DEBUGFS_DEL(channel_use, vlan); | 269 | DEBUGFS_DEL(channel_use, vlan); |
278 | DEBUGFS_DEL(drop_unencrypted, vlan); | 270 | DEBUGFS_DEL(drop_unencrypted, vlan); |
279 | DEBUGFS_DEL(ieee802_1x_pac, vlan); | ||
280 | } | 271 | } |
281 | 272 | ||
282 | static void del_monitor_files(struct ieee80211_sub_if_data *sdata) | 273 | static void del_monitor_files(struct ieee80211_sub_if_data *sdata) |
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c index 8f5944c53d4e..ed7c9f3b4602 100644 --- a/net/mac80211/debugfs_sta.c +++ b/net/mac80211/debugfs_sta.c | |||
@@ -33,25 +33,16 @@ static ssize_t sta_ ##name## _read(struct file *file, \ | |||
33 | #define STA_READ_LU(name, field) STA_READ(name, 20, field, "%lu\n") | 33 | #define STA_READ_LU(name, field) STA_READ(name, 20, field, "%lu\n") |
34 | #define STA_READ_S(name, field) STA_READ(name, 20, field, "%s\n") | 34 | #define STA_READ_S(name, field) STA_READ(name, 20, field, "%s\n") |
35 | 35 | ||
36 | #define STA_READ_RATE(name, field) \ | 36 | #define STA_OPS(name) \ |
37 | static ssize_t sta_##name##_read(struct file *file, \ | 37 | static const struct file_operations sta_ ##name## _ops = { \ |
38 | char __user *userbuf, \ | 38 | .read = sta_##name##_read, \ |
39 | size_t count, loff_t *ppos) \ | 39 | .open = mac80211_open_file_generic, \ |
40 | { \ | ||
41 | struct sta_info *sta = file->private_data; \ | ||
42 | struct ieee80211_local *local = wdev_priv(sta->dev->ieee80211_ptr);\ | ||
43 | struct ieee80211_hw_mode *mode = local->oper_hw_mode; \ | ||
44 | char buf[20]; \ | ||
45 | int res = scnprintf(buf, sizeof(buf), "%d\n", \ | ||
46 | (sta->field >= 0 && \ | ||
47 | sta->field < mode->num_rates) ? \ | ||
48 | mode->rates[sta->field].rate : -1); \ | ||
49 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ | ||
50 | } | 40 | } |
51 | 41 | ||
52 | #define STA_OPS(name) \ | 42 | #define STA_OPS_WR(name) \ |
53 | static const struct file_operations sta_ ##name## _ops = { \ | 43 | static const struct file_operations sta_ ##name## _ops = { \ |
54 | .read = sta_##name##_read, \ | 44 | .read = sta_##name##_read, \ |
45 | .write = sta_##name##_write, \ | ||
55 | .open = mac80211_open_file_generic, \ | 46 | .open = mac80211_open_file_generic, \ |
56 | } | 47 | } |
57 | 48 | ||
@@ -70,8 +61,6 @@ STA_FILE(rx_fragments, rx_fragments, LU); | |||
70 | STA_FILE(rx_dropped, rx_dropped, LU); | 61 | STA_FILE(rx_dropped, rx_dropped, LU); |
71 | STA_FILE(tx_fragments, tx_fragments, LU); | 62 | STA_FILE(tx_fragments, tx_fragments, LU); |
72 | STA_FILE(tx_filtered, tx_filtered_count, LU); | 63 | STA_FILE(tx_filtered, tx_filtered_count, LU); |
73 | STA_FILE(txrate, txrate, RATE); | ||
74 | STA_FILE(last_txrate, last_txrate, RATE); | ||
75 | STA_FILE(tx_retry_failed, tx_retry_failed, LU); | 64 | STA_FILE(tx_retry_failed, tx_retry_failed, LU); |
76 | STA_FILE(tx_retry_count, tx_retry_count, LU); | 65 | STA_FILE(tx_retry_count, tx_retry_count, LU); |
77 | STA_FILE(last_rssi, last_rssi, D); | 66 | STA_FILE(last_rssi, last_rssi, D); |
@@ -85,12 +74,10 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf, | |||
85 | { | 74 | { |
86 | char buf[100]; | 75 | char buf[100]; |
87 | struct sta_info *sta = file->private_data; | 76 | struct sta_info *sta = file->private_data; |
88 | int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s", | 77 | int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
89 | sta->flags & WLAN_STA_AUTH ? "AUTH\n" : "", | 78 | sta->flags & WLAN_STA_AUTH ? "AUTH\n" : "", |
90 | sta->flags & WLAN_STA_ASSOC ? "ASSOC\n" : "", | 79 | sta->flags & WLAN_STA_ASSOC ? "ASSOC\n" : "", |
91 | sta->flags & WLAN_STA_PS ? "PS\n" : "", | 80 | sta->flags & WLAN_STA_PS ? "PS\n" : "", |
92 | sta->flags & WLAN_STA_TIM ? "TIM\n" : "", | ||
93 | sta->flags & WLAN_STA_PERM ? "PERM\n" : "", | ||
94 | sta->flags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "", | 81 | sta->flags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "", |
95 | sta->flags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "", | 82 | sta->flags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "", |
96 | sta->flags & WLAN_STA_WME ? "WME\n" : "", | 83 | sta->flags & WLAN_STA_WME ? "WME\n" : "", |
@@ -111,31 +98,6 @@ static ssize_t sta_num_ps_buf_frames_read(struct file *file, | |||
111 | } | 98 | } |
112 | STA_OPS(num_ps_buf_frames); | 99 | STA_OPS(num_ps_buf_frames); |
113 | 100 | ||
114 | static ssize_t sta_last_ack_rssi_read(struct file *file, char __user *userbuf, | ||
115 | size_t count, loff_t *ppos) | ||
116 | { | ||
117 | char buf[100]; | ||
118 | struct sta_info *sta = file->private_data; | ||
119 | int res = scnprintf(buf, sizeof(buf), "%d %d %d\n", | ||
120 | sta->last_ack_rssi[0], | ||
121 | sta->last_ack_rssi[1], | ||
122 | sta->last_ack_rssi[2]); | ||
123 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); | ||
124 | } | ||
125 | STA_OPS(last_ack_rssi); | ||
126 | |||
127 | static ssize_t sta_last_ack_ms_read(struct file *file, char __user *userbuf, | ||
128 | size_t count, loff_t *ppos) | ||
129 | { | ||
130 | char buf[20]; | ||
131 | struct sta_info *sta = file->private_data; | ||
132 | int res = scnprintf(buf, sizeof(buf), "%d\n", | ||
133 | sta->last_ack ? | ||
134 | jiffies_to_msecs(jiffies - sta->last_ack) : -1); | ||
135 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); | ||
136 | } | ||
137 | STA_OPS(last_ack_ms); | ||
138 | |||
139 | static ssize_t sta_inactive_ms_read(struct file *file, char __user *userbuf, | 101 | static ssize_t sta_inactive_ms_read(struct file *file, char __user *userbuf, |
140 | size_t count, loff_t *ppos) | 102 | size_t count, loff_t *ppos) |
141 | { | 103 | { |
@@ -191,6 +153,113 @@ static ssize_t sta_wme_tx_queue_read(struct file *file, char __user *userbuf, | |||
191 | STA_OPS(wme_tx_queue); | 153 | STA_OPS(wme_tx_queue); |
192 | #endif | 154 | #endif |
193 | 155 | ||
156 | static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf, | ||
157 | size_t count, loff_t *ppos) | ||
158 | { | ||
159 | char buf[768], *p = buf; | ||
160 | int i; | ||
161 | struct sta_info *sta = file->private_data; | ||
162 | p += scnprintf(p, sizeof(buf)+buf-p, "Agg state for STA is:\n"); | ||
163 | p += scnprintf(p, sizeof(buf)+buf-p, " STA next dialog_token is %d \n " | ||
164 | "TIDs info is: \n TID :", | ||
165 | (sta->ampdu_mlme.dialog_token_allocator + 1)); | ||
166 | for (i = 0; i < STA_TID_NUM; i++) | ||
167 | p += scnprintf(p, sizeof(buf)+buf-p, "%5d", i); | ||
168 | |||
169 | p += scnprintf(p, sizeof(buf)+buf-p, "\n RX :"); | ||
170 | for (i = 0; i < STA_TID_NUM; i++) | ||
171 | p += scnprintf(p, sizeof(buf)+buf-p, "%5d", | ||
172 | sta->ampdu_mlme.tid_rx[i].state); | ||
173 | |||
174 | p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:"); | ||
175 | for (i = 0; i < STA_TID_NUM; i++) | ||
176 | p += scnprintf(p, sizeof(buf)+buf-p, "%5d", | ||
177 | sta->ampdu_mlme.tid_rx[i].dialog_token); | ||
178 | |||
179 | p += scnprintf(p, sizeof(buf)+buf-p, "\n TX :"); | ||
180 | for (i = 0; i < STA_TID_NUM; i++) | ||
181 | p += scnprintf(p, sizeof(buf)+buf-p, "%5d", | ||
182 | sta->ampdu_mlme.tid_tx[i].state); | ||
183 | |||
184 | p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:"); | ||
185 | for (i = 0; i < STA_TID_NUM; i++) | ||
186 | p += scnprintf(p, sizeof(buf)+buf-p, "%5d", | ||
187 | sta->ampdu_mlme.tid_tx[i].dialog_token); | ||
188 | |||
189 | p += scnprintf(p, sizeof(buf)+buf-p, "\n SSN :"); | ||
190 | for (i = 0; i < STA_TID_NUM; i++) | ||
191 | p += scnprintf(p, sizeof(buf)+buf-p, "%5d", | ||
192 | sta->ampdu_mlme.tid_tx[i].ssn); | ||
193 | |||
194 | p += scnprintf(p, sizeof(buf)+buf-p, "\n"); | ||
195 | |||
196 | return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); | ||
197 | } | ||
198 | |||
199 | static ssize_t sta_agg_status_write(struct file *file, | ||
200 | const char __user *user_buf, size_t count, loff_t *ppos) | ||
201 | { | ||
202 | struct sta_info *sta = file->private_data; | ||
203 | struct net_device *dev = sta->dev; | ||
204 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
205 | struct ieee80211_hw *hw = &local->hw; | ||
206 | u8 *da = sta->addr; | ||
207 | static int tid_static_tx[16] = {0, 0, 0, 0, 0, 0, 0, 0, | ||
208 | 0, 0, 0, 0, 0, 0, 0, 0}; | ||
209 | static int tid_static_rx[16] = {1, 1, 1, 1, 1, 1, 1, 1, | ||
210 | 1, 1, 1, 1, 1, 1, 1, 1}; | ||
211 | char *endp; | ||
212 | char buf[32]; | ||
213 | int buf_size, rs; | ||
214 | unsigned int tid_num; | ||
215 | char state[4]; | ||
216 | |||
217 | memset(buf, 0x00, sizeof(buf)); | ||
218 | buf_size = min(count, (sizeof(buf)-1)); | ||
219 | if (copy_from_user(buf, user_buf, buf_size)) | ||
220 | return -EFAULT; | ||
221 | |||
222 | tid_num = simple_strtoul(buf, &endp, 0); | ||
223 | if (endp == buf) | ||
224 | return -EINVAL; | ||
225 | |||
226 | if ((tid_num >= 100) && (tid_num <= 115)) { | ||
227 | /* toggle Rx aggregation command */ | ||
228 | tid_num = tid_num - 100; | ||
229 | if (tid_static_rx[tid_num] == 1) { | ||
230 | strcpy(state, "off "); | ||
231 | ieee80211_sta_stop_rx_ba_session(dev, da, tid_num, 0, | ||
232 | WLAN_REASON_QSTA_REQUIRE_SETUP); | ||
233 | sta->ampdu_mlme.tid_rx[tid_num].buf_size = 0xFF; | ||
234 | tid_static_rx[tid_num] = 0; | ||
235 | } else { | ||
236 | strcpy(state, "on "); | ||
237 | sta->ampdu_mlme.tid_rx[tid_num].buf_size = 0x00; | ||
238 | tid_static_rx[tid_num] = 1; | ||
239 | } | ||
240 | printk(KERN_DEBUG "debugfs - try switching tid %u %s\n", | ||
241 | tid_num, state); | ||
242 | } else if ((tid_num >= 0) && (tid_num <= 15)) { | ||
243 | /* toggle Tx aggregation command */ | ||
244 | if (tid_static_tx[tid_num] == 0) { | ||
245 | strcpy(state, "on "); | ||
246 | rs = ieee80211_start_tx_ba_session(hw, da, tid_num); | ||
247 | if (rs == 0) | ||
248 | tid_static_tx[tid_num] = 1; | ||
249 | } else { | ||
250 | strcpy(state, "off"); | ||
251 | rs = ieee80211_stop_tx_ba_session(hw, da, tid_num, 1); | ||
252 | if (rs == 0) | ||
253 | tid_static_tx[tid_num] = 0; | ||
254 | } | ||
255 | printk(KERN_DEBUG "debugfs - switching tid %u %s, return=%d\n", | ||
256 | tid_num, state, rs); | ||
257 | } | ||
258 | |||
259 | return count; | ||
260 | } | ||
261 | STA_OPS_WR(agg_status); | ||
262 | |||
194 | #define DEBUGFS_ADD(name) \ | 263 | #define DEBUGFS_ADD(name) \ |
195 | sta->debugfs.name = debugfs_create_file(#name, 0444, \ | 264 | sta->debugfs.name = debugfs_create_file(#name, 0444, \ |
196 | sta->debugfs.dir, sta, &sta_ ##name## _ops); | 265 | sta->debugfs.dir, sta, &sta_ ##name## _ops); |
@@ -203,12 +272,13 @@ STA_OPS(wme_tx_queue); | |||
203 | void ieee80211_sta_debugfs_add(struct sta_info *sta) | 272 | void ieee80211_sta_debugfs_add(struct sta_info *sta) |
204 | { | 273 | { |
205 | struct dentry *stations_dir = sta->local->debugfs.stations; | 274 | struct dentry *stations_dir = sta->local->debugfs.stations; |
206 | DECLARE_MAC_BUF(mac); | 275 | DECLARE_MAC_BUF(mbuf); |
276 | u8 *mac; | ||
207 | 277 | ||
208 | if (!stations_dir) | 278 | if (!stations_dir) |
209 | return; | 279 | return; |
210 | 280 | ||
211 | print_mac(mac, sta->addr); | 281 | mac = print_mac(mbuf, sta->addr); |
212 | 282 | ||
213 | sta->debugfs.dir = debugfs_create_dir(mac, stations_dir); | 283 | sta->debugfs.dir = debugfs_create_dir(mac, stations_dir); |
214 | if (!sta->debugfs.dir) | 284 | if (!sta->debugfs.dir) |
@@ -216,28 +286,26 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta) | |||
216 | 286 | ||
217 | DEBUGFS_ADD(flags); | 287 | DEBUGFS_ADD(flags); |
218 | DEBUGFS_ADD(num_ps_buf_frames); | 288 | DEBUGFS_ADD(num_ps_buf_frames); |
219 | DEBUGFS_ADD(last_ack_rssi); | ||
220 | DEBUGFS_ADD(last_ack_ms); | ||
221 | DEBUGFS_ADD(inactive_ms); | 289 | DEBUGFS_ADD(inactive_ms); |
222 | DEBUGFS_ADD(last_seq_ctrl); | 290 | DEBUGFS_ADD(last_seq_ctrl); |
223 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS | 291 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
224 | DEBUGFS_ADD(wme_rx_queue); | 292 | DEBUGFS_ADD(wme_rx_queue); |
225 | DEBUGFS_ADD(wme_tx_queue); | 293 | DEBUGFS_ADD(wme_tx_queue); |
226 | #endif | 294 | #endif |
295 | DEBUGFS_ADD(agg_status); | ||
227 | } | 296 | } |
228 | 297 | ||
229 | void ieee80211_sta_debugfs_remove(struct sta_info *sta) | 298 | void ieee80211_sta_debugfs_remove(struct sta_info *sta) |
230 | { | 299 | { |
231 | DEBUGFS_DEL(flags); | 300 | DEBUGFS_DEL(flags); |
232 | DEBUGFS_DEL(num_ps_buf_frames); | 301 | DEBUGFS_DEL(num_ps_buf_frames); |
233 | DEBUGFS_DEL(last_ack_rssi); | ||
234 | DEBUGFS_DEL(last_ack_ms); | ||
235 | DEBUGFS_DEL(inactive_ms); | 302 | DEBUGFS_DEL(inactive_ms); |
236 | DEBUGFS_DEL(last_seq_ctrl); | 303 | DEBUGFS_DEL(last_seq_ctrl); |
237 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS | 304 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
238 | DEBUGFS_DEL(wme_rx_queue); | 305 | DEBUGFS_DEL(wme_rx_queue); |
239 | DEBUGFS_DEL(wme_tx_queue); | 306 | DEBUGFS_DEL(wme_tx_queue); |
240 | #endif | 307 | #endif |
308 | DEBUGFS_DEL(agg_status); | ||
241 | 309 | ||
242 | debugfs_remove(sta->debugfs.dir); | 310 | debugfs_remove(sta->debugfs.dir); |
243 | sta->debugfs.dir = NULL; | 311 | sta->debugfs.dir = NULL; |
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c index 28bcdf9fc3df..2133c9fd27a4 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c | |||
@@ -67,9 +67,19 @@ static void ieee80211_configure_filter(struct ieee80211_local *local) | |||
67 | new_flags |= FIF_ALLMULTI; | 67 | new_flags |= FIF_ALLMULTI; |
68 | 68 | ||
69 | if (local->monitors) | 69 | if (local->monitors) |
70 | new_flags |= FIF_CONTROL | | 70 | new_flags |= FIF_BCN_PRBRESP_PROMISC; |
71 | FIF_OTHER_BSS | | 71 | |
72 | FIF_BCN_PRBRESP_PROMISC; | 72 | if (local->fif_fcsfail) |
73 | new_flags |= FIF_FCSFAIL; | ||
74 | |||
75 | if (local->fif_plcpfail) | ||
76 | new_flags |= FIF_PLCPFAIL; | ||
77 | |||
78 | if (local->fif_control) | ||
79 | new_flags |= FIF_CONTROL; | ||
80 | |||
81 | if (local->fif_other_bss) | ||
82 | new_flags |= FIF_OTHER_BSS; | ||
73 | 83 | ||
74 | changed_flags = local->filter_flags ^ new_flags; | 84 | changed_flags = local->filter_flags ^ new_flags; |
75 | 85 | ||
@@ -173,8 +183,52 @@ static int ieee80211_open(struct net_device *dev) | |||
173 | list_for_each_entry(nsdata, &local->interfaces, list) { | 183 | list_for_each_entry(nsdata, &local->interfaces, list) { |
174 | struct net_device *ndev = nsdata->dev; | 184 | struct net_device *ndev = nsdata->dev; |
175 | 185 | ||
176 | if (ndev != dev && ndev != local->mdev && netif_running(ndev) && | 186 | if (ndev != dev && ndev != local->mdev && netif_running(ndev)) { |
177 | compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0) { | 187 | /* |
188 | * Allow only a single IBSS interface to be up at any | ||
189 | * time. This is restricted because beacon distribution | ||
190 | * cannot work properly if both are in the same IBSS. | ||
191 | * | ||
192 | * To remove this restriction we'd have to disallow them | ||
193 | * from setting the same SSID on different IBSS interfaces | ||
194 | * belonging to the same hardware. Then, however, we're | ||
195 | * faced with having to adopt two different TSF timers... | ||
196 | */ | ||
197 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && | ||
198 | nsdata->vif.type == IEEE80211_IF_TYPE_IBSS) | ||
199 | return -EBUSY; | ||
200 | |||
201 | /* | ||
202 | * Disallow multiple IBSS/STA mode interfaces. | ||
203 | * | ||
204 | * This is a technical restriction, it is possible although | ||
205 | * most likely not IEEE 802.11 compliant to have multiple | ||
206 | * STAs with just a single hardware (the TSF timer will not | ||
207 | * be adjusted properly.) | ||
208 | * | ||
209 | * However, because mac80211 uses the master device's BSS | ||
210 | * information for each STA/IBSS interface, doing this will | ||
211 | * currently corrupt that BSS information completely, unless, | ||
212 | * a not very useful case, both STAs are associated to the | ||
213 | * same BSS. | ||
214 | * | ||
215 | * To remove this restriction, the BSS information needs to | ||
216 | * be embedded in the STA/IBSS mode sdata instead of using | ||
217 | * the master device's BSS structure. | ||
218 | */ | ||
219 | if ((sdata->vif.type == IEEE80211_IF_TYPE_STA || | ||
220 | sdata->vif.type == IEEE80211_IF_TYPE_IBSS) && | ||
221 | (nsdata->vif.type == IEEE80211_IF_TYPE_STA || | ||
222 | nsdata->vif.type == IEEE80211_IF_TYPE_IBSS)) | ||
223 | return -EBUSY; | ||
224 | |||
225 | /* | ||
226 | * The remaining checks are only performed for interfaces | ||
227 | * with the same MAC address. | ||
228 | */ | ||
229 | if (compare_ether_addr(dev->dev_addr, ndev->dev_addr)) | ||
230 | continue; | ||
231 | |||
178 | /* | 232 | /* |
179 | * check whether it may have the same address | 233 | * check whether it may have the same address |
180 | */ | 234 | */ |
@@ -186,8 +240,7 @@ static int ieee80211_open(struct net_device *dev) | |||
186 | * can only add VLANs to enabled APs | 240 | * can only add VLANs to enabled APs |
187 | */ | 241 | */ |
188 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN && | 242 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN && |
189 | nsdata->vif.type == IEEE80211_IF_TYPE_AP && | 243 | nsdata->vif.type == IEEE80211_IF_TYPE_AP) |
190 | netif_running(nsdata->dev)) | ||
191 | sdata->u.vlan.ap = nsdata; | 244 | sdata->u.vlan.ap = nsdata; |
192 | } | 245 | } |
193 | } | 246 | } |
@@ -229,15 +282,28 @@ static int ieee80211_open(struct net_device *dev) | |||
229 | /* no need to tell driver */ | 282 | /* no need to tell driver */ |
230 | break; | 283 | break; |
231 | case IEEE80211_IF_TYPE_MNTR: | 284 | case IEEE80211_IF_TYPE_MNTR: |
285 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) { | ||
286 | local->cooked_mntrs++; | ||
287 | break; | ||
288 | } | ||
289 | |||
232 | /* must be before the call to ieee80211_configure_filter */ | 290 | /* must be before the call to ieee80211_configure_filter */ |
233 | local->monitors++; | 291 | local->monitors++; |
234 | if (local->monitors == 1) { | 292 | if (local->monitors == 1) |
235 | netif_tx_lock_bh(local->mdev); | ||
236 | ieee80211_configure_filter(local); | ||
237 | netif_tx_unlock_bh(local->mdev); | ||
238 | |||
239 | local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; | 293 | local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; |
240 | } | 294 | |
295 | if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL) | ||
296 | local->fif_fcsfail++; | ||
297 | if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL) | ||
298 | local->fif_plcpfail++; | ||
299 | if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL) | ||
300 | local->fif_control++; | ||
301 | if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) | ||
302 | local->fif_other_bss++; | ||
303 | |||
304 | netif_tx_lock_bh(local->mdev); | ||
305 | ieee80211_configure_filter(local); | ||
306 | netif_tx_unlock_bh(local->mdev); | ||
241 | break; | 307 | break; |
242 | case IEEE80211_IF_TYPE_STA: | 308 | case IEEE80211_IF_TYPE_STA: |
243 | case IEEE80211_IF_TYPE_IBSS: | 309 | case IEEE80211_IF_TYPE_IBSS: |
@@ -352,14 +418,27 @@ static int ieee80211_stop(struct net_device *dev) | |||
352 | /* no need to tell driver */ | 418 | /* no need to tell driver */ |
353 | break; | 419 | break; |
354 | case IEEE80211_IF_TYPE_MNTR: | 420 | case IEEE80211_IF_TYPE_MNTR: |
355 | local->monitors--; | 421 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) { |
356 | if (local->monitors == 0) { | 422 | local->cooked_mntrs--; |
357 | netif_tx_lock_bh(local->mdev); | 423 | break; |
358 | ieee80211_configure_filter(local); | 424 | } |
359 | netif_tx_unlock_bh(local->mdev); | ||
360 | 425 | ||
426 | local->monitors--; | ||
427 | if (local->monitors == 0) | ||
361 | local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; | 428 | local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; |
362 | } | 429 | |
430 | if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL) | ||
431 | local->fif_fcsfail--; | ||
432 | if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL) | ||
433 | local->fif_plcpfail--; | ||
434 | if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL) | ||
435 | local->fif_control--; | ||
436 | if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS) | ||
437 | local->fif_other_bss--; | ||
438 | |||
439 | netif_tx_lock_bh(local->mdev); | ||
440 | ieee80211_configure_filter(local); | ||
441 | netif_tx_unlock_bh(local->mdev); | ||
363 | break; | 442 | break; |
364 | case IEEE80211_IF_TYPE_STA: | 443 | case IEEE80211_IF_TYPE_STA: |
365 | case IEEE80211_IF_TYPE_IBSS: | 444 | case IEEE80211_IF_TYPE_IBSS: |
@@ -414,6 +493,329 @@ static int ieee80211_stop(struct net_device *dev) | |||
414 | return 0; | 493 | return 0; |
415 | } | 494 | } |
416 | 495 | ||
496 | int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid) | ||
497 | { | ||
498 | struct ieee80211_local *local = hw_to_local(hw); | ||
499 | struct sta_info *sta; | ||
500 | struct ieee80211_sub_if_data *sdata; | ||
501 | u16 start_seq_num = 0; | ||
502 | u8 *state; | ||
503 | int ret; | ||
504 | DECLARE_MAC_BUF(mac); | ||
505 | |||
506 | if (tid >= STA_TID_NUM) | ||
507 | return -EINVAL; | ||
508 | |||
509 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
510 | printk(KERN_DEBUG "Open BA session requested for %s tid %u\n", | ||
511 | print_mac(mac, ra), tid); | ||
512 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
513 | |||
514 | sta = sta_info_get(local, ra); | ||
515 | if (!sta) { | ||
516 | printk(KERN_DEBUG "Could not find the station\n"); | ||
517 | return -ENOENT; | ||
518 | } | ||
519 | |||
520 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
521 | |||
522 | /* we have tried too many times, receiver does not want A-MPDU */ | ||
523 | if (sta->ampdu_mlme.tid_tx[tid].addba_req_num > HT_AGG_MAX_RETRIES) { | ||
524 | ret = -EBUSY; | ||
525 | goto start_ba_exit; | ||
526 | } | ||
527 | |||
528 | state = &sta->ampdu_mlme.tid_tx[tid].state; | ||
529 | /* check if the TID is not in aggregation flow already */ | ||
530 | if (*state != HT_AGG_STATE_IDLE) { | ||
531 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
532 | printk(KERN_DEBUG "BA request denied - session is not " | ||
533 | "idle on tid %u\n", tid); | ||
534 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
535 | ret = -EAGAIN; | ||
536 | goto start_ba_exit; | ||
537 | } | ||
538 | |||
539 | /* ensure that TX flow won't interrupt us | ||
540 | * until the end of the call to requeue function */ | ||
541 | spin_lock_bh(&local->mdev->queue_lock); | ||
542 | |||
543 | /* create a new queue for this aggregation */ | ||
544 | ret = ieee80211_ht_agg_queue_add(local, sta, tid); | ||
545 | |||
546 | /* case no queue is available to aggregation | ||
547 | * don't switch to aggregation */ | ||
548 | if (ret) { | ||
549 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
550 | printk(KERN_DEBUG "BA request denied - no queue available for" | ||
551 | " tid %d\n", tid); | ||
552 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
553 | spin_unlock_bh(&local->mdev->queue_lock); | ||
554 | goto start_ba_exit; | ||
555 | } | ||
556 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | ||
557 | |||
558 | /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the | ||
559 | * call back right away, it must see that the flow has begun */ | ||
560 | *state |= HT_ADDBA_REQUESTED_MSK; | ||
561 | |||
562 | if (local->ops->ampdu_action) | ||
563 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START, | ||
564 | ra, tid, &start_seq_num); | ||
565 | |||
566 | if (ret) { | ||
567 | /* No need to requeue the packets in the agg queue, since we | ||
568 | * held the tx lock: no packet could be enqueued to the newly | ||
569 | * allocated queue */ | ||
570 | ieee80211_ht_agg_queue_remove(local, sta, tid, 0); | ||
571 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
572 | printk(KERN_DEBUG "BA request denied - HW or queue unavailable" | ||
573 | " for tid %d\n", tid); | ||
574 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
575 | spin_unlock_bh(&local->mdev->queue_lock); | ||
576 | *state = HT_AGG_STATE_IDLE; | ||
577 | goto start_ba_exit; | ||
578 | } | ||
579 | |||
580 | /* Will put all the packets in the new SW queue */ | ||
581 | ieee80211_requeue(local, ieee802_1d_to_ac[tid]); | ||
582 | spin_unlock_bh(&local->mdev->queue_lock); | ||
583 | |||
584 | /* We have most probably almost emptied the legacy queue */ | ||
585 | /* ieee80211_wake_queue(local_to_hw(local), ieee802_1d_to_ac[tid]); */ | ||
586 | |||
587 | /* send an addBA request */ | ||
588 | sta->ampdu_mlme.dialog_token_allocator++; | ||
589 | sta->ampdu_mlme.tid_tx[tid].dialog_token = | ||
590 | sta->ampdu_mlme.dialog_token_allocator; | ||
591 | sta->ampdu_mlme.tid_tx[tid].ssn = start_seq_num; | ||
592 | |||
593 | ieee80211_send_addba_request(sta->dev, ra, tid, | ||
594 | sta->ampdu_mlme.tid_tx[tid].dialog_token, | ||
595 | sta->ampdu_mlme.tid_tx[tid].ssn, | ||
596 | 0x40, 5000); | ||
597 | |||
598 | /* activate the timer for the recipient's addBA response */ | ||
599 | sta->ampdu_mlme.tid_tx[tid].addba_resp_timer.expires = | ||
600 | jiffies + ADDBA_RESP_INTERVAL; | ||
601 | add_timer(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer); | ||
602 | printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid); | ||
603 | |||
604 | start_ba_exit: | ||
605 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
606 | sta_info_put(sta); | ||
607 | return ret; | ||
608 | } | ||
609 | EXPORT_SYMBOL(ieee80211_start_tx_ba_session); | ||
610 | |||
611 | int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw, | ||
612 | u8 *ra, u16 tid, | ||
613 | enum ieee80211_back_parties initiator) | ||
614 | { | ||
615 | struct ieee80211_local *local = hw_to_local(hw); | ||
616 | struct sta_info *sta; | ||
617 | u8 *state; | ||
618 | int ret = 0; | ||
619 | DECLARE_MAC_BUF(mac); | ||
620 | |||
621 | if (tid >= STA_TID_NUM) | ||
622 | return -EINVAL; | ||
623 | |||
624 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
625 | printk(KERN_DEBUG "Stop a BA session requested for %s tid %u\n", | ||
626 | print_mac(mac, ra), tid); | ||
627 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
628 | |||
629 | sta = sta_info_get(local, ra); | ||
630 | if (!sta) | ||
631 | return -ENOENT; | ||
632 | |||
633 | /* check if the TID is in aggregation */ | ||
634 | state = &sta->ampdu_mlme.tid_tx[tid].state; | ||
635 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
636 | |||
637 | if (*state != HT_AGG_STATE_OPERATIONAL) { | ||
638 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
639 | printk(KERN_DEBUG "Try to stop Tx aggregation on" | ||
640 | " non active TID\n"); | ||
641 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
642 | ret = -ENOENT; | ||
643 | goto stop_BA_exit; | ||
644 | } | ||
645 | |||
646 | ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]); | ||
647 | |||
648 | *state = HT_AGG_STATE_REQ_STOP_BA_MSK | | ||
649 | (initiator << HT_AGG_STATE_INITIATOR_SHIFT); | ||
650 | |||
651 | if (local->ops->ampdu_action) | ||
652 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP, | ||
653 | ra, tid, NULL); | ||
654 | |||
655 | /* case HW denied going back to legacy */ | ||
656 | if (ret) { | ||
657 | WARN_ON(ret != -EBUSY); | ||
658 | *state = HT_AGG_STATE_OPERATIONAL; | ||
659 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | ||
660 | goto stop_BA_exit; | ||
661 | } | ||
662 | |||
663 | stop_BA_exit: | ||
664 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
665 | sta_info_put(sta); | ||
666 | return ret; | ||
667 | } | ||
668 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_session); | ||
669 | |||
670 | void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid) | ||
671 | { | ||
672 | struct ieee80211_local *local = hw_to_local(hw); | ||
673 | struct sta_info *sta; | ||
674 | u8 *state; | ||
675 | DECLARE_MAC_BUF(mac); | ||
676 | |||
677 | if (tid >= STA_TID_NUM) { | ||
678 | printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n", | ||
679 | tid, STA_TID_NUM); | ||
680 | return; | ||
681 | } | ||
682 | |||
683 | sta = sta_info_get(local, ra); | ||
684 | if (!sta) { | ||
685 | printk(KERN_DEBUG "Could not find station: %s\n", | ||
686 | print_mac(mac, ra)); | ||
687 | return; | ||
688 | } | ||
689 | |||
690 | state = &sta->ampdu_mlme.tid_tx[tid].state; | ||
691 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
692 | |||
693 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | ||
694 | printk(KERN_DEBUG "addBA was not requested yet, state is %d\n", | ||
695 | *state); | ||
696 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
697 | sta_info_put(sta); | ||
698 | return; | ||
699 | } | ||
700 | |||
701 | WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK); | ||
702 | |||
703 | *state |= HT_ADDBA_DRV_READY_MSK; | ||
704 | |||
705 | if (*state == HT_AGG_STATE_OPERATIONAL) { | ||
706 | printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid); | ||
707 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | ||
708 | } | ||
709 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
710 | sta_info_put(sta); | ||
711 | } | ||
712 | EXPORT_SYMBOL(ieee80211_start_tx_ba_cb); | ||
713 | |||
714 | void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid) | ||
715 | { | ||
716 | struct ieee80211_local *local = hw_to_local(hw); | ||
717 | struct sta_info *sta; | ||
718 | u8 *state; | ||
719 | int agg_queue; | ||
720 | DECLARE_MAC_BUF(mac); | ||
721 | |||
722 | if (tid >= STA_TID_NUM) { | ||
723 | printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n", | ||
724 | tid, STA_TID_NUM); | ||
725 | return; | ||
726 | } | ||
727 | |||
728 | printk(KERN_DEBUG "Stop a BA session requested on DA %s tid %d\n", | ||
729 | print_mac(mac, ra), tid); | ||
730 | |||
731 | sta = sta_info_get(local, ra); | ||
732 | if (!sta) { | ||
733 | printk(KERN_DEBUG "Could not find station: %s\n", | ||
734 | print_mac(mac, ra)); | ||
735 | return; | ||
736 | } | ||
737 | state = &sta->ampdu_mlme.tid_tx[tid].state; | ||
738 | |||
739 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
740 | if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) { | ||
741 | printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n"); | ||
742 | sta_info_put(sta); | ||
743 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
744 | return; | ||
745 | } | ||
746 | |||
747 | if (*state & HT_AGG_STATE_INITIATOR_MSK) | ||
748 | ieee80211_send_delba(sta->dev, ra, tid, | ||
749 | WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE); | ||
750 | |||
751 | agg_queue = sta->tid_to_tx_q[tid]; | ||
752 | |||
753 | /* avoid ordering issues: we are the only one that can modify | ||
754 | * the content of the qdiscs */ | ||
755 | spin_lock_bh(&local->mdev->queue_lock); | ||
756 | /* remove the queue for this aggregation */ | ||
757 | ieee80211_ht_agg_queue_remove(local, sta, tid, 1); | ||
758 | spin_unlock_bh(&local->mdev->queue_lock); | ||
759 | |||
760 | /* we just requeued the all the frames that were in the removed | ||
761 | * queue, and since we might miss a softirq we do netif_schedule. | ||
762 | * ieee80211_wake_queue is not used here as this queue is not | ||
763 | * necessarily stopped */ | ||
764 | netif_schedule(local->mdev); | ||
765 | *state = HT_AGG_STATE_IDLE; | ||
766 | sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0; | ||
767 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
768 | |||
769 | sta_info_put(sta); | ||
770 | } | ||
771 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb); | ||
772 | |||
773 | void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, | ||
774 | const u8 *ra, u16 tid) | ||
775 | { | ||
776 | struct ieee80211_local *local = hw_to_local(hw); | ||
777 | struct ieee80211_ra_tid *ra_tid; | ||
778 | struct sk_buff *skb = dev_alloc_skb(0); | ||
779 | |||
780 | if (unlikely(!skb)) { | ||
781 | if (net_ratelimit()) | ||
782 | printk(KERN_WARNING "%s: Not enough memory, " | ||
783 | "dropping start BA session", skb->dev->name); | ||
784 | return; | ||
785 | } | ||
786 | ra_tid = (struct ieee80211_ra_tid *) &skb->cb; | ||
787 | memcpy(&ra_tid->ra, ra, ETH_ALEN); | ||
788 | ra_tid->tid = tid; | ||
789 | |||
790 | skb->pkt_type = IEEE80211_ADDBA_MSG; | ||
791 | skb_queue_tail(&local->skb_queue, skb); | ||
792 | tasklet_schedule(&local->tasklet); | ||
793 | } | ||
794 | EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe); | ||
795 | |||
796 | void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, | ||
797 | const u8 *ra, u16 tid) | ||
798 | { | ||
799 | struct ieee80211_local *local = hw_to_local(hw); | ||
800 | struct ieee80211_ra_tid *ra_tid; | ||
801 | struct sk_buff *skb = dev_alloc_skb(0); | ||
802 | |||
803 | if (unlikely(!skb)) { | ||
804 | if (net_ratelimit()) | ||
805 | printk(KERN_WARNING "%s: Not enough memory, " | ||
806 | "dropping stop BA session", skb->dev->name); | ||
807 | return; | ||
808 | } | ||
809 | ra_tid = (struct ieee80211_ra_tid *) &skb->cb; | ||
810 | memcpy(&ra_tid->ra, ra, ETH_ALEN); | ||
811 | ra_tid->tid = tid; | ||
812 | |||
813 | skb->pkt_type = IEEE80211_DELBA_MSG; | ||
814 | skb_queue_tail(&local->skb_queue, skb); | ||
815 | tasklet_schedule(&local->tasklet); | ||
816 | } | ||
817 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe); | ||
818 | |||
417 | static void ieee80211_set_multicast_list(struct net_device *dev) | 819 | static void ieee80211_set_multicast_list(struct net_device *dev) |
418 | { | 820 | { |
419 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 821 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
@@ -479,8 +881,11 @@ int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr) | |||
479 | 881 | ||
480 | /* Create STA entry for the new peer */ | 882 | /* Create STA entry for the new peer */ |
481 | sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL); | 883 | sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL); |
482 | if (!sta) | 884 | if (IS_ERR(sta)) |
483 | return -ENOMEM; | 885 | return PTR_ERR(sta); |
886 | |||
887 | sta->flags |= WLAN_STA_AUTHORIZED; | ||
888 | |||
484 | sta_info_put(sta); | 889 | sta_info_put(sta); |
485 | 890 | ||
486 | /* Remove STA entry for the old peer */ | 891 | /* Remove STA entry for the old peer */ |
@@ -553,37 +958,28 @@ int ieee80211_if_config_beacon(struct net_device *dev) | |||
553 | 958 | ||
554 | int ieee80211_hw_config(struct ieee80211_local *local) | 959 | int ieee80211_hw_config(struct ieee80211_local *local) |
555 | { | 960 | { |
556 | struct ieee80211_hw_mode *mode; | ||
557 | struct ieee80211_channel *chan; | 961 | struct ieee80211_channel *chan; |
558 | int ret = 0; | 962 | int ret = 0; |
559 | 963 | ||
560 | if (local->sta_sw_scanning) { | 964 | if (local->sta_sw_scanning) |
561 | chan = local->scan_channel; | 965 | chan = local->scan_channel; |
562 | mode = local->scan_hw_mode; | 966 | else |
563 | } else { | ||
564 | chan = local->oper_channel; | 967 | chan = local->oper_channel; |
565 | mode = local->oper_hw_mode; | ||
566 | } | ||
567 | 968 | ||
568 | local->hw.conf.channel = chan->chan; | 969 | local->hw.conf.channel = chan; |
569 | local->hw.conf.channel_val = chan->val; | 970 | |
570 | if (!local->hw.conf.power_level) { | 971 | if (!local->hw.conf.power_level) |
571 | local->hw.conf.power_level = chan->power_level; | 972 | local->hw.conf.power_level = chan->max_power; |
572 | } else { | 973 | else |
573 | local->hw.conf.power_level = min(chan->power_level, | 974 | local->hw.conf.power_level = min(chan->max_power, |
574 | local->hw.conf.power_level); | 975 | local->hw.conf.power_level); |
575 | } | 976 | |
576 | local->hw.conf.freq = chan->freq; | 977 | local->hw.conf.max_antenna_gain = chan->max_antenna_gain; |
577 | local->hw.conf.phymode = mode->mode; | ||
578 | local->hw.conf.antenna_max = chan->antenna_max; | ||
579 | local->hw.conf.chan = chan; | ||
580 | local->hw.conf.mode = mode; | ||
581 | 978 | ||
582 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 979 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
583 | printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d " | 980 | printk(KERN_DEBUG "%s: HW CONFIG: freq=%d\n", |
584 | "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq, | 981 | wiphy_name(local->hw.wiphy), chan->center_freq); |
585 | local->hw.conf.phymode); | 982 | #endif |
586 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | ||
587 | 983 | ||
588 | if (local->open_count) | 984 | if (local->open_count) |
589 | ret = local->ops->config(local_to_hw(local), &local->hw.conf); | 985 | ret = local->ops->config(local_to_hw(local), &local->hw.conf); |
@@ -601,11 +997,13 @@ int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht, | |||
601 | struct ieee80211_ht_bss_info *req_bss_cap) | 997 | struct ieee80211_ht_bss_info *req_bss_cap) |
602 | { | 998 | { |
603 | struct ieee80211_conf *conf = &local->hw.conf; | 999 | struct ieee80211_conf *conf = &local->hw.conf; |
604 | struct ieee80211_hw_mode *mode = conf->mode; | 1000 | struct ieee80211_supported_band *sband; |
605 | int i; | 1001 | int i; |
606 | 1002 | ||
1003 | sband = local->hw.wiphy->bands[conf->channel->band]; | ||
1004 | |||
607 | /* HT is not supported */ | 1005 | /* HT is not supported */ |
608 | if (!mode->ht_info.ht_supported) { | 1006 | if (!sband->ht_info.ht_supported) { |
609 | conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; | 1007 | conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; |
610 | return -EOPNOTSUPP; | 1008 | return -EOPNOTSUPP; |
611 | } | 1009 | } |
@@ -615,17 +1013,17 @@ int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht, | |||
615 | conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; | 1013 | conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; |
616 | } else { | 1014 | } else { |
617 | conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE; | 1015 | conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE; |
618 | conf->ht_conf.cap = req_ht_cap->cap & mode->ht_info.cap; | 1016 | conf->ht_conf.cap = req_ht_cap->cap & sband->ht_info.cap; |
619 | conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS); | 1017 | conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS); |
620 | conf->ht_conf.cap |= | 1018 | conf->ht_conf.cap |= |
621 | mode->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS; | 1019 | sband->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS; |
622 | conf->ht_bss_conf.primary_channel = | 1020 | conf->ht_bss_conf.primary_channel = |
623 | req_bss_cap->primary_channel; | 1021 | req_bss_cap->primary_channel; |
624 | conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap; | 1022 | conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap; |
625 | conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode; | 1023 | conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode; |
626 | for (i = 0; i < SUPP_MCS_SET_LEN; i++) | 1024 | for (i = 0; i < SUPP_MCS_SET_LEN; i++) |
627 | conf->ht_conf.supp_mcs_set[i] = | 1025 | conf->ht_conf.supp_mcs_set[i] = |
628 | mode->ht_info.supp_mcs_set[i] & | 1026 | sband->ht_info.supp_mcs_set[i] & |
629 | req_ht_cap->supp_mcs_set[i]; | 1027 | req_ht_cap->supp_mcs_set[i]; |
630 | 1028 | ||
631 | /* In STA mode, this gives us indication | 1029 | /* In STA mode, this gives us indication |
@@ -713,6 +1111,7 @@ static void ieee80211_tasklet_handler(unsigned long data) | |||
713 | struct sk_buff *skb; | 1111 | struct sk_buff *skb; |
714 | struct ieee80211_rx_status rx_status; | 1112 | struct ieee80211_rx_status rx_status; |
715 | struct ieee80211_tx_status *tx_status; | 1113 | struct ieee80211_tx_status *tx_status; |
1114 | struct ieee80211_ra_tid *ra_tid; | ||
716 | 1115 | ||
717 | while ((skb = skb_dequeue(&local->skb_queue)) || | 1116 | while ((skb = skb_dequeue(&local->skb_queue)) || |
718 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { | 1117 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { |
@@ -733,6 +1132,18 @@ static void ieee80211_tasklet_handler(unsigned long data) | |||
733 | skb, tx_status); | 1132 | skb, tx_status); |
734 | kfree(tx_status); | 1133 | kfree(tx_status); |
735 | break; | 1134 | break; |
1135 | case IEEE80211_DELBA_MSG: | ||
1136 | ra_tid = (struct ieee80211_ra_tid *) &skb->cb; | ||
1137 | ieee80211_stop_tx_ba_cb(local_to_hw(local), | ||
1138 | ra_tid->ra, ra_tid->tid); | ||
1139 | dev_kfree_skb(skb); | ||
1140 | break; | ||
1141 | case IEEE80211_ADDBA_MSG: | ||
1142 | ra_tid = (struct ieee80211_ra_tid *) &skb->cb; | ||
1143 | ieee80211_start_tx_ba_cb(local_to_hw(local), | ||
1144 | ra_tid->ra, ra_tid->tid); | ||
1145 | dev_kfree_skb(skb); | ||
1146 | break ; | ||
736 | default: /* should never get here! */ | 1147 | default: /* should never get here! */ |
737 | printk(KERN_ERR "%s: Unknown message type (%d)\n", | 1148 | printk(KERN_ERR "%s: Unknown message type (%d)\n", |
738 | wiphy_name(local->hw.wiphy), skb->pkt_type); | 1149 | wiphy_name(local->hw.wiphy), skb->pkt_type); |
@@ -810,6 +1221,77 @@ no_key: | |||
810 | } | 1221 | } |
811 | } | 1222 | } |
812 | 1223 | ||
1224 | static void ieee80211_handle_filtered_frame(struct ieee80211_local *local, | ||
1225 | struct sta_info *sta, | ||
1226 | struct sk_buff *skb, | ||
1227 | struct ieee80211_tx_status *status) | ||
1228 | { | ||
1229 | sta->tx_filtered_count++; | ||
1230 | |||
1231 | /* | ||
1232 | * Clear the TX filter mask for this STA when sending the next | ||
1233 | * packet. If the STA went to power save mode, this will happen | ||
1234 | * happen when it wakes up for the next time. | ||
1235 | */ | ||
1236 | sta->flags |= WLAN_STA_CLEAR_PS_FILT; | ||
1237 | |||
1238 | /* | ||
1239 | * This code races in the following way: | ||
1240 | * | ||
1241 | * (1) STA sends frame indicating it will go to sleep and does so | ||
1242 | * (2) hardware/firmware adds STA to filter list, passes frame up | ||
1243 | * (3) hardware/firmware processes TX fifo and suppresses a frame | ||
1244 | * (4) we get TX status before having processed the frame and | ||
1245 | * knowing that the STA has gone to sleep. | ||
1246 | * | ||
1247 | * This is actually quite unlikely even when both those events are | ||
1248 | * processed from interrupts coming in quickly after one another or | ||
1249 | * even at the same time because we queue both TX status events and | ||
1250 | * RX frames to be processed by a tasklet and process them in the | ||
1251 | * same order that they were received or TX status last. Hence, there | ||
1252 | * is no race as long as the frame RX is processed before the next TX | ||
1253 | * status, which drivers can ensure, see below. | ||
1254 | * | ||
1255 | * Note that this can only happen if the hardware or firmware can | ||
1256 | * actually add STAs to the filter list, if this is done by the | ||
1257 | * driver in response to set_tim() (which will only reduce the race | ||
1258 | * this whole filtering tries to solve, not completely solve it) | ||
1259 | * this situation cannot happen. | ||
1260 | * | ||
1261 | * To completely solve this race drivers need to make sure that they | ||
1262 | * (a) don't mix the irq-safe/not irq-safe TX status/RX processing | ||
1263 | * functions and | ||
1264 | * (b) always process RX events before TX status events if ordering | ||
1265 | * can be unknown, for example with different interrupt status | ||
1266 | * bits. | ||
1267 | */ | ||
1268 | if (sta->flags & WLAN_STA_PS && | ||
1269 | skb_queue_len(&sta->tx_filtered) < STA_MAX_TX_BUFFER) { | ||
1270 | ieee80211_remove_tx_extra(local, sta->key, skb, | ||
1271 | &status->control); | ||
1272 | skb_queue_tail(&sta->tx_filtered, skb); | ||
1273 | return; | ||
1274 | } | ||
1275 | |||
1276 | if (!(sta->flags & WLAN_STA_PS) && | ||
1277 | !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) { | ||
1278 | /* Software retry the packet once */ | ||
1279 | status->control.flags |= IEEE80211_TXCTL_REQUEUE; | ||
1280 | ieee80211_remove_tx_extra(local, sta->key, skb, | ||
1281 | &status->control); | ||
1282 | dev_queue_xmit(skb); | ||
1283 | return; | ||
1284 | } | ||
1285 | |||
1286 | if (net_ratelimit()) | ||
1287 | printk(KERN_DEBUG "%s: dropped TX filtered frame, " | ||
1288 | "queue_len=%d PS=%d @%lu\n", | ||
1289 | wiphy_name(local->hw.wiphy), | ||
1290 | skb_queue_len(&sta->tx_filtered), | ||
1291 | !!(sta->flags & WLAN_STA_PS), jiffies); | ||
1292 | dev_kfree_skb(skb); | ||
1293 | } | ||
1294 | |||
813 | void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | 1295 | void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, |
814 | struct ieee80211_tx_status *status) | 1296 | struct ieee80211_tx_status *status) |
815 | { | 1297 | { |
@@ -819,7 +1301,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
819 | u16 frag, type; | 1301 | u16 frag, type; |
820 | struct ieee80211_tx_status_rtap_hdr *rthdr; | 1302 | struct ieee80211_tx_status_rtap_hdr *rthdr; |
821 | struct ieee80211_sub_if_data *sdata; | 1303 | struct ieee80211_sub_if_data *sdata; |
822 | int monitors; | 1304 | struct net_device *prev_dev = NULL; |
823 | 1305 | ||
824 | if (!status) { | 1306 | if (!status) { |
825 | printk(KERN_ERR | 1307 | printk(KERN_ERR |
@@ -834,11 +1316,16 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
834 | sta = sta_info_get(local, hdr->addr1); | 1316 | sta = sta_info_get(local, hdr->addr1); |
835 | if (sta) { | 1317 | if (sta) { |
836 | if (sta->flags & WLAN_STA_PS) { | 1318 | if (sta->flags & WLAN_STA_PS) { |
837 | /* The STA is in power save mode, so assume | 1319 | /* |
1320 | * The STA is in power save mode, so assume | ||
838 | * that this TX packet failed because of that. | 1321 | * that this TX packet failed because of that. |
839 | */ | 1322 | */ |
840 | status->excessive_retries = 0; | 1323 | status->excessive_retries = 0; |
841 | status->flags |= IEEE80211_TX_STATUS_TX_FILTERED; | 1324 | status->flags |= IEEE80211_TX_STATUS_TX_FILTERED; |
1325 | ieee80211_handle_filtered_frame(local, sta, | ||
1326 | skb, status); | ||
1327 | sta_info_put(sta); | ||
1328 | return; | ||
842 | } | 1329 | } |
843 | sta_info_put(sta); | 1330 | sta_info_put(sta); |
844 | } | 1331 | } |
@@ -848,47 +1335,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
848 | struct sta_info *sta; | 1335 | struct sta_info *sta; |
849 | sta = sta_info_get(local, hdr->addr1); | 1336 | sta = sta_info_get(local, hdr->addr1); |
850 | if (sta) { | 1337 | if (sta) { |
851 | sta->tx_filtered_count++; | 1338 | ieee80211_handle_filtered_frame(local, sta, skb, |
852 | 1339 | status); | |
853 | /* Clear the TX filter mask for this STA when sending | ||
854 | * the next packet. If the STA went to power save mode, | ||
855 | * this will happen when it is waking up for the next | ||
856 | * time. */ | ||
857 | sta->clear_dst_mask = 1; | ||
858 | |||
859 | /* TODO: Is the WLAN_STA_PS flag always set here or is | ||
860 | * the race between RX and TX status causing some | ||
861 | * packets to be filtered out before 80211.o gets an | ||
862 | * update for PS status? This seems to be the case, so | ||
863 | * no changes are likely to be needed. */ | ||
864 | if (sta->flags & WLAN_STA_PS && | ||
865 | skb_queue_len(&sta->tx_filtered) < | ||
866 | STA_MAX_TX_BUFFER) { | ||
867 | ieee80211_remove_tx_extra(local, sta->key, | ||
868 | skb, | ||
869 | &status->control); | ||
870 | skb_queue_tail(&sta->tx_filtered, skb); | ||
871 | } else if (!(sta->flags & WLAN_STA_PS) && | ||
872 | !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) { | ||
873 | /* Software retry the packet once */ | ||
874 | status->control.flags |= IEEE80211_TXCTL_REQUEUE; | ||
875 | ieee80211_remove_tx_extra(local, sta->key, | ||
876 | skb, | ||
877 | &status->control); | ||
878 | dev_queue_xmit(skb); | ||
879 | } else { | ||
880 | if (net_ratelimit()) { | ||
881 | printk(KERN_DEBUG "%s: dropped TX " | ||
882 | "filtered frame queue_len=%d " | ||
883 | "PS=%d @%lu\n", | ||
884 | wiphy_name(local->hw.wiphy), | ||
885 | skb_queue_len( | ||
886 | &sta->tx_filtered), | ||
887 | !!(sta->flags & WLAN_STA_PS), | ||
888 | jiffies); | ||
889 | } | ||
890 | dev_kfree_skb(skb); | ||
891 | } | ||
892 | sta_info_put(sta); | 1340 | sta_info_put(sta); |
893 | return; | 1341 | return; |
894 | } | 1342 | } |
@@ -932,7 +1380,11 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
932 | /* this was a transmitted frame, but now we want to reuse it */ | 1380 | /* this was a transmitted frame, but now we want to reuse it */ |
933 | skb_orphan(skb); | 1381 | skb_orphan(skb); |
934 | 1382 | ||
935 | if (!local->monitors) { | 1383 | /* |
1384 | * This is a bit racy but we can avoid a lot of work | ||
1385 | * with this test... | ||
1386 | */ | ||
1387 | if (!local->monitors && !local->cooked_mntrs) { | ||
936 | dev_kfree_skb(skb); | 1388 | dev_kfree_skb(skb); |
937 | return; | 1389 | return; |
938 | } | 1390 | } |
@@ -966,51 +1418,44 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
966 | 1418 | ||
967 | rthdr->data_retries = status->retry_count; | 1419 | rthdr->data_retries = status->retry_count; |
968 | 1420 | ||
1421 | /* XXX: is this sufficient for BPF? */ | ||
1422 | skb_set_mac_header(skb, 0); | ||
1423 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
1424 | skb->pkt_type = PACKET_OTHERHOST; | ||
1425 | skb->protocol = htons(ETH_P_802_2); | ||
1426 | memset(skb->cb, 0, sizeof(skb->cb)); | ||
1427 | |||
969 | rcu_read_lock(); | 1428 | rcu_read_lock(); |
970 | monitors = local->monitors; | ||
971 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 1429 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
972 | /* | ||
973 | * Using the monitors counter is possibly racy, but | ||
974 | * if the value is wrong we simply either clone the skb | ||
975 | * once too much or forget sending it to one monitor iface | ||
976 | * The latter case isn't nice but fixing the race is much | ||
977 | * more complicated. | ||
978 | */ | ||
979 | if (!monitors || !skb) | ||
980 | goto out; | ||
981 | |||
982 | if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) { | 1430 | if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) { |
983 | if (!netif_running(sdata->dev)) | 1431 | if (!netif_running(sdata->dev)) |
984 | continue; | 1432 | continue; |
985 | monitors--; | 1433 | |
986 | if (monitors) | 1434 | if (prev_dev) { |
987 | skb2 = skb_clone(skb, GFP_ATOMIC); | 1435 | skb2 = skb_clone(skb, GFP_ATOMIC); |
988 | else | 1436 | if (skb2) { |
989 | skb2 = NULL; | 1437 | skb2->dev = prev_dev; |
990 | skb->dev = sdata->dev; | 1438 | netif_rx(skb2); |
991 | /* XXX: is this sufficient for BPF? */ | 1439 | } |
992 | skb_set_mac_header(skb, 0); | 1440 | } |
993 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 1441 | |
994 | skb->pkt_type = PACKET_OTHERHOST; | 1442 | prev_dev = sdata->dev; |
995 | skb->protocol = htons(ETH_P_802_2); | ||
996 | memset(skb->cb, 0, sizeof(skb->cb)); | ||
997 | netif_rx(skb); | ||
998 | skb = skb2; | ||
999 | } | 1443 | } |
1000 | } | 1444 | } |
1001 | out: | 1445 | if (prev_dev) { |
1446 | skb->dev = prev_dev; | ||
1447 | netif_rx(skb); | ||
1448 | skb = NULL; | ||
1449 | } | ||
1002 | rcu_read_unlock(); | 1450 | rcu_read_unlock(); |
1003 | if (skb) | 1451 | dev_kfree_skb(skb); |
1004 | dev_kfree_skb(skb); | ||
1005 | } | 1452 | } |
1006 | EXPORT_SYMBOL(ieee80211_tx_status); | 1453 | EXPORT_SYMBOL(ieee80211_tx_status); |
1007 | 1454 | ||
1008 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | 1455 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, |
1009 | const struct ieee80211_ops *ops) | 1456 | const struct ieee80211_ops *ops) |
1010 | { | 1457 | { |
1011 | struct net_device *mdev; | ||
1012 | struct ieee80211_local *local; | 1458 | struct ieee80211_local *local; |
1013 | struct ieee80211_sub_if_data *sdata; | ||
1014 | int priv_size; | 1459 | int priv_size; |
1015 | struct wiphy *wiphy; | 1460 | struct wiphy *wiphy; |
1016 | 1461 | ||
@@ -1056,25 +1501,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
1056 | BUG_ON(!ops->configure_filter); | 1501 | BUG_ON(!ops->configure_filter); |
1057 | local->ops = ops; | 1502 | local->ops = ops; |
1058 | 1503 | ||
1059 | /* for now, mdev needs sub_if_data :/ */ | ||
1060 | mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data), | ||
1061 | "wmaster%d", ether_setup); | ||
1062 | if (!mdev) { | ||
1063 | wiphy_free(wiphy); | ||
1064 | return NULL; | ||
1065 | } | ||
1066 | |||
1067 | sdata = IEEE80211_DEV_TO_SUB_IF(mdev); | ||
1068 | mdev->ieee80211_ptr = &sdata->wdev; | ||
1069 | sdata->wdev.wiphy = wiphy; | ||
1070 | |||
1071 | local->hw.queues = 1; /* default */ | 1504 | local->hw.queues = 1; /* default */ |
1072 | 1505 | ||
1073 | local->mdev = mdev; | ||
1074 | local->rx_pre_handlers = ieee80211_rx_pre_handlers; | ||
1075 | local->rx_handlers = ieee80211_rx_handlers; | ||
1076 | local->tx_handlers = ieee80211_tx_handlers; | ||
1077 | |||
1078 | local->bridge_packets = 1; | 1506 | local->bridge_packets = 1; |
1079 | 1507 | ||
1080 | local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | 1508 | local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
@@ -1083,33 +1511,12 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
1083 | local->long_retry_limit = 4; | 1511 | local->long_retry_limit = 4; |
1084 | local->hw.conf.radio_enabled = 1; | 1512 | local->hw.conf.radio_enabled = 1; |
1085 | 1513 | ||
1086 | local->enabled_modes = ~0; | ||
1087 | |||
1088 | INIT_LIST_HEAD(&local->modes_list); | ||
1089 | |||
1090 | INIT_LIST_HEAD(&local->interfaces); | 1514 | INIT_LIST_HEAD(&local->interfaces); |
1091 | 1515 | ||
1092 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work); | 1516 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work); |
1093 | ieee80211_rx_bss_list_init(mdev); | ||
1094 | 1517 | ||
1095 | sta_info_init(local); | 1518 | sta_info_init(local); |
1096 | 1519 | ||
1097 | mdev->hard_start_xmit = ieee80211_master_start_xmit; | ||
1098 | mdev->open = ieee80211_master_open; | ||
1099 | mdev->stop = ieee80211_master_stop; | ||
1100 | mdev->type = ARPHRD_IEEE80211; | ||
1101 | mdev->header_ops = &ieee80211_header_ops; | ||
1102 | mdev->set_multicast_list = ieee80211_master_set_multicast_list; | ||
1103 | |||
1104 | sdata->vif.type = IEEE80211_IF_TYPE_AP; | ||
1105 | sdata->dev = mdev; | ||
1106 | sdata->local = local; | ||
1107 | sdata->u.ap.force_unicast_rateidx = -1; | ||
1108 | sdata->u.ap.max_ratectrl_rateidx = -1; | ||
1109 | ieee80211_if_sdata_init(sdata); | ||
1110 | /* no RCU needed since we're still during init phase */ | ||
1111 | list_add_tail(&sdata->list, &local->interfaces); | ||
1112 | |||
1113 | tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, | 1520 | tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, |
1114 | (unsigned long)local); | 1521 | (unsigned long)local); |
1115 | tasklet_disable(&local->tx_pending_tasklet); | 1522 | tasklet_disable(&local->tx_pending_tasklet); |
@@ -1131,11 +1538,63 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
1131 | struct ieee80211_local *local = hw_to_local(hw); | 1538 | struct ieee80211_local *local = hw_to_local(hw); |
1132 | const char *name; | 1539 | const char *name; |
1133 | int result; | 1540 | int result; |
1541 | enum ieee80211_band band; | ||
1542 | struct net_device *mdev; | ||
1543 | struct ieee80211_sub_if_data *sdata; | ||
1544 | |||
1545 | /* | ||
1546 | * generic code guarantees at least one band, | ||
1547 | * set this very early because much code assumes | ||
1548 | * that hw.conf.channel is assigned | ||
1549 | */ | ||
1550 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
1551 | struct ieee80211_supported_band *sband; | ||
1552 | |||
1553 | sband = local->hw.wiphy->bands[band]; | ||
1554 | if (sband) { | ||
1555 | /* init channel we're on */ | ||
1556 | local->hw.conf.channel = | ||
1557 | local->oper_channel = | ||
1558 | local->scan_channel = &sband->channels[0]; | ||
1559 | break; | ||
1560 | } | ||
1561 | } | ||
1134 | 1562 | ||
1135 | result = wiphy_register(local->hw.wiphy); | 1563 | result = wiphy_register(local->hw.wiphy); |
1136 | if (result < 0) | 1564 | if (result < 0) |
1137 | return result; | 1565 | return result; |
1138 | 1566 | ||
1567 | /* for now, mdev needs sub_if_data :/ */ | ||
1568 | mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data), | ||
1569 | "wmaster%d", ether_setup); | ||
1570 | if (!mdev) | ||
1571 | goto fail_mdev_alloc; | ||
1572 | |||
1573 | sdata = IEEE80211_DEV_TO_SUB_IF(mdev); | ||
1574 | mdev->ieee80211_ptr = &sdata->wdev; | ||
1575 | sdata->wdev.wiphy = local->hw.wiphy; | ||
1576 | |||
1577 | local->mdev = mdev; | ||
1578 | |||
1579 | ieee80211_rx_bss_list_init(mdev); | ||
1580 | |||
1581 | mdev->hard_start_xmit = ieee80211_master_start_xmit; | ||
1582 | mdev->open = ieee80211_master_open; | ||
1583 | mdev->stop = ieee80211_master_stop; | ||
1584 | mdev->type = ARPHRD_IEEE80211; | ||
1585 | mdev->header_ops = &ieee80211_header_ops; | ||
1586 | mdev->set_multicast_list = ieee80211_master_set_multicast_list; | ||
1587 | |||
1588 | sdata->vif.type = IEEE80211_IF_TYPE_AP; | ||
1589 | sdata->dev = mdev; | ||
1590 | sdata->local = local; | ||
1591 | sdata->u.ap.force_unicast_rateidx = -1; | ||
1592 | sdata->u.ap.max_ratectrl_rateidx = -1; | ||
1593 | ieee80211_if_sdata_init(sdata); | ||
1594 | |||
1595 | /* no RCU needed since we're still during init phase */ | ||
1596 | list_add_tail(&sdata->list, &local->interfaces); | ||
1597 | |||
1139 | name = wiphy_dev(local->hw.wiphy)->driver->name; | 1598 | name = wiphy_dev(local->hw.wiphy)->driver->name; |
1140 | local->hw.workqueue = create_singlethread_workqueue(name); | 1599 | local->hw.workqueue = create_singlethread_workqueue(name); |
1141 | if (!local->hw.workqueue) { | 1600 | if (!local->hw.workqueue) { |
@@ -1227,49 +1686,18 @@ fail_sta_info: | |||
1227 | debugfs_hw_del(local); | 1686 | debugfs_hw_del(local); |
1228 | destroy_workqueue(local->hw.workqueue); | 1687 | destroy_workqueue(local->hw.workqueue); |
1229 | fail_workqueue: | 1688 | fail_workqueue: |
1689 | ieee80211_if_free(local->mdev); | ||
1690 | local->mdev = NULL; | ||
1691 | fail_mdev_alloc: | ||
1230 | wiphy_unregister(local->hw.wiphy); | 1692 | wiphy_unregister(local->hw.wiphy); |
1231 | return result; | 1693 | return result; |
1232 | } | 1694 | } |
1233 | EXPORT_SYMBOL(ieee80211_register_hw); | 1695 | EXPORT_SYMBOL(ieee80211_register_hw); |
1234 | 1696 | ||
1235 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, | ||
1236 | struct ieee80211_hw_mode *mode) | ||
1237 | { | ||
1238 | struct ieee80211_local *local = hw_to_local(hw); | ||
1239 | struct ieee80211_rate *rate; | ||
1240 | int i; | ||
1241 | |||
1242 | INIT_LIST_HEAD(&mode->list); | ||
1243 | list_add_tail(&mode->list, &local->modes_list); | ||
1244 | |||
1245 | local->hw_modes |= (1 << mode->mode); | ||
1246 | for (i = 0; i < mode->num_rates; i++) { | ||
1247 | rate = &(mode->rates[i]); | ||
1248 | rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate; | ||
1249 | } | ||
1250 | ieee80211_prepare_rates(local, mode); | ||
1251 | |||
1252 | if (!local->oper_hw_mode) { | ||
1253 | /* Default to this mode */ | ||
1254 | local->hw.conf.phymode = mode->mode; | ||
1255 | local->oper_hw_mode = local->scan_hw_mode = mode; | ||
1256 | local->oper_channel = local->scan_channel = &mode->channels[0]; | ||
1257 | local->hw.conf.mode = local->oper_hw_mode; | ||
1258 | local->hw.conf.chan = local->oper_channel; | ||
1259 | } | ||
1260 | |||
1261 | if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED)) | ||
1262 | ieee80211_set_default_regdomain(mode); | ||
1263 | |||
1264 | return 0; | ||
1265 | } | ||
1266 | EXPORT_SYMBOL(ieee80211_register_hwmode); | ||
1267 | |||
1268 | void ieee80211_unregister_hw(struct ieee80211_hw *hw) | 1697 | void ieee80211_unregister_hw(struct ieee80211_hw *hw) |
1269 | { | 1698 | { |
1270 | struct ieee80211_local *local = hw_to_local(hw); | 1699 | struct ieee80211_local *local = hw_to_local(hw); |
1271 | struct ieee80211_sub_if_data *sdata, *tmp; | 1700 | struct ieee80211_sub_if_data *sdata, *tmp; |
1272 | int i; | ||
1273 | 1701 | ||
1274 | tasklet_kill(&local->tx_pending_tasklet); | 1702 | tasklet_kill(&local->tx_pending_tasklet); |
1275 | tasklet_kill(&local->tasklet); | 1703 | tasklet_kill(&local->tasklet); |
@@ -1310,11 +1738,6 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw) | |||
1310 | rate_control_deinitialize(local); | 1738 | rate_control_deinitialize(local); |
1311 | debugfs_hw_del(local); | 1739 | debugfs_hw_del(local); |
1312 | 1740 | ||
1313 | for (i = 0; i < NUM_IEEE80211_MODES; i++) { | ||
1314 | kfree(local->supp_rates[i]); | ||
1315 | kfree(local->basic_rates[i]); | ||
1316 | } | ||
1317 | |||
1318 | if (skb_queue_len(&local->skb_queue) | 1741 | if (skb_queue_len(&local->skb_queue) |
1319 | || skb_queue_len(&local->skb_queue_unreliable)) | 1742 | || skb_queue_len(&local->skb_queue_unreliable)) |
1320 | printk(KERN_WARNING "%s: skb_queue not empty\n", | 1743 | printk(KERN_WARNING "%s: skb_queue not empty\n", |
@@ -1326,6 +1749,8 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw) | |||
1326 | wiphy_unregister(local->hw.wiphy); | 1749 | wiphy_unregister(local->hw.wiphy); |
1327 | ieee80211_wep_free(local); | 1750 | ieee80211_wep_free(local); |
1328 | ieee80211_led_exit(local); | 1751 | ieee80211_led_exit(local); |
1752 | ieee80211_if_free(local->mdev); | ||
1753 | local->mdev = NULL; | ||
1329 | } | 1754 | } |
1330 | EXPORT_SYMBOL(ieee80211_unregister_hw); | 1755 | EXPORT_SYMBOL(ieee80211_unregister_hw); |
1331 | 1756 | ||
@@ -1333,7 +1758,6 @@ void ieee80211_free_hw(struct ieee80211_hw *hw) | |||
1333 | { | 1758 | { |
1334 | struct ieee80211_local *local = hw_to_local(hw); | 1759 | struct ieee80211_local *local = hw_to_local(hw); |
1335 | 1760 | ||
1336 | ieee80211_if_free(local->mdev); | ||
1337 | wiphy_free(local->hw.wiphy); | 1761 | wiphy_free(local->hw.wiphy); |
1338 | } | 1762 | } |
1339 | EXPORT_SYMBOL(ieee80211_free_hw); | 1763 | EXPORT_SYMBOL(ieee80211_free_hw); |
@@ -1361,7 +1785,6 @@ static int __init ieee80211_init(void) | |||
1361 | } | 1785 | } |
1362 | 1786 | ||
1363 | ieee80211_debugfs_netdev_init(); | 1787 | ieee80211_debugfs_netdev_init(); |
1364 | ieee80211_regdomain_init(); | ||
1365 | 1788 | ||
1366 | return 0; | 1789 | return 0; |
1367 | 1790 | ||
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 72ecbf7bf962..b07b3cbfd039 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -79,8 +79,7 @@ struct ieee80211_sta_bss { | |||
79 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 79 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
80 | size_t ssid_len; | 80 | size_t ssid_len; |
81 | u16 capability; /* host byte order */ | 81 | u16 capability; /* host byte order */ |
82 | int hw_mode; | 82 | enum ieee80211_band band; |
83 | int channel; | ||
84 | int freq; | 83 | int freq; |
85 | int rssi, signal, noise; | 84 | int rssi, signal, noise; |
86 | u8 *wpa_ie; | 85 | u8 *wpa_ie; |
@@ -109,9 +108,17 @@ struct ieee80211_sta_bss { | |||
109 | }; | 108 | }; |
110 | 109 | ||
111 | 110 | ||
112 | typedef enum { | 111 | typedef unsigned __bitwise__ ieee80211_tx_result; |
113 | TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED | 112 | #define TX_CONTINUE ((__force ieee80211_tx_result) 0u) |
114 | } ieee80211_txrx_result; | 113 | #define TX_DROP ((__force ieee80211_tx_result) 1u) |
114 | #define TX_QUEUED ((__force ieee80211_tx_result) 2u) | ||
115 | |||
116 | typedef unsigned __bitwise__ ieee80211_rx_result; | ||
117 | #define RX_CONTINUE ((__force ieee80211_rx_result) 0u) | ||
118 | #define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u) | ||
119 | #define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u) | ||
120 | #define RX_QUEUED ((__force ieee80211_rx_result) 3u) | ||
121 | |||
115 | 122 | ||
116 | /* flags used in struct ieee80211_txrx_data.flags */ | 123 | /* flags used in struct ieee80211_txrx_data.flags */ |
117 | /* whether the MSDU was fragmented */ | 124 | /* whether the MSDU was fragmented */ |
@@ -124,6 +131,7 @@ typedef enum { | |||
124 | #define IEEE80211_TXRXD_RXRA_MATCH BIT(5) | 131 | #define IEEE80211_TXRXD_RXRA_MATCH BIT(5) |
125 | #define IEEE80211_TXRXD_TX_INJECTED BIT(6) | 132 | #define IEEE80211_TXRXD_TX_INJECTED BIT(6) |
126 | #define IEEE80211_TXRXD_RX_AMSDU BIT(7) | 133 | #define IEEE80211_TXRXD_RX_AMSDU BIT(7) |
134 | #define IEEE80211_TXRXD_RX_CMNTR_REPORTED BIT(8) | ||
127 | struct ieee80211_txrx_data { | 135 | struct ieee80211_txrx_data { |
128 | struct sk_buff *skb; | 136 | struct sk_buff *skb; |
129 | struct net_device *dev; | 137 | struct net_device *dev; |
@@ -136,13 +144,12 @@ struct ieee80211_txrx_data { | |||
136 | union { | 144 | union { |
137 | struct { | 145 | struct { |
138 | struct ieee80211_tx_control *control; | 146 | struct ieee80211_tx_control *control; |
139 | struct ieee80211_hw_mode *mode; | 147 | struct ieee80211_channel *channel; |
140 | struct ieee80211_rate *rate; | 148 | struct ieee80211_rate *rate; |
141 | /* use this rate (if set) for last fragment; rate can | 149 | /* use this rate (if set) for last fragment; rate can |
142 | * be set to lower rate for the first fragments, e.g., | 150 | * be set to lower rate for the first fragments, e.g., |
143 | * when using CTS protection with IEEE 802.11g. */ | 151 | * when using CTS protection with IEEE 802.11g. */ |
144 | struct ieee80211_rate *last_frag_rate; | 152 | struct ieee80211_rate *last_frag_rate; |
145 | int last_frag_hwrate; | ||
146 | 153 | ||
147 | /* Extra fragments (in addition to the first fragment | 154 | /* Extra fragments (in addition to the first fragment |
148 | * in skb) */ | 155 | * in skb) */ |
@@ -151,6 +158,7 @@ struct ieee80211_txrx_data { | |||
151 | } tx; | 158 | } tx; |
152 | struct { | 159 | struct { |
153 | struct ieee80211_rx_status *status; | 160 | struct ieee80211_rx_status *status; |
161 | struct ieee80211_rate *rate; | ||
154 | int sent_ps_buffered; | 162 | int sent_ps_buffered; |
155 | int queue; | 163 | int queue; |
156 | int load; | 164 | int load; |
@@ -165,6 +173,7 @@ struct ieee80211_txrx_data { | |||
165 | #define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1) | 173 | #define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1) |
166 | #define IEEE80211_TXPD_REQUEUE BIT(2) | 174 | #define IEEE80211_TXPD_REQUEUE BIT(2) |
167 | #define IEEE80211_TXPD_EAPOL_FRAME BIT(3) | 175 | #define IEEE80211_TXPD_EAPOL_FRAME BIT(3) |
176 | #define IEEE80211_TXPD_AMPDU BIT(4) | ||
168 | /* Stored in sk_buff->cb */ | 177 | /* Stored in sk_buff->cb */ |
169 | struct ieee80211_tx_packet_data { | 178 | struct ieee80211_tx_packet_data { |
170 | int ifindex; | 179 | int ifindex; |
@@ -178,18 +187,10 @@ struct ieee80211_tx_stored_packet { | |||
178 | struct sk_buff *skb; | 187 | struct sk_buff *skb; |
179 | int num_extra_frag; | 188 | int num_extra_frag; |
180 | struct sk_buff **extra_frag; | 189 | struct sk_buff **extra_frag; |
181 | int last_frag_rateidx; | ||
182 | int last_frag_hwrate; | ||
183 | struct ieee80211_rate *last_frag_rate; | 190 | struct ieee80211_rate *last_frag_rate; |
184 | unsigned int last_frag_rate_ctrl_probe; | 191 | unsigned int last_frag_rate_ctrl_probe; |
185 | }; | 192 | }; |
186 | 193 | ||
187 | typedef ieee80211_txrx_result (*ieee80211_tx_handler) | ||
188 | (struct ieee80211_txrx_data *tx); | ||
189 | |||
190 | typedef ieee80211_txrx_result (*ieee80211_rx_handler) | ||
191 | (struct ieee80211_txrx_data *rx); | ||
192 | |||
193 | struct beacon_data { | 194 | struct beacon_data { |
194 | u8 *head, *tail; | 195 | u8 *head, *tail; |
195 | int head_len, tail_len; | 196 | int head_len, tail_len; |
@@ -206,7 +207,7 @@ struct ieee80211_if_ap { | |||
206 | 207 | ||
207 | /* yes, this looks ugly, but guarantees that we can later use | 208 | /* yes, this looks ugly, but guarantees that we can later use |
208 | * bitmap_empty :) | 209 | * bitmap_empty :) |
209 | * NB: don't ever use set_bit, use bss_tim_set/bss_tim_clear! */ | 210 | * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ |
210 | u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]; | 211 | u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]; |
211 | atomic_t num_sta_ps; /* number of stations in PS mode */ | 212 | atomic_t num_sta_ps; /* number of stations in PS mode */ |
212 | struct sk_buff_head ps_bc_buf; | 213 | struct sk_buff_head ps_bc_buf; |
@@ -282,7 +283,7 @@ struct ieee80211_if_sta { | |||
282 | 283 | ||
283 | unsigned long ibss_join_req; | 284 | unsigned long ibss_join_req; |
284 | struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ | 285 | struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ |
285 | u32 supp_rates_bits; | 286 | u32 supp_rates_bits[IEEE80211_NUM_BANDS]; |
286 | 287 | ||
287 | int wmm_last_param_set; | 288 | int wmm_last_param_set; |
288 | }; | 289 | }; |
@@ -292,6 +293,7 @@ struct ieee80211_if_sta { | |||
292 | #define IEEE80211_SDATA_ALLMULTI BIT(0) | 293 | #define IEEE80211_SDATA_ALLMULTI BIT(0) |
293 | #define IEEE80211_SDATA_PROMISC BIT(1) | 294 | #define IEEE80211_SDATA_PROMISC BIT(1) |
294 | #define IEEE80211_SDATA_USERSPACE_MLME BIT(2) | 295 | #define IEEE80211_SDATA_USERSPACE_MLME BIT(2) |
296 | #define IEEE80211_SDATA_OPERATING_GMODE BIT(3) | ||
295 | struct ieee80211_sub_if_data { | 297 | struct ieee80211_sub_if_data { |
296 | struct list_head list; | 298 | struct list_head list; |
297 | 299 | ||
@@ -306,11 +308,11 @@ struct ieee80211_sub_if_data { | |||
306 | unsigned int flags; | 308 | unsigned int flags; |
307 | 309 | ||
308 | int drop_unencrypted; | 310 | int drop_unencrypted; |
311 | |||
309 | /* | 312 | /* |
310 | * IEEE 802.1X Port access control in effect, | 313 | * basic rates of this AP or the AP we're associated to |
311 | * drop packets to/from unauthorized port | ||
312 | */ | 314 | */ |
313 | int ieee802_1x_pac; | 315 | u64 basic_rates; |
314 | 316 | ||
315 | u16 sequence; | 317 | u16 sequence; |
316 | 318 | ||
@@ -338,6 +340,7 @@ struct ieee80211_sub_if_data { | |||
338 | struct ieee80211_if_wds wds; | 340 | struct ieee80211_if_wds wds; |
339 | struct ieee80211_if_vlan vlan; | 341 | struct ieee80211_if_vlan vlan; |
340 | struct ieee80211_if_sta sta; | 342 | struct ieee80211_if_sta sta; |
343 | u32 mntr_flags; | ||
341 | } u; | 344 | } u; |
342 | int channel_use; | 345 | int channel_use; |
343 | int channel_use_raw; | 346 | int channel_use_raw; |
@@ -348,7 +351,6 @@ struct ieee80211_sub_if_data { | |||
348 | struct { | 351 | struct { |
349 | struct dentry *channel_use; | 352 | struct dentry *channel_use; |
350 | struct dentry *drop_unencrypted; | 353 | struct dentry *drop_unencrypted; |
351 | struct dentry *ieee802_1x_pac; | ||
352 | struct dentry *state; | 354 | struct dentry *state; |
353 | struct dentry *bssid; | 355 | struct dentry *bssid; |
354 | struct dentry *prev_bssid; | 356 | struct dentry *prev_bssid; |
@@ -367,7 +369,6 @@ struct ieee80211_sub_if_data { | |||
367 | struct { | 369 | struct { |
368 | struct dentry *channel_use; | 370 | struct dentry *channel_use; |
369 | struct dentry *drop_unencrypted; | 371 | struct dentry *drop_unencrypted; |
370 | struct dentry *ieee802_1x_pac; | ||
371 | struct dentry *num_sta_ps; | 372 | struct dentry *num_sta_ps; |
372 | struct dentry *dtim_count; | 373 | struct dentry *dtim_count; |
373 | struct dentry *num_beacons; | 374 | struct dentry *num_beacons; |
@@ -378,13 +379,11 @@ struct ieee80211_sub_if_data { | |||
378 | struct { | 379 | struct { |
379 | struct dentry *channel_use; | 380 | struct dentry *channel_use; |
380 | struct dentry *drop_unencrypted; | 381 | struct dentry *drop_unencrypted; |
381 | struct dentry *ieee802_1x_pac; | ||
382 | struct dentry *peer; | 382 | struct dentry *peer; |
383 | } wds; | 383 | } wds; |
384 | struct { | 384 | struct { |
385 | struct dentry *channel_use; | 385 | struct dentry *channel_use; |
386 | struct dentry *drop_unencrypted; | 386 | struct dentry *drop_unencrypted; |
387 | struct dentry *ieee802_1x_pac; | ||
388 | } vlan; | 387 | } vlan; |
389 | struct { | 388 | struct { |
390 | struct dentry *mode; | 389 | struct dentry *mode; |
@@ -407,6 +406,8 @@ struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p) | |||
407 | enum { | 406 | enum { |
408 | IEEE80211_RX_MSG = 1, | 407 | IEEE80211_RX_MSG = 1, |
409 | IEEE80211_TX_STATUS_MSG = 2, | 408 | IEEE80211_TX_STATUS_MSG = 2, |
409 | IEEE80211_DELBA_MSG = 3, | ||
410 | IEEE80211_ADDBA_MSG = 4, | ||
410 | }; | 411 | }; |
411 | 412 | ||
412 | struct ieee80211_local { | 413 | struct ieee80211_local { |
@@ -417,12 +418,11 @@ struct ieee80211_local { | |||
417 | 418 | ||
418 | const struct ieee80211_ops *ops; | 419 | const struct ieee80211_ops *ops; |
419 | 420 | ||
420 | /* List of registered struct ieee80211_hw_mode */ | ||
421 | struct list_head modes_list; | ||
422 | |||
423 | struct net_device *mdev; /* wmaster# - "master" 802.11 device */ | 421 | struct net_device *mdev; /* wmaster# - "master" 802.11 device */ |
424 | int open_count; | 422 | int open_count; |
425 | int monitors; | 423 | int monitors, cooked_mntrs; |
424 | /* number of interfaces with corresponding FIF_ flags */ | ||
425 | int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss; | ||
426 | unsigned int filter_flags; /* FIF_* */ | 426 | unsigned int filter_flags; /* FIF_* */ |
427 | struct iw_statistics wstats; | 427 | struct iw_statistics wstats; |
428 | u8 wstats_flags; | 428 | u8 wstats_flags; |
@@ -450,8 +450,8 @@ struct ieee80211_local { | |||
450 | struct sta_info *sta_hash[STA_HASH_SIZE]; | 450 | struct sta_info *sta_hash[STA_HASH_SIZE]; |
451 | struct timer_list sta_cleanup; | 451 | struct timer_list sta_cleanup; |
452 | 452 | ||
453 | unsigned long state[NUM_TX_DATA_QUEUES]; | 453 | unsigned long state[NUM_TX_DATA_QUEUES_AMPDU]; |
454 | struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES]; | 454 | struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES_AMPDU]; |
455 | struct tasklet_struct tx_pending_tasklet; | 455 | struct tasklet_struct tx_pending_tasklet; |
456 | 456 | ||
457 | /* number of interfaces with corresponding IFF_ flags */ | 457 | /* number of interfaces with corresponding IFF_ flags */ |
@@ -459,11 +459,6 @@ struct ieee80211_local { | |||
459 | 459 | ||
460 | struct rate_control_ref *rate_ctrl; | 460 | struct rate_control_ref *rate_ctrl; |
461 | 461 | ||
462 | /* Supported and basic rate filters for different modes. These are | ||
463 | * pointers to -1 terminated lists and rates in 100 kbps units. */ | ||
464 | int *supp_rates[NUM_IEEE80211_MODES]; | ||
465 | int *basic_rates[NUM_IEEE80211_MODES]; | ||
466 | |||
467 | int rts_threshold; | 462 | int rts_threshold; |
468 | int fragmentation_threshold; | 463 | int fragmentation_threshold; |
469 | int short_retry_limit; /* dot11ShortRetryLimit */ | 464 | int short_retry_limit; /* dot11ShortRetryLimit */ |
@@ -477,21 +472,18 @@ struct ieee80211_local { | |||
477 | * deliver multicast frames both back to wireless | 472 | * deliver multicast frames both back to wireless |
478 | * media and to the local net stack */ | 473 | * media and to the local net stack */ |
479 | 474 | ||
480 | ieee80211_rx_handler *rx_pre_handlers; | ||
481 | ieee80211_rx_handler *rx_handlers; | ||
482 | ieee80211_tx_handler *tx_handlers; | ||
483 | |||
484 | struct list_head interfaces; | 475 | struct list_head interfaces; |
485 | 476 | ||
486 | bool sta_sw_scanning; | 477 | bool sta_sw_scanning; |
487 | bool sta_hw_scanning; | 478 | bool sta_hw_scanning; |
488 | int scan_channel_idx; | 479 | int scan_channel_idx; |
480 | enum ieee80211_band scan_band; | ||
481 | |||
489 | enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; | 482 | enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; |
490 | unsigned long last_scan_completed; | 483 | unsigned long last_scan_completed; |
491 | struct delayed_work scan_work; | 484 | struct delayed_work scan_work; |
492 | struct net_device *scan_dev; | 485 | struct net_device *scan_dev; |
493 | struct ieee80211_channel *oper_channel, *scan_channel; | 486 | struct ieee80211_channel *oper_channel, *scan_channel; |
494 | struct ieee80211_hw_mode *oper_hw_mode, *scan_hw_mode; | ||
495 | u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; | 487 | u8 scan_ssid[IEEE80211_MAX_SSID_LEN]; |
496 | size_t scan_ssid_len; | 488 | size_t scan_ssid_len; |
497 | struct list_head sta_bss_list; | 489 | struct list_head sta_bss_list; |
@@ -560,14 +552,8 @@ struct ieee80211_local { | |||
560 | int wifi_wme_noack_test; | 552 | int wifi_wme_noack_test; |
561 | unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ | 553 | unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ |
562 | 554 | ||
563 | unsigned int enabled_modes; /* bitfield of allowed modes; | ||
564 | * (1 << MODE_*) */ | ||
565 | unsigned int hw_modes; /* bitfield of supported hardware modes; | ||
566 | * (1 << MODE_*) */ | ||
567 | |||
568 | #ifdef CONFIG_MAC80211_DEBUGFS | 555 | #ifdef CONFIG_MAC80211_DEBUGFS |
569 | struct local_debugfsdentries { | 556 | struct local_debugfsdentries { |
570 | struct dentry *channel; | ||
571 | struct dentry *frequency; | 557 | struct dentry *frequency; |
572 | struct dentry *antenna_sel_tx; | 558 | struct dentry *antenna_sel_tx; |
573 | struct dentry *antenna_sel_rx; | 559 | struct dentry *antenna_sel_rx; |
@@ -577,9 +563,7 @@ struct ieee80211_local { | |||
577 | struct dentry *short_retry_limit; | 563 | struct dentry *short_retry_limit; |
578 | struct dentry *long_retry_limit; | 564 | struct dentry *long_retry_limit; |
579 | struct dentry *total_ps_buffered; | 565 | struct dentry *total_ps_buffered; |
580 | struct dentry *mode; | ||
581 | struct dentry *wep_iv; | 566 | struct dentry *wep_iv; |
582 | struct dentry *modes; | ||
583 | struct dentry *statistics; | 567 | struct dentry *statistics; |
584 | struct local_debugfsdentries_statsdentries { | 568 | struct local_debugfsdentries_statsdentries { |
585 | struct dentry *transmitted_fragment_count; | 569 | struct dentry *transmitted_fragment_count; |
@@ -627,6 +611,12 @@ struct ieee80211_local { | |||
627 | #endif | 611 | #endif |
628 | }; | 612 | }; |
629 | 613 | ||
614 | /* this struct represents 802.11n's RA/TID combination */ | ||
615 | struct ieee80211_ra_tid { | ||
616 | u8 ra[ETH_ALEN]; | ||
617 | u16 tid; | ||
618 | }; | ||
619 | |||
630 | static inline struct ieee80211_local *hw_to_local( | 620 | static inline struct ieee80211_local *hw_to_local( |
631 | struct ieee80211_hw *hw) | 621 | struct ieee80211_hw *hw) |
632 | { | 622 | { |
@@ -650,57 +640,6 @@ struct sta_attribute { | |||
650 | ssize_t (*store)(struct sta_info *, const char *buf, size_t count); | 640 | ssize_t (*store)(struct sta_info *, const char *buf, size_t count); |
651 | }; | 641 | }; |
652 | 642 | ||
653 | static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid) | ||
654 | { | ||
655 | /* | ||
656 | * This format has been mandated by the IEEE specifications, | ||
657 | * so this line may not be changed to use the __set_bit() format. | ||
658 | */ | ||
659 | bss->tim[aid / 8] |= (1 << (aid % 8)); | ||
660 | } | ||
661 | |||
662 | static inline void bss_tim_set(struct ieee80211_local *local, | ||
663 | struct ieee80211_if_ap *bss, u16 aid) | ||
664 | { | ||
665 | read_lock_bh(&local->sta_lock); | ||
666 | __bss_tim_set(bss, aid); | ||
667 | read_unlock_bh(&local->sta_lock); | ||
668 | } | ||
669 | |||
670 | static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid) | ||
671 | { | ||
672 | /* | ||
673 | * This format has been mandated by the IEEE specifications, | ||
674 | * so this line may not be changed to use the __clear_bit() format. | ||
675 | */ | ||
676 | bss->tim[aid / 8] &= ~(1 << (aid % 8)); | ||
677 | } | ||
678 | |||
679 | static inline void bss_tim_clear(struct ieee80211_local *local, | ||
680 | struct ieee80211_if_ap *bss, u16 aid) | ||
681 | { | ||
682 | read_lock_bh(&local->sta_lock); | ||
683 | __bss_tim_clear(bss, aid); | ||
684 | read_unlock_bh(&local->sta_lock); | ||
685 | } | ||
686 | |||
687 | /** | ||
688 | * ieee80211_is_erp_rate - Check if a rate is an ERP rate | ||
689 | * @phymode: The PHY-mode for this rate (MODE_IEEE80211...) | ||
690 | * @rate: Transmission rate to check, in 100 kbps | ||
691 | * | ||
692 | * Check if a given rate is an Extended Rate PHY (ERP) rate. | ||
693 | */ | ||
694 | static inline int ieee80211_is_erp_rate(int phymode, int rate) | ||
695 | { | ||
696 | if (phymode == MODE_IEEE80211G) { | ||
697 | if (rate != 10 && rate != 20 && | ||
698 | rate != 55 && rate != 110) | ||
699 | return 1; | ||
700 | } | ||
701 | return 0; | ||
702 | } | ||
703 | |||
704 | static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) | 643 | static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) |
705 | { | 644 | { |
706 | return compare_ether_addr(raddr, addr) == 0 || | 645 | return compare_ether_addr(raddr, addr) == 0 || |
@@ -712,13 +651,9 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) | |||
712 | int ieee80211_hw_config(struct ieee80211_local *local); | 651 | int ieee80211_hw_config(struct ieee80211_local *local); |
713 | int ieee80211_if_config(struct net_device *dev); | 652 | int ieee80211_if_config(struct net_device *dev); |
714 | int ieee80211_if_config_beacon(struct net_device *dev); | 653 | int ieee80211_if_config_beacon(struct net_device *dev); |
715 | void ieee80211_prepare_rates(struct ieee80211_local *local, | ||
716 | struct ieee80211_hw_mode *mode); | ||
717 | void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx); | 654 | void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx); |
718 | int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr); | 655 | int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr); |
719 | void ieee80211_if_setup(struct net_device *dev); | 656 | void ieee80211_if_setup(struct net_device *dev); |
720 | struct ieee80211_rate *ieee80211_get_rate(struct ieee80211_local *local, | ||
721 | int phymode, int hwrate); | ||
722 | int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht, | 657 | int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht, |
723 | struct ieee80211_ht_info *req_ht_cap, | 658 | struct ieee80211_ht_info *req_ht_cap, |
724 | struct ieee80211_ht_bss_info *req_bss_cap); | 659 | struct ieee80211_ht_bss_info *req_bss_cap); |
@@ -749,7 +684,7 @@ extern const struct iw_handler_def ieee80211_iw_handler_def; | |||
749 | /* ieee80211_ioctl.c */ | 684 | /* ieee80211_ioctl.c */ |
750 | int ieee80211_set_compression(struct ieee80211_local *local, | 685 | int ieee80211_set_compression(struct ieee80211_local *local, |
751 | struct net_device *dev, struct sta_info *sta); | 686 | struct net_device *dev, struct sta_info *sta); |
752 | int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq); | 687 | int ieee80211_set_freq(struct ieee80211_local *local, int freq); |
753 | /* ieee80211_sta.c */ | 688 | /* ieee80211_sta.c */ |
754 | void ieee80211_sta_timer(unsigned long data); | 689 | void ieee80211_sta_timer(unsigned long data); |
755 | void ieee80211_sta_work(struct work_struct *work); | 690 | void ieee80211_sta_work(struct work_struct *work); |
@@ -763,9 +698,9 @@ int ieee80211_sta_req_scan(struct net_device *dev, u8 *ssid, size_t ssid_len); | |||
763 | void ieee80211_sta_req_auth(struct net_device *dev, | 698 | void ieee80211_sta_req_auth(struct net_device *dev, |
764 | struct ieee80211_if_sta *ifsta); | 699 | struct ieee80211_if_sta *ifsta); |
765 | int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len); | 700 | int ieee80211_sta_scan_results(struct net_device *dev, char *buf, size_t len); |
766 | ieee80211_txrx_result ieee80211_sta_rx_scan(struct net_device *dev, | 701 | ieee80211_rx_result ieee80211_sta_rx_scan( |
767 | struct sk_buff *skb, | 702 | struct net_device *dev, struct sk_buff *skb, |
768 | struct ieee80211_rx_status *rx_status); | 703 | struct ieee80211_rx_status *rx_status); |
769 | void ieee80211_rx_bss_list_init(struct net_device *dev); | 704 | void ieee80211_rx_bss_list_init(struct net_device *dev); |
770 | void ieee80211_rx_bss_list_deinit(struct net_device *dev); | 705 | void ieee80211_rx_bss_list_deinit(struct net_device *dev); |
771 | int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len); | 706 | int ieee80211_sta_set_extra_ie(struct net_device *dev, char *ie, size_t len); |
@@ -782,9 +717,15 @@ int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie, | |||
782 | int ieee80211_ht_addt_info_ie_to_ht_bss_info( | 717 | int ieee80211_ht_addt_info_ie_to_ht_bss_info( |
783 | struct ieee80211_ht_addt_info *ht_add_info_ie, | 718 | struct ieee80211_ht_addt_info *ht_add_info_ie, |
784 | struct ieee80211_ht_bss_info *bss_info); | 719 | struct ieee80211_ht_bss_info *bss_info); |
720 | void ieee80211_send_addba_request(struct net_device *dev, const u8 *da, | ||
721 | u16 tid, u8 dialog_token, u16 start_seq_num, | ||
722 | u16 agg_size, u16 timeout); | ||
723 | void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, | ||
724 | u16 initiator, u16 reason_code); | ||
785 | void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da, | 725 | void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da, |
786 | u16 tid, u16 initiator, u16 reason); | 726 | u16 tid, u16 initiator, u16 reason); |
787 | void sta_rx_agg_session_timer_expired(unsigned long data); | 727 | void sta_rx_agg_session_timer_expired(unsigned long data); |
728 | void sta_addba_resp_timer_expired(unsigned long data); | ||
788 | /* ieee80211_iface.c */ | 729 | /* ieee80211_iface.c */ |
789 | int ieee80211_if_add(struct net_device *dev, const char *name, | 730 | int ieee80211_if_add(struct net_device *dev, const char *name, |
790 | struct net_device **new_dev, int type); | 731 | struct net_device **new_dev, int type); |
@@ -796,16 +737,7 @@ int ieee80211_if_remove(struct net_device *dev, const char *name, int id); | |||
796 | void ieee80211_if_free(struct net_device *dev); | 737 | void ieee80211_if_free(struct net_device *dev); |
797 | void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata); | 738 | void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata); |
798 | 739 | ||
799 | /* regdomain.c */ | ||
800 | void ieee80211_regdomain_init(void); | ||
801 | void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode); | ||
802 | |||
803 | /* rx handling */ | ||
804 | extern ieee80211_rx_handler ieee80211_rx_pre_handlers[]; | ||
805 | extern ieee80211_rx_handler ieee80211_rx_handlers[]; | ||
806 | |||
807 | /* tx handling */ | 740 | /* tx handling */ |
808 | extern ieee80211_tx_handler ieee80211_tx_handlers[]; | ||
809 | void ieee80211_clear_tx_pending(struct ieee80211_local *local); | 741 | void ieee80211_clear_tx_pending(struct ieee80211_local *local); |
810 | void ieee80211_tx_pending(unsigned long data); | 742 | void ieee80211_tx_pending(unsigned long data); |
811 | int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev); | 743 | int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev); |
diff --git a/net/mac80211/ieee80211_iface.c b/net/mac80211/ieee80211_iface.c index 92f1eb2da311..0d6824bca92b 100644 --- a/net/mac80211/ieee80211_iface.c +++ b/net/mac80211/ieee80211_iface.c | |||
@@ -118,6 +118,8 @@ void ieee80211_if_set_type(struct net_device *dev, int type) | |||
118 | sdata->bss = NULL; | 118 | sdata->bss = NULL; |
119 | sdata->vif.type = type; | 119 | sdata->vif.type = type; |
120 | 120 | ||
121 | sdata->basic_rates = 0; | ||
122 | |||
121 | switch (type) { | 123 | switch (type) { |
122 | case IEEE80211_IF_TYPE_WDS: | 124 | case IEEE80211_IF_TYPE_WDS: |
123 | /* nothing special */ | 125 | /* nothing special */ |
@@ -158,6 +160,8 @@ void ieee80211_if_set_type(struct net_device *dev, int type) | |||
158 | case IEEE80211_IF_TYPE_MNTR: | 160 | case IEEE80211_IF_TYPE_MNTR: |
159 | dev->type = ARPHRD_IEEE80211_RADIOTAP; | 161 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
160 | dev->hard_start_xmit = ieee80211_monitor_start_xmit; | 162 | dev->hard_start_xmit = ieee80211_monitor_start_xmit; |
163 | sdata->u.mntr_flags = MONITOR_FLAG_CONTROL | | ||
164 | MONITOR_FLAG_OTHER_BSS; | ||
161 | break; | 165 | break; |
162 | default: | 166 | default: |
163 | printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x", | 167 | printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x", |
@@ -189,6 +193,7 @@ void ieee80211_if_reinit(struct net_device *dev) | |||
189 | /* Remove all virtual interfaces that use this BSS | 193 | /* Remove all virtual interfaces that use this BSS |
190 | * as their sdata->bss */ | 194 | * as their sdata->bss */ |
191 | struct ieee80211_sub_if_data *tsdata, *n; | 195 | struct ieee80211_sub_if_data *tsdata, *n; |
196 | struct beacon_data *beacon; | ||
192 | 197 | ||
193 | list_for_each_entry_safe(tsdata, n, &local->interfaces, list) { | 198 | list_for_each_entry_safe(tsdata, n, &local->interfaces, list) { |
194 | if (tsdata != sdata && tsdata->bss == &sdata->u.ap) { | 199 | if (tsdata != sdata && tsdata->bss == &sdata->u.ap) { |
@@ -206,7 +211,10 @@ void ieee80211_if_reinit(struct net_device *dev) | |||
206 | } | 211 | } |
207 | } | 212 | } |
208 | 213 | ||
209 | kfree(sdata->u.ap.beacon); | 214 | beacon = sdata->u.ap.beacon; |
215 | rcu_assign_pointer(sdata->u.ap.beacon, NULL); | ||
216 | synchronize_rcu(); | ||
217 | kfree(beacon); | ||
210 | 218 | ||
211 | while ((skb = skb_dequeue(&sdata->u.ap.ps_bc_buf))) { | 219 | while ((skb = skb_dequeue(&sdata->u.ap.ps_bc_buf))) { |
212 | local->total_ps_buffered--; | 220 | local->total_ps_buffered--; |
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c index 5024d3733834..7551db3f3abc 100644 --- a/net/mac80211/ieee80211_ioctl.c +++ b/net/mac80211/ieee80211_ioctl.c | |||
@@ -33,8 +33,8 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr, | |||
33 | size_t key_len) | 33 | size_t key_len) |
34 | { | 34 | { |
35 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 35 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
36 | int ret = 0; | 36 | int ret; |
37 | struct sta_info *sta; | 37 | struct sta_info *sta = NULL; |
38 | struct ieee80211_key *key; | 38 | struct ieee80211_key *key; |
39 | struct ieee80211_sub_if_data *sdata; | 39 | struct ieee80211_sub_if_data *sdata; |
40 | 40 | ||
@@ -46,58 +46,64 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr, | |||
46 | return -EINVAL; | 46 | return -EINVAL; |
47 | } | 47 | } |
48 | 48 | ||
49 | if (is_broadcast_ether_addr(sta_addr)) { | 49 | if (remove) { |
50 | sta = NULL; | 50 | if (is_broadcast_ether_addr(sta_addr)) { |
51 | key = sdata->keys[idx]; | 51 | key = sdata->keys[idx]; |
52 | } else { | 52 | } else { |
53 | set_tx_key = 0; | 53 | sta = sta_info_get(local, sta_addr); |
54 | /* | 54 | if (!sta) { |
55 | * According to the standard, the key index of a pairwise | 55 | ret = -ENOENT; |
56 | * key must be zero. However, some AP are broken when it | 56 | key = NULL; |
57 | * comes to WEP key indices, so we work around this. | 57 | goto err_out; |
58 | */ | 58 | } |
59 | if (idx != 0 && alg != ALG_WEP) { | 59 | |
60 | printk(KERN_DEBUG "%s: set_encrypt - non-zero idx for " | 60 | key = sta->key; |
61 | "individual key\n", dev->name); | ||
62 | return -EINVAL; | ||
63 | } | 61 | } |
64 | 62 | ||
65 | sta = sta_info_get(local, sta_addr); | 63 | if (!key) |
66 | if (!sta) { | 64 | ret = -ENOENT; |
67 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 65 | else |
68 | DECLARE_MAC_BUF(mac); | 66 | ret = 0; |
69 | printk(KERN_DEBUG "%s: set_encrypt - unknown addr " | 67 | } else { |
70 | "%s\n", | 68 | key = ieee80211_key_alloc(alg, idx, key_len, _key); |
71 | dev->name, print_mac(mac, sta_addr)); | 69 | if (!key) |
72 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 70 | return -ENOMEM; |
73 | 71 | ||
74 | return -ENOENT; | 72 | if (!is_broadcast_ether_addr(sta_addr)) { |
73 | set_tx_key = 0; | ||
74 | /* | ||
75 | * According to the standard, the key index of a | ||
76 | * pairwise key must be zero. However, some AP are | ||
77 | * broken when it comes to WEP key indices, so we | ||
78 | * work around this. | ||
79 | */ | ||
80 | if (idx != 0 && alg != ALG_WEP) { | ||
81 | ret = -EINVAL; | ||
82 | goto err_out; | ||
83 | } | ||
84 | |||
85 | sta = sta_info_get(local, sta_addr); | ||
86 | if (!sta) { | ||
87 | ret = -ENOENT; | ||
88 | goto err_out; | ||
89 | } | ||
75 | } | 90 | } |
76 | 91 | ||
77 | key = sta->key; | 92 | ieee80211_key_link(key, sdata, sta); |
78 | } | ||
79 | 93 | ||
80 | if (remove) { | 94 | if (set_tx_key || (!sta && !sdata->default_key && key)) |
81 | ieee80211_key_free(key); | 95 | ieee80211_set_default_key(sdata, idx); |
96 | |||
97 | /* don't free key later */ | ||
82 | key = NULL; | 98 | key = NULL; |
83 | } else { | ||
84 | /* | ||
85 | * Automatically frees any old key if present. | ||
86 | */ | ||
87 | key = ieee80211_key_alloc(sdata, sta, alg, idx, key_len, _key); | ||
88 | if (!key) { | ||
89 | ret = -ENOMEM; | ||
90 | goto err_out; | ||
91 | } | ||
92 | } | ||
93 | 99 | ||
94 | if (set_tx_key || (!sta && !sdata->default_key && key)) | 100 | ret = 0; |
95 | ieee80211_set_default_key(sdata, idx); | 101 | } |
96 | 102 | ||
97 | ret = 0; | ||
98 | err_out: | 103 | err_out: |
99 | if (sta) | 104 | if (sta) |
100 | sta_info_put(sta); | 105 | sta_info_put(sta); |
106 | ieee80211_key_free(key); | ||
101 | return ret; | 107 | return ret; |
102 | } | 108 | } |
103 | 109 | ||
@@ -129,22 +135,7 @@ static int ieee80211_ioctl_giwname(struct net_device *dev, | |||
129 | struct iw_request_info *info, | 135 | struct iw_request_info *info, |
130 | char *name, char *extra) | 136 | char *name, char *extra) |
131 | { | 137 | { |
132 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 138 | strcpy(name, "IEEE 802.11"); |
133 | |||
134 | switch (local->hw.conf.phymode) { | ||
135 | case MODE_IEEE80211A: | ||
136 | strcpy(name, "IEEE 802.11a"); | ||
137 | break; | ||
138 | case MODE_IEEE80211B: | ||
139 | strcpy(name, "IEEE 802.11b"); | ||
140 | break; | ||
141 | case MODE_IEEE80211G: | ||
142 | strcpy(name, "IEEE 802.11g"); | ||
143 | break; | ||
144 | default: | ||
145 | strcpy(name, "IEEE 802.11"); | ||
146 | break; | ||
147 | } | ||
148 | 139 | ||
149 | return 0; | 140 | return 0; |
150 | } | 141 | } |
@@ -156,7 +147,7 @@ static int ieee80211_ioctl_giwrange(struct net_device *dev, | |||
156 | { | 147 | { |
157 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 148 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
158 | struct iw_range *range = (struct iw_range *) extra; | 149 | struct iw_range *range = (struct iw_range *) extra; |
159 | struct ieee80211_hw_mode *mode = NULL; | 150 | enum ieee80211_band band; |
160 | int c = 0; | 151 | int c = 0; |
161 | 152 | ||
162 | data->length = sizeof(struct iw_range); | 153 | data->length = sizeof(struct iw_range); |
@@ -191,24 +182,27 @@ static int ieee80211_ioctl_giwrange(struct net_device *dev, | |||
191 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | | 182 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | |
192 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; | 183 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; |
193 | 184 | ||
194 | list_for_each_entry(mode, &local->modes_list, list) { | ||
195 | int i = 0; | ||
196 | 185 | ||
197 | if (!(local->enabled_modes & (1 << mode->mode)) || | 186 | for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { |
198 | (local->hw_modes & local->enabled_modes & | 187 | int i; |
199 | (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B)) | 188 | struct ieee80211_supported_band *sband; |
189 | |||
190 | sband = local->hw.wiphy->bands[band]; | ||
191 | |||
192 | if (!sband) | ||
200 | continue; | 193 | continue; |
201 | 194 | ||
202 | while (i < mode->num_channels && c < IW_MAX_FREQUENCIES) { | 195 | for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { |
203 | struct ieee80211_channel *chan = &mode->channels[i]; | 196 | struct ieee80211_channel *chan = &sband->channels[i]; |
204 | 197 | ||
205 | if (chan->flag & IEEE80211_CHAN_W_SCAN) { | 198 | if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { |
206 | range->freq[c].i = chan->chan; | 199 | range->freq[c].i = |
207 | range->freq[c].m = chan->freq * 100000; | 200 | ieee80211_frequency_to_channel( |
208 | range->freq[c].e = 1; | 201 | chan->center_freq); |
202 | range->freq[c].m = chan->center_freq; | ||
203 | range->freq[c].e = 6; | ||
209 | c++; | 204 | c++; |
210 | } | 205 | } |
211 | i++; | ||
212 | } | 206 | } |
213 | } | 207 | } |
214 | range->num_channels = c; | 208 | range->num_channels = c; |
@@ -294,22 +288,29 @@ static int ieee80211_ioctl_giwmode(struct net_device *dev, | |||
294 | return 0; | 288 | return 0; |
295 | } | 289 | } |
296 | 290 | ||
297 | int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq) | 291 | int ieee80211_set_freq(struct ieee80211_local *local, int freqMHz) |
298 | { | 292 | { |
299 | struct ieee80211_hw_mode *mode; | 293 | int set = 0; |
300 | int c, set = 0; | ||
301 | int ret = -EINVAL; | 294 | int ret = -EINVAL; |
295 | enum ieee80211_band band; | ||
296 | struct ieee80211_supported_band *sband; | ||
297 | int i; | ||
298 | |||
299 | for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { | ||
300 | sband = local->hw.wiphy->bands[band]; | ||
302 | 301 | ||
303 | list_for_each_entry(mode, &local->modes_list, list) { | 302 | if (!sband) |
304 | if (!(local->enabled_modes & (1 << mode->mode))) | ||
305 | continue; | 303 | continue; |
306 | for (c = 0; c < mode->num_channels; c++) { | 304 | |
307 | struct ieee80211_channel *chan = &mode->channels[c]; | 305 | for (i = 0; i < sband->n_channels; i++) { |
308 | if (chan->flag & IEEE80211_CHAN_W_SCAN && | 306 | struct ieee80211_channel *chan = &sband->channels[i]; |
309 | ((chan->chan == channel) || (chan->freq == freq))) { | 307 | |
310 | local->oper_channel = chan; | 308 | if (chan->flags & IEEE80211_CHAN_DISABLED) |
311 | local->oper_hw_mode = mode; | 309 | continue; |
310 | |||
311 | if (chan->center_freq == freqMHz) { | ||
312 | set = 1; | 312 | set = 1; |
313 | local->oper_channel = chan; | ||
313 | break; | 314 | break; |
314 | } | 315 | } |
315 | } | 316 | } |
@@ -347,13 +348,14 @@ static int ieee80211_ioctl_siwfreq(struct net_device *dev, | |||
347 | IEEE80211_STA_AUTO_CHANNEL_SEL; | 348 | IEEE80211_STA_AUTO_CHANNEL_SEL; |
348 | return 0; | 349 | return 0; |
349 | } else | 350 | } else |
350 | return ieee80211_set_channel(local, freq->m, -1); | 351 | return ieee80211_set_freq(local, |
352 | ieee80211_channel_to_frequency(freq->m)); | ||
351 | } else { | 353 | } else { |
352 | int i, div = 1000000; | 354 | int i, div = 1000000; |
353 | for (i = 0; i < freq->e; i++) | 355 | for (i = 0; i < freq->e; i++) |
354 | div /= 10; | 356 | div /= 10; |
355 | if (div > 0) | 357 | if (div > 0) |
356 | return ieee80211_set_channel(local, -1, freq->m / div); | 358 | return ieee80211_set_freq(local, freq->m / div); |
357 | else | 359 | else |
358 | return -EINVAL; | 360 | return -EINVAL; |
359 | } | 361 | } |
@@ -366,10 +368,7 @@ static int ieee80211_ioctl_giwfreq(struct net_device *dev, | |||
366 | { | 368 | { |
367 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 369 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
368 | 370 | ||
369 | /* TODO: in station mode (Managed/Ad-hoc) might need to poll low-level | 371 | freq->m = local->hw.conf.channel->center_freq; |
370 | * driver for the current channel with firmware-based management */ | ||
371 | |||
372 | freq->m = local->hw.conf.freq; | ||
373 | freq->e = 6; | 372 | freq->e = 6; |
374 | 373 | ||
375 | return 0; | 374 | return 0; |
@@ -566,15 +565,17 @@ static int ieee80211_ioctl_siwrate(struct net_device *dev, | |||
566 | struct iw_param *rate, char *extra) | 565 | struct iw_param *rate, char *extra) |
567 | { | 566 | { |
568 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 567 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
569 | struct ieee80211_hw_mode *mode; | 568 | int i, err = -EINVAL; |
570 | int i; | ||
571 | u32 target_rate = rate->value / 100000; | 569 | u32 target_rate = rate->value / 100000; |
572 | struct ieee80211_sub_if_data *sdata; | 570 | struct ieee80211_sub_if_data *sdata; |
571 | struct ieee80211_supported_band *sband; | ||
573 | 572 | ||
574 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 573 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
575 | if (!sdata->bss) | 574 | if (!sdata->bss) |
576 | return -ENODEV; | 575 | return -ENODEV; |
577 | mode = local->oper_hw_mode; | 576 | |
577 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
578 | |||
578 | /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates | 579 | /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates |
579 | * target_rate = X, rate->fixed = 1 means only rate X | 580 | * target_rate = X, rate->fixed = 1 means only rate X |
580 | * target_rate = X, rate->fixed = 0 means all rates <= X */ | 581 | * target_rate = X, rate->fixed = 0 means all rates <= X */ |
@@ -582,18 +583,20 @@ static int ieee80211_ioctl_siwrate(struct net_device *dev, | |||
582 | sdata->bss->force_unicast_rateidx = -1; | 583 | sdata->bss->force_unicast_rateidx = -1; |
583 | if (rate->value < 0) | 584 | if (rate->value < 0) |
584 | return 0; | 585 | return 0; |
585 | for (i=0; i < mode->num_rates; i++) { | 586 | |
586 | struct ieee80211_rate *rates = &mode->rates[i]; | 587 | for (i=0; i< sband->n_bitrates; i++) { |
587 | int this_rate = rates->rate; | 588 | struct ieee80211_rate *brate = &sband->bitrates[i]; |
589 | int this_rate = brate->bitrate; | ||
588 | 590 | ||
589 | if (target_rate == this_rate) { | 591 | if (target_rate == this_rate) { |
590 | sdata->bss->max_ratectrl_rateidx = i; | 592 | sdata->bss->max_ratectrl_rateidx = i; |
591 | if (rate->fixed) | 593 | if (rate->fixed) |
592 | sdata->bss->force_unicast_rateidx = i; | 594 | sdata->bss->force_unicast_rateidx = i; |
593 | return 0; | 595 | err = 0; |
596 | break; | ||
594 | } | 597 | } |
595 | } | 598 | } |
596 | return -EINVAL; | 599 | return err; |
597 | } | 600 | } |
598 | 601 | ||
599 | static int ieee80211_ioctl_giwrate(struct net_device *dev, | 602 | static int ieee80211_ioctl_giwrate(struct net_device *dev, |
@@ -603,18 +606,24 @@ static int ieee80211_ioctl_giwrate(struct net_device *dev, | |||
603 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 606 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
604 | struct sta_info *sta; | 607 | struct sta_info *sta; |
605 | struct ieee80211_sub_if_data *sdata; | 608 | struct ieee80211_sub_if_data *sdata; |
609 | struct ieee80211_supported_band *sband; | ||
606 | 610 | ||
607 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 611 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
612 | |||
608 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA) | 613 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA) |
609 | sta = sta_info_get(local, sdata->u.sta.bssid); | 614 | sta = sta_info_get(local, sdata->u.sta.bssid); |
610 | else | 615 | else |
611 | return -EOPNOTSUPP; | 616 | return -EOPNOTSUPP; |
612 | if (!sta) | 617 | if (!sta) |
613 | return -ENODEV; | 618 | return -ENODEV; |
614 | if (sta->txrate < local->oper_hw_mode->num_rates) | 619 | |
615 | rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000; | 620 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
621 | |||
622 | if (sta->txrate_idx < sband->n_bitrates) | ||
623 | rate->value = sband->bitrates[sta->txrate_idx].bitrate; | ||
616 | else | 624 | else |
617 | rate->value = 0; | 625 | rate->value = 0; |
626 | rate->value *= 100000; | ||
618 | sta_info_put(sta); | 627 | sta_info_put(sta); |
619 | return 0; | 628 | return 0; |
620 | } | 629 | } |
@@ -625,7 +634,7 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev, | |||
625 | { | 634 | { |
626 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 635 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
627 | bool need_reconfig = 0; | 636 | bool need_reconfig = 0; |
628 | u8 new_power_level; | 637 | int new_power_level; |
629 | 638 | ||
630 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) | 639 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) |
631 | return -EINVAL; | 640 | return -EINVAL; |
@@ -635,13 +644,15 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev, | |||
635 | if (data->txpower.fixed) { | 644 | if (data->txpower.fixed) { |
636 | new_power_level = data->txpower.value; | 645 | new_power_level = data->txpower.value; |
637 | } else { | 646 | } else { |
638 | /* Automatic power level. Get the px power from the current | 647 | /* |
639 | * channel. */ | 648 | * Automatic power level. Use maximum power for the current |
640 | struct ieee80211_channel* chan = local->oper_channel; | 649 | * channel. Should be part of rate control. |
650 | */ | ||
651 | struct ieee80211_channel* chan = local->hw.conf.channel; | ||
641 | if (!chan) | 652 | if (!chan) |
642 | return -EINVAL; | 653 | return -EINVAL; |
643 | 654 | ||
644 | new_power_level = chan->power_level; | 655 | new_power_level = chan->max_power; |
645 | } | 656 | } |
646 | 657 | ||
647 | if (local->hw.conf.power_level != new_power_level) { | 658 | if (local->hw.conf.power_level != new_power_level) { |
diff --git a/net/mac80211/ieee80211_key.h b/net/mac80211/ieee80211_key.h index fc770e98d47b..d670e6dbfa39 100644 --- a/net/mac80211/ieee80211_key.h +++ b/net/mac80211/ieee80211_key.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
15 | #include <linux/crypto.h> | 15 | #include <linux/crypto.h> |
16 | #include <linux/rcupdate.h> | ||
16 | #include <net/mac80211.h> | 17 | #include <net/mac80211.h> |
17 | 18 | ||
18 | /* ALG_TKIP | 19 | /* ALG_TKIP |
@@ -45,7 +46,19 @@ struct ieee80211_local; | |||
45 | struct ieee80211_sub_if_data; | 46 | struct ieee80211_sub_if_data; |
46 | struct sta_info; | 47 | struct sta_info; |
47 | 48 | ||
48 | #define KEY_FLAG_UPLOADED_TO_HARDWARE (1<<0) | 49 | /** |
50 | * enum ieee80211_internal_key_flags - internal key flags | ||
51 | * | ||
52 | * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present | ||
53 | * in the hardware for TX crypto hardware acceleration. | ||
54 | * @KEY_FLAG_REMOVE_FROM_HARDWARE: Indicates to the key code that this | ||
55 | * key is present in the hardware (but it cannot be used for | ||
56 | * hardware acceleration any more!) | ||
57 | */ | ||
58 | enum ieee80211_internal_key_flags { | ||
59 | KEY_FLAG_UPLOADED_TO_HARDWARE = BIT(0), | ||
60 | KEY_FLAG_REMOVE_FROM_HARDWARE = BIT(1), | ||
61 | }; | ||
49 | 62 | ||
50 | struct ieee80211_key { | 63 | struct ieee80211_key { |
51 | struct ieee80211_local *local; | 64 | struct ieee80211_local *local; |
@@ -112,12 +125,17 @@ struct ieee80211_key { | |||
112 | struct ieee80211_key_conf conf; | 125 | struct ieee80211_key_conf conf; |
113 | }; | 126 | }; |
114 | 127 | ||
115 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | 128 | struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg, |
116 | struct sta_info *sta, | ||
117 | enum ieee80211_key_alg alg, | ||
118 | int idx, | 129 | int idx, |
119 | size_t key_len, | 130 | size_t key_len, |
120 | const u8 *key_data); | 131 | const u8 *key_data); |
132 | /* | ||
133 | * Insert a key into data structures (sdata, sta if necessary) | ||
134 | * to make it used, free old key. | ||
135 | */ | ||
136 | void ieee80211_key_link(struct ieee80211_key *key, | ||
137 | struct ieee80211_sub_if_data *sdata, | ||
138 | struct sta_info *sta); | ||
121 | void ieee80211_key_free(struct ieee80211_key *key); | 139 | void ieee80211_key_free(struct ieee80211_key *key); |
122 | void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx); | 140 | void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx); |
123 | void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata); | 141 | void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata); |
diff --git a/net/mac80211/ieee80211_rate.c b/net/mac80211/ieee80211_rate.c index b957e67c5fba..ebe29b716b27 100644 --- a/net/mac80211/ieee80211_rate.c +++ b/net/mac80211/ieee80211_rate.c | |||
@@ -163,7 +163,8 @@ static void rate_control_release(struct kref *kref) | |||
163 | } | 163 | } |
164 | 164 | ||
165 | void rate_control_get_rate(struct net_device *dev, | 165 | void rate_control_get_rate(struct net_device *dev, |
166 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, | 166 | struct ieee80211_supported_band *sband, |
167 | struct sk_buff *skb, | ||
167 | struct rate_selection *sel) | 168 | struct rate_selection *sel) |
168 | { | 169 | { |
169 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 170 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
@@ -174,17 +175,17 @@ void rate_control_get_rate(struct net_device *dev, | |||
174 | 175 | ||
175 | memset(sel, 0, sizeof(struct rate_selection)); | 176 | memset(sel, 0, sizeof(struct rate_selection)); |
176 | 177 | ||
177 | ref->ops->get_rate(ref->priv, dev, mode, skb, sel); | 178 | ref->ops->get_rate(ref->priv, dev, sband, skb, sel); |
178 | 179 | ||
179 | /* Select a non-ERP backup rate. */ | 180 | /* Select a non-ERP backup rate. */ |
180 | if (!sel->nonerp) { | 181 | if (!sel->nonerp) { |
181 | for (i = 0; i < mode->num_rates - 1; i++) { | 182 | for (i = 0; i < sband->n_bitrates; i++) { |
182 | struct ieee80211_rate *rate = &mode->rates[i]; | 183 | struct ieee80211_rate *rate = &sband->bitrates[i]; |
183 | if (sel->rate->rate < rate->rate) | 184 | if (sel->rate->bitrate < rate->bitrate) |
184 | break; | 185 | break; |
185 | 186 | ||
186 | if (rate_supported(sta, mode, i) && | 187 | if (rate_supported(sta, sband->band, i) && |
187 | !(rate->flags & IEEE80211_RATE_ERP)) | 188 | !(rate->flags & IEEE80211_RATE_ERP_G)) |
188 | sel->nonerp = rate; | 189 | sel->nonerp = rate; |
189 | } | 190 | } |
190 | } | 191 | } |
diff --git a/net/mac80211/ieee80211_rate.h b/net/mac80211/ieee80211_rate.h index 73f19e8aa51c..5f9a2ca49a57 100644 --- a/net/mac80211/ieee80211_rate.h +++ b/net/mac80211/ieee80211_rate.h | |||
@@ -18,6 +18,7 @@ | |||
18 | #include "ieee80211_i.h" | 18 | #include "ieee80211_i.h" |
19 | #include "sta_info.h" | 19 | #include "sta_info.h" |
20 | 20 | ||
21 | /* TODO: kdoc */ | ||
21 | struct rate_selection { | 22 | struct rate_selection { |
22 | /* Selected transmission rate */ | 23 | /* Selected transmission rate */ |
23 | struct ieee80211_rate *rate; | 24 | struct ieee80211_rate *rate; |
@@ -34,7 +35,8 @@ struct rate_control_ops { | |||
34 | struct sk_buff *skb, | 35 | struct sk_buff *skb, |
35 | struct ieee80211_tx_status *status); | 36 | struct ieee80211_tx_status *status); |
36 | void (*get_rate)(void *priv, struct net_device *dev, | 37 | void (*get_rate)(void *priv, struct net_device *dev, |
37 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, | 38 | struct ieee80211_supported_band *band, |
39 | struct sk_buff *skb, | ||
38 | struct rate_selection *sel); | 40 | struct rate_selection *sel); |
39 | void (*rate_init)(void *priv, void *priv_sta, | 41 | void (*rate_init)(void *priv, void *priv_sta, |
40 | struct ieee80211_local *local, struct sta_info *sta); | 42 | struct ieee80211_local *local, struct sta_info *sta); |
@@ -66,7 +68,8 @@ void ieee80211_rate_control_unregister(struct rate_control_ops *ops); | |||
66 | struct rate_control_ref *rate_control_alloc(const char *name, | 68 | struct rate_control_ref *rate_control_alloc(const char *name, |
67 | struct ieee80211_local *local); | 69 | struct ieee80211_local *local); |
68 | void rate_control_get_rate(struct net_device *dev, | 70 | void rate_control_get_rate(struct net_device *dev, |
69 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, | 71 | struct ieee80211_supported_band *sband, |
72 | struct sk_buff *skb, | ||
70 | struct rate_selection *sel); | 73 | struct rate_selection *sel); |
71 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); | 74 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); |
72 | void rate_control_put(struct rate_control_ref *ref); | 75 | void rate_control_put(struct rate_control_ref *ref); |
@@ -127,23 +130,23 @@ static inline void rate_control_remove_sta_debugfs(struct sta_info *sta) | |||
127 | #endif | 130 | #endif |
128 | } | 131 | } |
129 | 132 | ||
130 | static inline int | 133 | static inline int rate_supported(struct sta_info *sta, |
131 | rate_supported(struct sta_info *sta, struct ieee80211_hw_mode *mode, int index) | 134 | enum ieee80211_band band, |
135 | int index) | ||
132 | { | 136 | { |
133 | return (sta == NULL || sta->supp_rates & BIT(index)) && | 137 | return (sta == NULL || sta->supp_rates[band] & BIT(index)); |
134 | (mode->rates[index].flags & IEEE80211_RATE_SUPPORTED); | ||
135 | } | 138 | } |
136 | 139 | ||
137 | static inline int | 140 | static inline int |
138 | rate_lowest_index(struct ieee80211_local *local, struct ieee80211_hw_mode *mode, | 141 | rate_lowest_index(struct ieee80211_local *local, |
142 | struct ieee80211_supported_band *sband, | ||
139 | struct sta_info *sta) | 143 | struct sta_info *sta) |
140 | { | 144 | { |
141 | int i; | 145 | int i; |
142 | 146 | ||
143 | for (i = 0; i < mode->num_rates; i++) { | 147 | for (i = 0; i < sband->n_bitrates; i++) |
144 | if (rate_supported(sta, mode, i)) | 148 | if (rate_supported(sta, sband->band, i)) |
145 | return i; | 149 | return i; |
146 | } | ||
147 | 150 | ||
148 | /* warn when we cannot find a rate. */ | 151 | /* warn when we cannot find a rate. */ |
149 | WARN_ON(1); | 152 | WARN_ON(1); |
@@ -152,10 +155,11 @@ rate_lowest_index(struct ieee80211_local *local, struct ieee80211_hw_mode *mode, | |||
152 | } | 155 | } |
153 | 156 | ||
154 | static inline struct ieee80211_rate * | 157 | static inline struct ieee80211_rate * |
155 | rate_lowest(struct ieee80211_local *local, struct ieee80211_hw_mode *mode, | 158 | rate_lowest(struct ieee80211_local *local, |
159 | struct ieee80211_supported_band *sband, | ||
156 | struct sta_info *sta) | 160 | struct sta_info *sta) |
157 | { | 161 | { |
158 | return &mode->rates[rate_lowest_index(local, mode, sta)]; | 162 | return &sband->bitrates[rate_lowest_index(local, sband, sta)]; |
159 | } | 163 | } |
160 | 164 | ||
161 | 165 | ||
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c index 9aeed5320228..ddb5832f37cb 100644 --- a/net/mac80211/ieee80211_sta.c +++ b/net/mac80211/ieee80211_sta.c | |||
@@ -74,7 +74,7 @@ | |||
74 | static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst, | 74 | static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst, |
75 | u8 *ssid, size_t ssid_len); | 75 | u8 *ssid, size_t ssid_len); |
76 | static struct ieee80211_sta_bss * | 76 | static struct ieee80211_sta_bss * |
77 | ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int channel, | 77 | ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, |
78 | u8 *ssid, u8 ssid_len); | 78 | u8 *ssid, u8 ssid_len); |
79 | static void ieee80211_rx_bss_put(struct net_device *dev, | 79 | static void ieee80211_rx_bss_put(struct net_device *dev, |
80 | struct ieee80211_sta_bss *bss); | 80 | struct ieee80211_sta_bss *bss); |
@@ -227,12 +227,7 @@ static void ieee802_11_parse_elems(u8 *start, size_t len, | |||
227 | 227 | ||
228 | static int ecw2cw(int ecw) | 228 | static int ecw2cw(int ecw) |
229 | { | 229 | { |
230 | int cw = 1; | 230 | return (1 << ecw) - 1; |
231 | while (ecw > 0) { | ||
232 | cw <<= 1; | ||
233 | ecw--; | ||
234 | } | ||
235 | return cw - 1; | ||
236 | } | 231 | } |
237 | 232 | ||
238 | static void ieee80211_sta_wmm_params(struct net_device *dev, | 233 | static void ieee80211_sta_wmm_params(struct net_device *dev, |
@@ -297,12 +292,13 @@ static void ieee80211_sta_wmm_params(struct net_device *dev, | |||
297 | params.aifs = pos[0] & 0x0f; | 292 | params.aifs = pos[0] & 0x0f; |
298 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); | 293 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); |
299 | params.cw_min = ecw2cw(pos[1] & 0x0f); | 294 | params.cw_min = ecw2cw(pos[1] & 0x0f); |
300 | /* TXOP is in units of 32 usec; burst_time in 0.1 ms */ | 295 | params.txop = pos[2] | (pos[3] << 8); |
301 | params.burst_time = (pos[2] | (pos[3] << 8)) * 32 / 100; | 296 | #ifdef CONFIG_MAC80211_DEBUG |
302 | printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d " | 297 | printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d " |
303 | "cWmin=%d cWmax=%d burst=%d\n", | 298 | "cWmin=%d cWmax=%d txop=%d\n", |
304 | dev->name, queue, aci, acm, params.aifs, params.cw_min, | 299 | dev->name, queue, aci, acm, params.aifs, params.cw_min, |
305 | params.cw_max, params.burst_time); | 300 | params.cw_max, params.txop); |
301 | #endif | ||
306 | /* TODO: handle ACM (block TX, fallback to next lowest allowed | 302 | /* TODO: handle ACM (block TX, fallback to next lowest allowed |
307 | * AC for now) */ | 303 | * AC for now) */ |
308 | if (local->ops->conf_tx(local_to_hw(local), queue, ¶ms)) { | 304 | if (local->ops->conf_tx(local_to_hw(local), queue, ¶ms)) { |
@@ -466,7 +462,7 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
466 | return; | 462 | return; |
467 | 463 | ||
468 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, | 464 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, |
469 | local->hw.conf.channel, | 465 | local->hw.conf.channel->center_freq, |
470 | ifsta->ssid, ifsta->ssid_len); | 466 | ifsta->ssid, ifsta->ssid_len); |
471 | if (bss) { | 467 | if (bss) { |
472 | if (bss->has_erp_value) | 468 | if (bss->has_erp_value) |
@@ -492,6 +488,7 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
492 | ifsta->last_probe = jiffies; | 488 | ifsta->last_probe = jiffies; |
493 | ieee80211_led_assoc(local, assoc); | 489 | ieee80211_led_assoc(local, assoc); |
494 | 490 | ||
491 | sdata->bss_conf.assoc = assoc; | ||
495 | ieee80211_bss_info_change_notify(sdata, changed); | 492 | ieee80211_bss_info_change_notify(sdata, changed); |
496 | } | 493 | } |
497 | 494 | ||
@@ -592,7 +589,6 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
592 | struct ieee80211_if_sta *ifsta) | 589 | struct ieee80211_if_sta *ifsta) |
593 | { | 590 | { |
594 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 591 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
595 | struct ieee80211_hw_mode *mode; | ||
596 | struct sk_buff *skb; | 592 | struct sk_buff *skb; |
597 | struct ieee80211_mgmt *mgmt; | 593 | struct ieee80211_mgmt *mgmt; |
598 | u8 *pos, *ies; | 594 | u8 *pos, *ies; |
@@ -600,6 +596,7 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
600 | u16 capab; | 596 | u16 capab; |
601 | struct ieee80211_sta_bss *bss; | 597 | struct ieee80211_sta_bss *bss; |
602 | int wmm = 0; | 598 | int wmm = 0; |
599 | struct ieee80211_supported_band *sband; | ||
603 | 600 | ||
604 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | 601 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
605 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + | 602 | sizeof(*mgmt) + 200 + ifsta->extra_ie_len + |
@@ -611,13 +608,19 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
611 | } | 608 | } |
612 | skb_reserve(skb, local->hw.extra_tx_headroom); | 609 | skb_reserve(skb, local->hw.extra_tx_headroom); |
613 | 610 | ||
614 | mode = local->oper_hw_mode; | 611 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
612 | |||
615 | capab = ifsta->capab; | 613 | capab = ifsta->capab; |
616 | if (mode->mode == MODE_IEEE80211G) { | 614 | |
617 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME | | 615 | if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) { |
618 | WLAN_CAPABILITY_SHORT_PREAMBLE; | 616 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) |
617 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; | ||
618 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) | ||
619 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; | ||
619 | } | 620 | } |
620 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, local->hw.conf.channel, | 621 | |
622 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, | ||
623 | local->hw.conf.channel->center_freq, | ||
621 | ifsta->ssid, ifsta->ssid_len); | 624 | ifsta->ssid, ifsta->ssid_len); |
622 | if (bss) { | 625 | if (bss) { |
623 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) | 626 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) |
@@ -656,23 +659,23 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
656 | *pos++ = ifsta->ssid_len; | 659 | *pos++ = ifsta->ssid_len; |
657 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | 660 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); |
658 | 661 | ||
659 | len = mode->num_rates; | 662 | len = sband->n_bitrates; |
660 | if (len > 8) | 663 | if (len > 8) |
661 | len = 8; | 664 | len = 8; |
662 | pos = skb_put(skb, len + 2); | 665 | pos = skb_put(skb, len + 2); |
663 | *pos++ = WLAN_EID_SUPP_RATES; | 666 | *pos++ = WLAN_EID_SUPP_RATES; |
664 | *pos++ = len; | 667 | *pos++ = len; |
665 | for (i = 0; i < len; i++) { | 668 | for (i = 0; i < len; i++) { |
666 | int rate = mode->rates[i].rate; | 669 | int rate = sband->bitrates[i].bitrate; |
667 | *pos++ = (u8) (rate / 5); | 670 | *pos++ = (u8) (rate / 5); |
668 | } | 671 | } |
669 | 672 | ||
670 | if (mode->num_rates > len) { | 673 | if (sband->n_bitrates > len) { |
671 | pos = skb_put(skb, mode->num_rates - len + 2); | 674 | pos = skb_put(skb, sband->n_bitrates - len + 2); |
672 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 675 | *pos++ = WLAN_EID_EXT_SUPP_RATES; |
673 | *pos++ = mode->num_rates - len; | 676 | *pos++ = sband->n_bitrates - len; |
674 | for (i = len; i < mode->num_rates; i++) { | 677 | for (i = len; i < sband->n_bitrates; i++) { |
675 | int rate = mode->rates[i].rate; | 678 | int rate = sband->bitrates[i].bitrate; |
676 | *pos++ = (u8) (rate / 5); | 679 | *pos++ = (u8) (rate / 5); |
677 | } | 680 | } |
678 | } | 681 | } |
@@ -695,17 +698,18 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
695 | *pos++ = 0; | 698 | *pos++ = 0; |
696 | } | 699 | } |
697 | /* wmm support is a must to HT */ | 700 | /* wmm support is a must to HT */ |
698 | if (wmm && mode->ht_info.ht_supported) { | 701 | if (wmm && sband->ht_info.ht_supported) { |
699 | __le16 tmp = cpu_to_le16(mode->ht_info.cap); | 702 | __le16 tmp = cpu_to_le16(sband->ht_info.cap); |
700 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); | 703 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2); |
701 | *pos++ = WLAN_EID_HT_CAPABILITY; | 704 | *pos++ = WLAN_EID_HT_CAPABILITY; |
702 | *pos++ = sizeof(struct ieee80211_ht_cap); | 705 | *pos++ = sizeof(struct ieee80211_ht_cap); |
703 | memset(pos, 0, sizeof(struct ieee80211_ht_cap)); | 706 | memset(pos, 0, sizeof(struct ieee80211_ht_cap)); |
704 | memcpy(pos, &tmp, sizeof(u16)); | 707 | memcpy(pos, &tmp, sizeof(u16)); |
705 | pos += sizeof(u16); | 708 | pos += sizeof(u16); |
706 | *pos++ = (mode->ht_info.ampdu_factor | | 709 | /* TODO: needs a define here for << 2 */ |
707 | (mode->ht_info.ampdu_density << 2)); | 710 | *pos++ = sband->ht_info.ampdu_factor | |
708 | memcpy(pos, mode->ht_info.supp_mcs_set, 16); | 711 | (sband->ht_info.ampdu_density << 2); |
712 | memcpy(pos, sband->ht_info.supp_mcs_set, 16); | ||
709 | } | 713 | } |
710 | 714 | ||
711 | kfree(ifsta->assocreq_ies); | 715 | kfree(ifsta->assocreq_ies); |
@@ -788,7 +792,8 @@ static int ieee80211_privacy_mismatch(struct net_device *dev, | |||
788 | if (!ifsta || (ifsta->flags & IEEE80211_STA_MIXED_CELL)) | 792 | if (!ifsta || (ifsta->flags & IEEE80211_STA_MIXED_CELL)) |
789 | return 0; | 793 | return 0; |
790 | 794 | ||
791 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, local->hw.conf.channel, | 795 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, |
796 | local->hw.conf.channel->center_freq, | ||
792 | ifsta->ssid, ifsta->ssid_len); | 797 | ifsta->ssid, ifsta->ssid_len); |
793 | if (!bss) | 798 | if (!bss) |
794 | return 0; | 799 | return 0; |
@@ -898,7 +903,7 @@ static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst, | |||
898 | u8 *ssid, size_t ssid_len) | 903 | u8 *ssid, size_t ssid_len) |
899 | { | 904 | { |
900 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 905 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
901 | struct ieee80211_hw_mode *mode; | 906 | struct ieee80211_supported_band *sband; |
902 | struct sk_buff *skb; | 907 | struct sk_buff *skb; |
903 | struct ieee80211_mgmt *mgmt; | 908 | struct ieee80211_mgmt *mgmt; |
904 | u8 *pos, *supp_rates, *esupp_rates = NULL; | 909 | u8 *pos, *supp_rates, *esupp_rates = NULL; |
@@ -932,11 +937,10 @@ static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst, | |||
932 | supp_rates = skb_put(skb, 2); | 937 | supp_rates = skb_put(skb, 2); |
933 | supp_rates[0] = WLAN_EID_SUPP_RATES; | 938 | supp_rates[0] = WLAN_EID_SUPP_RATES; |
934 | supp_rates[1] = 0; | 939 | supp_rates[1] = 0; |
935 | mode = local->oper_hw_mode; | 940 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
936 | for (i = 0; i < mode->num_rates; i++) { | 941 | |
937 | struct ieee80211_rate *rate = &mode->rates[i]; | 942 | for (i = 0; i < sband->n_bitrates; i++) { |
938 | if (!(rate->flags & IEEE80211_RATE_SUPPORTED)) | 943 | struct ieee80211_rate *rate = &sband->bitrates[i]; |
939 | continue; | ||
940 | if (esupp_rates) { | 944 | if (esupp_rates) { |
941 | pos = skb_put(skb, 1); | 945 | pos = skb_put(skb, 1); |
942 | esupp_rates[1]++; | 946 | esupp_rates[1]++; |
@@ -949,7 +953,7 @@ static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst, | |||
949 | pos = skb_put(skb, 1); | 953 | pos = skb_put(skb, 1); |
950 | supp_rates[1]++; | 954 | supp_rates[1]++; |
951 | } | 955 | } |
952 | *pos = rate->rate / 5; | 956 | *pos = rate->bitrate / 5; |
953 | } | 957 | } |
954 | 958 | ||
955 | ieee80211_sta_tx(dev, skb, 0); | 959 | ieee80211_sta_tx(dev, skb, 0); |
@@ -1044,6 +1048,58 @@ static void ieee80211_send_addba_resp(struct net_device *dev, u8 *da, u16 tid, | |||
1044 | return; | 1048 | return; |
1045 | } | 1049 | } |
1046 | 1050 | ||
1051 | void ieee80211_send_addba_request(struct net_device *dev, const u8 *da, | ||
1052 | u16 tid, u8 dialog_token, u16 start_seq_num, | ||
1053 | u16 agg_size, u16 timeout) | ||
1054 | { | ||
1055 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
1056 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1057 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
1058 | struct sk_buff *skb; | ||
1059 | struct ieee80211_mgmt *mgmt; | ||
1060 | u16 capab; | ||
1061 | |||
1062 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 + | ||
1063 | sizeof(mgmt->u.action.u.addba_req)); | ||
1064 | |||
1065 | |||
1066 | if (!skb) { | ||
1067 | printk(KERN_ERR "%s: failed to allocate buffer " | ||
1068 | "for addba request frame\n", dev->name); | ||
1069 | return; | ||
1070 | } | ||
1071 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
1072 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | ||
1073 | memset(mgmt, 0, 24); | ||
1074 | memcpy(mgmt->da, da, ETH_ALEN); | ||
1075 | memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); | ||
1076 | if (sdata->vif.type == IEEE80211_IF_TYPE_AP) | ||
1077 | memcpy(mgmt->bssid, dev->dev_addr, ETH_ALEN); | ||
1078 | else | ||
1079 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
1080 | |||
1081 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
1082 | IEEE80211_STYPE_ACTION); | ||
1083 | |||
1084 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_req)); | ||
1085 | |||
1086 | mgmt->u.action.category = WLAN_CATEGORY_BACK; | ||
1087 | mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ; | ||
1088 | |||
1089 | mgmt->u.action.u.addba_req.dialog_token = dialog_token; | ||
1090 | capab = (u16)(1 << 1); /* bit 1 aggregation policy */ | ||
1091 | capab |= (u16)(tid << 2); /* bit 5:2 TID number */ | ||
1092 | capab |= (u16)(agg_size << 6); /* bit 15:6 max size of aggergation */ | ||
1093 | |||
1094 | mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab); | ||
1095 | |||
1096 | mgmt->u.action.u.addba_req.timeout = cpu_to_le16(timeout); | ||
1097 | mgmt->u.action.u.addba_req.start_seq_num = | ||
1098 | cpu_to_le16(start_seq_num << 4); | ||
1099 | |||
1100 | ieee80211_sta_tx(dev, skb, 0); | ||
1101 | } | ||
1102 | |||
1047 | static void ieee80211_sta_process_addba_request(struct net_device *dev, | 1103 | static void ieee80211_sta_process_addba_request(struct net_device *dev, |
1048 | struct ieee80211_mgmt *mgmt, | 1104 | struct ieee80211_mgmt *mgmt, |
1049 | size_t len) | 1105 | size_t len) |
@@ -1093,9 +1149,11 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1093 | } | 1149 | } |
1094 | /* determine default buffer size */ | 1150 | /* determine default buffer size */ |
1095 | if (buf_size == 0) { | 1151 | if (buf_size == 0) { |
1096 | struct ieee80211_hw_mode *mode = conf->mode; | 1152 | struct ieee80211_supported_band *sband; |
1153 | |||
1154 | sband = local->hw.wiphy->bands[conf->channel->band]; | ||
1097 | buf_size = IEEE80211_MIN_AMPDU_BUF; | 1155 | buf_size = IEEE80211_MIN_AMPDU_BUF; |
1098 | buf_size = buf_size << mode->ht_info.ampdu_factor; | 1156 | buf_size = buf_size << sband->ht_info.ampdu_factor; |
1099 | } | 1157 | } |
1100 | 1158 | ||
1101 | tid_agg_rx = &sta->ampdu_mlme.tid_rx[tid]; | 1159 | tid_agg_rx = &sta->ampdu_mlme.tid_rx[tid]; |
@@ -1127,7 +1185,7 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev, | |||
1127 | 1185 | ||
1128 | if (local->ops->ampdu_action) | 1186 | if (local->ops->ampdu_action) |
1129 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START, | 1187 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START, |
1130 | sta->addr, tid, start_seq_num); | 1188 | sta->addr, tid, &start_seq_num); |
1131 | #ifdef CONFIG_MAC80211_HT_DEBUG | 1189 | #ifdef CONFIG_MAC80211_HT_DEBUG |
1132 | printk(KERN_DEBUG "Rx A-MPDU on tid %d result %d", tid, ret); | 1190 | printk(KERN_DEBUG "Rx A-MPDU on tid %d result %d", tid, ret); |
1133 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 1191 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
@@ -1155,8 +1213,80 @@ end_no_lock: | |||
1155 | sta_info_put(sta); | 1213 | sta_info_put(sta); |
1156 | } | 1214 | } |
1157 | 1215 | ||
1158 | static void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, | 1216 | static void ieee80211_sta_process_addba_resp(struct net_device *dev, |
1159 | u16 initiator, u16 reason_code) | 1217 | struct ieee80211_mgmt *mgmt, |
1218 | size_t len) | ||
1219 | { | ||
1220 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
1221 | struct ieee80211_hw *hw = &local->hw; | ||
1222 | struct sta_info *sta; | ||
1223 | u16 capab; | ||
1224 | u16 tid; | ||
1225 | u8 *state; | ||
1226 | |||
1227 | sta = sta_info_get(local, mgmt->sa); | ||
1228 | if (!sta) | ||
1229 | return; | ||
1230 | |||
1231 | capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab); | ||
1232 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||
1233 | |||
1234 | state = &sta->ampdu_mlme.tid_tx[tid].state; | ||
1235 | |||
1236 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1237 | |||
1238 | if (mgmt->u.action.u.addba_resp.dialog_token != | ||
1239 | sta->ampdu_mlme.tid_tx[tid].dialog_token) { | ||
1240 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1241 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1242 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); | ||
1243 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1244 | sta_info_put(sta); | ||
1245 | return; | ||
1246 | } | ||
1247 | |||
1248 | del_timer_sync(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer); | ||
1249 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1250 | printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid); | ||
1251 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1252 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) | ||
1253 | == WLAN_STATUS_SUCCESS) { | ||
1254 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | ||
1255 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1256 | printk(KERN_DEBUG "state not HT_ADDBA_REQUESTED_MSK:" | ||
1257 | "%d\n", *state); | ||
1258 | sta_info_put(sta); | ||
1259 | return; | ||
1260 | } | ||
1261 | |||
1262 | if (*state & HT_ADDBA_RECEIVED_MSK) | ||
1263 | printk(KERN_DEBUG "double addBA response\n"); | ||
1264 | |||
1265 | *state |= HT_ADDBA_RECEIVED_MSK; | ||
1266 | sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0; | ||
1267 | |||
1268 | if (*state == HT_AGG_STATE_OPERATIONAL) { | ||
1269 | printk(KERN_DEBUG "Aggregation on for tid %d \n", tid); | ||
1270 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | ||
1271 | } | ||
1272 | |||
1273 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1274 | printk(KERN_DEBUG "recipient accepted agg: tid %d \n", tid); | ||
1275 | } else { | ||
1276 | printk(KERN_DEBUG "recipient rejected agg: tid %d \n", tid); | ||
1277 | |||
1278 | sta->ampdu_mlme.tid_tx[tid].addba_req_num++; | ||
1279 | /* this will allow the state check in stop_BA_session */ | ||
1280 | *state = HT_AGG_STATE_OPERATIONAL; | ||
1281 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1282 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, | ||
1283 | WLAN_BACK_INITIATOR); | ||
1284 | } | ||
1285 | sta_info_put(sta); | ||
1286 | } | ||
1287 | |||
1288 | void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid, | ||
1289 | u16 initiator, u16 reason_code) | ||
1160 | { | 1290 | { |
1161 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1291 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1162 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1292 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
@@ -1229,7 +1359,7 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, | |||
1229 | BUG_ON(!local->ops->ampdu_action); | 1359 | BUG_ON(!local->ops->ampdu_action); |
1230 | 1360 | ||
1231 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_STOP, | 1361 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_STOP, |
1232 | ra, tid, EINVAL); | 1362 | ra, tid, NULL); |
1233 | if (ret) | 1363 | if (ret) |
1234 | printk(KERN_DEBUG "HW problem - can not stop rx " | 1364 | printk(KERN_DEBUG "HW problem - can not stop rx " |
1235 | "aggergation for tid %d\n", tid); | 1365 | "aggergation for tid %d\n", tid); |
@@ -1258,6 +1388,7 @@ void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid, | |||
1258 | sta_info_put(sta); | 1388 | sta_info_put(sta); |
1259 | } | 1389 | } |
1260 | 1390 | ||
1391 | |||
1261 | static void ieee80211_sta_process_delba(struct net_device *dev, | 1392 | static void ieee80211_sta_process_delba(struct net_device *dev, |
1262 | struct ieee80211_mgmt *mgmt, size_t len) | 1393 | struct ieee80211_mgmt *mgmt, size_t len) |
1263 | { | 1394 | { |
@@ -1277,14 +1408,70 @@ static void ieee80211_sta_process_delba(struct net_device *dev, | |||
1277 | 1408 | ||
1278 | #ifdef CONFIG_MAC80211_HT_DEBUG | 1409 | #ifdef CONFIG_MAC80211_HT_DEBUG |
1279 | if (net_ratelimit()) | 1410 | if (net_ratelimit()) |
1280 | printk(KERN_DEBUG "delba from %s on tid %d reason code %d\n", | 1411 | printk(KERN_DEBUG "delba from %s (%s) tid %d reason code %d\n", |
1281 | print_mac(mac, mgmt->sa), tid, | 1412 | print_mac(mac, mgmt->sa), |
1413 | initiator ? "recipient" : "initiator", tid, | ||
1282 | mgmt->u.action.u.delba.reason_code); | 1414 | mgmt->u.action.u.delba.reason_code); |
1283 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | 1415 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
1284 | 1416 | ||
1285 | if (initiator == WLAN_BACK_INITIATOR) | 1417 | if (initiator == WLAN_BACK_INITIATOR) |
1286 | ieee80211_sta_stop_rx_ba_session(dev, sta->addr, tid, | 1418 | ieee80211_sta_stop_rx_ba_session(dev, sta->addr, tid, |
1287 | WLAN_BACK_INITIATOR, 0); | 1419 | WLAN_BACK_INITIATOR, 0); |
1420 | else { /* WLAN_BACK_RECIPIENT */ | ||
1421 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1422 | sta->ampdu_mlme.tid_tx[tid].state = | ||
1423 | HT_AGG_STATE_OPERATIONAL; | ||
1424 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1425 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, | ||
1426 | WLAN_BACK_RECIPIENT); | ||
1427 | } | ||
1428 | sta_info_put(sta); | ||
1429 | } | ||
1430 | |||
1431 | /* | ||
1432 | * After sending add Block Ack request we activated a timer until | ||
1433 | * add Block Ack response will arrive from the recipient. | ||
1434 | * If this timer expires sta_addba_resp_timer_expired will be executed. | ||
1435 | */ | ||
1436 | void sta_addba_resp_timer_expired(unsigned long data) | ||
1437 | { | ||
1438 | /* not an elegant detour, but there is no choice as the timer passes | ||
1439 | * only one argument, and both sta_info and TID are needed, so init | ||
1440 | * flow in sta_info_add gives the TID as data, while the timer_to_id | ||
1441 | * array gives the sta through container_of */ | ||
1442 | u16 tid = *(int *)data; | ||
1443 | struct sta_info *temp_sta = container_of((void *)data, | ||
1444 | struct sta_info, timer_to_tid[tid]); | ||
1445 | |||
1446 | struct ieee80211_local *local = temp_sta->local; | ||
1447 | struct ieee80211_hw *hw = &local->hw; | ||
1448 | struct sta_info *sta; | ||
1449 | u8 *state; | ||
1450 | |||
1451 | sta = sta_info_get(local, temp_sta->addr); | ||
1452 | if (!sta) | ||
1453 | return; | ||
1454 | |||
1455 | state = &sta->ampdu_mlme.tid_tx[tid].state; | ||
1456 | /* check if the TID waits for addBA response */ | ||
1457 | spin_lock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1458 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | ||
1459 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1460 | *state = HT_AGG_STATE_IDLE; | ||
1461 | printk(KERN_DEBUG "timer expired on tid %d but we are not " | ||
1462 | "expecting addBA response there", tid); | ||
1463 | goto timer_expired_exit; | ||
1464 | } | ||
1465 | |||
1466 | printk(KERN_DEBUG "addBA response timer expired on tid %d\n", tid); | ||
1467 | |||
1468 | /* go through the state check in stop_BA_session */ | ||
1469 | *state = HT_AGG_STATE_OPERATIONAL; | ||
1470 | spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx); | ||
1471 | ieee80211_stop_tx_ba_session(hw, temp_sta->addr, tid, | ||
1472 | WLAN_BACK_INITIATOR); | ||
1473 | |||
1474 | timer_expired_exit: | ||
1288 | sta_info_put(sta); | 1475 | sta_info_put(sta); |
1289 | } | 1476 | } |
1290 | 1477 | ||
@@ -1536,15 +1723,16 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1536 | { | 1723 | { |
1537 | struct ieee80211_local *local = sdata->local; | 1724 | struct ieee80211_local *local = sdata->local; |
1538 | struct net_device *dev = sdata->dev; | 1725 | struct net_device *dev = sdata->dev; |
1539 | struct ieee80211_hw_mode *mode; | 1726 | struct ieee80211_supported_band *sband; |
1540 | struct sta_info *sta; | 1727 | struct sta_info *sta; |
1541 | u32 rates; | 1728 | u64 rates, basic_rates; |
1542 | u16 capab_info, status_code, aid; | 1729 | u16 capab_info, status_code, aid; |
1543 | struct ieee802_11_elems elems; | 1730 | struct ieee802_11_elems elems; |
1544 | struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; | 1731 | struct ieee80211_bss_conf *bss_conf = &sdata->bss_conf; |
1545 | u8 *pos; | 1732 | u8 *pos; |
1546 | int i, j; | 1733 | int i, j; |
1547 | DECLARE_MAC_BUF(mac); | 1734 | DECLARE_MAC_BUF(mac); |
1735 | bool have_higher_than_11mbit = false; | ||
1548 | 1736 | ||
1549 | /* AssocResp and ReassocResp have identical structure, so process both | 1737 | /* AssocResp and ReassocResp have identical structure, so process both |
1550 | * of them in this function. */ | 1738 | * of them in this function. */ |
@@ -1614,22 +1802,18 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1614 | if (ifsta->assocresp_ies) | 1802 | if (ifsta->assocresp_ies) |
1615 | memcpy(ifsta->assocresp_ies, pos, ifsta->assocresp_ies_len); | 1803 | memcpy(ifsta->assocresp_ies, pos, ifsta->assocresp_ies_len); |
1616 | 1804 | ||
1617 | /* set AID, ieee80211_set_associated() will tell the driver */ | ||
1618 | bss_conf->aid = aid; | ||
1619 | ieee80211_set_associated(dev, ifsta, 1); | ||
1620 | |||
1621 | /* Add STA entry for the AP */ | 1805 | /* Add STA entry for the AP */ |
1622 | sta = sta_info_get(local, ifsta->bssid); | 1806 | sta = sta_info_get(local, ifsta->bssid); |
1623 | if (!sta) { | 1807 | if (!sta) { |
1624 | struct ieee80211_sta_bss *bss; | 1808 | struct ieee80211_sta_bss *bss; |
1625 | sta = sta_info_add(local, dev, ifsta->bssid, GFP_KERNEL); | 1809 | sta = sta_info_add(local, dev, ifsta->bssid, GFP_KERNEL); |
1626 | if (!sta) { | 1810 | if (IS_ERR(sta)) { |
1627 | printk(KERN_DEBUG "%s: failed to add STA entry for the" | 1811 | printk(KERN_DEBUG "%s: failed to add STA entry for the" |
1628 | " AP\n", dev->name); | 1812 | " AP (error %ld)\n", dev->name, PTR_ERR(sta)); |
1629 | return; | 1813 | return; |
1630 | } | 1814 | } |
1631 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, | 1815 | bss = ieee80211_rx_bss_get(dev, ifsta->bssid, |
1632 | local->hw.conf.channel, | 1816 | local->hw.conf.channel->center_freq, |
1633 | ifsta->ssid, ifsta->ssid_len); | 1817 | ifsta->ssid, ifsta->ssid_len); |
1634 | if (bss) { | 1818 | if (bss) { |
1635 | sta->last_rssi = bss->rssi; | 1819 | sta->last_rssi = bss->rssi; |
@@ -1640,23 +1824,50 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1640 | } | 1824 | } |
1641 | 1825 | ||
1642 | sta->dev = dev; | 1826 | sta->dev = dev; |
1643 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP; | 1827 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP | |
1828 | WLAN_STA_AUTHORIZED; | ||
1644 | 1829 | ||
1645 | rates = 0; | 1830 | rates = 0; |
1646 | mode = local->oper_hw_mode; | 1831 | basic_rates = 0; |
1832 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
1833 | |||
1647 | for (i = 0; i < elems.supp_rates_len; i++) { | 1834 | for (i = 0; i < elems.supp_rates_len; i++) { |
1648 | int rate = (elems.supp_rates[i] & 0x7f) * 5; | 1835 | int rate = (elems.supp_rates[i] & 0x7f) * 5; |
1649 | for (j = 0; j < mode->num_rates; j++) | 1836 | |
1650 | if (mode->rates[j].rate == rate) | 1837 | if (rate > 110) |
1838 | have_higher_than_11mbit = true; | ||
1839 | |||
1840 | for (j = 0; j < sband->n_bitrates; j++) { | ||
1841 | if (sband->bitrates[j].bitrate == rate) | ||
1651 | rates |= BIT(j); | 1842 | rates |= BIT(j); |
1843 | if (elems.supp_rates[i] & 0x80) | ||
1844 | basic_rates |= BIT(j); | ||
1845 | } | ||
1652 | } | 1846 | } |
1847 | |||
1653 | for (i = 0; i < elems.ext_supp_rates_len; i++) { | 1848 | for (i = 0; i < elems.ext_supp_rates_len; i++) { |
1654 | int rate = (elems.ext_supp_rates[i] & 0x7f) * 5; | 1849 | int rate = (elems.ext_supp_rates[i] & 0x7f) * 5; |
1655 | for (j = 0; j < mode->num_rates; j++) | 1850 | |
1656 | if (mode->rates[j].rate == rate) | 1851 | if (rate > 110) |
1852 | have_higher_than_11mbit = true; | ||
1853 | |||
1854 | for (j = 0; j < sband->n_bitrates; j++) { | ||
1855 | if (sband->bitrates[j].bitrate == rate) | ||
1657 | rates |= BIT(j); | 1856 | rates |= BIT(j); |
1857 | if (elems.ext_supp_rates[i] & 0x80) | ||
1858 | basic_rates |= BIT(j); | ||
1859 | } | ||
1658 | } | 1860 | } |
1659 | sta->supp_rates = rates; | 1861 | |
1862 | sta->supp_rates[local->hw.conf.channel->band] = rates; | ||
1863 | sdata->basic_rates = basic_rates; | ||
1864 | |||
1865 | /* cf. IEEE 802.11 9.2.12 */ | ||
1866 | if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && | ||
1867 | have_higher_than_11mbit) | ||
1868 | sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; | ||
1869 | else | ||
1870 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; | ||
1660 | 1871 | ||
1661 | if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && | 1872 | if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && |
1662 | local->ops->conf_ht) { | 1873 | local->ops->conf_ht) { |
@@ -1679,6 +1890,9 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
1679 | elems.wmm_param_len); | 1890 | elems.wmm_param_len); |
1680 | } | 1891 | } |
1681 | 1892 | ||
1893 | /* set AID, ieee80211_set_associated() will tell the driver */ | ||
1894 | bss_conf->aid = aid; | ||
1895 | ieee80211_set_associated(dev, ifsta, 1); | ||
1682 | 1896 | ||
1683 | sta_info_put(sta); | 1897 | sta_info_put(sta); |
1684 | 1898 | ||
@@ -1719,7 +1933,7 @@ static void __ieee80211_rx_bss_hash_del(struct net_device *dev, | |||
1719 | 1933 | ||
1720 | 1934 | ||
1721 | static struct ieee80211_sta_bss * | 1935 | static struct ieee80211_sta_bss * |
1722 | ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid, int channel, | 1936 | ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid, int freq, |
1723 | u8 *ssid, u8 ssid_len) | 1937 | u8 *ssid, u8 ssid_len) |
1724 | { | 1938 | { |
1725 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1939 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
@@ -1731,7 +1945,7 @@ ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid, int channel, | |||
1731 | atomic_inc(&bss->users); | 1945 | atomic_inc(&bss->users); |
1732 | atomic_inc(&bss->users); | 1946 | atomic_inc(&bss->users); |
1733 | memcpy(bss->bssid, bssid, ETH_ALEN); | 1947 | memcpy(bss->bssid, bssid, ETH_ALEN); |
1734 | bss->channel = channel; | 1948 | bss->freq = freq; |
1735 | if (ssid && ssid_len <= IEEE80211_MAX_SSID_LEN) { | 1949 | if (ssid && ssid_len <= IEEE80211_MAX_SSID_LEN) { |
1736 | memcpy(bss->ssid, ssid, ssid_len); | 1950 | memcpy(bss->ssid, ssid, ssid_len); |
1737 | bss->ssid_len = ssid_len; | 1951 | bss->ssid_len = ssid_len; |
@@ -1747,7 +1961,7 @@ ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid, int channel, | |||
1747 | 1961 | ||
1748 | 1962 | ||
1749 | static struct ieee80211_sta_bss * | 1963 | static struct ieee80211_sta_bss * |
1750 | ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int channel, | 1964 | ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int freq, |
1751 | u8 *ssid, u8 ssid_len) | 1965 | u8 *ssid, u8 ssid_len) |
1752 | { | 1966 | { |
1753 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1967 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
@@ -1757,7 +1971,7 @@ ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid, int channel, | |||
1757 | bss = local->sta_bss_hash[STA_HASH(bssid)]; | 1971 | bss = local->sta_bss_hash[STA_HASH(bssid)]; |
1758 | while (bss) { | 1972 | while (bss) { |
1759 | if (!memcmp(bss->bssid, bssid, ETH_ALEN) && | 1973 | if (!memcmp(bss->bssid, bssid, ETH_ALEN) && |
1760 | bss->channel == channel && | 1974 | bss->freq == freq && |
1761 | bss->ssid_len == ssid_len && | 1975 | bss->ssid_len == ssid_len && |
1762 | (ssid_len == 0 || !memcmp(bss->ssid, ssid, ssid_len))) { | 1976 | (ssid_len == 0 || !memcmp(bss->ssid, ssid, ssid_len))) { |
1763 | atomic_inc(&bss->users); | 1977 | atomic_inc(&bss->users); |
@@ -1813,6 +2027,165 @@ void ieee80211_rx_bss_list_deinit(struct net_device *dev) | |||
1813 | } | 2027 | } |
1814 | 2028 | ||
1815 | 2029 | ||
2030 | static int ieee80211_sta_join_ibss(struct net_device *dev, | ||
2031 | struct ieee80211_if_sta *ifsta, | ||
2032 | struct ieee80211_sta_bss *bss) | ||
2033 | { | ||
2034 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2035 | int res, rates, i, j; | ||
2036 | struct sk_buff *skb; | ||
2037 | struct ieee80211_mgmt *mgmt; | ||
2038 | struct ieee80211_tx_control control; | ||
2039 | struct rate_selection ratesel; | ||
2040 | u8 *pos; | ||
2041 | struct ieee80211_sub_if_data *sdata; | ||
2042 | struct ieee80211_supported_band *sband; | ||
2043 | |||
2044 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
2045 | |||
2046 | /* Remove possible STA entries from other IBSS networks. */ | ||
2047 | sta_info_flush(local, NULL); | ||
2048 | |||
2049 | if (local->ops->reset_tsf) { | ||
2050 | /* Reset own TSF to allow time synchronization work. */ | ||
2051 | local->ops->reset_tsf(local_to_hw(local)); | ||
2052 | } | ||
2053 | memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); | ||
2054 | res = ieee80211_if_config(dev); | ||
2055 | if (res) | ||
2056 | return res; | ||
2057 | |||
2058 | local->hw.conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10; | ||
2059 | |||
2060 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
2061 | sdata->drop_unencrypted = bss->capability & | ||
2062 | WLAN_CAPABILITY_PRIVACY ? 1 : 0; | ||
2063 | |||
2064 | res = ieee80211_set_freq(local, bss->freq); | ||
2065 | |||
2066 | if (local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS) { | ||
2067 | printk(KERN_DEBUG "%s: IBSS not allowed on frequency " | ||
2068 | "%d MHz\n", dev->name, local->oper_channel->center_freq); | ||
2069 | return -1; | ||
2070 | } | ||
2071 | |||
2072 | /* Set beacon template */ | ||
2073 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | ||
2074 | do { | ||
2075 | if (!skb) | ||
2076 | break; | ||
2077 | |||
2078 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
2079 | |||
2080 | mgmt = (struct ieee80211_mgmt *) | ||
2081 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); | ||
2082 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); | ||
2083 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
2084 | IEEE80211_STYPE_BEACON); | ||
2085 | memset(mgmt->da, 0xff, ETH_ALEN); | ||
2086 | memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); | ||
2087 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
2088 | mgmt->u.beacon.beacon_int = | ||
2089 | cpu_to_le16(local->hw.conf.beacon_int); | ||
2090 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); | ||
2091 | |||
2092 | pos = skb_put(skb, 2 + ifsta->ssid_len); | ||
2093 | *pos++ = WLAN_EID_SSID; | ||
2094 | *pos++ = ifsta->ssid_len; | ||
2095 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | ||
2096 | |||
2097 | rates = bss->supp_rates_len; | ||
2098 | if (rates > 8) | ||
2099 | rates = 8; | ||
2100 | pos = skb_put(skb, 2 + rates); | ||
2101 | *pos++ = WLAN_EID_SUPP_RATES; | ||
2102 | *pos++ = rates; | ||
2103 | memcpy(pos, bss->supp_rates, rates); | ||
2104 | |||
2105 | if (bss->band == IEEE80211_BAND_2GHZ) { | ||
2106 | pos = skb_put(skb, 2 + 1); | ||
2107 | *pos++ = WLAN_EID_DS_PARAMS; | ||
2108 | *pos++ = 1; | ||
2109 | *pos++ = ieee80211_frequency_to_channel(bss->freq); | ||
2110 | } | ||
2111 | |||
2112 | pos = skb_put(skb, 2 + 2); | ||
2113 | *pos++ = WLAN_EID_IBSS_PARAMS; | ||
2114 | *pos++ = 2; | ||
2115 | /* FIX: set ATIM window based on scan results */ | ||
2116 | *pos++ = 0; | ||
2117 | *pos++ = 0; | ||
2118 | |||
2119 | if (bss->supp_rates_len > 8) { | ||
2120 | rates = bss->supp_rates_len - 8; | ||
2121 | pos = skb_put(skb, 2 + rates); | ||
2122 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
2123 | *pos++ = rates; | ||
2124 | memcpy(pos, &bss->supp_rates[8], rates); | ||
2125 | } | ||
2126 | |||
2127 | memset(&control, 0, sizeof(control)); | ||
2128 | rate_control_get_rate(dev, sband, skb, &ratesel); | ||
2129 | if (!ratesel.rate) { | ||
2130 | printk(KERN_DEBUG "%s: Failed to determine TX rate " | ||
2131 | "for IBSS beacon\n", dev->name); | ||
2132 | break; | ||
2133 | } | ||
2134 | control.vif = &sdata->vif; | ||
2135 | control.tx_rate = ratesel.rate; | ||
2136 | if (sdata->bss_conf.use_short_preamble && | ||
2137 | ratesel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) | ||
2138 | control.flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; | ||
2139 | control.antenna_sel_tx = local->hw.conf.antenna_sel_tx; | ||
2140 | control.flags |= IEEE80211_TXCTL_NO_ACK; | ||
2141 | control.retry_limit = 1; | ||
2142 | |||
2143 | ifsta->probe_resp = skb_copy(skb, GFP_ATOMIC); | ||
2144 | if (ifsta->probe_resp) { | ||
2145 | mgmt = (struct ieee80211_mgmt *) | ||
2146 | ifsta->probe_resp->data; | ||
2147 | mgmt->frame_control = | ||
2148 | IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
2149 | IEEE80211_STYPE_PROBE_RESP); | ||
2150 | } else { | ||
2151 | printk(KERN_DEBUG "%s: Could not allocate ProbeResp " | ||
2152 | "template for IBSS\n", dev->name); | ||
2153 | } | ||
2154 | |||
2155 | if (local->ops->beacon_update && | ||
2156 | local->ops->beacon_update(local_to_hw(local), | ||
2157 | skb, &control) == 0) { | ||
2158 | printk(KERN_DEBUG "%s: Configured IBSS beacon " | ||
2159 | "template\n", dev->name); | ||
2160 | skb = NULL; | ||
2161 | } | ||
2162 | |||
2163 | rates = 0; | ||
2164 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
2165 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
2166 | int bitrate = (bss->supp_rates[i] & 0x7f) * 5; | ||
2167 | for (j = 0; j < sband->n_bitrates; j++) | ||
2168 | if (sband->bitrates[j].bitrate == bitrate) | ||
2169 | rates |= BIT(j); | ||
2170 | } | ||
2171 | ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; | ||
2172 | } while (0); | ||
2173 | |||
2174 | if (skb) { | ||
2175 | printk(KERN_DEBUG "%s: Failed to configure IBSS beacon " | ||
2176 | "template\n", dev->name); | ||
2177 | dev_kfree_skb(skb); | ||
2178 | } | ||
2179 | |||
2180 | ifsta->state = IEEE80211_IBSS_JOINED; | ||
2181 | mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); | ||
2182 | |||
2183 | ieee80211_rx_bss_put(dev, bss); | ||
2184 | |||
2185 | return res; | ||
2186 | } | ||
2187 | |||
2188 | |||
1816 | static void ieee80211_rx_bss_info(struct net_device *dev, | 2189 | static void ieee80211_rx_bss_info(struct net_device *dev, |
1817 | struct ieee80211_mgmt *mgmt, | 2190 | struct ieee80211_mgmt *mgmt, |
1818 | size_t len, | 2191 | size_t len, |
@@ -1822,11 +2195,11 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
1822 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 2195 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1823 | struct ieee802_11_elems elems; | 2196 | struct ieee802_11_elems elems; |
1824 | size_t baselen; | 2197 | size_t baselen; |
1825 | int channel, clen; | 2198 | int freq, clen; |
1826 | struct ieee80211_sta_bss *bss; | 2199 | struct ieee80211_sta_bss *bss; |
1827 | struct sta_info *sta; | 2200 | struct sta_info *sta; |
1828 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 2201 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1829 | u64 timestamp; | 2202 | u64 beacon_timestamp, rx_timestamp; |
1830 | DECLARE_MAC_BUF(mac); | 2203 | DECLARE_MAC_BUF(mac); |
1831 | DECLARE_MAC_BUF(mac2); | 2204 | DECLARE_MAC_BUF(mac2); |
1832 | 2205 | ||
@@ -1843,56 +2216,28 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
1843 | if (baselen > len) | 2216 | if (baselen > len) |
1844 | return; | 2217 | return; |
1845 | 2218 | ||
1846 | timestamp = le64_to_cpu(mgmt->u.beacon.timestamp); | 2219 | beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp); |
1847 | |||
1848 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && beacon && | ||
1849 | memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) { | ||
1850 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | ||
1851 | static unsigned long last_tsf_debug = 0; | ||
1852 | u64 tsf; | ||
1853 | if (local->ops->get_tsf) | ||
1854 | tsf = local->ops->get_tsf(local_to_hw(local)); | ||
1855 | else | ||
1856 | tsf = -1LLU; | ||
1857 | if (time_after(jiffies, last_tsf_debug + 5 * HZ)) { | ||
1858 | printk(KERN_DEBUG "RX beacon SA=%s BSSID=" | ||
1859 | "%s TSF=0x%llx BCN=0x%llx diff=%lld " | ||
1860 | "@%lu\n", | ||
1861 | print_mac(mac, mgmt->sa), print_mac(mac2, mgmt->bssid), | ||
1862 | (unsigned long long)tsf, | ||
1863 | (unsigned long long)timestamp, | ||
1864 | (unsigned long long)(tsf - timestamp), | ||
1865 | jiffies); | ||
1866 | last_tsf_debug = jiffies; | ||
1867 | } | ||
1868 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | ||
1869 | } | ||
1870 | |||
1871 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); | 2220 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); |
1872 | 2221 | ||
1873 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates && | 2222 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates && |
1874 | memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 && | 2223 | memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 && |
1875 | (sta = sta_info_get(local, mgmt->sa))) { | 2224 | (sta = sta_info_get(local, mgmt->sa))) { |
1876 | struct ieee80211_hw_mode *mode; | 2225 | struct ieee80211_supported_band *sband; |
1877 | struct ieee80211_rate *rates; | 2226 | struct ieee80211_rate *bitrates; |
1878 | size_t num_rates; | 2227 | size_t num_rates; |
1879 | u32 supp_rates, prev_rates; | 2228 | u64 supp_rates, prev_rates; |
1880 | int i, j; | 2229 | int i, j; |
1881 | 2230 | ||
1882 | mode = local->sta_sw_scanning ? | 2231 | sband = local->hw.wiphy->bands[rx_status->band]; |
1883 | local->scan_hw_mode : local->oper_hw_mode; | ||
1884 | 2232 | ||
1885 | if (local->sta_hw_scanning) { | 2233 | if (!sband) { |
1886 | /* search for the correct mode matches the beacon */ | 2234 | WARN_ON(1); |
1887 | list_for_each_entry(mode, &local->modes_list, list) | 2235 | sband = local->hw.wiphy->bands[ |
1888 | if (mode->mode == rx_status->phymode) | 2236 | local->hw.conf.channel->band]; |
1889 | break; | ||
1890 | |||
1891 | if (mode == NULL) | ||
1892 | mode = local->oper_hw_mode; | ||
1893 | } | 2237 | } |
1894 | rates = mode->rates; | 2238 | |
1895 | num_rates = mode->num_rates; | 2239 | bitrates = sband->bitrates; |
2240 | num_rates = sband->n_bitrates; | ||
1896 | 2241 | ||
1897 | supp_rates = 0; | 2242 | supp_rates = 0; |
1898 | for (i = 0; i < elems.supp_rates_len + | 2243 | for (i = 0; i < elems.supp_rates_len + |
@@ -1906,24 +2251,27 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
1906 | [i - elems.supp_rates_len]; | 2251 | [i - elems.supp_rates_len]; |
1907 | own_rate = 5 * (rate & 0x7f); | 2252 | own_rate = 5 * (rate & 0x7f); |
1908 | for (j = 0; j < num_rates; j++) | 2253 | for (j = 0; j < num_rates; j++) |
1909 | if (rates[j].rate == own_rate) | 2254 | if (bitrates[j].bitrate == own_rate) |
1910 | supp_rates |= BIT(j); | 2255 | supp_rates |= BIT(j); |
1911 | } | 2256 | } |
1912 | 2257 | ||
1913 | prev_rates = sta->supp_rates; | 2258 | prev_rates = sta->supp_rates[rx_status->band]; |
1914 | sta->supp_rates &= supp_rates; | 2259 | sta->supp_rates[rx_status->band] &= supp_rates; |
1915 | if (sta->supp_rates == 0) { | 2260 | if (sta->supp_rates[rx_status->band] == 0) { |
1916 | /* No matching rates - this should not really happen. | 2261 | /* No matching rates - this should not really happen. |
1917 | * Make sure that at least one rate is marked | 2262 | * Make sure that at least one rate is marked |
1918 | * supported to avoid issues with TX rate ctrl. */ | 2263 | * supported to avoid issues with TX rate ctrl. */ |
1919 | sta->supp_rates = sdata->u.sta.supp_rates_bits; | 2264 | sta->supp_rates[rx_status->band] = |
2265 | sdata->u.sta.supp_rates_bits[rx_status->band]; | ||
1920 | } | 2266 | } |
1921 | if (sta->supp_rates != prev_rates) { | 2267 | if (sta->supp_rates[rx_status->band] != prev_rates) { |
1922 | printk(KERN_DEBUG "%s: updated supp_rates set for " | 2268 | printk(KERN_DEBUG "%s: updated supp_rates set for " |
1923 | "%s based on beacon info (0x%x & 0x%x -> " | 2269 | "%s based on beacon info (0x%llx & 0x%llx -> " |
1924 | "0x%x)\n", | 2270 | "0x%llx)\n", |
1925 | dev->name, print_mac(mac, sta->addr), prev_rates, | 2271 | dev->name, print_mac(mac, sta->addr), |
1926 | supp_rates, sta->supp_rates); | 2272 | (unsigned long long) prev_rates, |
2273 | (unsigned long long) supp_rates, | ||
2274 | (unsigned long long) sta->supp_rates[rx_status->band]); | ||
1927 | } | 2275 | } |
1928 | sta_info_put(sta); | 2276 | sta_info_put(sta); |
1929 | } | 2277 | } |
@@ -1932,14 +2280,14 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
1932 | return; | 2280 | return; |
1933 | 2281 | ||
1934 | if (elems.ds_params && elems.ds_params_len == 1) | 2282 | if (elems.ds_params && elems.ds_params_len == 1) |
1935 | channel = elems.ds_params[0]; | 2283 | freq = ieee80211_channel_to_frequency(elems.ds_params[0]); |
1936 | else | 2284 | else |
1937 | channel = rx_status->channel; | 2285 | freq = rx_status->freq; |
1938 | 2286 | ||
1939 | bss = ieee80211_rx_bss_get(dev, mgmt->bssid, channel, | 2287 | bss = ieee80211_rx_bss_get(dev, mgmt->bssid, freq, |
1940 | elems.ssid, elems.ssid_len); | 2288 | elems.ssid, elems.ssid_len); |
1941 | if (!bss) { | 2289 | if (!bss) { |
1942 | bss = ieee80211_rx_bss_add(dev, mgmt->bssid, channel, | 2290 | bss = ieee80211_rx_bss_add(dev, mgmt->bssid, freq, |
1943 | elems.ssid, elems.ssid_len); | 2291 | elems.ssid, elems.ssid_len); |
1944 | if (!bss) | 2292 | if (!bss) |
1945 | return; | 2293 | return; |
@@ -1952,8 +2300,12 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
1952 | #endif | 2300 | #endif |
1953 | } | 2301 | } |
1954 | 2302 | ||
1955 | if (bss->probe_resp && beacon) { | 2303 | bss->band = rx_status->band; |
1956 | /* Do not allow beacon to override data from Probe Response. */ | 2304 | |
2305 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | ||
2306 | bss->probe_resp && beacon) { | ||
2307 | /* STA mode: | ||
2308 | * Do not allow beacon to override data from Probe Response. */ | ||
1957 | ieee80211_rx_bss_put(dev, bss); | 2309 | ieee80211_rx_bss_put(dev, bss); |
1958 | return; | 2310 | return; |
1959 | } | 2311 | } |
@@ -2050,27 +2402,69 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2050 | bss->ht_ie_len = 0; | 2402 | bss->ht_ie_len = 0; |
2051 | } | 2403 | } |
2052 | 2404 | ||
2053 | bss->hw_mode = rx_status->phymode; | 2405 | bss->timestamp = beacon_timestamp; |
2054 | bss->freq = rx_status->freq; | ||
2055 | if (channel != rx_status->channel && | ||
2056 | (bss->hw_mode == MODE_IEEE80211G || | ||
2057 | bss->hw_mode == MODE_IEEE80211B) && | ||
2058 | channel >= 1 && channel <= 14) { | ||
2059 | static const int freq_list[] = { | ||
2060 | 2412, 2417, 2422, 2427, 2432, 2437, 2442, | ||
2061 | 2447, 2452, 2457, 2462, 2467, 2472, 2484 | ||
2062 | }; | ||
2063 | /* IEEE 802.11g/b mode can receive packets from neighboring | ||
2064 | * channels, so map the channel into frequency. */ | ||
2065 | bss->freq = freq_list[channel - 1]; | ||
2066 | } | ||
2067 | bss->timestamp = timestamp; | ||
2068 | bss->last_update = jiffies; | 2406 | bss->last_update = jiffies; |
2069 | bss->rssi = rx_status->ssi; | 2407 | bss->rssi = rx_status->ssi; |
2070 | bss->signal = rx_status->signal; | 2408 | bss->signal = rx_status->signal; |
2071 | bss->noise = rx_status->noise; | 2409 | bss->noise = rx_status->noise; |
2072 | if (!beacon) | 2410 | if (!beacon) |
2073 | bss->probe_resp++; | 2411 | bss->probe_resp++; |
2412 | |||
2413 | /* check if we need to merge IBSS */ | ||
2414 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && beacon && | ||
2415 | !local->sta_sw_scanning && !local->sta_hw_scanning && | ||
2416 | bss->capability & WLAN_CAPABILITY_IBSS && | ||
2417 | bss->freq == local->oper_channel->center_freq && | ||
2418 | elems.ssid_len == sdata->u.sta.ssid_len && | ||
2419 | memcmp(elems.ssid, sdata->u.sta.ssid, sdata->u.sta.ssid_len) == 0) { | ||
2420 | if (rx_status->flag & RX_FLAG_TSFT) { | ||
2421 | /* in order for correct IBSS merging we need mactime | ||
2422 | * | ||
2423 | * since mactime is defined as the time the first data | ||
2424 | * symbol of the frame hits the PHY, and the timestamp | ||
2425 | * of the beacon is defined as "the time that the data | ||
2426 | * symbol containing the first bit of the timestamp is | ||
2427 | * transmitted to the PHY plus the transmitting STA’s | ||
2428 | * delays through its local PHY from the MAC-PHY | ||
2429 | * interface to its interface with the WM" | ||
2430 | * (802.11 11.1.2) - equals the time this bit arrives at | ||
2431 | * the receiver - we have to take into account the | ||
2432 | * offset between the two. | ||
2433 | * e.g: at 1 MBit that means mactime is 192 usec earlier | ||
2434 | * (=24 bytes * 8 usecs/byte) than the beacon timestamp. | ||
2435 | */ | ||
2436 | int rate = local->hw.wiphy->bands[rx_status->band]-> | ||
2437 | bitrates[rx_status->rate_idx].bitrate; | ||
2438 | rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate); | ||
2439 | } else if (local && local->ops && local->ops->get_tsf) | ||
2440 | /* second best option: get current TSF */ | ||
2441 | rx_timestamp = local->ops->get_tsf(local_to_hw(local)); | ||
2442 | else | ||
2443 | /* can't merge without knowing the TSF */ | ||
2444 | rx_timestamp = -1LLU; | ||
2445 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | ||
2446 | printk(KERN_DEBUG "RX beacon SA=%s BSSID=" | ||
2447 | "%s TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", | ||
2448 | print_mac(mac, mgmt->sa), | ||
2449 | print_mac(mac2, mgmt->bssid), | ||
2450 | (unsigned long long)rx_timestamp, | ||
2451 | (unsigned long long)beacon_timestamp, | ||
2452 | (unsigned long long)(rx_timestamp - beacon_timestamp), | ||
2453 | jiffies); | ||
2454 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | ||
2455 | if (beacon_timestamp > rx_timestamp) { | ||
2456 | #ifndef CONFIG_MAC80211_IBSS_DEBUG | ||
2457 | if (net_ratelimit()) | ||
2458 | #endif | ||
2459 | printk(KERN_DEBUG "%s: beacon TSF higher than " | ||
2460 | "local TSF - IBSS merge with BSSID %s\n", | ||
2461 | dev->name, print_mac(mac, mgmt->bssid)); | ||
2462 | ieee80211_sta_join_ibss(dev, &sdata->u.sta, bss); | ||
2463 | ieee80211_ibss_add_sta(dev, NULL, | ||
2464 | mgmt->bssid, mgmt->sa); | ||
2465 | } | ||
2466 | } | ||
2467 | |||
2074 | ieee80211_rx_bss_put(dev, bss); | 2468 | ieee80211_rx_bss_put(dev, bss); |
2075 | } | 2469 | } |
2076 | 2470 | ||
@@ -2235,6 +2629,12 @@ static void ieee80211_rx_mgmt_action(struct net_device *dev, | |||
2235 | break; | 2629 | break; |
2236 | ieee80211_sta_process_addba_request(dev, mgmt, len); | 2630 | ieee80211_sta_process_addba_request(dev, mgmt, len); |
2237 | break; | 2631 | break; |
2632 | case WLAN_ACTION_ADDBA_RESP: | ||
2633 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2634 | sizeof(mgmt->u.action.u.addba_resp))) | ||
2635 | break; | ||
2636 | ieee80211_sta_process_addba_resp(dev, mgmt, len); | ||
2637 | break; | ||
2238 | case WLAN_ACTION_DELBA: | 2638 | case WLAN_ACTION_DELBA: |
2239 | if (len < (IEEE80211_MIN_ACTION_SIZE + | 2639 | if (len < (IEEE80211_MIN_ACTION_SIZE + |
2240 | sizeof(mgmt->u.action.u.delba))) | 2640 | sizeof(mgmt->u.action.u.delba))) |
@@ -2348,7 +2748,7 @@ static void ieee80211_sta_rx_queued_mgmt(struct net_device *dev, | |||
2348 | } | 2748 | } |
2349 | 2749 | ||
2350 | 2750 | ||
2351 | ieee80211_txrx_result | 2751 | ieee80211_rx_result |
2352 | ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb, | 2752 | ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb, |
2353 | struct ieee80211_rx_status *rx_status) | 2753 | struct ieee80211_rx_status *rx_status) |
2354 | { | 2754 | { |
@@ -2356,31 +2756,31 @@ ieee80211_sta_rx_scan(struct net_device *dev, struct sk_buff *skb, | |||
2356 | u16 fc; | 2756 | u16 fc; |
2357 | 2757 | ||
2358 | if (skb->len < 2) | 2758 | if (skb->len < 2) |
2359 | return TXRX_DROP; | 2759 | return RX_DROP_UNUSABLE; |
2360 | 2760 | ||
2361 | mgmt = (struct ieee80211_mgmt *) skb->data; | 2761 | mgmt = (struct ieee80211_mgmt *) skb->data; |
2362 | fc = le16_to_cpu(mgmt->frame_control); | 2762 | fc = le16_to_cpu(mgmt->frame_control); |
2363 | 2763 | ||
2364 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) | 2764 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) |
2365 | return TXRX_CONTINUE; | 2765 | return RX_CONTINUE; |
2366 | 2766 | ||
2367 | if (skb->len < 24) | 2767 | if (skb->len < 24) |
2368 | return TXRX_DROP; | 2768 | return RX_DROP_MONITOR; |
2369 | 2769 | ||
2370 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { | 2770 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { |
2371 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP) { | 2771 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP) { |
2372 | ieee80211_rx_mgmt_probe_resp(dev, mgmt, | 2772 | ieee80211_rx_mgmt_probe_resp(dev, mgmt, |
2373 | skb->len, rx_status); | 2773 | skb->len, rx_status); |
2374 | dev_kfree_skb(skb); | 2774 | dev_kfree_skb(skb); |
2375 | return TXRX_QUEUED; | 2775 | return RX_QUEUED; |
2376 | } else if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) { | 2776 | } else if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) { |
2377 | ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len, | 2777 | ieee80211_rx_mgmt_beacon(dev, mgmt, skb->len, |
2378 | rx_status); | 2778 | rx_status); |
2379 | dev_kfree_skb(skb); | 2779 | dev_kfree_skb(skb); |
2380 | return TXRX_QUEUED; | 2780 | return RX_QUEUED; |
2381 | } | 2781 | } |
2382 | } | 2782 | } |
2383 | return TXRX_CONTINUE; | 2783 | return RX_CONTINUE; |
2384 | } | 2784 | } |
2385 | 2785 | ||
2386 | 2786 | ||
@@ -2629,7 +3029,7 @@ static int ieee80211_sta_config_auth(struct net_device *dev, | |||
2629 | } | 3029 | } |
2630 | 3030 | ||
2631 | spin_lock_bh(&local->sta_bss_lock); | 3031 | spin_lock_bh(&local->sta_bss_lock); |
2632 | freq = local->oper_channel->freq; | 3032 | freq = local->oper_channel->center_freq; |
2633 | list_for_each_entry(bss, &local->sta_bss_list, list) { | 3033 | list_for_each_entry(bss, &local->sta_bss_list, list) { |
2634 | if (!(bss->capability & WLAN_CAPABILITY_ESS)) | 3034 | if (!(bss->capability & WLAN_CAPABILITY_ESS)) |
2635 | continue; | 3035 | continue; |
@@ -2660,7 +3060,7 @@ static int ieee80211_sta_config_auth(struct net_device *dev, | |||
2660 | spin_unlock_bh(&local->sta_bss_lock); | 3060 | spin_unlock_bh(&local->sta_bss_lock); |
2661 | 3061 | ||
2662 | if (selected) { | 3062 | if (selected) { |
2663 | ieee80211_set_channel(local, -1, selected->freq); | 3063 | ieee80211_set_freq(local, selected->freq); |
2664 | if (!(ifsta->flags & IEEE80211_STA_SSID_SET)) | 3064 | if (!(ifsta->flags & IEEE80211_STA_SSID_SET)) |
2665 | ieee80211_sta_set_ssid(dev, selected->ssid, | 3065 | ieee80211_sta_set_ssid(dev, selected->ssid, |
2666 | selected->ssid_len); | 3066 | selected->ssid_len); |
@@ -2684,162 +3084,6 @@ static int ieee80211_sta_config_auth(struct net_device *dev, | |||
2684 | return -1; | 3084 | return -1; |
2685 | } | 3085 | } |
2686 | 3086 | ||
2687 | static int ieee80211_sta_join_ibss(struct net_device *dev, | ||
2688 | struct ieee80211_if_sta *ifsta, | ||
2689 | struct ieee80211_sta_bss *bss) | ||
2690 | { | ||
2691 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
2692 | int res, rates, i, j; | ||
2693 | struct sk_buff *skb; | ||
2694 | struct ieee80211_mgmt *mgmt; | ||
2695 | struct ieee80211_tx_control control; | ||
2696 | struct ieee80211_hw_mode *mode; | ||
2697 | struct rate_selection ratesel; | ||
2698 | u8 *pos; | ||
2699 | struct ieee80211_sub_if_data *sdata; | ||
2700 | |||
2701 | /* Remove possible STA entries from other IBSS networks. */ | ||
2702 | sta_info_flush(local, NULL); | ||
2703 | |||
2704 | if (local->ops->reset_tsf) { | ||
2705 | /* Reset own TSF to allow time synchronization work. */ | ||
2706 | local->ops->reset_tsf(local_to_hw(local)); | ||
2707 | } | ||
2708 | memcpy(ifsta->bssid, bss->bssid, ETH_ALEN); | ||
2709 | res = ieee80211_if_config(dev); | ||
2710 | if (res) | ||
2711 | return res; | ||
2712 | |||
2713 | local->hw.conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10; | ||
2714 | |||
2715 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
2716 | sdata->drop_unencrypted = bss->capability & | ||
2717 | WLAN_CAPABILITY_PRIVACY ? 1 : 0; | ||
2718 | |||
2719 | res = ieee80211_set_channel(local, -1, bss->freq); | ||
2720 | |||
2721 | if (!(local->oper_channel->flag & IEEE80211_CHAN_W_IBSS)) { | ||
2722 | printk(KERN_DEBUG "%s: IBSS not allowed on channel %d " | ||
2723 | "(%d MHz)\n", dev->name, local->hw.conf.channel, | ||
2724 | local->hw.conf.freq); | ||
2725 | return -1; | ||
2726 | } | ||
2727 | |||
2728 | /* Set beacon template based on scan results */ | ||
2729 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); | ||
2730 | do { | ||
2731 | if (!skb) | ||
2732 | break; | ||
2733 | |||
2734 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
2735 | |||
2736 | mgmt = (struct ieee80211_mgmt *) | ||
2737 | skb_put(skb, 24 + sizeof(mgmt->u.beacon)); | ||
2738 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); | ||
2739 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
2740 | IEEE80211_STYPE_BEACON); | ||
2741 | memset(mgmt->da, 0xff, ETH_ALEN); | ||
2742 | memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); | ||
2743 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
2744 | mgmt->u.beacon.beacon_int = | ||
2745 | cpu_to_le16(local->hw.conf.beacon_int); | ||
2746 | mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability); | ||
2747 | |||
2748 | pos = skb_put(skb, 2 + ifsta->ssid_len); | ||
2749 | *pos++ = WLAN_EID_SSID; | ||
2750 | *pos++ = ifsta->ssid_len; | ||
2751 | memcpy(pos, ifsta->ssid, ifsta->ssid_len); | ||
2752 | |||
2753 | rates = bss->supp_rates_len; | ||
2754 | if (rates > 8) | ||
2755 | rates = 8; | ||
2756 | pos = skb_put(skb, 2 + rates); | ||
2757 | *pos++ = WLAN_EID_SUPP_RATES; | ||
2758 | *pos++ = rates; | ||
2759 | memcpy(pos, bss->supp_rates, rates); | ||
2760 | |||
2761 | pos = skb_put(skb, 2 + 1); | ||
2762 | *pos++ = WLAN_EID_DS_PARAMS; | ||
2763 | *pos++ = 1; | ||
2764 | *pos++ = bss->channel; | ||
2765 | |||
2766 | pos = skb_put(skb, 2 + 2); | ||
2767 | *pos++ = WLAN_EID_IBSS_PARAMS; | ||
2768 | *pos++ = 2; | ||
2769 | /* FIX: set ATIM window based on scan results */ | ||
2770 | *pos++ = 0; | ||
2771 | *pos++ = 0; | ||
2772 | |||
2773 | if (bss->supp_rates_len > 8) { | ||
2774 | rates = bss->supp_rates_len - 8; | ||
2775 | pos = skb_put(skb, 2 + rates); | ||
2776 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | ||
2777 | *pos++ = rates; | ||
2778 | memcpy(pos, &bss->supp_rates[8], rates); | ||
2779 | } | ||
2780 | |||
2781 | memset(&control, 0, sizeof(control)); | ||
2782 | rate_control_get_rate(dev, local->oper_hw_mode, skb, &ratesel); | ||
2783 | if (!ratesel.rate) { | ||
2784 | printk(KERN_DEBUG "%s: Failed to determine TX rate " | ||
2785 | "for IBSS beacon\n", dev->name); | ||
2786 | break; | ||
2787 | } | ||
2788 | control.vif = &sdata->vif; | ||
2789 | control.tx_rate = | ||
2790 | (sdata->bss_conf.use_short_preamble && | ||
2791 | (ratesel.rate->flags & IEEE80211_RATE_PREAMBLE2)) ? | ||
2792 | ratesel.rate->val2 : ratesel.rate->val; | ||
2793 | control.antenna_sel_tx = local->hw.conf.antenna_sel_tx; | ||
2794 | control.power_level = local->hw.conf.power_level; | ||
2795 | control.flags |= IEEE80211_TXCTL_NO_ACK; | ||
2796 | control.retry_limit = 1; | ||
2797 | |||
2798 | ifsta->probe_resp = skb_copy(skb, GFP_ATOMIC); | ||
2799 | if (ifsta->probe_resp) { | ||
2800 | mgmt = (struct ieee80211_mgmt *) | ||
2801 | ifsta->probe_resp->data; | ||
2802 | mgmt->frame_control = | ||
2803 | IEEE80211_FC(IEEE80211_FTYPE_MGMT, | ||
2804 | IEEE80211_STYPE_PROBE_RESP); | ||
2805 | } else { | ||
2806 | printk(KERN_DEBUG "%s: Could not allocate ProbeResp " | ||
2807 | "template for IBSS\n", dev->name); | ||
2808 | } | ||
2809 | |||
2810 | if (local->ops->beacon_update && | ||
2811 | local->ops->beacon_update(local_to_hw(local), | ||
2812 | skb, &control) == 0) { | ||
2813 | printk(KERN_DEBUG "%s: Configured IBSS beacon " | ||
2814 | "template based on scan results\n", dev->name); | ||
2815 | skb = NULL; | ||
2816 | } | ||
2817 | |||
2818 | rates = 0; | ||
2819 | mode = local->oper_hw_mode; | ||
2820 | for (i = 0; i < bss->supp_rates_len; i++) { | ||
2821 | int bitrate = (bss->supp_rates[i] & 0x7f) * 5; | ||
2822 | for (j = 0; j < mode->num_rates; j++) | ||
2823 | if (mode->rates[j].rate == bitrate) | ||
2824 | rates |= BIT(j); | ||
2825 | } | ||
2826 | ifsta->supp_rates_bits = rates; | ||
2827 | } while (0); | ||
2828 | |||
2829 | if (skb) { | ||
2830 | printk(KERN_DEBUG "%s: Failed to configure IBSS beacon " | ||
2831 | "template\n", dev->name); | ||
2832 | dev_kfree_skb(skb); | ||
2833 | } | ||
2834 | |||
2835 | ifsta->state = IEEE80211_IBSS_JOINED; | ||
2836 | mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); | ||
2837 | |||
2838 | ieee80211_rx_bss_put(dev, bss); | ||
2839 | |||
2840 | return res; | ||
2841 | } | ||
2842 | |||
2843 | 3087 | ||
2844 | static int ieee80211_sta_create_ibss(struct net_device *dev, | 3088 | static int ieee80211_sta_create_ibss(struct net_device *dev, |
2845 | struct ieee80211_if_sta *ifsta) | 3089 | struct ieee80211_if_sta *ifsta) |
@@ -2847,7 +3091,7 @@ static int ieee80211_sta_create_ibss(struct net_device *dev, | |||
2847 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 3091 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
2848 | struct ieee80211_sta_bss *bss; | 3092 | struct ieee80211_sta_bss *bss; |
2849 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 3093 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2850 | struct ieee80211_hw_mode *mode; | 3094 | struct ieee80211_supported_band *sband; |
2851 | u8 bssid[ETH_ALEN], *pos; | 3095 | u8 bssid[ETH_ALEN], *pos; |
2852 | int i; | 3096 | int i; |
2853 | DECLARE_MAC_BUF(mac); | 3097 | DECLARE_MAC_BUF(mac); |
@@ -2869,28 +3113,28 @@ static int ieee80211_sta_create_ibss(struct net_device *dev, | |||
2869 | printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %s\n", | 3113 | printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %s\n", |
2870 | dev->name, print_mac(mac, bssid)); | 3114 | dev->name, print_mac(mac, bssid)); |
2871 | 3115 | ||
2872 | bss = ieee80211_rx_bss_add(dev, bssid, local->hw.conf.channel, | 3116 | bss = ieee80211_rx_bss_add(dev, bssid, |
3117 | local->hw.conf.channel->center_freq, | ||
2873 | sdata->u.sta.ssid, sdata->u.sta.ssid_len); | 3118 | sdata->u.sta.ssid, sdata->u.sta.ssid_len); |
2874 | if (!bss) | 3119 | if (!bss) |
2875 | return -ENOMEM; | 3120 | return -ENOMEM; |
2876 | 3121 | ||
2877 | mode = local->oper_hw_mode; | 3122 | bss->band = local->hw.conf.channel->band; |
3123 | sband = local->hw.wiphy->bands[bss->band]; | ||
2878 | 3124 | ||
2879 | if (local->hw.conf.beacon_int == 0) | 3125 | if (local->hw.conf.beacon_int == 0) |
2880 | local->hw.conf.beacon_int = 100; | 3126 | local->hw.conf.beacon_int = 100; |
2881 | bss->beacon_int = local->hw.conf.beacon_int; | 3127 | bss->beacon_int = local->hw.conf.beacon_int; |
2882 | bss->hw_mode = local->hw.conf.phymode; | ||
2883 | bss->freq = local->hw.conf.freq; | ||
2884 | bss->last_update = jiffies; | 3128 | bss->last_update = jiffies; |
2885 | bss->capability = WLAN_CAPABILITY_IBSS; | 3129 | bss->capability = WLAN_CAPABILITY_IBSS; |
2886 | if (sdata->default_key) { | 3130 | if (sdata->default_key) { |
2887 | bss->capability |= WLAN_CAPABILITY_PRIVACY; | 3131 | bss->capability |= WLAN_CAPABILITY_PRIVACY; |
2888 | } else | 3132 | } else |
2889 | sdata->drop_unencrypted = 0; | 3133 | sdata->drop_unencrypted = 0; |
2890 | bss->supp_rates_len = mode->num_rates; | 3134 | bss->supp_rates_len = sband->n_bitrates; |
2891 | pos = bss->supp_rates; | 3135 | pos = bss->supp_rates; |
2892 | for (i = 0; i < mode->num_rates; i++) { | 3136 | for (i = 0; i < sband->n_bitrates; i++) { |
2893 | int rate = mode->rates[i].rate; | 3137 | int rate = sband->bitrates[i].bitrate; |
2894 | *pos++ = (u8) (rate / 5); | 3138 | *pos++ = (u8) (rate / 5); |
2895 | } | 3139 | } |
2896 | 3140 | ||
@@ -2939,7 +3183,8 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
2939 | "%s\n", print_mac(mac, bssid), print_mac(mac2, ifsta->bssid)); | 3183 | "%s\n", print_mac(mac, bssid), print_mac(mac2, ifsta->bssid)); |
2940 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 3184 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
2941 | if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0 && | 3185 | if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0 && |
2942 | (bss = ieee80211_rx_bss_get(dev, bssid, local->hw.conf.channel, | 3186 | (bss = ieee80211_rx_bss_get(dev, bssid, |
3187 | local->hw.conf.channel->center_freq, | ||
2943 | ifsta->ssid, ifsta->ssid_len))) { | 3188 | ifsta->ssid, ifsta->ssid_len))) { |
2944 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %s" | 3189 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %s" |
2945 | " based on configured SSID\n", | 3190 | " based on configured SSID\n", |
@@ -2967,13 +3212,13 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
2967 | if (time_after(jiffies, ifsta->ibss_join_req + | 3212 | if (time_after(jiffies, ifsta->ibss_join_req + |
2968 | IEEE80211_IBSS_JOIN_TIMEOUT)) { | 3213 | IEEE80211_IBSS_JOIN_TIMEOUT)) { |
2969 | if ((ifsta->flags & IEEE80211_STA_CREATE_IBSS) && | 3214 | if ((ifsta->flags & IEEE80211_STA_CREATE_IBSS) && |
2970 | local->oper_channel->flag & IEEE80211_CHAN_W_IBSS) | 3215 | (!(local->oper_channel->flags & |
3216 | IEEE80211_CHAN_NO_IBSS))) | ||
2971 | return ieee80211_sta_create_ibss(dev, ifsta); | 3217 | return ieee80211_sta_create_ibss(dev, ifsta); |
2972 | if (ifsta->flags & IEEE80211_STA_CREATE_IBSS) { | 3218 | if (ifsta->flags & IEEE80211_STA_CREATE_IBSS) { |
2973 | printk(KERN_DEBUG "%s: IBSS not allowed on the" | 3219 | printk(KERN_DEBUG "%s: IBSS not allowed on" |
2974 | " configured channel %d (%d MHz)\n", | 3220 | " %d MHz\n", dev->name, |
2975 | dev->name, local->hw.conf.channel, | 3221 | local->hw.conf.channel->center_freq); |
2976 | local->hw.conf.freq); | ||
2977 | } | 3222 | } |
2978 | 3223 | ||
2979 | /* No IBSS found - decrease scan interval and continue | 3224 | /* No IBSS found - decrease scan interval and continue |
@@ -2992,7 +3237,7 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
2992 | 3237 | ||
2993 | int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len) | 3238 | int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len) |
2994 | { | 3239 | { |
2995 | struct ieee80211_sub_if_data *sdata; | 3240 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2996 | struct ieee80211_if_sta *ifsta; | 3241 | struct ieee80211_if_sta *ifsta; |
2997 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 3242 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
2998 | 3243 | ||
@@ -3006,18 +3251,23 @@ int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len) | |||
3006 | int i; | 3251 | int i; |
3007 | 3252 | ||
3008 | memset(&qparam, 0, sizeof(qparam)); | 3253 | memset(&qparam, 0, sizeof(qparam)); |
3009 | /* TODO: are these ok defaults for all hw_modes? */ | 3254 | |
3010 | qparam.aifs = 2; | 3255 | qparam.aifs = 2; |
3011 | qparam.cw_min = | 3256 | |
3012 | local->hw.conf.phymode == MODE_IEEE80211B ? 31 : 15; | 3257 | if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && |
3258 | !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)) | ||
3259 | qparam.cw_min = 31; | ||
3260 | else | ||
3261 | qparam.cw_min = 15; | ||
3262 | |||
3013 | qparam.cw_max = 1023; | 3263 | qparam.cw_max = 1023; |
3014 | qparam.burst_time = 0; | 3264 | qparam.txop = 0; |
3265 | |||
3015 | for (i = IEEE80211_TX_QUEUE_DATA0; i < NUM_TX_DATA_QUEUES; i++) | 3266 | for (i = IEEE80211_TX_QUEUE_DATA0; i < NUM_TX_DATA_QUEUES; i++) |
3016 | { | ||
3017 | local->ops->conf_tx(local_to_hw(local), | 3267 | local->ops->conf_tx(local_to_hw(local), |
3018 | i + IEEE80211_TX_QUEUE_DATA0, | 3268 | i + IEEE80211_TX_QUEUE_DATA0, |
3019 | &qparam); | 3269 | &qparam); |
3020 | } | 3270 | |
3021 | /* IBSS uses different parameters for Beacon sending */ | 3271 | /* IBSS uses different parameters for Beacon sending */ |
3022 | qparam.cw_min++; | 3272 | qparam.cw_min++; |
3023 | qparam.cw_min *= 2; | 3273 | qparam.cw_min *= 2; |
@@ -3026,7 +3276,6 @@ int ieee80211_sta_set_ssid(struct net_device *dev, char *ssid, size_t len) | |||
3026 | IEEE80211_TX_QUEUE_BEACON, &qparam); | 3276 | IEEE80211_TX_QUEUE_BEACON, &qparam); |
3027 | } | 3277 | } |
3028 | 3278 | ||
3029 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
3030 | ifsta = &sdata->u.sta; | 3279 | ifsta = &sdata->u.sta; |
3031 | 3280 | ||
3032 | if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0) | 3281 | if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0) |
@@ -3185,7 +3434,7 @@ void ieee80211_sta_scan_work(struct work_struct *work) | |||
3185 | container_of(work, struct ieee80211_local, scan_work.work); | 3434 | container_of(work, struct ieee80211_local, scan_work.work); |
3186 | struct net_device *dev = local->scan_dev; | 3435 | struct net_device *dev = local->scan_dev; |
3187 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 3436 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
3188 | struct ieee80211_hw_mode *mode; | 3437 | struct ieee80211_supported_band *sband; |
3189 | struct ieee80211_channel *chan; | 3438 | struct ieee80211_channel *chan; |
3190 | int skip; | 3439 | int skip; |
3191 | unsigned long next_delay = 0; | 3440 | unsigned long next_delay = 0; |
@@ -3195,44 +3444,59 @@ void ieee80211_sta_scan_work(struct work_struct *work) | |||
3195 | 3444 | ||
3196 | switch (local->scan_state) { | 3445 | switch (local->scan_state) { |
3197 | case SCAN_SET_CHANNEL: | 3446 | case SCAN_SET_CHANNEL: |
3198 | mode = local->scan_hw_mode; | 3447 | /* |
3199 | if (local->scan_hw_mode->list.next == &local->modes_list && | 3448 | * Get current scan band. scan_band may be IEEE80211_NUM_BANDS |
3200 | local->scan_channel_idx >= mode->num_channels) { | 3449 | * after we successfully scanned the last channel of the last |
3450 | * band (and the last band is supported by the hw) | ||
3451 | */ | ||
3452 | if (local->scan_band < IEEE80211_NUM_BANDS) | ||
3453 | sband = local->hw.wiphy->bands[local->scan_band]; | ||
3454 | else | ||
3455 | sband = NULL; | ||
3456 | |||
3457 | /* | ||
3458 | * If we are at an unsupported band and have more bands | ||
3459 | * left to scan, advance to the next supported one. | ||
3460 | */ | ||
3461 | while (!sband && local->scan_band < IEEE80211_NUM_BANDS - 1) { | ||
3462 | local->scan_band++; | ||
3463 | sband = local->hw.wiphy->bands[local->scan_band]; | ||
3464 | local->scan_channel_idx = 0; | ||
3465 | } | ||
3466 | |||
3467 | /* if no more bands/channels left, complete scan */ | ||
3468 | if (!sband || local->scan_channel_idx >= sband->n_channels) { | ||
3201 | ieee80211_scan_completed(local_to_hw(local)); | 3469 | ieee80211_scan_completed(local_to_hw(local)); |
3202 | return; | 3470 | return; |
3203 | } | 3471 | } |
3204 | skip = !(local->enabled_modes & (1 << mode->mode)); | 3472 | skip = 0; |
3205 | chan = &mode->channels[local->scan_channel_idx]; | 3473 | chan = &sband->channels[local->scan_channel_idx]; |
3206 | if (!(chan->flag & IEEE80211_CHAN_W_SCAN) || | 3474 | |
3475 | if (chan->flags & IEEE80211_CHAN_DISABLED || | ||
3207 | (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && | 3476 | (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && |
3208 | !(chan->flag & IEEE80211_CHAN_W_IBSS)) || | 3477 | chan->flags & IEEE80211_CHAN_NO_IBSS)) |
3209 | (local->hw_modes & local->enabled_modes & | ||
3210 | (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B)) | ||
3211 | skip = 1; | 3478 | skip = 1; |
3212 | 3479 | ||
3213 | if (!skip) { | 3480 | if (!skip) { |
3214 | #if 0 | ||
3215 | printk(KERN_DEBUG "%s: scan channel %d (%d MHz)\n", | ||
3216 | dev->name, chan->chan, chan->freq); | ||
3217 | #endif | ||
3218 | |||
3219 | local->scan_channel = chan; | 3481 | local->scan_channel = chan; |
3220 | if (ieee80211_hw_config(local)) { | 3482 | if (ieee80211_hw_config(local)) { |
3221 | printk(KERN_DEBUG "%s: failed to set channel " | 3483 | printk(KERN_DEBUG "%s: failed to set freq to " |
3222 | "%d (%d MHz) for scan\n", dev->name, | 3484 | "%d MHz for scan\n", dev->name, |
3223 | chan->chan, chan->freq); | 3485 | chan->center_freq); |
3224 | skip = 1; | 3486 | skip = 1; |
3225 | } | 3487 | } |
3226 | } | 3488 | } |
3227 | 3489 | ||
3490 | /* advance state machine to next channel/band */ | ||
3228 | local->scan_channel_idx++; | 3491 | local->scan_channel_idx++; |
3229 | if (local->scan_channel_idx >= local->scan_hw_mode->num_channels) { | 3492 | if (local->scan_channel_idx >= sband->n_channels) { |
3230 | if (local->scan_hw_mode->list.next != &local->modes_list) { | 3493 | /* |
3231 | local->scan_hw_mode = list_entry(local->scan_hw_mode->list.next, | 3494 | * scan_band may end up == IEEE80211_NUM_BANDS, but |
3232 | struct ieee80211_hw_mode, | 3495 | * we'll catch that case above and complete the scan |
3233 | list); | 3496 | * if that is the case. |
3234 | local->scan_channel_idx = 0; | 3497 | */ |
3235 | } | 3498 | local->scan_band++; |
3499 | local->scan_channel_idx = 0; | ||
3236 | } | 3500 | } |
3237 | 3501 | ||
3238 | if (skip) | 3502 | if (skip) |
@@ -3243,13 +3507,14 @@ void ieee80211_sta_scan_work(struct work_struct *work) | |||
3243 | local->scan_state = SCAN_SEND_PROBE; | 3507 | local->scan_state = SCAN_SEND_PROBE; |
3244 | break; | 3508 | break; |
3245 | case SCAN_SEND_PROBE: | 3509 | case SCAN_SEND_PROBE: |
3246 | if (local->scan_channel->flag & IEEE80211_CHAN_W_ACTIVE_SCAN) { | 3510 | next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; |
3247 | ieee80211_send_probe_req(dev, NULL, local->scan_ssid, | ||
3248 | local->scan_ssid_len); | ||
3249 | next_delay = IEEE80211_CHANNEL_TIME; | ||
3250 | } else | ||
3251 | next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; | ||
3252 | local->scan_state = SCAN_SET_CHANNEL; | 3511 | local->scan_state = SCAN_SET_CHANNEL; |
3512 | |||
3513 | if (local->scan_channel->flags & IEEE80211_CHAN_PASSIVE_SCAN) | ||
3514 | break; | ||
3515 | ieee80211_send_probe_req(dev, NULL, local->scan_ssid, | ||
3516 | local->scan_ssid_len); | ||
3517 | next_delay = IEEE80211_CHANNEL_TIME; | ||
3253 | break; | 3518 | break; |
3254 | } | 3519 | } |
3255 | 3520 | ||
@@ -3324,10 +3589,8 @@ static int ieee80211_sta_start_scan(struct net_device *dev, | |||
3324 | } else | 3589 | } else |
3325 | local->scan_ssid_len = 0; | 3590 | local->scan_ssid_len = 0; |
3326 | local->scan_state = SCAN_SET_CHANNEL; | 3591 | local->scan_state = SCAN_SET_CHANNEL; |
3327 | local->scan_hw_mode = list_entry(local->modes_list.next, | ||
3328 | struct ieee80211_hw_mode, | ||
3329 | list); | ||
3330 | local->scan_channel_idx = 0; | 3592 | local->scan_channel_idx = 0; |
3593 | local->scan_band = IEEE80211_BAND_2GHZ; | ||
3331 | local->scan_dev = dev; | 3594 | local->scan_dev = dev; |
3332 | 3595 | ||
3333 | netif_tx_lock_bh(local->mdev); | 3596 | netif_tx_lock_bh(local->mdev); |
@@ -3382,9 +3645,6 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
3382 | bss->last_update + IEEE80211_SCAN_RESULT_EXPIRE)) | 3645 | bss->last_update + IEEE80211_SCAN_RESULT_EXPIRE)) |
3383 | return current_ev; | 3646 | return current_ev; |
3384 | 3647 | ||
3385 | if (!(local->enabled_modes & (1 << bss->hw_mode))) | ||
3386 | return current_ev; | ||
3387 | |||
3388 | memset(&iwe, 0, sizeof(iwe)); | 3648 | memset(&iwe, 0, sizeof(iwe)); |
3389 | iwe.cmd = SIOCGIWAP; | 3649 | iwe.cmd = SIOCGIWAP; |
3390 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | 3650 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
@@ -3412,12 +3672,15 @@ ieee80211_sta_scan_result(struct net_device *dev, | |||
3412 | 3672 | ||
3413 | memset(&iwe, 0, sizeof(iwe)); | 3673 | memset(&iwe, 0, sizeof(iwe)); |
3414 | iwe.cmd = SIOCGIWFREQ; | 3674 | iwe.cmd = SIOCGIWFREQ; |
3415 | iwe.u.freq.m = bss->channel; | 3675 | iwe.u.freq.m = bss->freq; |
3416 | iwe.u.freq.e = 0; | 3676 | iwe.u.freq.e = 6; |
3417 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 3677 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, |
3418 | IW_EV_FREQ_LEN); | 3678 | IW_EV_FREQ_LEN); |
3419 | iwe.u.freq.m = bss->freq * 100000; | 3679 | |
3420 | iwe.u.freq.e = 1; | 3680 | memset(&iwe, 0, sizeof(iwe)); |
3681 | iwe.cmd = SIOCGIWFREQ; | ||
3682 | iwe.u.freq.m = ieee80211_frequency_to_channel(bss->freq); | ||
3683 | iwe.u.freq.e = 0; | ||
3421 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 3684 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, |
3422 | IW_EV_FREQ_LEN); | 3685 | IW_EV_FREQ_LEN); |
3423 | 3686 | ||
@@ -3557,10 +3820,13 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev, | |||
3557 | wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name); | 3820 | wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name); |
3558 | 3821 | ||
3559 | sta = sta_info_add(local, dev, addr, GFP_ATOMIC); | 3822 | sta = sta_info_add(local, dev, addr, GFP_ATOMIC); |
3560 | if (!sta) | 3823 | if (IS_ERR(sta)) |
3561 | return NULL; | 3824 | return NULL; |
3562 | 3825 | ||
3563 | sta->supp_rates = sdata->u.sta.supp_rates_bits; | 3826 | sta->flags |= WLAN_STA_AUTHORIZED; |
3827 | |||
3828 | sta->supp_rates[local->hw.conf.channel->band] = | ||
3829 | sdata->u.sta.supp_rates_bits[local->hw.conf.channel->band]; | ||
3564 | 3830 | ||
3565 | rate_control_rate_init(sta, local); | 3831 | rate_control_rate_init(sta, local); |
3566 | 3832 | ||
diff --git a/net/mac80211/key.c b/net/mac80211/key.c index ed57fb8e82fc..eac9c59dbc4d 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/etherdevice.h> | 13 | #include <linux/etherdevice.h> |
14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
15 | #include <linux/rcupdate.h> | 15 | #include <linux/rcupdate.h> |
16 | #include <linux/rtnetlink.h> | ||
16 | #include <net/mac80211.h> | 17 | #include <net/mac80211.h> |
17 | #include "ieee80211_i.h" | 18 | #include "ieee80211_i.h" |
18 | #include "debugfs_key.h" | 19 | #include "debugfs_key.h" |
@@ -34,6 +35,10 @@ | |||
34 | * | 35 | * |
35 | * All operations here are called under RTNL so no extra locking is | 36 | * All operations here are called under RTNL so no extra locking is |
36 | * required. | 37 | * required. |
38 | * | ||
39 | * NOTE: This code requires that sta info *destruction* is done under | ||
40 | * RTNL, otherwise it can try to access already freed STA structs | ||
41 | * when a STA key is being freed. | ||
37 | */ | 42 | */ |
38 | 43 | ||
39 | static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | 44 | static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
@@ -84,16 +89,25 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key) | |||
84 | key->conf.keyidx, print_mac(mac, addr), ret); | 89 | key->conf.keyidx, print_mac(mac, addr), ret); |
85 | } | 90 | } |
86 | 91 | ||
92 | static void ieee80211_key_mark_hw_accel_off(struct ieee80211_key *key) | ||
93 | { | ||
94 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { | ||
95 | key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; | ||
96 | key->flags |= KEY_FLAG_REMOVE_FROM_HARDWARE; | ||
97 | } | ||
98 | } | ||
99 | |||
87 | static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) | 100 | static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) |
88 | { | 101 | { |
89 | const u8 *addr; | 102 | const u8 *addr; |
90 | int ret; | 103 | int ret; |
91 | DECLARE_MAC_BUF(mac); | 104 | DECLARE_MAC_BUF(mac); |
92 | 105 | ||
93 | if (!key->local->ops->set_key) | 106 | if (!key || !key->local->ops->set_key) |
94 | return; | 107 | return; |
95 | 108 | ||
96 | if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) | 109 | if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && |
110 | !(key->flags & KEY_FLAG_REMOVE_FROM_HARDWARE)) | ||
97 | return; | 111 | return; |
98 | 112 | ||
99 | addr = get_mac_for_key(key); | 113 | addr = get_mac_for_key(key); |
@@ -108,12 +122,11 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) | |||
108 | wiphy_name(key->local->hw.wiphy), | 122 | wiphy_name(key->local->hw.wiphy), |
109 | key->conf.keyidx, print_mac(mac, addr), ret); | 123 | key->conf.keyidx, print_mac(mac, addr), ret); |
110 | 124 | ||
111 | key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; | 125 | key->flags &= ~(KEY_FLAG_UPLOADED_TO_HARDWARE | |
126 | KEY_FLAG_REMOVE_FROM_HARDWARE); | ||
112 | } | 127 | } |
113 | 128 | ||
114 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | 129 | struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg, |
115 | struct sta_info *sta, | ||
116 | enum ieee80211_key_alg alg, | ||
117 | int idx, | 130 | int idx, |
118 | size_t key_len, | 131 | size_t key_len, |
119 | const u8 *key_data) | 132 | const u8 *key_data) |
@@ -137,10 +150,7 @@ struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | |||
137 | key->conf.keyidx = idx; | 150 | key->conf.keyidx = idx; |
138 | key->conf.keylen = key_len; | 151 | key->conf.keylen = key_len; |
139 | memcpy(key->conf.key, key_data, key_len); | 152 | memcpy(key->conf.key, key_data, key_len); |
140 | 153 | INIT_LIST_HEAD(&key->list); | |
141 | key->local = sdata->local; | ||
142 | key->sdata = sdata; | ||
143 | key->sta = sta; | ||
144 | 154 | ||
145 | if (alg == ALG_CCMP) { | 155 | if (alg == ALG_CCMP) { |
146 | /* | 156 | /* |
@@ -154,13 +164,68 @@ struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | |||
154 | } | 164 | } |
155 | } | 165 | } |
156 | 166 | ||
157 | ieee80211_debugfs_key_add(key->local, key); | 167 | return key; |
168 | } | ||
158 | 169 | ||
159 | /* remove key first */ | 170 | static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata, |
160 | if (sta) | 171 | struct sta_info *sta, |
161 | ieee80211_key_free(sta->key); | 172 | struct ieee80211_key *key, |
162 | else | 173 | struct ieee80211_key *new) |
163 | ieee80211_key_free(sdata->keys[idx]); | 174 | { |
175 | int idx, defkey; | ||
176 | |||
177 | if (sta) { | ||
178 | rcu_assign_pointer(sta->key, new); | ||
179 | } else { | ||
180 | WARN_ON(new && key && new->conf.keyidx != key->conf.keyidx); | ||
181 | |||
182 | if (key) | ||
183 | idx = key->conf.keyidx; | ||
184 | else | ||
185 | idx = new->conf.keyidx; | ||
186 | |||
187 | defkey = key && sdata->default_key == key; | ||
188 | |||
189 | if (defkey && !new) | ||
190 | ieee80211_set_default_key(sdata, -1); | ||
191 | |||
192 | rcu_assign_pointer(sdata->keys[idx], new); | ||
193 | if (new) | ||
194 | list_add(&new->list, &sdata->key_list); | ||
195 | |||
196 | if (defkey && new) | ||
197 | ieee80211_set_default_key(sdata, new->conf.keyidx); | ||
198 | } | ||
199 | |||
200 | if (key) { | ||
201 | ieee80211_key_mark_hw_accel_off(key); | ||
202 | /* | ||
203 | * We'll use an empty list to indicate that the key | ||
204 | * has already been removed. | ||
205 | */ | ||
206 | list_del_init(&key->list); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | void ieee80211_key_link(struct ieee80211_key *key, | ||
211 | struct ieee80211_sub_if_data *sdata, | ||
212 | struct sta_info *sta) | ||
213 | { | ||
214 | struct ieee80211_key *old_key; | ||
215 | int idx; | ||
216 | |||
217 | ASSERT_RTNL(); | ||
218 | might_sleep(); | ||
219 | |||
220 | BUG_ON(!sdata); | ||
221 | BUG_ON(!key); | ||
222 | |||
223 | idx = key->conf.keyidx; | ||
224 | key->local = sdata->local; | ||
225 | key->sdata = sdata; | ||
226 | key->sta = sta; | ||
227 | |||
228 | ieee80211_debugfs_key_add(key->local, key); | ||
164 | 229 | ||
165 | if (sta) { | 230 | if (sta) { |
166 | ieee80211_debugfs_key_sta_link(key, sta); | 231 | ieee80211_debugfs_key_sta_link(key, sta); |
@@ -186,50 +251,59 @@ struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, | |||
186 | } | 251 | } |
187 | } | 252 | } |
188 | 253 | ||
189 | /* enable hwaccel if appropriate */ | ||
190 | if (netif_running(key->sdata->dev)) | ||
191 | ieee80211_key_enable_hw_accel(key); | ||
192 | |||
193 | if (sta) | 254 | if (sta) |
194 | rcu_assign_pointer(sta->key, key); | 255 | old_key = sta->key; |
195 | else | 256 | else |
196 | rcu_assign_pointer(sdata->keys[idx], key); | 257 | old_key = sdata->keys[idx]; |
197 | 258 | ||
198 | list_add(&key->list, &sdata->key_list); | 259 | __ieee80211_key_replace(sdata, sta, old_key, key); |
199 | 260 | ||
200 | return key; | 261 | if (old_key) { |
262 | synchronize_rcu(); | ||
263 | ieee80211_key_free(old_key); | ||
264 | } | ||
265 | |||
266 | if (netif_running(sdata->dev)) | ||
267 | ieee80211_key_enable_hw_accel(key); | ||
201 | } | 268 | } |
202 | 269 | ||
203 | void ieee80211_key_free(struct ieee80211_key *key) | 270 | void ieee80211_key_free(struct ieee80211_key *key) |
204 | { | 271 | { |
272 | ASSERT_RTNL(); | ||
273 | might_sleep(); | ||
274 | |||
205 | if (!key) | 275 | if (!key) |
206 | return; | 276 | return; |
207 | 277 | ||
208 | if (key->sta) { | 278 | if (key->sdata) { |
209 | rcu_assign_pointer(key->sta->key, NULL); | 279 | /* |
210 | } else { | 280 | * Replace key with nothingness. |
211 | if (key->sdata->default_key == key) | 281 | * |
212 | ieee80211_set_default_key(key->sdata, -1); | 282 | * Because other code may have key reference (RCU protected) |
213 | if (key->conf.keyidx >= 0 && | 283 | * right now, we then wait for a grace period before freeing |
214 | key->conf.keyidx < NUM_DEFAULT_KEYS) | 284 | * it. |
215 | rcu_assign_pointer(key->sdata->keys[key->conf.keyidx], | 285 | * An empty list indicates it was never added to the key list |
216 | NULL); | 286 | * or has been removed already. It may, however, still be in |
217 | else | 287 | * hardware for acceleration. |
218 | WARN_ON(1); | 288 | */ |
219 | } | 289 | if (!list_empty(&key->list)) |
290 | __ieee80211_key_replace(key->sdata, key->sta, | ||
291 | key, NULL); | ||
220 | 292 | ||
221 | /* wait for all key users to complete */ | 293 | synchronize_rcu(); |
222 | synchronize_rcu(); | ||
223 | 294 | ||
224 | /* remove from hwaccel if appropriate */ | 295 | /* |
225 | ieee80211_key_disable_hw_accel(key); | 296 | * Remove from hwaccel if appropriate, this will |
297 | * only happen when the key is actually unlinked, | ||
298 | * it will already be done when the key was replaced. | ||
299 | */ | ||
300 | ieee80211_key_disable_hw_accel(key); | ||
301 | } | ||
226 | 302 | ||
227 | if (key->conf.alg == ALG_CCMP) | 303 | if (key->conf.alg == ALG_CCMP) |
228 | ieee80211_aes_key_free(key->u.ccmp.tfm); | 304 | ieee80211_aes_key_free(key->u.ccmp.tfm); |
229 | ieee80211_debugfs_key_remove(key); | 305 | ieee80211_debugfs_key_remove(key); |
230 | 306 | ||
231 | list_del(&key->list); | ||
232 | |||
233 | kfree(key); | 307 | kfree(key); |
234 | } | 308 | } |
235 | 309 | ||
@@ -253,6 +327,10 @@ void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx) | |||
253 | void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata) | 327 | void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata) |
254 | { | 328 | { |
255 | struct ieee80211_key *key, *tmp; | 329 | struct ieee80211_key *key, *tmp; |
330 | LIST_HEAD(tmp_list); | ||
331 | |||
332 | ASSERT_RTNL(); | ||
333 | might_sleep(); | ||
256 | 334 | ||
257 | list_for_each_entry_safe(key, tmp, &sdata->key_list, list) | 335 | list_for_each_entry_safe(key, tmp, &sdata->key_list, list) |
258 | ieee80211_key_free(key); | 336 | ieee80211_key_free(key); |
@@ -262,8 +340,10 @@ void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata) | |||
262 | { | 340 | { |
263 | struct ieee80211_key *key; | 341 | struct ieee80211_key *key; |
264 | 342 | ||
265 | WARN_ON(!netif_running(sdata->dev)); | 343 | ASSERT_RTNL(); |
266 | if (!netif_running(sdata->dev)) | 344 | might_sleep(); |
345 | |||
346 | if (WARN_ON(!netif_running(sdata->dev))) | ||
267 | return; | 347 | return; |
268 | 348 | ||
269 | list_for_each_entry(key, &sdata->key_list, list) | 349 | list_for_each_entry(key, &sdata->key_list, list) |
@@ -274,6 +354,9 @@ void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata) | |||
274 | { | 354 | { |
275 | struct ieee80211_key *key; | 355 | struct ieee80211_key *key; |
276 | 356 | ||
357 | ASSERT_RTNL(); | ||
358 | might_sleep(); | ||
359 | |||
277 | list_for_each_entry(key, &sdata->key_list, list) | 360 | list_for_each_entry(key, &sdata->key_list, list) |
278 | ieee80211_key_disable_hw_accel(key); | 361 | ieee80211_key_disable_hw_accel(key); |
279 | } | 362 | } |
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c index c339571632b2..9762803e4876 100644 --- a/net/mac80211/rc80211_pid_algo.c +++ b/net/mac80211/rc80211_pid_algo.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | 2 | * Copyright 2002-2005, Instant802 Networks, Inc. |
3 | * Copyright 2005, Devicescape Software, Inc. | 3 | * Copyright 2005, Devicescape Software, Inc. |
4 | * Copyright 2007, Mattias Nissler <mattias.nissler@gmx.de> | 4 | * Copyright 2007, Mattias Nissler <mattias.nissler@gmx.de> |
5 | * Copyright 2007, Stefano Brivio <stefano.brivio@polimi.it> | 5 | * Copyright 2007-2008, Stefano Brivio <stefano.brivio@polimi.it> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
@@ -64,71 +64,66 @@ | |||
64 | */ | 64 | */ |
65 | 65 | ||
66 | 66 | ||
67 | /* Shift the adjustment so that we won't switch to a lower rate if it exhibited | 67 | /* Adjust the rate while ensuring that we won't switch to a lower rate if it |
68 | * a worse failed frames behaviour and we'll choose the highest rate whose | 68 | * exhibited a worse failed frames behaviour and we'll choose the highest rate |
69 | * failed frames behaviour is not worse than the one of the original rate | 69 | * whose failed frames behaviour is not worse than the one of the original rate |
70 | * target. While at it, check that the adjustment is within the ranges. Then, | 70 | * target. While at it, check that the new rate is valid. */ |
71 | * provide the new rate index. */ | ||
72 | static int rate_control_pid_shift_adjust(struct rc_pid_rateinfo *r, | ||
73 | int adj, int cur, int l) | ||
74 | { | ||
75 | int i, j, k, tmp; | ||
76 | |||
77 | j = r[cur].rev_index; | ||
78 | i = j + adj; | ||
79 | |||
80 | if (i < 0) | ||
81 | return r[0].index; | ||
82 | if (i >= l - 1) | ||
83 | return r[l - 1].index; | ||
84 | |||
85 | tmp = i; | ||
86 | |||
87 | if (adj < 0) { | ||
88 | for (k = j; k >= i; k--) | ||
89 | if (r[k].diff <= r[j].diff) | ||
90 | tmp = k; | ||
91 | } else { | ||
92 | for (k = i + 1; k + i < l; k++) | ||
93 | if (r[k].diff <= r[i].diff) | ||
94 | tmp = k; | ||
95 | } | ||
96 | |||
97 | return r[tmp].index; | ||
98 | } | ||
99 | |||
100 | static void rate_control_pid_adjust_rate(struct ieee80211_local *local, | 71 | static void rate_control_pid_adjust_rate(struct ieee80211_local *local, |
101 | struct sta_info *sta, int adj, | 72 | struct sta_info *sta, int adj, |
102 | struct rc_pid_rateinfo *rinfo) | 73 | struct rc_pid_rateinfo *rinfo) |
103 | { | 74 | { |
104 | struct ieee80211_sub_if_data *sdata; | 75 | struct ieee80211_sub_if_data *sdata; |
105 | struct ieee80211_hw_mode *mode; | 76 | struct ieee80211_supported_band *sband; |
106 | int newidx; | 77 | int cur_sorted, new_sorted, probe, tmp, n_bitrates, band; |
107 | int maxrate; | 78 | int cur = sta->txrate_idx; |
108 | int back = (adj > 0) ? 1 : -1; | ||
109 | 79 | ||
110 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | 80 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
81 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
82 | band = sband->band; | ||
83 | n_bitrates = sband->n_bitrates; | ||
111 | 84 | ||
112 | mode = local->oper_hw_mode; | 85 | /* Map passed arguments to sorted values. */ |
113 | maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; | 86 | cur_sorted = rinfo[cur].rev_index; |
87 | new_sorted = cur_sorted + adj; | ||
114 | 88 | ||
115 | newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate, | 89 | /* Check limits. */ |
116 | mode->num_rates); | 90 | if (new_sorted < 0) |
91 | new_sorted = rinfo[0].rev_index; | ||
92 | else if (new_sorted >= n_bitrates) | ||
93 | new_sorted = rinfo[n_bitrates - 1].rev_index; | ||
117 | 94 | ||
118 | while (newidx != sta->txrate) { | 95 | tmp = new_sorted; |
119 | if (rate_supported(sta, mode, newidx) && | ||
120 | (maxrate < 0 || newidx <= maxrate)) { | ||
121 | sta->txrate = newidx; | ||
122 | break; | ||
123 | } | ||
124 | 96 | ||
125 | newidx += back; | 97 | if (adj < 0) { |
98 | /* Ensure that the rate decrease isn't disadvantageous. */ | ||
99 | for (probe = cur_sorted; probe >= new_sorted; probe--) | ||
100 | if (rinfo[probe].diff <= rinfo[cur_sorted].diff && | ||
101 | rate_supported(sta, band, rinfo[probe].index)) | ||
102 | tmp = probe; | ||
103 | } else { | ||
104 | /* Look for rate increase with zero (or below) cost. */ | ||
105 | for (probe = new_sorted + 1; probe < n_bitrates; probe++) | ||
106 | if (rinfo[probe].diff <= rinfo[new_sorted].diff && | ||
107 | rate_supported(sta, band, rinfo[probe].index)) | ||
108 | tmp = probe; | ||
126 | } | 109 | } |
127 | 110 | ||
111 | /* Fit the rate found to the nearest supported rate. */ | ||
112 | do { | ||
113 | if (rate_supported(sta, band, rinfo[tmp].index)) { | ||
114 | sta->txrate_idx = rinfo[tmp].index; | ||
115 | break; | ||
116 | } | ||
117 | if (adj < 0) | ||
118 | tmp--; | ||
119 | else | ||
120 | tmp++; | ||
121 | } while (tmp < n_bitrates && tmp >= 0); | ||
122 | |||
128 | #ifdef CONFIG_MAC80211_DEBUGFS | 123 | #ifdef CONFIG_MAC80211_DEBUGFS |
129 | rate_control_pid_event_rate_change( | 124 | rate_control_pid_event_rate_change( |
130 | &((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events, | 125 | &((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events, |
131 | newidx, mode->rates[newidx].rate); | 126 | sta->txrate_idx, sband->bitrates[sta->txrate_idx].bitrate); |
132 | #endif | 127 | #endif |
133 | } | 128 | } |
134 | 129 | ||
@@ -155,7 +150,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
155 | { | 150 | { |
156 | struct rc_pid_sta_info *spinfo = sta->rate_ctrl_priv; | 151 | struct rc_pid_sta_info *spinfo = sta->rate_ctrl_priv; |
157 | struct rc_pid_rateinfo *rinfo = pinfo->rinfo; | 152 | struct rc_pid_rateinfo *rinfo = pinfo->rinfo; |
158 | struct ieee80211_hw_mode *mode; | 153 | struct ieee80211_supported_band *sband; |
159 | u32 pf; | 154 | u32 pf; |
160 | s32 err_avg; | 155 | s32 err_avg; |
161 | u32 err_prop; | 156 | u32 err_prop; |
@@ -164,7 +159,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
164 | int adj, i, j, tmp; | 159 | int adj, i, j, tmp; |
165 | unsigned long period; | 160 | unsigned long period; |
166 | 161 | ||
167 | mode = local->oper_hw_mode; | 162 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
168 | spinfo = sta->rate_ctrl_priv; | 163 | spinfo = sta->rate_ctrl_priv; |
169 | 164 | ||
170 | /* In case nothing happened during the previous control interval, turn | 165 | /* In case nothing happened during the previous control interval, turn |
@@ -190,18 +185,18 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo, | |||
190 | spinfo->tx_num_failed = 0; | 185 | spinfo->tx_num_failed = 0; |
191 | 186 | ||
192 | /* If we just switched rate, update the rate behaviour info. */ | 187 | /* If we just switched rate, update the rate behaviour info. */ |
193 | if (pinfo->oldrate != sta->txrate) { | 188 | if (pinfo->oldrate != sta->txrate_idx) { |
194 | 189 | ||
195 | i = rinfo[pinfo->oldrate].rev_index; | 190 | i = rinfo[pinfo->oldrate].rev_index; |
196 | j = rinfo[sta->txrate].rev_index; | 191 | j = rinfo[sta->txrate_idx].rev_index; |
197 | 192 | ||
198 | tmp = (pf - spinfo->last_pf); | 193 | tmp = (pf - spinfo->last_pf); |
199 | tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT); | 194 | tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT); |
200 | 195 | ||
201 | rinfo[j].diff = rinfo[i].diff + tmp; | 196 | rinfo[j].diff = rinfo[i].diff + tmp; |
202 | pinfo->oldrate = sta->txrate; | 197 | pinfo->oldrate = sta->txrate_idx; |
203 | } | 198 | } |
204 | rate_control_pid_normalize(pinfo, mode->num_rates); | 199 | rate_control_pid_normalize(pinfo, sband->n_bitrates); |
205 | 200 | ||
206 | /* Compute the proportional, integral and derivative errors. */ | 201 | /* Compute the proportional, integral and derivative errors. */ |
207 | err_prop = (pinfo->target << RC_PID_ARITH_SHIFT) - pf; | 202 | err_prop = (pinfo->target << RC_PID_ARITH_SHIFT) - pf; |
@@ -242,8 +237,10 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev, | |||
242 | struct sta_info *sta; | 237 | struct sta_info *sta; |
243 | struct rc_pid_sta_info *spinfo; | 238 | struct rc_pid_sta_info *spinfo; |
244 | unsigned long period; | 239 | unsigned long period; |
240 | struct ieee80211_supported_band *sband; | ||
245 | 241 | ||
246 | sta = sta_info_get(local, hdr->addr1); | 242 | sta = sta_info_get(local, hdr->addr1); |
243 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
247 | 244 | ||
248 | if (!sta) | 245 | if (!sta) |
249 | return; | 246 | return; |
@@ -251,13 +248,13 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev, | |||
251 | /* Don't update the state if we're not controlling the rate. */ | 248 | /* Don't update the state if we're not controlling the rate. */ |
252 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | 249 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
253 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { | 250 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { |
254 | sta->txrate = sdata->bss->max_ratectrl_rateidx; | 251 | sta->txrate_idx = sdata->bss->max_ratectrl_rateidx; |
255 | return; | 252 | return; |
256 | } | 253 | } |
257 | 254 | ||
258 | /* Ignore all frames that were sent with a different rate than the rate | 255 | /* Ignore all frames that were sent with a different rate than the rate |
259 | * we currently advise mac80211 to use. */ | 256 | * we currently advise mac80211 to use. */ |
260 | if (status->control.rate != &local->oper_hw_mode->rates[sta->txrate]) | 257 | if (status->control.tx_rate != &sband->bitrates[sta->txrate_idx]) |
261 | goto ignore; | 258 | goto ignore; |
262 | 259 | ||
263 | spinfo = sta->rate_ctrl_priv; | 260 | spinfo = sta->rate_ctrl_priv; |
@@ -283,9 +280,6 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev, | |||
283 | sta->tx_num_consecutive_failures++; | 280 | sta->tx_num_consecutive_failures++; |
284 | sta->tx_num_mpdu_fail++; | 281 | sta->tx_num_mpdu_fail++; |
285 | } else { | 282 | } else { |
286 | sta->last_ack_rssi[0] = sta->last_ack_rssi[1]; | ||
287 | sta->last_ack_rssi[1] = sta->last_ack_rssi[2]; | ||
288 | sta->last_ack_rssi[2] = status->ack_signal; | ||
289 | sta->tx_num_consecutive_failures = 0; | 283 | sta->tx_num_consecutive_failures = 0; |
290 | sta->tx_num_mpdu_ok++; | 284 | sta->tx_num_mpdu_ok++; |
291 | } | 285 | } |
@@ -304,7 +298,7 @@ ignore: | |||
304 | } | 298 | } |
305 | 299 | ||
306 | static void rate_control_pid_get_rate(void *priv, struct net_device *dev, | 300 | static void rate_control_pid_get_rate(void *priv, struct net_device *dev, |
307 | struct ieee80211_hw_mode *mode, | 301 | struct ieee80211_supported_band *sband, |
308 | struct sk_buff *skb, | 302 | struct sk_buff *skb, |
309 | struct rate_selection *sel) | 303 | struct rate_selection *sel) |
310 | { | 304 | { |
@@ -322,7 +316,7 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev, | |||
322 | fc = le16_to_cpu(hdr->frame_control); | 316 | fc = le16_to_cpu(hdr->frame_control); |
323 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || | 317 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || |
324 | is_multicast_ether_addr(hdr->addr1) || !sta) { | 318 | is_multicast_ether_addr(hdr->addr1) || !sta) { |
325 | sel->rate = rate_lowest(local, mode, sta); | 319 | sel->rate = rate_lowest(local, sband, sta); |
326 | if (sta) | 320 | if (sta) |
327 | sta_info_put(sta); | 321 | sta_info_put(sta); |
328 | return; | 322 | return; |
@@ -331,23 +325,23 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev, | |||
331 | /* If a forced rate is in effect, select it. */ | 325 | /* If a forced rate is in effect, select it. */ |
332 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 326 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
333 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) | 327 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) |
334 | sta->txrate = sdata->bss->force_unicast_rateidx; | 328 | sta->txrate_idx = sdata->bss->force_unicast_rateidx; |
335 | 329 | ||
336 | rateidx = sta->txrate; | 330 | rateidx = sta->txrate_idx; |
337 | 331 | ||
338 | if (rateidx >= mode->num_rates) | 332 | if (rateidx >= sband->n_bitrates) |
339 | rateidx = mode->num_rates - 1; | 333 | rateidx = sband->n_bitrates - 1; |
340 | 334 | ||
341 | sta->last_txrate = rateidx; | 335 | sta->last_txrate_idx = rateidx; |
342 | 336 | ||
343 | sta_info_put(sta); | 337 | sta_info_put(sta); |
344 | 338 | ||
345 | sel->rate = &mode->rates[rateidx]; | 339 | sel->rate = &sband->bitrates[rateidx]; |
346 | 340 | ||
347 | #ifdef CONFIG_MAC80211_DEBUGFS | 341 | #ifdef CONFIG_MAC80211_DEBUGFS |
348 | rate_control_pid_event_tx_rate( | 342 | rate_control_pid_event_tx_rate( |
349 | &((struct rc_pid_sta_info *) sta->rate_ctrl_priv)->events, | 343 | &((struct rc_pid_sta_info *) sta->rate_ctrl_priv)->events, |
350 | rateidx, mode->rates[rateidx].rate); | 344 | rateidx, sband->bitrates[rateidx].bitrate); |
351 | #endif | 345 | #endif |
352 | } | 346 | } |
353 | 347 | ||
@@ -359,28 +353,32 @@ static void rate_control_pid_rate_init(void *priv, void *priv_sta, | |||
359 | * as we need to have IEEE 802.1X auth succeed immediately after assoc.. | 353 | * as we need to have IEEE 802.1X auth succeed immediately after assoc.. |
360 | * Until that method is implemented, we will use the lowest supported | 354 | * Until that method is implemented, we will use the lowest supported |
361 | * rate as a workaround. */ | 355 | * rate as a workaround. */ |
362 | sta->txrate = rate_lowest_index(local, local->oper_hw_mode, sta); | 356 | struct ieee80211_supported_band *sband; |
357 | |||
358 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
359 | sta->txrate_idx = rate_lowest_index(local, sband, sta); | ||
363 | } | 360 | } |
364 | 361 | ||
365 | static void *rate_control_pid_alloc(struct ieee80211_local *local) | 362 | static void *rate_control_pid_alloc(struct ieee80211_local *local) |
366 | { | 363 | { |
367 | struct rc_pid_info *pinfo; | 364 | struct rc_pid_info *pinfo; |
368 | struct rc_pid_rateinfo *rinfo; | 365 | struct rc_pid_rateinfo *rinfo; |
369 | struct ieee80211_hw_mode *mode; | 366 | struct ieee80211_supported_band *sband; |
370 | int i, j, tmp; | 367 | int i, j, tmp; |
371 | bool s; | 368 | bool s; |
372 | #ifdef CONFIG_MAC80211_DEBUGFS | 369 | #ifdef CONFIG_MAC80211_DEBUGFS |
373 | struct rc_pid_debugfs_entries *de; | 370 | struct rc_pid_debugfs_entries *de; |
374 | #endif | 371 | #endif |
375 | 372 | ||
373 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
374 | |||
376 | pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC); | 375 | pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC); |
377 | if (!pinfo) | 376 | if (!pinfo) |
378 | return NULL; | 377 | return NULL; |
379 | 378 | ||
380 | /* We can safely assume that oper_hw_mode won't change unless we get | 379 | /* We can safely assume that sband won't change unless we get |
381 | * reinitialized. */ | 380 | * reinitialized. */ |
382 | mode = local->oper_hw_mode; | 381 | rinfo = kmalloc(sizeof(*rinfo) * sband->n_bitrates, GFP_ATOMIC); |
383 | rinfo = kmalloc(sizeof(*rinfo) * mode->num_rates, GFP_ATOMIC); | ||
384 | if (!rinfo) { | 382 | if (!rinfo) { |
385 | kfree(pinfo); | 383 | kfree(pinfo); |
386 | return NULL; | 384 | return NULL; |
@@ -389,7 +387,7 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local) | |||
389 | /* Sort the rates. This is optimized for the most common case (i.e. | 387 | /* Sort the rates. This is optimized for the most common case (i.e. |
390 | * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed | 388 | * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed |
391 | * mapping too. */ | 389 | * mapping too. */ |
392 | for (i = 0; i < mode->num_rates; i++) { | 390 | for (i = 0; i < sband->n_bitrates; i++) { |
393 | rinfo[i].index = i; | 391 | rinfo[i].index = i; |
394 | rinfo[i].rev_index = i; | 392 | rinfo[i].rev_index = i; |
395 | if (pinfo->fast_start) | 393 | if (pinfo->fast_start) |
@@ -397,11 +395,11 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local) | |||
397 | else | 395 | else |
398 | rinfo[i].diff = i * pinfo->norm_offset; | 396 | rinfo[i].diff = i * pinfo->norm_offset; |
399 | } | 397 | } |
400 | for (i = 1; i < mode->num_rates; i++) { | 398 | for (i = 1; i < sband->n_bitrates; i++) { |
401 | s = 0; | 399 | s = 0; |
402 | for (j = 0; j < mode->num_rates - i; j++) | 400 | for (j = 0; j < sband->n_bitrates - i; j++) |
403 | if (unlikely(mode->rates[rinfo[j].index].rate > | 401 | if (unlikely(sband->bitrates[rinfo[j].index].bitrate > |
404 | mode->rates[rinfo[j + 1].index].rate)) { | 402 | sband->bitrates[rinfo[j + 1].index].bitrate)) { |
405 | tmp = rinfo[j].index; | 403 | tmp = rinfo[j].index; |
406 | rinfo[j].index = rinfo[j + 1].index; | 404 | rinfo[j].index = rinfo[j + 1].index; |
407 | rinfo[j + 1].index = tmp; | 405 | rinfo[j + 1].index = tmp; |
diff --git a/net/mac80211/rc80211_simple.c b/net/mac80211/rc80211_simple.c index 9a78b116acff..bcc541d4b95c 100644 --- a/net/mac80211/rc80211_simple.c +++ b/net/mac80211/rc80211_simple.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/jiffies.h> | ||
10 | #include <linux/init.h> | 11 | #include <linux/init.h> |
11 | #include <linux/netdevice.h> | 12 | #include <linux/netdevice.h> |
12 | #include <linux/types.h> | 13 | #include <linux/types.h> |
@@ -35,8 +36,8 @@ static void rate_control_rate_inc(struct ieee80211_local *local, | |||
35 | struct sta_info *sta) | 36 | struct sta_info *sta) |
36 | { | 37 | { |
37 | struct ieee80211_sub_if_data *sdata; | 38 | struct ieee80211_sub_if_data *sdata; |
38 | struct ieee80211_hw_mode *mode; | 39 | struct ieee80211_supported_band *sband; |
39 | int i = sta->txrate; | 40 | int i = sta->txrate_idx; |
40 | int maxrate; | 41 | int maxrate; |
41 | 42 | ||
42 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | 43 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
@@ -45,18 +46,17 @@ static void rate_control_rate_inc(struct ieee80211_local *local, | |||
45 | return; | 46 | return; |
46 | } | 47 | } |
47 | 48 | ||
48 | mode = local->oper_hw_mode; | 49 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
49 | maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; | 50 | maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; |
50 | 51 | ||
51 | if (i > mode->num_rates) | 52 | if (i > sband->n_bitrates) |
52 | i = mode->num_rates - 2; | 53 | i = sband->n_bitrates - 2; |
53 | 54 | ||
54 | while (i + 1 < mode->num_rates) { | 55 | while (i + 1 < sband->n_bitrates) { |
55 | i++; | 56 | i++; |
56 | if (sta->supp_rates & BIT(i) && | 57 | if (rate_supported(sta, sband->band, i) && |
57 | mode->rates[i].flags & IEEE80211_RATE_SUPPORTED && | ||
58 | (maxrate < 0 || i <= maxrate)) { | 58 | (maxrate < 0 || i <= maxrate)) { |
59 | sta->txrate = i; | 59 | sta->txrate_idx = i; |
60 | break; | 60 | break; |
61 | } | 61 | } |
62 | } | 62 | } |
@@ -67,8 +67,8 @@ static void rate_control_rate_dec(struct ieee80211_local *local, | |||
67 | struct sta_info *sta) | 67 | struct sta_info *sta) |
68 | { | 68 | { |
69 | struct ieee80211_sub_if_data *sdata; | 69 | struct ieee80211_sub_if_data *sdata; |
70 | struct ieee80211_hw_mode *mode; | 70 | struct ieee80211_supported_band *sband; |
71 | int i = sta->txrate; | 71 | int i = sta->txrate_idx; |
72 | 72 | ||
73 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | 73 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
74 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { | 74 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { |
@@ -76,15 +76,14 @@ static void rate_control_rate_dec(struct ieee80211_local *local, | |||
76 | return; | 76 | return; |
77 | } | 77 | } |
78 | 78 | ||
79 | mode = local->oper_hw_mode; | 79 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
80 | if (i > mode->num_rates) | 80 | if (i > sband->n_bitrates) |
81 | i = mode->num_rates; | 81 | i = sband->n_bitrates; |
82 | 82 | ||
83 | while (i > 0) { | 83 | while (i > 0) { |
84 | i--; | 84 | i--; |
85 | if (sta->supp_rates & BIT(i) && | 85 | if (rate_supported(sta, sband->band, i)) { |
86 | mode->rates[i].flags & IEEE80211_RATE_SUPPORTED) { | 86 | sta->txrate_idx = i; |
87 | sta->txrate = i; | ||
88 | break; | 87 | break; |
89 | } | 88 | } |
90 | } | 89 | } |
@@ -132,9 +131,6 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev, | |||
132 | sta->tx_num_consecutive_failures++; | 131 | sta->tx_num_consecutive_failures++; |
133 | sta->tx_num_mpdu_fail++; | 132 | sta->tx_num_mpdu_fail++; |
134 | } else { | 133 | } else { |
135 | sta->last_ack_rssi[0] = sta->last_ack_rssi[1]; | ||
136 | sta->last_ack_rssi[1] = sta->last_ack_rssi[2]; | ||
137 | sta->last_ack_rssi[2] = status->ack_signal; | ||
138 | sta->tx_num_consecutive_failures = 0; | 134 | sta->tx_num_consecutive_failures = 0; |
139 | sta->tx_num_mpdu_ok++; | 135 | sta->tx_num_mpdu_ok++; |
140 | } | 136 | } |
@@ -168,7 +164,7 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev, | |||
168 | } else if (per_failed < RATE_CONTROL_NUM_UP) { | 164 | } else if (per_failed < RATE_CONTROL_NUM_UP) { |
169 | rate_control_rate_inc(local, sta); | 165 | rate_control_rate_inc(local, sta); |
170 | } | 166 | } |
171 | srctrl->tx_avg_rate_sum += status->control.rate->rate; | 167 | srctrl->tx_avg_rate_sum += status->control.tx_rate->bitrate; |
172 | srctrl->tx_avg_rate_num++; | 168 | srctrl->tx_avg_rate_num++; |
173 | srctrl->tx_num_failures = 0; | 169 | srctrl->tx_num_failures = 0; |
174 | srctrl->tx_num_xmit = 0; | 170 | srctrl->tx_num_xmit = 0; |
@@ -177,7 +173,7 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev, | |||
177 | rate_control_rate_dec(local, sta); | 173 | rate_control_rate_dec(local, sta); |
178 | } | 174 | } |
179 | 175 | ||
180 | if (srctrl->avg_rate_update + 60 * HZ < jiffies) { | 176 | if (time_after(jiffies, srctrl->avg_rate_update + 60 * HZ)) { |
181 | srctrl->avg_rate_update = jiffies; | 177 | srctrl->avg_rate_update = jiffies; |
182 | if (srctrl->tx_avg_rate_num > 0) { | 178 | if (srctrl->tx_avg_rate_num > 0) { |
183 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 179 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
@@ -201,7 +197,7 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev, | |||
201 | 197 | ||
202 | static void | 198 | static void |
203 | rate_control_simple_get_rate(void *priv, struct net_device *dev, | 199 | rate_control_simple_get_rate(void *priv, struct net_device *dev, |
204 | struct ieee80211_hw_mode *mode, | 200 | struct ieee80211_supported_band *sband, |
205 | struct sk_buff *skb, | 201 | struct sk_buff *skb, |
206 | struct rate_selection *sel) | 202 | struct rate_selection *sel) |
207 | { | 203 | { |
@@ -219,7 +215,7 @@ rate_control_simple_get_rate(void *priv, struct net_device *dev, | |||
219 | fc = le16_to_cpu(hdr->frame_control); | 215 | fc = le16_to_cpu(hdr->frame_control); |
220 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || | 216 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || |
221 | is_multicast_ether_addr(hdr->addr1) || !sta) { | 217 | is_multicast_ether_addr(hdr->addr1) || !sta) { |
222 | sel->rate = rate_lowest(local, mode, sta); | 218 | sel->rate = rate_lowest(local, sband, sta); |
223 | if (sta) | 219 | if (sta) |
224 | sta_info_put(sta); | 220 | sta_info_put(sta); |
225 | return; | 221 | return; |
@@ -228,18 +224,18 @@ rate_control_simple_get_rate(void *priv, struct net_device *dev, | |||
228 | /* If a forced rate is in effect, select it. */ | 224 | /* If a forced rate is in effect, select it. */ |
229 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 225 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
230 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) | 226 | if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) |
231 | sta->txrate = sdata->bss->force_unicast_rateidx; | 227 | sta->txrate_idx = sdata->bss->force_unicast_rateidx; |
232 | 228 | ||
233 | rateidx = sta->txrate; | 229 | rateidx = sta->txrate_idx; |
234 | 230 | ||
235 | if (rateidx >= mode->num_rates) | 231 | if (rateidx >= sband->n_bitrates) |
236 | rateidx = mode->num_rates - 1; | 232 | rateidx = sband->n_bitrates - 1; |
237 | 233 | ||
238 | sta->last_txrate = rateidx; | 234 | sta->last_txrate_idx = rateidx; |
239 | 235 | ||
240 | sta_info_put(sta); | 236 | sta_info_put(sta); |
241 | 237 | ||
242 | sel->rate = &mode->rates[rateidx]; | 238 | sel->rate = &sband->bitrates[rateidx]; |
243 | } | 239 | } |
244 | 240 | ||
245 | 241 | ||
@@ -247,21 +243,15 @@ static void rate_control_simple_rate_init(void *priv, void *priv_sta, | |||
247 | struct ieee80211_local *local, | 243 | struct ieee80211_local *local, |
248 | struct sta_info *sta) | 244 | struct sta_info *sta) |
249 | { | 245 | { |
250 | struct ieee80211_hw_mode *mode; | 246 | struct ieee80211_supported_band *sband; |
251 | int i; | 247 | |
252 | sta->txrate = 0; | 248 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
253 | mode = local->oper_hw_mode; | 249 | |
254 | /* TODO: This routine should consider using RSSI from previous packets | 250 | /* TODO: This routine should consider using RSSI from previous packets |
255 | * as we need to have IEEE 802.1X auth succeed immediately after assoc.. | 251 | * as we need to have IEEE 802.1X auth succeed immediately after assoc.. |
256 | * Until that method is implemented, we will use the lowest supported rate | 252 | * Until that method is implemented, we will use the lowest supported rate |
257 | * as a workaround, */ | 253 | * as a workaround, */ |
258 | for (i = 0; i < mode->num_rates; i++) { | 254 | sta->txrate_idx = rate_lowest_index(local, sband, sta); |
259 | if ((sta->supp_rates & BIT(i)) && | ||
260 | (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) { | ||
261 | sta->txrate = i; | ||
262 | break; | ||
263 | } | ||
264 | } | ||
265 | } | 255 | } |
266 | 256 | ||
267 | 257 | ||
diff --git a/net/mac80211/regdomain.c b/net/mac80211/regdomain.c deleted file mode 100644 index f42678fa62d1..000000000000 --- a/net/mac80211/regdomain.c +++ /dev/null | |||
@@ -1,152 +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 | /* | ||
11 | * This regulatory domain control implementation is known to be incomplete | ||
12 | * and confusing. mac80211 regulatory domain control will be significantly | ||
13 | * reworked in the not-too-distant future. | ||
14 | * | ||
15 | * For now, drivers wishing to control which channels are and aren't available | ||
16 | * are advised as follows: | ||
17 | * - set the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag | ||
18 | * - continue to include *ALL* possible channels in the modes registered | ||
19 | * through ieee80211_register_hwmode() | ||
20 | * - for each allowable ieee80211_channel structure registered in the above | ||
21 | * call, set the flag member to some meaningful value such as | ||
22 | * IEEE80211_CHAN_W_SCAN | IEEE80211_CHAN_W_ACTIVE_SCAN | | ||
23 | * IEEE80211_CHAN_W_IBSS. | ||
24 | * - leave flag as 0 for non-allowable channels | ||
25 | * | ||
26 | * The usual implementation is for a driver to read a device EEPROM to | ||
27 | * determine which regulatory domain it should be operating under, then | ||
28 | * looking up the allowable channels in a driver-local table, then performing | ||
29 | * the above. | ||
30 | */ | ||
31 | |||
32 | #include <linux/module.h> | ||
33 | #include <linux/netdevice.h> | ||
34 | #include <net/mac80211.h> | ||
35 | #include "ieee80211_i.h" | ||
36 | |||
37 | static int ieee80211_regdom = 0x10; /* FCC */ | ||
38 | module_param(ieee80211_regdom, int, 0444); | ||
39 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK"); | ||
40 | |||
41 | /* | ||
42 | * If firmware is upgraded by the vendor, additional channels can be used based | ||
43 | * on the new Japanese regulatory rules. This is indicated by setting | ||
44 | * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel | ||
45 | * module. | ||
46 | */ | ||
47 | static int ieee80211_japan_5ghz /* = 0 */; | ||
48 | module_param(ieee80211_japan_5ghz, int, 0444); | ||
49 | MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz"); | ||
50 | |||
51 | |||
52 | struct ieee80211_channel_range { | ||
53 | short start_freq; | ||
54 | short end_freq; | ||
55 | unsigned char power_level; | ||
56 | unsigned char antenna_max; | ||
57 | }; | ||
58 | |||
59 | static const struct ieee80211_channel_range ieee80211_fcc_channels[] = { | ||
60 | { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */, | ||
61 | { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */, | ||
62 | { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */, | ||
63 | { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */, | ||
64 | { 0 } | ||
65 | }; | ||
66 | |||
67 | static const struct ieee80211_channel_range ieee80211_mkk_channels[] = { | ||
68 | { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */, | ||
69 | { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */, | ||
70 | { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */, | ||
71 | { 0 } | ||
72 | }; | ||
73 | |||
74 | |||
75 | static const struct ieee80211_channel_range *channel_range = | ||
76 | ieee80211_fcc_channels; | ||
77 | |||
78 | |||
79 | static void ieee80211_unmask_channel(int mode, struct ieee80211_channel *chan) | ||
80 | { | ||
81 | int i; | ||
82 | |||
83 | chan->flag = 0; | ||
84 | |||
85 | for (i = 0; channel_range[i].start_freq; i++) { | ||
86 | const struct ieee80211_channel_range *r = &channel_range[i]; | ||
87 | if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) { | ||
88 | if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz && | ||
89 | chan->freq >= 5260 && chan->freq <= 5320) { | ||
90 | /* | ||
91 | * Skip new channels in Japan since the | ||
92 | * firmware was not marked having been upgraded | ||
93 | * by the vendor. | ||
94 | */ | ||
95 | continue; | ||
96 | } | ||
97 | |||
98 | if (ieee80211_regdom == 0x10 && | ||
99 | (chan->freq == 5190 || chan->freq == 5210 || | ||
100 | chan->freq == 5230)) { | ||
101 | /* Skip MKK channels when in FCC domain. */ | ||
102 | continue; | ||
103 | } | ||
104 | |||
105 | chan->flag |= IEEE80211_CHAN_W_SCAN | | ||
106 | IEEE80211_CHAN_W_ACTIVE_SCAN | | ||
107 | IEEE80211_CHAN_W_IBSS; | ||
108 | chan->power_level = r->power_level; | ||
109 | chan->antenna_max = r->antenna_max; | ||
110 | |||
111 | if (ieee80211_regdom == 64 && | ||
112 | (chan->freq == 5170 || chan->freq == 5190 || | ||
113 | chan->freq == 5210 || chan->freq == 5230)) { | ||
114 | /* | ||
115 | * New regulatory rules in Japan have backwards | ||
116 | * compatibility with old channels in 5.15-5.25 | ||
117 | * GHz band, but the station is not allowed to | ||
118 | * use active scan on these old channels. | ||
119 | */ | ||
120 | chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN; | ||
121 | } | ||
122 | |||
123 | if (ieee80211_regdom == 64 && | ||
124 | (chan->freq == 5260 || chan->freq == 5280 || | ||
125 | chan->freq == 5300 || chan->freq == 5320)) { | ||
126 | /* | ||
127 | * IBSS is not allowed on 5.25-5.35 GHz band | ||
128 | * due to radar detection requirements. | ||
129 | */ | ||
130 | chan->flag &= ~IEEE80211_CHAN_W_IBSS; | ||
131 | } | ||
132 | |||
133 | break; | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | |||
138 | |||
139 | void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode) | ||
140 | { | ||
141 | int c; | ||
142 | for (c = 0; c < mode->num_channels; c++) | ||
143 | ieee80211_unmask_channel(mode->mode, &mode->channels[c]); | ||
144 | } | ||
145 | |||
146 | |||
147 | void ieee80211_regdomain_init(void) | ||
148 | { | ||
149 | if (ieee80211_regdom == 0x40) | ||
150 | channel_range = ieee80211_mkk_channels; | ||
151 | } | ||
152 | |||
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 535407d07fa4..48574f6c0e74 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/jiffies.h> | ||
12 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
13 | #include <linux/skbuff.h> | 14 | #include <linux/skbuff.h> |
14 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
@@ -82,10 +83,10 @@ static inline int should_drop_frame(struct ieee80211_rx_status *status, | |||
82 | */ | 83 | */ |
83 | static struct sk_buff * | 84 | static struct sk_buff * |
84 | ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | 85 | ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, |
85 | struct ieee80211_rx_status *status) | 86 | struct ieee80211_rx_status *status, |
87 | struct ieee80211_rate *rate) | ||
86 | { | 88 | { |
87 | struct ieee80211_sub_if_data *sdata; | 89 | struct ieee80211_sub_if_data *sdata; |
88 | struct ieee80211_rate *rate; | ||
89 | int needed_headroom = 0; | 90 | int needed_headroom = 0; |
90 | struct ieee80211_radiotap_header *rthdr; | 91 | struct ieee80211_radiotap_header *rthdr; |
91 | __le64 *rttsft = NULL; | 92 | __le64 *rttsft = NULL; |
@@ -194,14 +195,11 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
194 | rtfixed->rx_flags |= | 195 | rtfixed->rx_flags |= |
195 | cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS); | 196 | cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS); |
196 | 197 | ||
197 | rate = ieee80211_get_rate(local, status->phymode, | 198 | rtfixed->rate = rate->bitrate / 5; |
198 | status->rate); | ||
199 | if (rate) | ||
200 | rtfixed->rate = rate->rate / 5; | ||
201 | 199 | ||
202 | rtfixed->chan_freq = cpu_to_le16(status->freq); | 200 | rtfixed->chan_freq = cpu_to_le16(status->freq); |
203 | 201 | ||
204 | if (status->phymode == MODE_IEEE80211A) | 202 | if (status->band == IEEE80211_BAND_5GHZ) |
205 | rtfixed->chan_flags = | 203 | rtfixed->chan_flags = |
206 | cpu_to_le16(IEEE80211_CHAN_OFDM | | 204 | cpu_to_le16(IEEE80211_CHAN_OFDM | |
207 | IEEE80211_CHAN_5GHZ); | 205 | IEEE80211_CHAN_5GHZ); |
@@ -226,6 +224,9 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
226 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR) | 224 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR) |
227 | continue; | 225 | continue; |
228 | 226 | ||
227 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) | ||
228 | continue; | ||
229 | |||
229 | if (prev_dev) { | 230 | if (prev_dev) { |
230 | skb2 = skb_clone(skb, GFP_ATOMIC); | 231 | skb2 = skb_clone(skb, GFP_ATOMIC); |
231 | if (skb2) { | 232 | if (skb2) { |
@@ -249,15 +250,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
249 | } | 250 | } |
250 | 251 | ||
251 | 252 | ||
252 | /* pre-rx handlers | 253 | static void ieee80211_parse_qos(struct ieee80211_txrx_data *rx) |
253 | * | ||
254 | * these don't have dev/sdata fields in the rx data | ||
255 | * The sta value should also not be used because it may | ||
256 | * be NULL even though a STA (in IBSS mode) will be added. | ||
257 | */ | ||
258 | |||
259 | static ieee80211_txrx_result | ||
260 | ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx) | ||
261 | { | 254 | { |
262 | u8 *data = rx->skb->data; | 255 | u8 *data = rx->skb->data; |
263 | int tid; | 256 | int tid; |
@@ -290,64 +283,15 @@ ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx) | |||
290 | /* Set skb->priority to 1d tag if highest order bit of TID is not set. | 283 | /* Set skb->priority to 1d tag if highest order bit of TID is not set. |
291 | * For now, set skb->priority to 0 for other cases. */ | 284 | * For now, set skb->priority to 0 for other cases. */ |
292 | rx->skb->priority = (tid > 7) ? 0 : tid; | 285 | rx->skb->priority = (tid > 7) ? 0 : tid; |
293 | |||
294 | return TXRX_CONTINUE; | ||
295 | } | 286 | } |
296 | 287 | ||
297 | 288 | static void ieee80211_verify_ip_alignment(struct ieee80211_txrx_data *rx) | |
298 | static u32 ieee80211_rx_load_stats(struct ieee80211_local *local, | ||
299 | struct sk_buff *skb, | ||
300 | struct ieee80211_rx_status *status) | ||
301 | { | 289 | { |
302 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
303 | u32 load = 0, hdrtime; | ||
304 | struct ieee80211_rate *rate; | ||
305 | struct ieee80211_hw_mode *mode = local->hw.conf.mode; | ||
306 | int i; | ||
307 | |||
308 | /* Estimate total channel use caused by this frame */ | ||
309 | |||
310 | if (unlikely(mode->num_rates < 0)) | ||
311 | return TXRX_CONTINUE; | ||
312 | |||
313 | rate = &mode->rates[0]; | ||
314 | for (i = 0; i < mode->num_rates; i++) { | ||
315 | if (mode->rates[i].val == status->rate) { | ||
316 | rate = &mode->rates[i]; | ||
317 | break; | ||
318 | } | ||
319 | } | ||
320 | |||
321 | /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, | ||
322 | * 1 usec = 1/8 * (1080 / 10) = 13.5 */ | ||
323 | |||
324 | if (mode->mode == MODE_IEEE80211A || | ||
325 | (mode->mode == MODE_IEEE80211G && | ||
326 | rate->flags & IEEE80211_RATE_ERP)) | ||
327 | hdrtime = CHAN_UTIL_HDR_SHORT; | ||
328 | else | ||
329 | hdrtime = CHAN_UTIL_HDR_LONG; | ||
330 | |||
331 | load = hdrtime; | ||
332 | if (!is_multicast_ether_addr(hdr->addr1)) | ||
333 | load += hdrtime; | ||
334 | |||
335 | load += skb->len * rate->rate_inv; | ||
336 | |||
337 | /* Divide channel_use by 8 to avoid wrapping around the counter */ | ||
338 | load >>= CHAN_UTIL_SHIFT; | ||
339 | |||
340 | return load; | ||
341 | } | ||
342 | |||
343 | #ifdef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT | 290 | #ifdef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT |
344 | static ieee80211_txrx_result | ||
345 | ieee80211_rx_h_verify_ip_alignment(struct ieee80211_txrx_data *rx) | ||
346 | { | ||
347 | int hdrlen; | 291 | int hdrlen; |
348 | 292 | ||
349 | if (!WLAN_FC_DATA_PRESENT(rx->fc)) | 293 | if (!WLAN_FC_DATA_PRESENT(rx->fc)) |
350 | return TXRX_CONTINUE; | 294 | return; |
351 | 295 | ||
352 | /* | 296 | /* |
353 | * Drivers are required to align the payload data in a way that | 297 | * Drivers are required to align the payload data in a way that |
@@ -372,32 +316,55 @@ ieee80211_rx_h_verify_ip_alignment(struct ieee80211_txrx_data *rx) | |||
372 | if (rx->flags & IEEE80211_TXRXD_RX_AMSDU) | 316 | if (rx->flags & IEEE80211_TXRXD_RX_AMSDU) |
373 | hdrlen += ETH_HLEN; | 317 | hdrlen += ETH_HLEN; |
374 | WARN_ON_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3); | 318 | WARN_ON_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3); |
375 | |||
376 | return TXRX_CONTINUE; | ||
377 | } | ||
378 | #endif | 319 | #endif |
320 | } | ||
379 | 321 | ||
380 | ieee80211_rx_handler ieee80211_rx_pre_handlers[] = | 322 | |
323 | static u32 ieee80211_rx_load_stats(struct ieee80211_local *local, | ||
324 | struct sk_buff *skb, | ||
325 | struct ieee80211_rx_status *status, | ||
326 | struct ieee80211_rate *rate) | ||
381 | { | 327 | { |
382 | ieee80211_rx_h_parse_qos, | 328 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
383 | #ifdef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT | 329 | u32 load = 0, hdrtime; |
384 | ieee80211_rx_h_verify_ip_alignment, | 330 | |
385 | #endif | 331 | /* Estimate total channel use caused by this frame */ |
386 | NULL | 332 | |
387 | }; | 333 | /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, |
334 | * 1 usec = 1/8 * (1080 / 10) = 13.5 */ | ||
335 | |||
336 | if (status->band == IEEE80211_BAND_5GHZ || | ||
337 | (status->band == IEEE80211_BAND_5GHZ && | ||
338 | rate->flags & IEEE80211_RATE_ERP_G)) | ||
339 | hdrtime = CHAN_UTIL_HDR_SHORT; | ||
340 | else | ||
341 | hdrtime = CHAN_UTIL_HDR_LONG; | ||
342 | |||
343 | load = hdrtime; | ||
344 | if (!is_multicast_ether_addr(hdr->addr1)) | ||
345 | load += hdrtime; | ||
346 | |||
347 | /* TODO: optimise again */ | ||
348 | load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate; | ||
349 | |||
350 | /* Divide channel_use by 8 to avoid wrapping around the counter */ | ||
351 | load >>= CHAN_UTIL_SHIFT; | ||
352 | |||
353 | return load; | ||
354 | } | ||
388 | 355 | ||
389 | /* rx handlers */ | 356 | /* rx handlers */ |
390 | 357 | ||
391 | static ieee80211_txrx_result | 358 | static ieee80211_rx_result |
392 | ieee80211_rx_h_if_stats(struct ieee80211_txrx_data *rx) | 359 | ieee80211_rx_h_if_stats(struct ieee80211_txrx_data *rx) |
393 | { | 360 | { |
394 | if (rx->sta) | 361 | if (rx->sta) |
395 | rx->sta->channel_use_raw += rx->u.rx.load; | 362 | rx->sta->channel_use_raw += rx->u.rx.load; |
396 | rx->sdata->channel_use_raw += rx->u.rx.load; | 363 | rx->sdata->channel_use_raw += rx->u.rx.load; |
397 | return TXRX_CONTINUE; | 364 | return RX_CONTINUE; |
398 | } | 365 | } |
399 | 366 | ||
400 | static ieee80211_txrx_result | 367 | static ieee80211_rx_result |
401 | ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx) | 368 | ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx) |
402 | { | 369 | { |
403 | struct ieee80211_local *local = rx->local; | 370 | struct ieee80211_local *local = rx->local; |
@@ -409,21 +376,21 @@ ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx) | |||
409 | if (unlikely(local->sta_sw_scanning)) { | 376 | if (unlikely(local->sta_sw_scanning)) { |
410 | /* drop all the other packets during a software scan anyway */ | 377 | /* drop all the other packets during a software scan anyway */ |
411 | if (ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status) | 378 | if (ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status) |
412 | != TXRX_QUEUED) | 379 | != RX_QUEUED) |
413 | dev_kfree_skb(skb); | 380 | dev_kfree_skb(skb); |
414 | return TXRX_QUEUED; | 381 | return RX_QUEUED; |
415 | } | 382 | } |
416 | 383 | ||
417 | if (unlikely(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) { | 384 | if (unlikely(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) { |
418 | /* scanning finished during invoking of handlers */ | 385 | /* scanning finished during invoking of handlers */ |
419 | I802_DEBUG_INC(local->rx_handlers_drop_passive_scan); | 386 | I802_DEBUG_INC(local->rx_handlers_drop_passive_scan); |
420 | return TXRX_DROP; | 387 | return RX_DROP_UNUSABLE; |
421 | } | 388 | } |
422 | 389 | ||
423 | return TXRX_CONTINUE; | 390 | return RX_CONTINUE; |
424 | } | 391 | } |
425 | 392 | ||
426 | static ieee80211_txrx_result | 393 | static ieee80211_rx_result |
427 | ieee80211_rx_h_check(struct ieee80211_txrx_data *rx) | 394 | ieee80211_rx_h_check(struct ieee80211_txrx_data *rx) |
428 | { | 395 | { |
429 | struct ieee80211_hdr *hdr; | 396 | struct ieee80211_hdr *hdr; |
@@ -438,14 +405,14 @@ ieee80211_rx_h_check(struct ieee80211_txrx_data *rx) | |||
438 | rx->local->dot11FrameDuplicateCount++; | 405 | rx->local->dot11FrameDuplicateCount++; |
439 | rx->sta->num_duplicates++; | 406 | rx->sta->num_duplicates++; |
440 | } | 407 | } |
441 | return TXRX_DROP; | 408 | return RX_DROP_MONITOR; |
442 | } else | 409 | } else |
443 | rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl; | 410 | rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl; |
444 | } | 411 | } |
445 | 412 | ||
446 | if (unlikely(rx->skb->len < 16)) { | 413 | if (unlikely(rx->skb->len < 16)) { |
447 | I802_DEBUG_INC(rx->local->rx_handlers_drop_short); | 414 | I802_DEBUG_INC(rx->local->rx_handlers_drop_short); |
448 | return TXRX_DROP; | 415 | return RX_DROP_MONITOR; |
449 | } | 416 | } |
450 | 417 | ||
451 | /* Drop disallowed frame classes based on STA auth/assoc state; | 418 | /* Drop disallowed frame classes based on STA auth/assoc state; |
@@ -467,23 +434,23 @@ ieee80211_rx_h_check(struct ieee80211_txrx_data *rx) | |||
467 | || !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) { | 434 | || !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) { |
468 | /* Drop IBSS frames and frames for other hosts | 435 | /* Drop IBSS frames and frames for other hosts |
469 | * silently. */ | 436 | * silently. */ |
470 | return TXRX_DROP; | 437 | return RX_DROP_MONITOR; |
471 | } | 438 | } |
472 | 439 | ||
473 | return TXRX_DROP; | 440 | return RX_DROP_MONITOR; |
474 | } | 441 | } |
475 | 442 | ||
476 | return TXRX_CONTINUE; | 443 | return RX_CONTINUE; |
477 | } | 444 | } |
478 | 445 | ||
479 | 446 | ||
480 | static ieee80211_txrx_result | 447 | static ieee80211_rx_result |
481 | ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) | 448 | ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) |
482 | { | 449 | { |
483 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 450 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; |
484 | int keyidx; | 451 | int keyidx; |
485 | int hdrlen; | 452 | int hdrlen; |
486 | ieee80211_txrx_result result = TXRX_DROP; | 453 | ieee80211_rx_result result = RX_DROP_UNUSABLE; |
487 | struct ieee80211_key *stakey = NULL; | 454 | struct ieee80211_key *stakey = NULL; |
488 | 455 | ||
489 | /* | 456 | /* |
@@ -513,14 +480,14 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) | |||
513 | */ | 480 | */ |
514 | 481 | ||
515 | if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) | 482 | if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) |
516 | return TXRX_CONTINUE; | 483 | return RX_CONTINUE; |
517 | 484 | ||
518 | /* | 485 | /* |
519 | * No point in finding a key and decrypting if the frame is neither | 486 | * No point in finding a key and decrypting if the frame is neither |
520 | * addressed to us nor a multicast frame. | 487 | * addressed to us nor a multicast frame. |
521 | */ | 488 | */ |
522 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) | 489 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) |
523 | return TXRX_CONTINUE; | 490 | return RX_CONTINUE; |
524 | 491 | ||
525 | if (rx->sta) | 492 | if (rx->sta) |
526 | stakey = rcu_dereference(rx->sta->key); | 493 | stakey = rcu_dereference(rx->sta->key); |
@@ -539,12 +506,12 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) | |||
539 | */ | 506 | */ |
540 | if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && | 507 | if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && |
541 | (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) | 508 | (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) |
542 | return TXRX_CONTINUE; | 509 | return RX_CONTINUE; |
543 | 510 | ||
544 | hdrlen = ieee80211_get_hdrlen(rx->fc); | 511 | hdrlen = ieee80211_get_hdrlen(rx->fc); |
545 | 512 | ||
546 | if (rx->skb->len < 8 + hdrlen) | 513 | if (rx->skb->len < 8 + hdrlen) |
547 | return TXRX_DROP; /* TODO: count this? */ | 514 | return RX_DROP_UNUSABLE; /* TODO: count this? */ |
548 | 515 | ||
549 | /* | 516 | /* |
550 | * no need to call ieee80211_wep_get_keyidx, | 517 | * no need to call ieee80211_wep_get_keyidx, |
@@ -573,7 +540,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) | |||
573 | printk(KERN_DEBUG "%s: RX protected frame," | 540 | printk(KERN_DEBUG "%s: RX protected frame," |
574 | " but have no key\n", rx->dev->name); | 541 | " but have no key\n", rx->dev->name); |
575 | #endif /* CONFIG_MAC80211_DEBUG */ | 542 | #endif /* CONFIG_MAC80211_DEBUG */ |
576 | return TXRX_DROP; | 543 | return RX_DROP_MONITOR; |
577 | } | 544 | } |
578 | 545 | ||
579 | /* Check for weak IVs if possible */ | 546 | /* Check for weak IVs if possible */ |
@@ -612,7 +579,7 @@ static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta) | |||
612 | if (sdata->bss) | 579 | if (sdata->bss) |
613 | atomic_inc(&sdata->bss->num_sta_ps); | 580 | atomic_inc(&sdata->bss->num_sta_ps); |
614 | sta->flags |= WLAN_STA_PS; | 581 | sta->flags |= WLAN_STA_PS; |
615 | sta->pspoll = 0; | 582 | sta->flags &= ~WLAN_STA_PSPOLL; |
616 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 583 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
617 | printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n", | 584 | printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n", |
618 | dev->name, print_mac(mac, sta->addr), sta->aid); | 585 | dev->name, print_mac(mac, sta->addr), sta->aid); |
@@ -629,20 +596,20 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | |||
629 | DECLARE_MAC_BUF(mac); | 596 | DECLARE_MAC_BUF(mac); |
630 | 597 | ||
631 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | 598 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
599 | |||
632 | if (sdata->bss) | 600 | if (sdata->bss) |
633 | atomic_dec(&sdata->bss->num_sta_ps); | 601 | atomic_dec(&sdata->bss->num_sta_ps); |
634 | sta->flags &= ~(WLAN_STA_PS | WLAN_STA_TIM); | 602 | |
635 | sta->pspoll = 0; | 603 | sta->flags &= ~(WLAN_STA_PS | WLAN_STA_PSPOLL); |
636 | if (!skb_queue_empty(&sta->ps_tx_buf)) { | 604 | |
637 | if (local->ops->set_tim) | 605 | if (!skb_queue_empty(&sta->ps_tx_buf)) |
638 | local->ops->set_tim(local_to_hw(local), sta->aid, 0); | 606 | sta_info_clear_tim_bit(sta); |
639 | if (sdata->bss) | 607 | |
640 | bss_tim_clear(local, sdata->bss, sta->aid); | ||
641 | } | ||
642 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 608 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
643 | printk(KERN_DEBUG "%s: STA %s aid %d exits power save mode\n", | 609 | printk(KERN_DEBUG "%s: STA %s aid %d exits power save mode\n", |
644 | dev->name, print_mac(mac, sta->addr), sta->aid); | 610 | dev->name, print_mac(mac, sta->addr), sta->aid); |
645 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 611 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
612 | |||
646 | /* Send all buffered frames to the station */ | 613 | /* Send all buffered frames to the station */ |
647 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { | 614 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { |
648 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; | 615 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; |
@@ -666,7 +633,7 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | |||
666 | return sent; | 633 | return sent; |
667 | } | 634 | } |
668 | 635 | ||
669 | static ieee80211_txrx_result | 636 | static ieee80211_rx_result |
670 | ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx) | 637 | ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx) |
671 | { | 638 | { |
672 | struct sta_info *sta = rx->sta; | 639 | struct sta_info *sta = rx->sta; |
@@ -674,7 +641,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx) | |||
674 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 641 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; |
675 | 642 | ||
676 | if (!sta) | 643 | if (!sta) |
677 | return TXRX_CONTINUE; | 644 | return RX_CONTINUE; |
678 | 645 | ||
679 | /* Update last_rx only for IBSS packets which are for the current | 646 | /* Update last_rx only for IBSS packets which are for the current |
680 | * BSSID to avoid keeping the current IBSS network alive in cases where | 647 | * BSSID to avoid keeping the current IBSS network alive in cases where |
@@ -695,7 +662,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx) | |||
695 | } | 662 | } |
696 | 663 | ||
697 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) | 664 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) |
698 | return TXRX_CONTINUE; | 665 | return RX_CONTINUE; |
699 | 666 | ||
700 | sta->rx_fragments++; | 667 | sta->rx_fragments++; |
701 | sta->rx_bytes += rx->skb->len; | 668 | sta->rx_bytes += rx->skb->len; |
@@ -722,10 +689,10 @@ ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx) | |||
722 | * as a dropped packed. */ | 689 | * as a dropped packed. */ |
723 | sta->rx_packets++; | 690 | sta->rx_packets++; |
724 | dev_kfree_skb(rx->skb); | 691 | dev_kfree_skb(rx->skb); |
725 | return TXRX_QUEUED; | 692 | return RX_QUEUED; |
726 | } | 693 | } |
727 | 694 | ||
728 | return TXRX_CONTINUE; | 695 | return RX_CONTINUE; |
729 | } /* ieee80211_rx_h_sta_process */ | 696 | } /* ieee80211_rx_h_sta_process */ |
730 | 697 | ||
731 | static inline struct ieee80211_fragment_entry * | 698 | static inline struct ieee80211_fragment_entry * |
@@ -801,7 +768,7 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, | |||
801 | compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0) | 768 | compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0) |
802 | continue; | 769 | continue; |
803 | 770 | ||
804 | if (entry->first_frag_time + 2 * HZ < jiffies) { | 771 | if (time_after(jiffies, entry->first_frag_time + 2 * HZ)) { |
805 | __skb_queue_purge(&entry->skb_list); | 772 | __skb_queue_purge(&entry->skb_list); |
806 | continue; | 773 | continue; |
807 | } | 774 | } |
@@ -811,7 +778,7 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, | |||
811 | return NULL; | 778 | return NULL; |
812 | } | 779 | } |
813 | 780 | ||
814 | static ieee80211_txrx_result | 781 | static ieee80211_rx_result |
815 | ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | 782 | ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) |
816 | { | 783 | { |
817 | struct ieee80211_hdr *hdr; | 784 | struct ieee80211_hdr *hdr; |
@@ -848,7 +815,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | |||
848 | rx->key->u.ccmp.rx_pn[rx->u.rx.queue], | 815 | rx->key->u.ccmp.rx_pn[rx->u.rx.queue], |
849 | CCMP_PN_LEN); | 816 | CCMP_PN_LEN); |
850 | } | 817 | } |
851 | return TXRX_QUEUED; | 818 | return RX_QUEUED; |
852 | } | 819 | } |
853 | 820 | ||
854 | /* This is a fragment for a frame that should already be pending in | 821 | /* This is a fragment for a frame that should already be pending in |
@@ -858,7 +825,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | |||
858 | rx->u.rx.queue, hdr); | 825 | rx->u.rx.queue, hdr); |
859 | if (!entry) { | 826 | if (!entry) { |
860 | I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); | 827 | I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); |
861 | return TXRX_DROP; | 828 | return RX_DROP_MONITOR; |
862 | } | 829 | } |
863 | 830 | ||
864 | /* Verify that MPDUs within one MSDU have sequential PN values. | 831 | /* Verify that MPDUs within one MSDU have sequential PN values. |
@@ -867,7 +834,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | |||
867 | int i; | 834 | int i; |
868 | u8 pn[CCMP_PN_LEN], *rpn; | 835 | u8 pn[CCMP_PN_LEN], *rpn; |
869 | if (!rx->key || rx->key->conf.alg != ALG_CCMP) | 836 | if (!rx->key || rx->key->conf.alg != ALG_CCMP) |
870 | return TXRX_DROP; | 837 | return RX_DROP_UNUSABLE; |
871 | memcpy(pn, entry->last_pn, CCMP_PN_LEN); | 838 | memcpy(pn, entry->last_pn, CCMP_PN_LEN); |
872 | for (i = CCMP_PN_LEN - 1; i >= 0; i--) { | 839 | for (i = CCMP_PN_LEN - 1; i >= 0; i--) { |
873 | pn[i]++; | 840 | pn[i]++; |
@@ -885,7 +852,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | |||
885 | rpn[0], rpn[1], rpn[2], rpn[3], rpn[4], | 852 | rpn[0], rpn[1], rpn[2], rpn[3], rpn[4], |
886 | rpn[5], pn[0], pn[1], pn[2], pn[3], | 853 | rpn[5], pn[0], pn[1], pn[2], pn[3], |
887 | pn[4], pn[5]); | 854 | pn[4], pn[5]); |
888 | return TXRX_DROP; | 855 | return RX_DROP_UNUSABLE; |
889 | } | 856 | } |
890 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); | 857 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); |
891 | } | 858 | } |
@@ -896,7 +863,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | |||
896 | entry->extra_len += rx->skb->len; | 863 | entry->extra_len += rx->skb->len; |
897 | if (rx->fc & IEEE80211_FCTL_MOREFRAGS) { | 864 | if (rx->fc & IEEE80211_FCTL_MOREFRAGS) { |
898 | rx->skb = NULL; | 865 | rx->skb = NULL; |
899 | return TXRX_QUEUED; | 866 | return RX_QUEUED; |
900 | } | 867 | } |
901 | 868 | ||
902 | rx->skb = __skb_dequeue(&entry->skb_list); | 869 | rx->skb = __skb_dequeue(&entry->skb_list); |
@@ -906,7 +873,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | |||
906 | GFP_ATOMIC))) { | 873 | GFP_ATOMIC))) { |
907 | I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); | 874 | I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); |
908 | __skb_queue_purge(&entry->skb_list); | 875 | __skb_queue_purge(&entry->skb_list); |
909 | return TXRX_DROP; | 876 | return RX_DROP_UNUSABLE; |
910 | } | 877 | } |
911 | } | 878 | } |
912 | while ((skb = __skb_dequeue(&entry->skb_list))) { | 879 | while ((skb = __skb_dequeue(&entry->skb_list))) { |
@@ -924,10 +891,10 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) | |||
924 | rx->local->dot11MulticastReceivedFrameCount++; | 891 | rx->local->dot11MulticastReceivedFrameCount++; |
925 | else | 892 | else |
926 | ieee80211_led_rx(rx->local); | 893 | ieee80211_led_rx(rx->local); |
927 | return TXRX_CONTINUE; | 894 | return RX_CONTINUE; |
928 | } | 895 | } |
929 | 896 | ||
930 | static ieee80211_txrx_result | 897 | static ieee80211_rx_result |
931 | ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) | 898 | ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) |
932 | { | 899 | { |
933 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | 900 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); |
@@ -939,11 +906,11 @@ ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) | |||
939 | (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL || | 906 | (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL || |
940 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL || | 907 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL || |
941 | !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))) | 908 | !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))) |
942 | return TXRX_CONTINUE; | 909 | return RX_CONTINUE; |
943 | 910 | ||
944 | if ((sdata->vif.type != IEEE80211_IF_TYPE_AP) && | 911 | if ((sdata->vif.type != IEEE80211_IF_TYPE_AP) && |
945 | (sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) | 912 | (sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) |
946 | return TXRX_DROP; | 913 | return RX_DROP_UNUSABLE; |
947 | 914 | ||
948 | skb = skb_dequeue(&rx->sta->tx_filtered); | 915 | skb = skb_dequeue(&rx->sta->tx_filtered); |
949 | if (!skb) { | 916 | if (!skb) { |
@@ -958,9 +925,11 @@ ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) | |||
958 | struct ieee80211_hdr *hdr = | 925 | struct ieee80211_hdr *hdr = |
959 | (struct ieee80211_hdr *) skb->data; | 926 | (struct ieee80211_hdr *) skb->data; |
960 | 927 | ||
961 | /* tell TX path to send one frame even though the STA may | 928 | /* |
962 | * still remain is PS mode after this frame exchange */ | 929 | * Tell TX path to send one frame even though the STA may |
963 | rx->sta->pspoll = 1; | 930 | * still remain is PS mode after this frame exchange. |
931 | */ | ||
932 | rx->sta->flags |= WLAN_STA_PSPOLL; | ||
964 | 933 | ||
965 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 934 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
966 | printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n", | 935 | printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n", |
@@ -970,38 +939,37 @@ ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) | |||
970 | 939 | ||
971 | /* Use MoreData flag to indicate whether there are more | 940 | /* Use MoreData flag to indicate whether there are more |
972 | * buffered frames for this STA */ | 941 | * buffered frames for this STA */ |
973 | if (no_pending_pkts) { | 942 | if (no_pending_pkts) |
974 | hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREDATA); | 943 | hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREDATA); |
975 | rx->sta->flags &= ~WLAN_STA_TIM; | 944 | else |
976 | } else | ||
977 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); | 945 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
978 | 946 | ||
979 | dev_queue_xmit(skb); | 947 | dev_queue_xmit(skb); |
980 | 948 | ||
981 | if (no_pending_pkts) { | 949 | if (no_pending_pkts) |
982 | if (rx->local->ops->set_tim) | 950 | sta_info_clear_tim_bit(rx->sta); |
983 | rx->local->ops->set_tim(local_to_hw(rx->local), | ||
984 | rx->sta->aid, 0); | ||
985 | if (rx->sdata->bss) | ||
986 | bss_tim_clear(rx->local, rx->sdata->bss, rx->sta->aid); | ||
987 | } | ||
988 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 951 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
989 | } else if (!rx->u.rx.sent_ps_buffered) { | 952 | } else if (!rx->u.rx.sent_ps_buffered) { |
953 | /* | ||
954 | * FIXME: This can be the result of a race condition between | ||
955 | * us expiring a frame and the station polling for it. | ||
956 | * Should we send it a null-func frame indicating we | ||
957 | * have nothing buffered for it? | ||
958 | */ | ||
990 | printk(KERN_DEBUG "%s: STA %s sent PS Poll even " | 959 | printk(KERN_DEBUG "%s: STA %s sent PS Poll even " |
991 | "though there is no buffered frames for it\n", | 960 | "though there is no buffered frames for it\n", |
992 | rx->dev->name, print_mac(mac, rx->sta->addr)); | 961 | rx->dev->name, print_mac(mac, rx->sta->addr)); |
993 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 962 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
994 | |||
995 | } | 963 | } |
996 | 964 | ||
997 | /* Free PS Poll skb here instead of returning TXRX_DROP that would | 965 | /* Free PS Poll skb here instead of returning RX_DROP that would |
998 | * count as an dropped frame. */ | 966 | * count as an dropped frame. */ |
999 | dev_kfree_skb(rx->skb); | 967 | dev_kfree_skb(rx->skb); |
1000 | 968 | ||
1001 | return TXRX_QUEUED; | 969 | return RX_QUEUED; |
1002 | } | 970 | } |
1003 | 971 | ||
1004 | static ieee80211_txrx_result | 972 | static ieee80211_rx_result |
1005 | ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx) | 973 | ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx) |
1006 | { | 974 | { |
1007 | u16 fc = rx->fc; | 975 | u16 fc = rx->fc; |
@@ -1009,7 +977,7 @@ ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx) | |||
1009 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data; | 977 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data; |
1010 | 978 | ||
1011 | if (!WLAN_FC_IS_QOS_DATA(fc)) | 979 | if (!WLAN_FC_IS_QOS_DATA(fc)) |
1012 | return TXRX_CONTINUE; | 980 | return RX_CONTINUE; |
1013 | 981 | ||
1014 | /* remove the qos control field, update frame type and meta-data */ | 982 | /* remove the qos control field, update frame type and meta-data */ |
1015 | memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2); | 983 | memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2); |
@@ -1018,17 +986,17 @@ ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx) | |||
1018 | rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA; | 986 | rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA; |
1019 | hdr->frame_control = cpu_to_le16(fc); | 987 | hdr->frame_control = cpu_to_le16(fc); |
1020 | 988 | ||
1021 | return TXRX_CONTINUE; | 989 | return RX_CONTINUE; |
1022 | } | 990 | } |
1023 | 991 | ||
1024 | static int | 992 | static int |
1025 | ieee80211_802_1x_port_control(struct ieee80211_txrx_data *rx) | 993 | ieee80211_802_1x_port_control(struct ieee80211_txrx_data *rx) |
1026 | { | 994 | { |
1027 | if (unlikely(rx->sdata->ieee802_1x_pac && | 995 | if (unlikely(!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED))) { |
1028 | (!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED)))) { | ||
1029 | #ifdef CONFIG_MAC80211_DEBUG | 996 | #ifdef CONFIG_MAC80211_DEBUG |
1030 | printk(KERN_DEBUG "%s: dropped frame " | 997 | if (net_ratelimit()) |
1031 | "(unauthorized port)\n", rx->dev->name); | 998 | printk(KERN_DEBUG "%s: dropped frame " |
999 | "(unauthorized port)\n", rx->dev->name); | ||
1032 | #endif /* CONFIG_MAC80211_DEBUG */ | 1000 | #endif /* CONFIG_MAC80211_DEBUG */ |
1033 | return -EACCES; | 1001 | return -EACCES; |
1034 | } | 1002 | } |
@@ -1275,7 +1243,7 @@ ieee80211_deliver_skb(struct ieee80211_txrx_data *rx) | |||
1275 | } | 1243 | } |
1276 | } | 1244 | } |
1277 | 1245 | ||
1278 | static ieee80211_txrx_result | 1246 | static ieee80211_rx_result |
1279 | ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | 1247 | ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) |
1280 | { | 1248 | { |
1281 | struct net_device *dev = rx->dev; | 1249 | struct net_device *dev = rx->dev; |
@@ -1291,17 +1259,17 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | |||
1291 | 1259 | ||
1292 | fc = rx->fc; | 1260 | fc = rx->fc; |
1293 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) | 1261 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) |
1294 | return TXRX_CONTINUE; | 1262 | return RX_CONTINUE; |
1295 | 1263 | ||
1296 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | 1264 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) |
1297 | return TXRX_DROP; | 1265 | return RX_DROP_MONITOR; |
1298 | 1266 | ||
1299 | if (!(rx->flags & IEEE80211_TXRXD_RX_AMSDU)) | 1267 | if (!(rx->flags & IEEE80211_TXRXD_RX_AMSDU)) |
1300 | return TXRX_CONTINUE; | 1268 | return RX_CONTINUE; |
1301 | 1269 | ||
1302 | err = ieee80211_data_to_8023(rx); | 1270 | err = ieee80211_data_to_8023(rx); |
1303 | if (unlikely(err)) | 1271 | if (unlikely(err)) |
1304 | return TXRX_DROP; | 1272 | return RX_DROP_UNUSABLE; |
1305 | 1273 | ||
1306 | skb->dev = dev; | 1274 | skb->dev = dev; |
1307 | 1275 | ||
@@ -1311,7 +1279,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | |||
1311 | /* skip the wrapping header */ | 1279 | /* skip the wrapping header */ |
1312 | eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr)); | 1280 | eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr)); |
1313 | if (!eth) | 1281 | if (!eth) |
1314 | return TXRX_DROP; | 1282 | return RX_DROP_UNUSABLE; |
1315 | 1283 | ||
1316 | while (skb != frame) { | 1284 | while (skb != frame) { |
1317 | u8 padding; | 1285 | u8 padding; |
@@ -1326,7 +1294,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | |||
1326 | /* the last MSDU has no padding */ | 1294 | /* the last MSDU has no padding */ |
1327 | if (subframe_len > remaining) { | 1295 | if (subframe_len > remaining) { |
1328 | printk(KERN_DEBUG "%s: wrong buffer size", dev->name); | 1296 | printk(KERN_DEBUG "%s: wrong buffer size", dev->name); |
1329 | return TXRX_DROP; | 1297 | return RX_DROP_UNUSABLE; |
1330 | } | 1298 | } |
1331 | 1299 | ||
1332 | skb_pull(skb, sizeof(struct ethhdr)); | 1300 | skb_pull(skb, sizeof(struct ethhdr)); |
@@ -1338,7 +1306,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | |||
1338 | subframe_len); | 1306 | subframe_len); |
1339 | 1307 | ||
1340 | if (frame == NULL) | 1308 | if (frame == NULL) |
1341 | return TXRX_DROP; | 1309 | return RX_DROP_UNUSABLE; |
1342 | 1310 | ||
1343 | skb_reserve(frame, local->hw.extra_tx_headroom + | 1311 | skb_reserve(frame, local->hw.extra_tx_headroom + |
1344 | sizeof(struct ethhdr)); | 1312 | sizeof(struct ethhdr)); |
@@ -1351,7 +1319,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | |||
1351 | printk(KERN_DEBUG "%s: wrong buffer size ", | 1319 | printk(KERN_DEBUG "%s: wrong buffer size ", |
1352 | dev->name); | 1320 | dev->name); |
1353 | dev_kfree_skb(frame); | 1321 | dev_kfree_skb(frame); |
1354 | return TXRX_DROP; | 1322 | return RX_DROP_UNUSABLE; |
1355 | } | 1323 | } |
1356 | } | 1324 | } |
1357 | 1325 | ||
@@ -1381,7 +1349,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | |||
1381 | 1349 | ||
1382 | if (!ieee80211_frame_allowed(rx)) { | 1350 | if (!ieee80211_frame_allowed(rx)) { |
1383 | if (skb == frame) /* last frame */ | 1351 | if (skb == frame) /* last frame */ |
1384 | return TXRX_DROP; | 1352 | return RX_DROP_UNUSABLE; |
1385 | dev_kfree_skb(frame); | 1353 | dev_kfree_skb(frame); |
1386 | continue; | 1354 | continue; |
1387 | } | 1355 | } |
@@ -1389,10 +1357,10 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx) | |||
1389 | ieee80211_deliver_skb(rx); | 1357 | ieee80211_deliver_skb(rx); |
1390 | } | 1358 | } |
1391 | 1359 | ||
1392 | return TXRX_QUEUED; | 1360 | return RX_QUEUED; |
1393 | } | 1361 | } |
1394 | 1362 | ||
1395 | static ieee80211_txrx_result | 1363 | static ieee80211_rx_result |
1396 | ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) | 1364 | ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) |
1397 | { | 1365 | { |
1398 | struct net_device *dev = rx->dev; | 1366 | struct net_device *dev = rx->dev; |
@@ -1401,17 +1369,17 @@ ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) | |||
1401 | 1369 | ||
1402 | fc = rx->fc; | 1370 | fc = rx->fc; |
1403 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) | 1371 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) |
1404 | return TXRX_CONTINUE; | 1372 | return RX_CONTINUE; |
1405 | 1373 | ||
1406 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | 1374 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) |
1407 | return TXRX_DROP; | 1375 | return RX_DROP_MONITOR; |
1408 | 1376 | ||
1409 | err = ieee80211_data_to_8023(rx); | 1377 | err = ieee80211_data_to_8023(rx); |
1410 | if (unlikely(err)) | 1378 | if (unlikely(err)) |
1411 | return TXRX_DROP; | 1379 | return RX_DROP_UNUSABLE; |
1412 | 1380 | ||
1413 | if (!ieee80211_frame_allowed(rx)) | 1381 | if (!ieee80211_frame_allowed(rx)) |
1414 | return TXRX_DROP; | 1382 | return RX_DROP_MONITOR; |
1415 | 1383 | ||
1416 | rx->skb->dev = dev; | 1384 | rx->skb->dev = dev; |
1417 | 1385 | ||
@@ -1420,10 +1388,10 @@ ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) | |||
1420 | 1388 | ||
1421 | ieee80211_deliver_skb(rx); | 1389 | ieee80211_deliver_skb(rx); |
1422 | 1390 | ||
1423 | return TXRX_QUEUED; | 1391 | return RX_QUEUED; |
1424 | } | 1392 | } |
1425 | 1393 | ||
1426 | static ieee80211_txrx_result | 1394 | static ieee80211_rx_result |
1427 | ieee80211_rx_h_ctrl(struct ieee80211_txrx_data *rx) | 1395 | ieee80211_rx_h_ctrl(struct ieee80211_txrx_data *rx) |
1428 | { | 1396 | { |
1429 | struct ieee80211_local *local = rx->local; | 1397 | struct ieee80211_local *local = rx->local; |
@@ -1435,15 +1403,15 @@ ieee80211_rx_h_ctrl(struct ieee80211_txrx_data *rx) | |||
1435 | u16 tid; | 1403 | u16 tid; |
1436 | 1404 | ||
1437 | if (likely((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL)) | 1405 | if (likely((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL)) |
1438 | return TXRX_CONTINUE; | 1406 | return RX_CONTINUE; |
1439 | 1407 | ||
1440 | if ((rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BACK_REQ) { | 1408 | if ((rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BACK_REQ) { |
1441 | if (!rx->sta) | 1409 | if (!rx->sta) |
1442 | return TXRX_CONTINUE; | 1410 | return RX_CONTINUE; |
1443 | tid = le16_to_cpu(bar->control) >> 12; | 1411 | tid = le16_to_cpu(bar->control) >> 12; |
1444 | tid_agg_rx = &(rx->sta->ampdu_mlme.tid_rx[tid]); | 1412 | tid_agg_rx = &(rx->sta->ampdu_mlme.tid_rx[tid]); |
1445 | if (tid_agg_rx->state != HT_AGG_STATE_OPERATIONAL) | 1413 | if (tid_agg_rx->state != HT_AGG_STATE_OPERATIONAL) |
1446 | return TXRX_CONTINUE; | 1414 | return RX_CONTINUE; |
1447 | 1415 | ||
1448 | start_seq_num = le16_to_cpu(bar->start_seq_num) >> 4; | 1416 | start_seq_num = le16_to_cpu(bar->start_seq_num) >> 4; |
1449 | 1417 | ||
@@ -1460,19 +1428,19 @@ ieee80211_rx_h_ctrl(struct ieee80211_txrx_data *rx) | |||
1460 | ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, | 1428 | ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, |
1461 | start_seq_num, 1); | 1429 | start_seq_num, 1); |
1462 | rcu_read_unlock(); | 1430 | rcu_read_unlock(); |
1463 | return TXRX_DROP; | 1431 | return RX_DROP_UNUSABLE; |
1464 | } | 1432 | } |
1465 | 1433 | ||
1466 | return TXRX_CONTINUE; | 1434 | return RX_CONTINUE; |
1467 | } | 1435 | } |
1468 | 1436 | ||
1469 | static ieee80211_txrx_result | 1437 | static ieee80211_rx_result |
1470 | ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx) | 1438 | ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx) |
1471 | { | 1439 | { |
1472 | struct ieee80211_sub_if_data *sdata; | 1440 | struct ieee80211_sub_if_data *sdata; |
1473 | 1441 | ||
1474 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) | 1442 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) |
1475 | return TXRX_DROP; | 1443 | return RX_DROP_MONITOR; |
1476 | 1444 | ||
1477 | sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | 1445 | sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); |
1478 | if ((sdata->vif.type == IEEE80211_IF_TYPE_STA || | 1446 | if ((sdata->vif.type == IEEE80211_IF_TYPE_STA || |
@@ -1480,56 +1448,13 @@ ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx) | |||
1480 | !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME)) | 1448 | !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME)) |
1481 | ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status); | 1449 | ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status); |
1482 | else | 1450 | else |
1483 | return TXRX_DROP; | 1451 | return RX_DROP_MONITOR; |
1484 | 1452 | ||
1485 | return TXRX_QUEUED; | 1453 | return RX_QUEUED; |
1486 | } | ||
1487 | |||
1488 | static inline ieee80211_txrx_result __ieee80211_invoke_rx_handlers( | ||
1489 | struct ieee80211_local *local, | ||
1490 | ieee80211_rx_handler *handlers, | ||
1491 | struct ieee80211_txrx_data *rx, | ||
1492 | struct sta_info *sta) | ||
1493 | { | ||
1494 | ieee80211_rx_handler *handler; | ||
1495 | ieee80211_txrx_result res = TXRX_DROP; | ||
1496 | |||
1497 | for (handler = handlers; *handler != NULL; handler++) { | ||
1498 | res = (*handler)(rx); | ||
1499 | |||
1500 | switch (res) { | ||
1501 | case TXRX_CONTINUE: | ||
1502 | continue; | ||
1503 | case TXRX_DROP: | ||
1504 | I802_DEBUG_INC(local->rx_handlers_drop); | ||
1505 | if (sta) | ||
1506 | sta->rx_dropped++; | ||
1507 | break; | ||
1508 | case TXRX_QUEUED: | ||
1509 | I802_DEBUG_INC(local->rx_handlers_queued); | ||
1510 | break; | ||
1511 | } | ||
1512 | break; | ||
1513 | } | ||
1514 | |||
1515 | if (res == TXRX_DROP) | ||
1516 | dev_kfree_skb(rx->skb); | ||
1517 | return res; | ||
1518 | } | ||
1519 | |||
1520 | static inline void ieee80211_invoke_rx_handlers(struct ieee80211_local *local, | ||
1521 | ieee80211_rx_handler *handlers, | ||
1522 | struct ieee80211_txrx_data *rx, | ||
1523 | struct sta_info *sta) | ||
1524 | { | ||
1525 | if (__ieee80211_invoke_rx_handlers(local, handlers, rx, sta) == | ||
1526 | TXRX_CONTINUE) | ||
1527 | dev_kfree_skb(rx->skb); | ||
1528 | } | 1454 | } |
1529 | 1455 | ||
1530 | static void ieee80211_rx_michael_mic_report(struct net_device *dev, | 1456 | static void ieee80211_rx_michael_mic_report(struct net_device *dev, |
1531 | struct ieee80211_hdr *hdr, | 1457 | struct ieee80211_hdr *hdr, |
1532 | struct sta_info *sta, | ||
1533 | struct ieee80211_txrx_data *rx) | 1458 | struct ieee80211_txrx_data *rx) |
1534 | { | 1459 | { |
1535 | int keyidx, hdrlen; | 1460 | int keyidx, hdrlen; |
@@ -1548,7 +1473,7 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev, | |||
1548 | dev->name, print_mac(mac, hdr->addr2), | 1473 | dev->name, print_mac(mac, hdr->addr2), |
1549 | print_mac(mac2, hdr->addr1), keyidx); | 1474 | print_mac(mac2, hdr->addr1), keyidx); |
1550 | 1475 | ||
1551 | if (!sta) { | 1476 | if (!rx->sta) { |
1552 | /* | 1477 | /* |
1553 | * Some hardware seem to generate incorrect Michael MIC | 1478 | * Some hardware seem to generate incorrect Michael MIC |
1554 | * reports; ignore them to avoid triggering countermeasures. | 1479 | * reports; ignore them to avoid triggering countermeasures. |
@@ -1600,7 +1525,88 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev, | |||
1600 | rx->skb = NULL; | 1525 | rx->skb = NULL; |
1601 | } | 1526 | } |
1602 | 1527 | ||
1603 | ieee80211_rx_handler ieee80211_rx_handlers[] = | 1528 | static void ieee80211_rx_cooked_monitor(struct ieee80211_txrx_data *rx) |
1529 | { | ||
1530 | struct ieee80211_sub_if_data *sdata; | ||
1531 | struct ieee80211_local *local = rx->local; | ||
1532 | struct ieee80211_rtap_hdr { | ||
1533 | struct ieee80211_radiotap_header hdr; | ||
1534 | u8 flags; | ||
1535 | u8 rate; | ||
1536 | __le16 chan_freq; | ||
1537 | __le16 chan_flags; | ||
1538 | } __attribute__ ((packed)) *rthdr; | ||
1539 | struct sk_buff *skb = rx->skb, *skb2; | ||
1540 | struct net_device *prev_dev = NULL; | ||
1541 | struct ieee80211_rx_status *status = rx->u.rx.status; | ||
1542 | |||
1543 | if (rx->flags & IEEE80211_TXRXD_RX_CMNTR_REPORTED) | ||
1544 | goto out_free_skb; | ||
1545 | |||
1546 | if (skb_headroom(skb) < sizeof(*rthdr) && | ||
1547 | pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) | ||
1548 | goto out_free_skb; | ||
1549 | |||
1550 | rthdr = (void *)skb_push(skb, sizeof(*rthdr)); | ||
1551 | memset(rthdr, 0, sizeof(*rthdr)); | ||
1552 | rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); | ||
1553 | rthdr->hdr.it_present = | ||
1554 | cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | | ||
1555 | (1 << IEEE80211_RADIOTAP_RATE) | | ||
1556 | (1 << IEEE80211_RADIOTAP_CHANNEL)); | ||
1557 | |||
1558 | rthdr->rate = rx->u.rx.rate->bitrate / 5; | ||
1559 | rthdr->chan_freq = cpu_to_le16(status->freq); | ||
1560 | |||
1561 | if (status->band == IEEE80211_BAND_5GHZ) | ||
1562 | rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_OFDM | | ||
1563 | IEEE80211_CHAN_5GHZ); | ||
1564 | else | ||
1565 | rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_DYN | | ||
1566 | IEEE80211_CHAN_2GHZ); | ||
1567 | |||
1568 | skb_set_mac_header(skb, 0); | ||
1569 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
1570 | skb->pkt_type = PACKET_OTHERHOST; | ||
1571 | skb->protocol = htons(ETH_P_802_2); | ||
1572 | |||
1573 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
1574 | if (!netif_running(sdata->dev)) | ||
1575 | continue; | ||
1576 | |||
1577 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || | ||
1578 | !(sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)) | ||
1579 | continue; | ||
1580 | |||
1581 | if (prev_dev) { | ||
1582 | skb2 = skb_clone(skb, GFP_ATOMIC); | ||
1583 | if (skb2) { | ||
1584 | skb2->dev = prev_dev; | ||
1585 | netif_rx(skb2); | ||
1586 | } | ||
1587 | } | ||
1588 | |||
1589 | prev_dev = sdata->dev; | ||
1590 | sdata->dev->stats.rx_packets++; | ||
1591 | sdata->dev->stats.rx_bytes += skb->len; | ||
1592 | } | ||
1593 | |||
1594 | if (prev_dev) { | ||
1595 | skb->dev = prev_dev; | ||
1596 | netif_rx(skb); | ||
1597 | skb = NULL; | ||
1598 | } else | ||
1599 | goto out_free_skb; | ||
1600 | |||
1601 | rx->flags |= IEEE80211_TXRXD_RX_CMNTR_REPORTED; | ||
1602 | return; | ||
1603 | |||
1604 | out_free_skb: | ||
1605 | dev_kfree_skb(skb); | ||
1606 | } | ||
1607 | |||
1608 | typedef ieee80211_rx_result (*ieee80211_rx_handler)(struct ieee80211_txrx_data *); | ||
1609 | static ieee80211_rx_handler ieee80211_rx_handlers[] = | ||
1604 | { | 1610 | { |
1605 | ieee80211_rx_h_if_stats, | 1611 | ieee80211_rx_h_if_stats, |
1606 | ieee80211_rx_h_passive_scan, | 1612 | ieee80211_rx_h_passive_scan, |
@@ -1622,6 +1628,47 @@ ieee80211_rx_handler ieee80211_rx_handlers[] = | |||
1622 | NULL | 1628 | NULL |
1623 | }; | 1629 | }; |
1624 | 1630 | ||
1631 | static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | ||
1632 | struct ieee80211_txrx_data *rx, | ||
1633 | struct sk_buff *skb) | ||
1634 | { | ||
1635 | ieee80211_rx_handler *handler; | ||
1636 | ieee80211_rx_result res = RX_DROP_MONITOR; | ||
1637 | |||
1638 | rx->skb = skb; | ||
1639 | rx->sdata = sdata; | ||
1640 | rx->dev = sdata->dev; | ||
1641 | |||
1642 | for (handler = ieee80211_rx_handlers; *handler != NULL; handler++) { | ||
1643 | res = (*handler)(rx); | ||
1644 | |||
1645 | switch (res) { | ||
1646 | case RX_CONTINUE: | ||
1647 | continue; | ||
1648 | case RX_DROP_UNUSABLE: | ||
1649 | case RX_DROP_MONITOR: | ||
1650 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); | ||
1651 | if (rx->sta) | ||
1652 | rx->sta->rx_dropped++; | ||
1653 | break; | ||
1654 | case RX_QUEUED: | ||
1655 | I802_DEBUG_INC(sdata->local->rx_handlers_queued); | ||
1656 | break; | ||
1657 | } | ||
1658 | break; | ||
1659 | } | ||
1660 | |||
1661 | switch (res) { | ||
1662 | case RX_CONTINUE: | ||
1663 | case RX_DROP_MONITOR: | ||
1664 | ieee80211_rx_cooked_monitor(rx); | ||
1665 | break; | ||
1666 | case RX_DROP_UNUSABLE: | ||
1667 | dev_kfree_skb(rx->skb); | ||
1668 | break; | ||
1669 | } | ||
1670 | } | ||
1671 | |||
1625 | /* main receive path */ | 1672 | /* main receive path */ |
1626 | 1673 | ||
1627 | static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | 1674 | static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, |
@@ -1649,7 +1696,10 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1649 | case IEEE80211_IF_TYPE_IBSS: | 1696 | case IEEE80211_IF_TYPE_IBSS: |
1650 | if (!bssid) | 1697 | if (!bssid) |
1651 | return 0; | 1698 | return 0; |
1652 | if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { | 1699 | if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && |
1700 | (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) | ||
1701 | return 1; | ||
1702 | else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { | ||
1653 | if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) | 1703 | if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) |
1654 | return 0; | 1704 | return 0; |
1655 | rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH; | 1705 | rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH; |
@@ -1707,11 +1757,11 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1707 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | 1757 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, |
1708 | struct sk_buff *skb, | 1758 | struct sk_buff *skb, |
1709 | struct ieee80211_rx_status *status, | 1759 | struct ieee80211_rx_status *status, |
1710 | u32 load) | 1760 | u32 load, |
1761 | struct ieee80211_rate *rate) | ||
1711 | { | 1762 | { |
1712 | struct ieee80211_local *local = hw_to_local(hw); | 1763 | struct ieee80211_local *local = hw_to_local(hw); |
1713 | struct ieee80211_sub_if_data *sdata; | 1764 | struct ieee80211_sub_if_data *sdata; |
1714 | struct sta_info *sta; | ||
1715 | struct ieee80211_hdr *hdr; | 1765 | struct ieee80211_hdr *hdr; |
1716 | struct ieee80211_txrx_data rx; | 1766 | struct ieee80211_txrx_data rx; |
1717 | u16 type; | 1767 | u16 type; |
@@ -1727,40 +1777,31 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1727 | 1777 | ||
1728 | rx.u.rx.status = status; | 1778 | rx.u.rx.status = status; |
1729 | rx.u.rx.load = load; | 1779 | rx.u.rx.load = load; |
1780 | rx.u.rx.rate = rate; | ||
1730 | rx.fc = le16_to_cpu(hdr->frame_control); | 1781 | rx.fc = le16_to_cpu(hdr->frame_control); |
1731 | type = rx.fc & IEEE80211_FCTL_FTYPE; | 1782 | type = rx.fc & IEEE80211_FCTL_FTYPE; |
1732 | 1783 | ||
1733 | if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT) | 1784 | if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT) |
1734 | local->dot11ReceivedFragmentCount++; | 1785 | local->dot11ReceivedFragmentCount++; |
1735 | 1786 | ||
1736 | sta = rx.sta = sta_info_get(local, hdr->addr2); | 1787 | rx.sta = sta_info_get(local, hdr->addr2); |
1737 | if (sta) { | 1788 | if (rx.sta) { |
1738 | rx.dev = rx.sta->dev; | 1789 | rx.dev = rx.sta->dev; |
1739 | rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev); | 1790 | rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev); |
1740 | } | 1791 | } |
1741 | 1792 | ||
1742 | if ((status->flag & RX_FLAG_MMIC_ERROR)) { | 1793 | if ((status->flag & RX_FLAG_MMIC_ERROR)) { |
1743 | ieee80211_rx_michael_mic_report(local->mdev, hdr, sta, &rx); | 1794 | ieee80211_rx_michael_mic_report(local->mdev, hdr, &rx); |
1744 | goto end; | 1795 | goto end; |
1745 | } | 1796 | } |
1746 | 1797 | ||
1747 | if (unlikely(local->sta_sw_scanning || local->sta_hw_scanning)) | 1798 | if (unlikely(local->sta_sw_scanning || local->sta_hw_scanning)) |
1748 | rx.flags |= IEEE80211_TXRXD_RXIN_SCAN; | 1799 | rx.flags |= IEEE80211_TXRXD_RXIN_SCAN; |
1749 | 1800 | ||
1750 | if (__ieee80211_invoke_rx_handlers(local, local->rx_pre_handlers, &rx, | 1801 | ieee80211_parse_qos(&rx); |
1751 | sta) != TXRX_CONTINUE) | 1802 | ieee80211_verify_ip_alignment(&rx); |
1752 | goto end; | ||
1753 | skb = rx.skb; | ||
1754 | 1803 | ||
1755 | if (sta && !(sta->flags & (WLAN_STA_WDS | WLAN_STA_ASSOC_AP)) && | 1804 | skb = rx.skb; |
1756 | !atomic_read(&local->iff_promiscs) && | ||
1757 | !is_multicast_ether_addr(hdr->addr1)) { | ||
1758 | rx.flags |= IEEE80211_TXRXD_RXRA_MATCH; | ||
1759 | ieee80211_invoke_rx_handlers(local, local->rx_handlers, &rx, | ||
1760 | rx.sta); | ||
1761 | sta_info_put(sta); | ||
1762 | return; | ||
1763 | } | ||
1764 | 1805 | ||
1765 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 1806 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
1766 | if (!netif_running(sdata->dev)) | 1807 | if (!netif_running(sdata->dev)) |
@@ -1772,8 +1813,6 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1772 | bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); | 1813 | bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); |
1773 | rx.flags |= IEEE80211_TXRXD_RXRA_MATCH; | 1814 | rx.flags |= IEEE80211_TXRXD_RXRA_MATCH; |
1774 | prepares = prepare_for_handlers(sdata, bssid, &rx, hdr); | 1815 | prepares = prepare_for_handlers(sdata, bssid, &rx, hdr); |
1775 | /* prepare_for_handlers can change sta */ | ||
1776 | sta = rx.sta; | ||
1777 | 1816 | ||
1778 | if (!prepares) | 1817 | if (!prepares) |
1779 | continue; | 1818 | continue; |
@@ -1804,26 +1843,18 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1804 | continue; | 1843 | continue; |
1805 | } | 1844 | } |
1806 | rx.fc = le16_to_cpu(hdr->frame_control); | 1845 | rx.fc = le16_to_cpu(hdr->frame_control); |
1807 | rx.skb = skb_new; | 1846 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new); |
1808 | rx.dev = prev->dev; | ||
1809 | rx.sdata = prev; | ||
1810 | ieee80211_invoke_rx_handlers(local, local->rx_handlers, | ||
1811 | &rx, sta); | ||
1812 | prev = sdata; | 1847 | prev = sdata; |
1813 | } | 1848 | } |
1814 | if (prev) { | 1849 | if (prev) { |
1815 | rx.fc = le16_to_cpu(hdr->frame_control); | 1850 | rx.fc = le16_to_cpu(hdr->frame_control); |
1816 | rx.skb = skb; | 1851 | ieee80211_invoke_rx_handlers(prev, &rx, skb); |
1817 | rx.dev = prev->dev; | ||
1818 | rx.sdata = prev; | ||
1819 | ieee80211_invoke_rx_handlers(local, local->rx_handlers, | ||
1820 | &rx, sta); | ||
1821 | } else | 1852 | } else |
1822 | dev_kfree_skb(skb); | 1853 | dev_kfree_skb(skb); |
1823 | 1854 | ||
1824 | end: | 1855 | end: |
1825 | if (sta) | 1856 | if (rx.sta) |
1826 | sta_info_put(sta); | 1857 | sta_info_put(rx.sta); |
1827 | } | 1858 | } |
1828 | 1859 | ||
1829 | #define SEQ_MODULO 0x1000 | 1860 | #define SEQ_MODULO 0x1000 |
@@ -1859,6 +1890,8 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
1859 | u16 head_seq_num, buf_size; | 1890 | u16 head_seq_num, buf_size; |
1860 | int index; | 1891 | int index; |
1861 | u32 pkt_load; | 1892 | u32 pkt_load; |
1893 | struct ieee80211_supported_band *sband; | ||
1894 | struct ieee80211_rate *rate; | ||
1862 | 1895 | ||
1863 | buf_size = tid_agg_rx->buf_size; | 1896 | buf_size = tid_agg_rx->buf_size; |
1864 | head_seq_num = tid_agg_rx->head_seq_num; | 1897 | head_seq_num = tid_agg_rx->head_seq_num; |
@@ -1889,12 +1922,14 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
1889 | memcpy(&status, | 1922 | memcpy(&status, |
1890 | tid_agg_rx->reorder_buf[index]->cb, | 1923 | tid_agg_rx->reorder_buf[index]->cb, |
1891 | sizeof(status)); | 1924 | sizeof(status)); |
1925 | sband = local->hw.wiphy->bands[status.band]; | ||
1926 | rate = &sband->bitrates[status.rate_idx]; | ||
1892 | pkt_load = ieee80211_rx_load_stats(local, | 1927 | pkt_load = ieee80211_rx_load_stats(local, |
1893 | tid_agg_rx->reorder_buf[index], | 1928 | tid_agg_rx->reorder_buf[index], |
1894 | &status); | 1929 | &status, rate); |
1895 | __ieee80211_rx_handle_packet(hw, | 1930 | __ieee80211_rx_handle_packet(hw, |
1896 | tid_agg_rx->reorder_buf[index], | 1931 | tid_agg_rx->reorder_buf[index], |
1897 | &status, pkt_load); | 1932 | &status, pkt_load, rate); |
1898 | tid_agg_rx->stored_mpdu_num--; | 1933 | tid_agg_rx->stored_mpdu_num--; |
1899 | tid_agg_rx->reorder_buf[index] = NULL; | 1934 | tid_agg_rx->reorder_buf[index] = NULL; |
1900 | } | 1935 | } |
@@ -1934,11 +1969,13 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
1934 | /* release the reordered frame back to stack */ | 1969 | /* release the reordered frame back to stack */ |
1935 | memcpy(&status, tid_agg_rx->reorder_buf[index]->cb, | 1970 | memcpy(&status, tid_agg_rx->reorder_buf[index]->cb, |
1936 | sizeof(status)); | 1971 | sizeof(status)); |
1972 | sband = local->hw.wiphy->bands[status.band]; | ||
1973 | rate = &sband->bitrates[status.rate_idx]; | ||
1937 | pkt_load = ieee80211_rx_load_stats(local, | 1974 | pkt_load = ieee80211_rx_load_stats(local, |
1938 | tid_agg_rx->reorder_buf[index], | 1975 | tid_agg_rx->reorder_buf[index], |
1939 | &status); | 1976 | &status, rate); |
1940 | __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], | 1977 | __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], |
1941 | &status, pkt_load); | 1978 | &status, pkt_load, rate); |
1942 | tid_agg_rx->stored_mpdu_num--; | 1979 | tid_agg_rx->stored_mpdu_num--; |
1943 | tid_agg_rx->reorder_buf[index] = NULL; | 1980 | tid_agg_rx->reorder_buf[index] = NULL; |
1944 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); | 1981 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); |
@@ -2019,6 +2056,25 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2019 | { | 2056 | { |
2020 | struct ieee80211_local *local = hw_to_local(hw); | 2057 | struct ieee80211_local *local = hw_to_local(hw); |
2021 | u32 pkt_load; | 2058 | u32 pkt_load; |
2059 | struct ieee80211_rate *rate = NULL; | ||
2060 | struct ieee80211_supported_band *sband; | ||
2061 | |||
2062 | if (status->band < 0 || | ||
2063 | status->band > IEEE80211_NUM_BANDS) { | ||
2064 | WARN_ON(1); | ||
2065 | return; | ||
2066 | } | ||
2067 | |||
2068 | sband = local->hw.wiphy->bands[status->band]; | ||
2069 | |||
2070 | if (!sband || | ||
2071 | status->rate_idx < 0 || | ||
2072 | status->rate_idx >= sband->n_bitrates) { | ||
2073 | WARN_ON(1); | ||
2074 | return; | ||
2075 | } | ||
2076 | |||
2077 | rate = &sband->bitrates[status->rate_idx]; | ||
2022 | 2078 | ||
2023 | /* | 2079 | /* |
2024 | * key references and virtual interfaces are protected using RCU | 2080 | * key references and virtual interfaces are protected using RCU |
@@ -2033,17 +2089,17 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2033 | * if it was previously present. | 2089 | * if it was previously present. |
2034 | * Also, frames with less than 16 bytes are dropped. | 2090 | * Also, frames with less than 16 bytes are dropped. |
2035 | */ | 2091 | */ |
2036 | skb = ieee80211_rx_monitor(local, skb, status); | 2092 | skb = ieee80211_rx_monitor(local, skb, status, rate); |
2037 | if (!skb) { | 2093 | if (!skb) { |
2038 | rcu_read_unlock(); | 2094 | rcu_read_unlock(); |
2039 | return; | 2095 | return; |
2040 | } | 2096 | } |
2041 | 2097 | ||
2042 | pkt_load = ieee80211_rx_load_stats(local, skb, status); | 2098 | pkt_load = ieee80211_rx_load_stats(local, skb, status, rate); |
2043 | local->channel_use_raw += pkt_load; | 2099 | local->channel_use_raw += pkt_load; |
2044 | 2100 | ||
2045 | if (!ieee80211_rx_reorder_ampdu(local, skb)) | 2101 | if (!ieee80211_rx_reorder_ampdu(local, skb)) |
2046 | __ieee80211_rx_handle_packet(hw, skb, status, pkt_load); | 2102 | __ieee80211_rx_handle_packet(hw, skb, status, pkt_load, rate); |
2047 | 2103 | ||
2048 | rcu_read_unlock(); | 2104 | rcu_read_unlock(); |
2049 | } | 2105 | } |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 1f74bd296357..e384e6632d97 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -55,48 +55,34 @@ static int sta_info_hash_del(struct ieee80211_local *local, | |||
55 | return -ENOENT; | 55 | return -ENOENT; |
56 | } | 56 | } |
57 | 57 | ||
58 | struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr) | 58 | /* must hold local->sta_lock */ |
59 | static struct sta_info *__sta_info_find(struct ieee80211_local *local, | ||
60 | u8 *addr) | ||
59 | { | 61 | { |
60 | struct sta_info *sta; | 62 | struct sta_info *sta; |
61 | 63 | ||
62 | read_lock_bh(&local->sta_lock); | ||
63 | sta = local->sta_hash[STA_HASH(addr)]; | 64 | sta = local->sta_hash[STA_HASH(addr)]; |
64 | while (sta) { | 65 | while (sta) { |
65 | if (memcmp(sta->addr, addr, ETH_ALEN) == 0) { | 66 | if (compare_ether_addr(sta->addr, addr) == 0) |
66 | __sta_info_get(sta); | ||
67 | break; | 67 | break; |
68 | } | ||
69 | sta = sta->hnext; | 68 | sta = sta->hnext; |
70 | } | 69 | } |
71 | read_unlock_bh(&local->sta_lock); | ||
72 | |||
73 | return sta; | 70 | return sta; |
74 | } | 71 | } |
75 | EXPORT_SYMBOL(sta_info_get); | ||
76 | 72 | ||
77 | int sta_info_min_txrate_get(struct ieee80211_local *local) | 73 | struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr) |
78 | { | 74 | { |
79 | struct sta_info *sta; | 75 | struct sta_info *sta; |
80 | struct ieee80211_hw_mode *mode; | ||
81 | int min_txrate = 9999999; | ||
82 | int i; | ||
83 | 76 | ||
84 | read_lock_bh(&local->sta_lock); | 77 | read_lock_bh(&local->sta_lock); |
85 | mode = local->oper_hw_mode; | 78 | sta = __sta_info_find(local, addr); |
86 | for (i = 0; i < STA_HASH_SIZE; i++) { | 79 | if (sta) |
87 | sta = local->sta_hash[i]; | 80 | __sta_info_get(sta); |
88 | while (sta) { | ||
89 | if (sta->txrate < min_txrate) | ||
90 | min_txrate = sta->txrate; | ||
91 | sta = sta->hnext; | ||
92 | } | ||
93 | } | ||
94 | read_unlock_bh(&local->sta_lock); | 81 | read_unlock_bh(&local->sta_lock); |
95 | if (min_txrate == 9999999) | ||
96 | min_txrate = 0; | ||
97 | 82 | ||
98 | return mode->rates[min_txrate].rate; | 83 | return sta; |
99 | } | 84 | } |
85 | EXPORT_SYMBOL(sta_info_get); | ||
100 | 86 | ||
101 | 87 | ||
102 | static void sta_info_release(struct kref *kref) | 88 | static void sta_info_release(struct kref *kref) |
@@ -117,8 +103,10 @@ static void sta_info_release(struct kref *kref) | |||
117 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { | 103 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { |
118 | dev_kfree_skb_any(skb); | 104 | dev_kfree_skb_any(skb); |
119 | } | 105 | } |
120 | for (i = 0; i < STA_TID_NUM; i++) | 106 | for (i = 0; i < STA_TID_NUM; i++) { |
121 | del_timer_sync(&sta->ampdu_mlme.tid_rx[i].session_timer); | 107 | del_timer_sync(&sta->ampdu_mlme.tid_rx[i].session_timer); |
108 | del_timer_sync(&sta->ampdu_mlme.tid_tx[i].addba_resp_timer); | ||
109 | } | ||
122 | rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv); | 110 | rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv); |
123 | rate_control_put(sta->rate_ctrl); | 111 | rate_control_put(sta->rate_ctrl); |
124 | kfree(sta); | 112 | kfree(sta); |
@@ -132,8 +120,8 @@ void sta_info_put(struct sta_info *sta) | |||
132 | EXPORT_SYMBOL(sta_info_put); | 120 | EXPORT_SYMBOL(sta_info_put); |
133 | 121 | ||
134 | 122 | ||
135 | struct sta_info * sta_info_add(struct ieee80211_local *local, | 123 | struct sta_info *sta_info_add(struct ieee80211_local *local, |
136 | struct net_device *dev, u8 *addr, gfp_t gfp) | 124 | struct net_device *dev, u8 *addr, gfp_t gfp) |
137 | { | 125 | { |
138 | struct sta_info *sta; | 126 | struct sta_info *sta; |
139 | int i; | 127 | int i; |
@@ -141,7 +129,7 @@ struct sta_info * sta_info_add(struct ieee80211_local *local, | |||
141 | 129 | ||
142 | sta = kzalloc(sizeof(*sta), gfp); | 130 | sta = kzalloc(sizeof(*sta), gfp); |
143 | if (!sta) | 131 | if (!sta) |
144 | return NULL; | 132 | return ERR_PTR(-ENOMEM); |
145 | 133 | ||
146 | kref_init(&sta->kref); | 134 | kref_init(&sta->kref); |
147 | 135 | ||
@@ -150,30 +138,45 @@ struct sta_info * sta_info_add(struct ieee80211_local *local, | |||
150 | if (!sta->rate_ctrl_priv) { | 138 | if (!sta->rate_ctrl_priv) { |
151 | rate_control_put(sta->rate_ctrl); | 139 | rate_control_put(sta->rate_ctrl); |
152 | kfree(sta); | 140 | kfree(sta); |
153 | return NULL; | 141 | return ERR_PTR(-ENOMEM); |
154 | } | 142 | } |
155 | 143 | ||
156 | memcpy(sta->addr, addr, ETH_ALEN); | 144 | memcpy(sta->addr, addr, ETH_ALEN); |
157 | sta->local = local; | 145 | sta->local = local; |
158 | sta->dev = dev; | 146 | sta->dev = dev; |
159 | spin_lock_init(&sta->ampdu_mlme.ampdu_rx); | 147 | spin_lock_init(&sta->ampdu_mlme.ampdu_rx); |
148 | spin_lock_init(&sta->ampdu_mlme.ampdu_tx); | ||
160 | for (i = 0; i < STA_TID_NUM; i++) { | 149 | for (i = 0; i < STA_TID_NUM; i++) { |
161 | /* timer_to_tid must be initialized with identity mapping to | 150 | /* timer_to_tid must be initialized with identity mapping to |
162 | * enable session_timer's data differentiation. refer to | 151 | * enable session_timer's data differentiation. refer to |
163 | * sta_rx_agg_session_timer_expired for useage */ | 152 | * sta_rx_agg_session_timer_expired for useage */ |
164 | sta->timer_to_tid[i] = i; | 153 | sta->timer_to_tid[i] = i; |
154 | /* tid to tx queue: initialize according to HW (0 is valid) */ | ||
155 | sta->tid_to_tx_q[i] = local->hw.queues; | ||
165 | /* rx timers */ | 156 | /* rx timers */ |
166 | sta->ampdu_mlme.tid_rx[i].session_timer.function = | 157 | sta->ampdu_mlme.tid_rx[i].session_timer.function = |
167 | sta_rx_agg_session_timer_expired; | 158 | sta_rx_agg_session_timer_expired; |
168 | sta->ampdu_mlme.tid_rx[i].session_timer.data = | 159 | sta->ampdu_mlme.tid_rx[i].session_timer.data = |
169 | (unsigned long)&sta->timer_to_tid[i]; | 160 | (unsigned long)&sta->timer_to_tid[i]; |
170 | init_timer(&sta->ampdu_mlme.tid_rx[i].session_timer); | 161 | init_timer(&sta->ampdu_mlme.tid_rx[i].session_timer); |
162 | /* tx timers */ | ||
163 | sta->ampdu_mlme.tid_tx[i].addba_resp_timer.function = | ||
164 | sta_addba_resp_timer_expired; | ||
165 | sta->ampdu_mlme.tid_tx[i].addba_resp_timer.data = | ||
166 | (unsigned long)&sta->timer_to_tid[i]; | ||
167 | init_timer(&sta->ampdu_mlme.tid_tx[i].addba_resp_timer); | ||
171 | } | 168 | } |
172 | skb_queue_head_init(&sta->ps_tx_buf); | 169 | skb_queue_head_init(&sta->ps_tx_buf); |
173 | skb_queue_head_init(&sta->tx_filtered); | 170 | skb_queue_head_init(&sta->tx_filtered); |
174 | __sta_info_get(sta); /* sta used by caller, decremented by | ||
175 | * sta_info_put() */ | ||
176 | write_lock_bh(&local->sta_lock); | 171 | write_lock_bh(&local->sta_lock); |
172 | /* mark sta as used (by caller) */ | ||
173 | __sta_info_get(sta); | ||
174 | /* check if STA exists already */ | ||
175 | if (__sta_info_find(local, addr)) { | ||
176 | write_unlock_bh(&local->sta_lock); | ||
177 | sta_info_put(sta); | ||
178 | return ERR_PTR(-EEXIST); | ||
179 | } | ||
177 | list_add(&sta->list, &local->sta_list); | 180 | list_add(&sta->list, &local->sta_list); |
178 | local->num_sta++; | 181 | local->num_sta++; |
179 | sta_info_hash_add(local, sta); | 182 | sta_info_hash_add(local, sta); |
@@ -204,6 +207,64 @@ struct sta_info * sta_info_add(struct ieee80211_local *local, | |||
204 | return sta; | 207 | return sta; |
205 | } | 208 | } |
206 | 209 | ||
210 | static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid) | ||
211 | { | ||
212 | /* | ||
213 | * This format has been mandated by the IEEE specifications, | ||
214 | * so this line may not be changed to use the __set_bit() format. | ||
215 | */ | ||
216 | bss->tim[aid / 8] |= (1 << (aid % 8)); | ||
217 | } | ||
218 | |||
219 | static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid) | ||
220 | { | ||
221 | /* | ||
222 | * This format has been mandated by the IEEE specifications, | ||
223 | * so this line may not be changed to use the __clear_bit() format. | ||
224 | */ | ||
225 | bss->tim[aid / 8] &= ~(1 << (aid % 8)); | ||
226 | } | ||
227 | |||
228 | static void __sta_info_set_tim_bit(struct ieee80211_if_ap *bss, | ||
229 | struct sta_info *sta) | ||
230 | { | ||
231 | if (bss) | ||
232 | __bss_tim_set(bss, sta->aid); | ||
233 | if (sta->local->ops->set_tim) | ||
234 | sta->local->ops->set_tim(local_to_hw(sta->local), sta->aid, 1); | ||
235 | } | ||
236 | |||
237 | void sta_info_set_tim_bit(struct sta_info *sta) | ||
238 | { | ||
239 | struct ieee80211_sub_if_data *sdata; | ||
240 | |||
241 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | ||
242 | |||
243 | read_lock_bh(&sta->local->sta_lock); | ||
244 | __sta_info_set_tim_bit(sdata->bss, sta); | ||
245 | read_unlock_bh(&sta->local->sta_lock); | ||
246 | } | ||
247 | |||
248 | static void __sta_info_clear_tim_bit(struct ieee80211_if_ap *bss, | ||
249 | struct sta_info *sta) | ||
250 | { | ||
251 | if (bss) | ||
252 | __bss_tim_clear(bss, sta->aid); | ||
253 | if (sta->local->ops->set_tim) | ||
254 | sta->local->ops->set_tim(local_to_hw(sta->local), sta->aid, 0); | ||
255 | } | ||
256 | |||
257 | void sta_info_clear_tim_bit(struct sta_info *sta) | ||
258 | { | ||
259 | struct ieee80211_sub_if_data *sdata; | ||
260 | |||
261 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | ||
262 | |||
263 | read_lock_bh(&sta->local->sta_lock); | ||
264 | __sta_info_clear_tim_bit(sdata->bss, sta); | ||
265 | read_unlock_bh(&sta->local->sta_lock); | ||
266 | } | ||
267 | |||
207 | /* Caller must hold local->sta_lock */ | 268 | /* Caller must hold local->sta_lock */ |
208 | void sta_info_remove(struct sta_info *sta) | 269 | void sta_info_remove(struct sta_info *sta) |
209 | { | 270 | { |
@@ -220,10 +281,9 @@ void sta_info_remove(struct sta_info *sta) | |||
220 | sta->flags &= ~WLAN_STA_PS; | 281 | sta->flags &= ~WLAN_STA_PS; |
221 | if (sdata->bss) | 282 | if (sdata->bss) |
222 | atomic_dec(&sdata->bss->num_sta_ps); | 283 | atomic_dec(&sdata->bss->num_sta_ps); |
284 | __sta_info_clear_tim_bit(sdata->bss, sta); | ||
223 | } | 285 | } |
224 | local->num_sta--; | 286 | local->num_sta--; |
225 | sta_info_remove_aid_ptr(sta); | ||
226 | |||
227 | } | 287 | } |
228 | 288 | ||
229 | void sta_info_free(struct sta_info *sta) | 289 | void sta_info_free(struct sta_info *sta) |
@@ -252,7 +312,7 @@ void sta_info_free(struct sta_info *sta) | |||
252 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 312 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
253 | 313 | ||
254 | ieee80211_key_free(sta->key); | 314 | ieee80211_key_free(sta->key); |
255 | sta->key = NULL; | 315 | WARN_ON(sta->key); |
256 | 316 | ||
257 | if (local->ops->sta_notify) { | 317 | if (local->ops->sta_notify) { |
258 | struct ieee80211_sub_if_data *sdata; | 318 | struct ieee80211_sub_if_data *sdata; |
@@ -299,6 +359,7 @@ static void sta_info_cleanup_expire_buffered(struct ieee80211_local *local, | |||
299 | { | 359 | { |
300 | unsigned long flags; | 360 | unsigned long flags; |
301 | struct sk_buff *skb; | 361 | struct sk_buff *skb; |
362 | struct ieee80211_sub_if_data *sdata; | ||
302 | DECLARE_MAC_BUF(mac); | 363 | DECLARE_MAC_BUF(mac); |
303 | 364 | ||
304 | if (skb_queue_empty(&sta->ps_tx_buf)) | 365 | if (skb_queue_empty(&sta->ps_tx_buf)) |
@@ -307,21 +368,23 @@ static void sta_info_cleanup_expire_buffered(struct ieee80211_local *local, | |||
307 | for (;;) { | 368 | for (;;) { |
308 | spin_lock_irqsave(&sta->ps_tx_buf.lock, flags); | 369 | spin_lock_irqsave(&sta->ps_tx_buf.lock, flags); |
309 | skb = skb_peek(&sta->ps_tx_buf); | 370 | skb = skb_peek(&sta->ps_tx_buf); |
310 | if (sta_info_buffer_expired(local, sta, skb)) { | 371 | if (sta_info_buffer_expired(local, sta, skb)) |
311 | skb = __skb_dequeue(&sta->ps_tx_buf); | 372 | skb = __skb_dequeue(&sta->ps_tx_buf); |
312 | if (skb_queue_empty(&sta->ps_tx_buf)) | 373 | else |
313 | sta->flags &= ~WLAN_STA_TIM; | ||
314 | } else | ||
315 | skb = NULL; | 374 | skb = NULL; |
316 | spin_unlock_irqrestore(&sta->ps_tx_buf.lock, flags); | 375 | spin_unlock_irqrestore(&sta->ps_tx_buf.lock, flags); |
317 | 376 | ||
318 | if (skb) { | 377 | if (!skb) |
319 | local->total_ps_buffered--; | ||
320 | printk(KERN_DEBUG "Buffered frame expired (STA " | ||
321 | "%s)\n", print_mac(mac, sta->addr)); | ||
322 | dev_kfree_skb(skb); | ||
323 | } else | ||
324 | break; | 378 | break; |
379 | |||
380 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | ||
381 | local->total_ps_buffered--; | ||
382 | printk(KERN_DEBUG "Buffered frame expired (STA " | ||
383 | "%s)\n", print_mac(mac, sta->addr)); | ||
384 | dev_kfree_skb(skb); | ||
385 | |||
386 | if (skb_queue_empty(&sta->ps_tx_buf)) | ||
387 | sta_info_clear_tim_bit(sta); | ||
325 | } | 388 | } |
326 | } | 389 | } |
327 | 390 | ||
@@ -400,23 +463,6 @@ void sta_info_stop(struct ieee80211_local *local) | |||
400 | sta_info_flush(local, NULL); | 463 | sta_info_flush(local, NULL); |
401 | } | 464 | } |
402 | 465 | ||
403 | void sta_info_remove_aid_ptr(struct sta_info *sta) | ||
404 | { | ||
405 | struct ieee80211_sub_if_data *sdata; | ||
406 | |||
407 | if (sta->aid <= 0) | ||
408 | return; | ||
409 | |||
410 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); | ||
411 | |||
412 | if (sdata->local->ops->set_tim) | ||
413 | sdata->local->ops->set_tim(local_to_hw(sdata->local), | ||
414 | sta->aid, 0); | ||
415 | if (sdata->bss) | ||
416 | __bss_tim_clear(sdata->bss, sta->aid); | ||
417 | } | ||
418 | |||
419 | |||
420 | /** | 466 | /** |
421 | * sta_info_flush - flush matching STA entries from the STA table | 467 | * sta_info_flush - flush matching STA entries from the STA table |
422 | * @local: local interface data | 468 | * @local: local interface data |
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 96fe3ed95038..86eed40ada78 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h | |||
@@ -15,31 +15,72 @@ | |||
15 | #include <linux/kref.h> | 15 | #include <linux/kref.h> |
16 | #include "ieee80211_key.h" | 16 | #include "ieee80211_key.h" |
17 | 17 | ||
18 | /* Stations flags (struct sta_info::flags) */ | 18 | /** |
19 | #define WLAN_STA_AUTH BIT(0) | 19 | * enum ieee80211_sta_info_flags - Stations flags |
20 | #define WLAN_STA_ASSOC BIT(1) | 20 | * |
21 | #define WLAN_STA_PS BIT(2) | 21 | * These flags are used with &struct sta_info's @flags member. |
22 | #define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */ | 22 | * |
23 | #define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */ | 23 | * @WLAN_STA_AUTH: Station is authenticated. |
24 | #define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is | 24 | * @WLAN_STA_ASSOC: Station is associated. |
25 | * controlling whether STA is authorized to | 25 | * @WLAN_STA_PS: Station is in power-save mode |
26 | * send and receive non-IEEE 802.1X frames | 26 | * @WLAN_STA_AUTHORIZED: Station is authorized to send/receive traffic. |
27 | */ | 27 | * This bit is always checked so needs to be enabled for all stations |
28 | #define WLAN_STA_SHORT_PREAMBLE BIT(7) | 28 | * when virtual port control is not in use. |
29 | /* whether this is an AP that we are associated with as a client */ | 29 | * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble |
30 | #define WLAN_STA_ASSOC_AP BIT(8) | 30 | * frames. |
31 | #define WLAN_STA_WME BIT(9) | 31 | * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP. |
32 | #define WLAN_STA_WDS BIT(27) | 32 | * @WLAN_STA_WME: Station is a QoS-STA. |
33 | * @WLAN_STA_WDS: Station is one of our WDS peers. | ||
34 | * @WLAN_STA_PSPOLL: Station has just PS-polled us. | ||
35 | * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the | ||
36 | * IEEE80211_TXCTL_CLEAR_PS_FILT control flag) when the next | ||
37 | * frame to this station is transmitted. | ||
38 | */ | ||
39 | enum ieee80211_sta_info_flags { | ||
40 | WLAN_STA_AUTH = 1<<0, | ||
41 | WLAN_STA_ASSOC = 1<<1, | ||
42 | WLAN_STA_PS = 1<<2, | ||
43 | WLAN_STA_AUTHORIZED = 1<<3, | ||
44 | WLAN_STA_SHORT_PREAMBLE = 1<<4, | ||
45 | WLAN_STA_ASSOC_AP = 1<<5, | ||
46 | WLAN_STA_WME = 1<<6, | ||
47 | WLAN_STA_WDS = 1<<7, | ||
48 | WLAN_STA_PSPOLL = 1<<8, | ||
49 | WLAN_STA_CLEAR_PS_FILT = 1<<9, | ||
50 | }; | ||
33 | 51 | ||
34 | #define STA_TID_NUM 16 | 52 | #define STA_TID_NUM 16 |
35 | #define ADDBA_RESP_INTERVAL HZ | 53 | #define ADDBA_RESP_INTERVAL HZ |
54 | #define HT_AGG_MAX_RETRIES (0x3) | ||
36 | 55 | ||
37 | #define HT_AGG_STATE_INITIATOR_SHIFT (4) | 56 | #define HT_AGG_STATE_INITIATOR_SHIFT (4) |
38 | 57 | ||
58 | #define HT_ADDBA_REQUESTED_MSK BIT(0) | ||
59 | #define HT_ADDBA_DRV_READY_MSK BIT(1) | ||
60 | #define HT_ADDBA_RECEIVED_MSK BIT(2) | ||
39 | #define HT_AGG_STATE_REQ_STOP_BA_MSK BIT(3) | 61 | #define HT_AGG_STATE_REQ_STOP_BA_MSK BIT(3) |
40 | 62 | #define HT_AGG_STATE_INITIATOR_MSK BIT(HT_AGG_STATE_INITIATOR_SHIFT) | |
41 | #define HT_AGG_STATE_IDLE (0x0) | 63 | #define HT_AGG_STATE_IDLE (0x0) |
42 | #define HT_AGG_STATE_OPERATIONAL (0x7) | 64 | #define HT_AGG_STATE_OPERATIONAL (HT_ADDBA_REQUESTED_MSK | \ |
65 | HT_ADDBA_DRV_READY_MSK | \ | ||
66 | HT_ADDBA_RECEIVED_MSK) | ||
67 | |||
68 | /** | ||
69 | * struct tid_ampdu_tx - TID aggregation information (Tx). | ||
70 | * | ||
71 | * @state: TID's state in session state machine. | ||
72 | * @dialog_token: dialog token for aggregation session | ||
73 | * @ssn: Starting Sequence Number expected to be aggregated. | ||
74 | * @addba_resp_timer: timer for peer's response to addba request | ||
75 | * @addba_req_num: number of times addBA request has been sent. | ||
76 | */ | ||
77 | struct tid_ampdu_tx { | ||
78 | u8 state; | ||
79 | u8 dialog_token; | ||
80 | u16 ssn; | ||
81 | struct timer_list addba_resp_timer; | ||
82 | u8 addba_req_num; | ||
83 | }; | ||
43 | 84 | ||
44 | /** | 85 | /** |
45 | * struct tid_ampdu_rx - TID aggregation information (Rx). | 86 | * struct tid_ampdu_rx - TID aggregation information (Rx). |
@@ -69,12 +110,18 @@ struct tid_ampdu_rx { | |||
69 | /** | 110 | /** |
70 | * struct sta_ampdu_mlme - STA aggregation information. | 111 | * struct sta_ampdu_mlme - STA aggregation information. |
71 | * | 112 | * |
72 | * @tid_agg_info_rx: aggregation info for Rx per TID | 113 | * @tid_rx: aggregation info for Rx per TID |
114 | * @tid_tx: aggregation info for Tx per TID | ||
73 | * @ampdu_rx: for locking sections in aggregation Rx flow | 115 | * @ampdu_rx: for locking sections in aggregation Rx flow |
116 | * @ampdu_tx: for locking sectionsi in aggregation Tx flow | ||
117 | * @dialog_token_allocator: dialog token enumerator for each new session; | ||
74 | */ | 118 | */ |
75 | struct sta_ampdu_mlme { | 119 | struct sta_ampdu_mlme { |
76 | struct tid_ampdu_rx tid_rx[STA_TID_NUM]; | 120 | struct tid_ampdu_rx tid_rx[STA_TID_NUM]; |
121 | struct tid_ampdu_tx tid_tx[STA_TID_NUM]; | ||
77 | spinlock_t ampdu_rx; | 122 | spinlock_t ampdu_rx; |
123 | spinlock_t ampdu_tx; | ||
124 | u8 dialog_token_allocator; | ||
78 | }; | 125 | }; |
79 | 126 | ||
80 | struct sta_info { | 127 | struct sta_info { |
@@ -90,12 +137,9 @@ struct sta_info { | |||
90 | 137 | ||
91 | struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in | 138 | struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in |
92 | * power saving state */ | 139 | * power saving state */ |
93 | int pspoll; /* whether STA has send a PS Poll frame */ | ||
94 | struct sk_buff_head tx_filtered; /* buffer of TX frames that were | 140 | struct sk_buff_head tx_filtered; /* buffer of TX frames that were |
95 | * already given to low-level driver, | 141 | * already given to low-level driver, |
96 | * but were filtered */ | 142 | * but were filtered */ |
97 | int clear_dst_mask; | ||
98 | |||
99 | unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */ | 143 | unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */ |
100 | unsigned long rx_bytes, tx_bytes; | 144 | unsigned long rx_bytes, tx_bytes; |
101 | unsigned long tx_retry_failed, tx_retry_count; | 145 | unsigned long tx_retry_failed, tx_retry_count; |
@@ -104,10 +148,11 @@ struct sta_info { | |||
104 | unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */ | 148 | unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */ |
105 | 149 | ||
106 | unsigned long last_rx; | 150 | unsigned long last_rx; |
107 | u32 supp_rates; /* bitmap of supported rates in local->curr_rates */ | 151 | /* bitmap of supported rates per band */ |
108 | int txrate; /* index in local->curr_rates */ | 152 | u64 supp_rates[IEEE80211_NUM_BANDS]; |
109 | int last_txrate; /* last rate used to send a frame to this STA */ | 153 | int txrate_idx; |
110 | int last_nonerp_idx; | 154 | /* last rates used to send a frame to this STA */ |
155 | int last_txrate_idx, last_nonerp_txrate_idx; | ||
111 | 156 | ||
112 | struct net_device *dev; /* which net device is this station associated | 157 | struct net_device *dev; /* which net device is this station associated |
113 | * to */ | 158 | * to */ |
@@ -132,8 +177,6 @@ struct sta_info { | |||
132 | int last_rssi; /* RSSI of last received frame from this STA */ | 177 | int last_rssi; /* RSSI of last received frame from this STA */ |
133 | int last_signal; /* signal of last received frame from this STA */ | 178 | int last_signal; /* signal of last received frame from this STA */ |
134 | int last_noise; /* noise of last received frame from this STA */ | 179 | int last_noise; /* noise of last received frame from this STA */ |
135 | int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */ | ||
136 | unsigned long last_ack; | ||
137 | int channel_use; | 180 | int channel_use; |
138 | int channel_use_raw; | 181 | int channel_use_raw; |
139 | 182 | ||
@@ -148,20 +191,20 @@ struct sta_info { | |||
148 | of this STA */ | 191 | of this STA */ |
149 | struct sta_ampdu_mlme ampdu_mlme; | 192 | struct sta_ampdu_mlme ampdu_mlme; |
150 | u8 timer_to_tid[STA_TID_NUM]; /* convert timer id to tid */ | 193 | u8 timer_to_tid[STA_TID_NUM]; /* convert timer id to tid */ |
194 | u8 tid_to_tx_q[STA_TID_NUM]; /* map tid to tx queue */ | ||
151 | 195 | ||
152 | #ifdef CONFIG_MAC80211_DEBUGFS | 196 | #ifdef CONFIG_MAC80211_DEBUGFS |
153 | struct sta_info_debugfsdentries { | 197 | struct sta_info_debugfsdentries { |
154 | struct dentry *dir; | 198 | struct dentry *dir; |
155 | struct dentry *flags; | 199 | struct dentry *flags; |
156 | struct dentry *num_ps_buf_frames; | 200 | struct dentry *num_ps_buf_frames; |
157 | struct dentry *last_ack_rssi; | ||
158 | struct dentry *last_ack_ms; | ||
159 | struct dentry *inactive_ms; | 201 | struct dentry *inactive_ms; |
160 | struct dentry *last_seq_ctrl; | 202 | struct dentry *last_seq_ctrl; |
161 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS | 203 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
162 | struct dentry *wme_rx_queue; | 204 | struct dentry *wme_rx_queue; |
163 | struct dentry *wme_tx_queue; | 205 | struct dentry *wme_tx_queue; |
164 | #endif | 206 | #endif |
207 | struct dentry *agg_status; | ||
165 | } debugfs; | 208 | } debugfs; |
166 | #endif | 209 | #endif |
167 | }; | 210 | }; |
@@ -191,16 +234,17 @@ static inline void __sta_info_get(struct sta_info *sta) | |||
191 | } | 234 | } |
192 | 235 | ||
193 | struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr); | 236 | struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr); |
194 | int sta_info_min_txrate_get(struct ieee80211_local *local); | ||
195 | void sta_info_put(struct sta_info *sta); | 237 | void sta_info_put(struct sta_info *sta); |
196 | struct sta_info * sta_info_add(struct ieee80211_local *local, | 238 | struct sta_info *sta_info_add(struct ieee80211_local *local, |
197 | struct net_device *dev, u8 *addr, gfp_t gfp); | 239 | struct net_device *dev, u8 *addr, gfp_t gfp); |
198 | void sta_info_remove(struct sta_info *sta); | 240 | void sta_info_remove(struct sta_info *sta); |
199 | void sta_info_free(struct sta_info *sta); | 241 | void sta_info_free(struct sta_info *sta); |
200 | void sta_info_init(struct ieee80211_local *local); | 242 | void sta_info_init(struct ieee80211_local *local); |
201 | int sta_info_start(struct ieee80211_local *local); | 243 | int sta_info_start(struct ieee80211_local *local); |
202 | void sta_info_stop(struct ieee80211_local *local); | 244 | void sta_info_stop(struct ieee80211_local *local); |
203 | void sta_info_remove_aid_ptr(struct sta_info *sta); | ||
204 | void sta_info_flush(struct ieee80211_local *local, struct net_device *dev); | 245 | void sta_info_flush(struct ieee80211_local *local, struct net_device *dev); |
205 | 246 | ||
247 | void sta_info_set_tim_bit(struct sta_info *sta); | ||
248 | void sta_info_clear_tim_bit(struct sta_info *sta); | ||
249 | |||
206 | #endif /* STA_INFO_H */ | 250 | #endif /* STA_INFO_H */ |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 67b509edd431..1cd58e01f1ee 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -92,9 +92,13 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr, | |||
92 | int rate, mrate, erp, dur, i; | 92 | int rate, mrate, erp, dur, i; |
93 | struct ieee80211_rate *txrate = tx->u.tx.rate; | 93 | struct ieee80211_rate *txrate = tx->u.tx.rate; |
94 | struct ieee80211_local *local = tx->local; | 94 | struct ieee80211_local *local = tx->local; |
95 | struct ieee80211_hw_mode *mode = tx->u.tx.mode; | 95 | struct ieee80211_supported_band *sband; |
96 | 96 | ||
97 | erp = txrate->flags & IEEE80211_RATE_ERP; | 97 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
98 | |||
99 | erp = 0; | ||
100 | if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) | ||
101 | erp = txrate->flags & IEEE80211_RATE_ERP_G; | ||
98 | 102 | ||
99 | /* | 103 | /* |
100 | * data and mgmt (except PS Poll): | 104 | * data and mgmt (except PS Poll): |
@@ -150,20 +154,36 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr, | |||
150 | * Mandatory rates for IEEE 802.11g PHY: 1, 2, 5.5, 11, 6, 12, 24 Mbps | 154 | * Mandatory rates for IEEE 802.11g PHY: 1, 2, 5.5, 11, 6, 12, 24 Mbps |
151 | */ | 155 | */ |
152 | rate = -1; | 156 | rate = -1; |
153 | mrate = 10; /* use 1 Mbps if everything fails */ | 157 | /* use lowest available if everything fails */ |
154 | for (i = 0; i < mode->num_rates; i++) { | 158 | mrate = sband->bitrates[0].bitrate; |
155 | struct ieee80211_rate *r = &mode->rates[i]; | 159 | for (i = 0; i < sband->n_bitrates; i++) { |
156 | if (r->rate > txrate->rate) | 160 | struct ieee80211_rate *r = &sband->bitrates[i]; |
157 | break; | ||
158 | 161 | ||
159 | if (IEEE80211_RATE_MODULATION(txrate->flags) != | 162 | if (r->bitrate > txrate->bitrate) |
160 | IEEE80211_RATE_MODULATION(r->flags)) | 163 | break; |
161 | continue; | ||
162 | 164 | ||
163 | if (r->flags & IEEE80211_RATE_BASIC) | 165 | if (tx->sdata->basic_rates & BIT(i)) |
164 | rate = r->rate; | 166 | rate = r->bitrate; |
165 | else if (r->flags & IEEE80211_RATE_MANDATORY) | 167 | |
166 | mrate = r->rate; | 168 | switch (sband->band) { |
169 | case IEEE80211_BAND_2GHZ: { | ||
170 | u32 flag; | ||
171 | if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) | ||
172 | flag = IEEE80211_RATE_MANDATORY_G; | ||
173 | else | ||
174 | flag = IEEE80211_RATE_MANDATORY_B; | ||
175 | if (r->flags & flag) | ||
176 | mrate = r->bitrate; | ||
177 | break; | ||
178 | } | ||
179 | case IEEE80211_BAND_5GHZ: | ||
180 | if (r->flags & IEEE80211_RATE_MANDATORY_A) | ||
181 | mrate = r->bitrate; | ||
182 | break; | ||
183 | case IEEE80211_NUM_BANDS: | ||
184 | WARN_ON(1); | ||
185 | break; | ||
186 | } | ||
167 | } | 187 | } |
168 | if (rate == -1) { | 188 | if (rate == -1) { |
169 | /* No matching basic rate found; use highest suitable mandatory | 189 | /* No matching basic rate found; use highest suitable mandatory |
@@ -184,7 +204,7 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr, | |||
184 | dur *= 2; /* ACK + SIFS */ | 204 | dur *= 2; /* ACK + SIFS */ |
185 | /* next fragment */ | 205 | /* next fragment */ |
186 | dur += ieee80211_frame_duration(local, next_frag_len, | 206 | dur += ieee80211_frame_duration(local, next_frag_len, |
187 | txrate->rate, erp, | 207 | txrate->bitrate, erp, |
188 | tx->sdata->bss_conf.use_short_preamble); | 208 | tx->sdata->bss_conf.use_short_preamble); |
189 | } | 209 | } |
190 | 210 | ||
@@ -212,7 +232,7 @@ static int inline is_ieee80211_device(struct net_device *dev, | |||
212 | 232 | ||
213 | /* tx handlers */ | 233 | /* tx handlers */ |
214 | 234 | ||
215 | static ieee80211_txrx_result | 235 | static ieee80211_tx_result |
216 | ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx) | 236 | ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx) |
217 | { | 237 | { |
218 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 238 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
@@ -222,15 +242,15 @@ ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx) | |||
222 | u32 sta_flags; | 242 | u32 sta_flags; |
223 | 243 | ||
224 | if (unlikely(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) | 244 | if (unlikely(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) |
225 | return TXRX_CONTINUE; | 245 | return TX_CONTINUE; |
226 | 246 | ||
227 | if (unlikely(tx->local->sta_sw_scanning) && | 247 | if (unlikely(tx->local->sta_sw_scanning) && |
228 | ((tx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || | 248 | ((tx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || |
229 | (tx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PROBE_REQ)) | 249 | (tx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PROBE_REQ)) |
230 | return TXRX_DROP; | 250 | return TX_DROP; |
231 | 251 | ||
232 | if (tx->flags & IEEE80211_TXRXD_TXPS_BUFFERED) | 252 | if (tx->flags & IEEE80211_TXRXD_TXPS_BUFFERED) |
233 | return TXRX_CONTINUE; | 253 | return TX_CONTINUE; |
234 | 254 | ||
235 | sta_flags = tx->sta ? tx->sta->flags : 0; | 255 | sta_flags = tx->sta ? tx->sta->flags : 0; |
236 | 256 | ||
@@ -245,7 +265,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx) | |||
245 | tx->dev->name, print_mac(mac, hdr->addr1)); | 265 | tx->dev->name, print_mac(mac, hdr->addr1)); |
246 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 266 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
247 | I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); | 267 | I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); |
248 | return TXRX_DROP; | 268 | return TX_DROP; |
249 | } | 269 | } |
250 | } else { | 270 | } else { |
251 | if (unlikely((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && | 271 | if (unlikely((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && |
@@ -255,15 +275,15 @@ ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx) | |||
255 | * No associated STAs - no need to send multicast | 275 | * No associated STAs - no need to send multicast |
256 | * frames. | 276 | * frames. |
257 | */ | 277 | */ |
258 | return TXRX_DROP; | 278 | return TX_DROP; |
259 | } | 279 | } |
260 | return TXRX_CONTINUE; | 280 | return TX_CONTINUE; |
261 | } | 281 | } |
262 | 282 | ||
263 | return TXRX_CONTINUE; | 283 | return TX_CONTINUE; |
264 | } | 284 | } |
265 | 285 | ||
266 | static ieee80211_txrx_result | 286 | static ieee80211_tx_result |
267 | ieee80211_tx_h_sequence(struct ieee80211_txrx_data *tx) | 287 | ieee80211_tx_h_sequence(struct ieee80211_txrx_data *tx) |
268 | { | 288 | { |
269 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | 289 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; |
@@ -271,7 +291,7 @@ ieee80211_tx_h_sequence(struct ieee80211_txrx_data *tx) | |||
271 | if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24) | 291 | if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24) |
272 | ieee80211_include_sequence(tx->sdata, hdr); | 292 | ieee80211_include_sequence(tx->sdata, hdr); |
273 | 293 | ||
274 | return TXRX_CONTINUE; | 294 | return TX_CONTINUE; |
275 | } | 295 | } |
276 | 296 | ||
277 | /* This function is called whenever the AP is about to exceed the maximum limit | 297 | /* This function is called whenever the AP is about to exceed the maximum limit |
@@ -321,7 +341,7 @@ static void purge_old_ps_buffers(struct ieee80211_local *local) | |||
321 | wiphy_name(local->hw.wiphy), purged); | 341 | wiphy_name(local->hw.wiphy), purged); |
322 | } | 342 | } |
323 | 343 | ||
324 | static ieee80211_txrx_result | 344 | static ieee80211_tx_result |
325 | ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx) | 345 | ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx) |
326 | { | 346 | { |
327 | /* | 347 | /* |
@@ -334,11 +354,11 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx) | |||
334 | 354 | ||
335 | /* not AP/IBSS or ordered frame */ | 355 | /* not AP/IBSS or ordered frame */ |
336 | if (!tx->sdata->bss || (tx->fc & IEEE80211_FCTL_ORDER)) | 356 | if (!tx->sdata->bss || (tx->fc & IEEE80211_FCTL_ORDER)) |
337 | return TXRX_CONTINUE; | 357 | return TX_CONTINUE; |
338 | 358 | ||
339 | /* no stations in PS mode */ | 359 | /* no stations in PS mode */ |
340 | if (!atomic_read(&tx->sdata->bss->num_sta_ps)) | 360 | if (!atomic_read(&tx->sdata->bss->num_sta_ps)) |
341 | return TXRX_CONTINUE; | 361 | return TX_CONTINUE; |
342 | 362 | ||
343 | /* buffered in mac80211 */ | 363 | /* buffered in mac80211 */ |
344 | if (tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) { | 364 | if (tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) { |
@@ -355,16 +375,16 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx) | |||
355 | } else | 375 | } else |
356 | tx->local->total_ps_buffered++; | 376 | tx->local->total_ps_buffered++; |
357 | skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb); | 377 | skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb); |
358 | return TXRX_QUEUED; | 378 | return TX_QUEUED; |
359 | } | 379 | } |
360 | 380 | ||
361 | /* buffered in hardware */ | 381 | /* buffered in hardware */ |
362 | tx->u.tx.control->flags |= IEEE80211_TXCTL_SEND_AFTER_DTIM; | 382 | tx->u.tx.control->flags |= IEEE80211_TXCTL_SEND_AFTER_DTIM; |
363 | 383 | ||
364 | return TXRX_CONTINUE; | 384 | return TX_CONTINUE; |
365 | } | 385 | } |
366 | 386 | ||
367 | static ieee80211_txrx_result | 387 | static ieee80211_tx_result |
368 | ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx) | 388 | ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx) |
369 | { | 389 | { |
370 | struct sta_info *sta = tx->sta; | 390 | struct sta_info *sta = tx->sta; |
@@ -373,9 +393,10 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx) | |||
373 | if (unlikely(!sta || | 393 | if (unlikely(!sta || |
374 | ((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && | 394 | ((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && |
375 | (tx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP))) | 395 | (tx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP))) |
376 | return TXRX_CONTINUE; | 396 | return TX_CONTINUE; |
377 | 397 | ||
378 | if (unlikely((sta->flags & WLAN_STA_PS) && !sta->pspoll)) { | 398 | if (unlikely((sta->flags & WLAN_STA_PS) && |
399 | !(sta->flags & WLAN_STA_PSPOLL))) { | ||
379 | struct ieee80211_tx_packet_data *pkt_data; | 400 | struct ieee80211_tx_packet_data *pkt_data; |
380 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 401 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
381 | printk(KERN_DEBUG "STA %s aid %d: PS buffer (entries " | 402 | printk(KERN_DEBUG "STA %s aid %d: PS buffer (entries " |
@@ -383,7 +404,6 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx) | |||
383 | print_mac(mac, sta->addr), sta->aid, | 404 | print_mac(mac, sta->addr), sta->aid, |
384 | skb_queue_len(&sta->ps_tx_buf)); | 405 | skb_queue_len(&sta->ps_tx_buf)); |
385 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 406 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
386 | sta->flags |= WLAN_STA_TIM; | ||
387 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) | 407 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) |
388 | purge_old_ps_buffers(tx->local); | 408 | purge_old_ps_buffers(tx->local); |
389 | if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) { | 409 | if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) { |
@@ -396,18 +416,15 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx) | |||
396 | dev_kfree_skb(old); | 416 | dev_kfree_skb(old); |
397 | } else | 417 | } else |
398 | tx->local->total_ps_buffered++; | 418 | tx->local->total_ps_buffered++; |
419 | |||
399 | /* Queue frame to be sent after STA sends an PS Poll frame */ | 420 | /* Queue frame to be sent after STA sends an PS Poll frame */ |
400 | if (skb_queue_empty(&sta->ps_tx_buf)) { | 421 | if (skb_queue_empty(&sta->ps_tx_buf)) |
401 | if (tx->local->ops->set_tim) | 422 | sta_info_set_tim_bit(sta); |
402 | tx->local->ops->set_tim(local_to_hw(tx->local), | 423 | |
403 | sta->aid, 1); | ||
404 | if (tx->sdata->bss) | ||
405 | bss_tim_set(tx->local, tx->sdata->bss, sta->aid); | ||
406 | } | ||
407 | pkt_data = (struct ieee80211_tx_packet_data *)tx->skb->cb; | 424 | pkt_data = (struct ieee80211_tx_packet_data *)tx->skb->cb; |
408 | pkt_data->jiffies = jiffies; | 425 | pkt_data->jiffies = jiffies; |
409 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); | 426 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); |
410 | return TXRX_QUEUED; | 427 | return TX_QUEUED; |
411 | } | 428 | } |
412 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 429 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
413 | else if (unlikely(sta->flags & WLAN_STA_PS)) { | 430 | else if (unlikely(sta->flags & WLAN_STA_PS)) { |
@@ -416,16 +433,16 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx) | |||
416 | print_mac(mac, sta->addr)); | 433 | print_mac(mac, sta->addr)); |
417 | } | 434 | } |
418 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 435 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
419 | sta->pspoll = 0; | 436 | sta->flags &= ~WLAN_STA_PSPOLL; |
420 | 437 | ||
421 | return TXRX_CONTINUE; | 438 | return TX_CONTINUE; |
422 | } | 439 | } |
423 | 440 | ||
424 | static ieee80211_txrx_result | 441 | static ieee80211_tx_result |
425 | ieee80211_tx_h_ps_buf(struct ieee80211_txrx_data *tx) | 442 | ieee80211_tx_h_ps_buf(struct ieee80211_txrx_data *tx) |
426 | { | 443 | { |
427 | if (unlikely(tx->flags & IEEE80211_TXRXD_TXPS_BUFFERED)) | 444 | if (unlikely(tx->flags & IEEE80211_TXRXD_TXPS_BUFFERED)) |
428 | return TXRX_CONTINUE; | 445 | return TX_CONTINUE; |
429 | 446 | ||
430 | if (tx->flags & IEEE80211_TXRXD_TXUNICAST) | 447 | if (tx->flags & IEEE80211_TXRXD_TXUNICAST) |
431 | return ieee80211_tx_h_unicast_ps_buf(tx); | 448 | return ieee80211_tx_h_unicast_ps_buf(tx); |
@@ -433,7 +450,7 @@ ieee80211_tx_h_ps_buf(struct ieee80211_txrx_data *tx) | |||
433 | return ieee80211_tx_h_multicast_ps_buf(tx); | 450 | return ieee80211_tx_h_multicast_ps_buf(tx); |
434 | } | 451 | } |
435 | 452 | ||
436 | static ieee80211_txrx_result | 453 | static ieee80211_tx_result |
437 | ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx) | 454 | ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx) |
438 | { | 455 | { |
439 | struct ieee80211_key *key; | 456 | struct ieee80211_key *key; |
@@ -449,7 +466,7 @@ ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx) | |||
449 | !(tx->u.tx.control->flags & IEEE80211_TXCTL_EAPOL_FRAME) && | 466 | !(tx->u.tx.control->flags & IEEE80211_TXCTL_EAPOL_FRAME) && |
450 | !(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) { | 467 | !(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) { |
451 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); | 468 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); |
452 | return TXRX_DROP; | 469 | return TX_DROP; |
453 | } else | 470 | } else |
454 | tx->key = NULL; | 471 | tx->key = NULL; |
455 | 472 | ||
@@ -478,10 +495,10 @@ ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx) | |||
478 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) | 495 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
479 | tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | 496 | tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; |
480 | 497 | ||
481 | return TXRX_CONTINUE; | 498 | return TX_CONTINUE; |
482 | } | 499 | } |
483 | 500 | ||
484 | static ieee80211_txrx_result | 501 | static ieee80211_tx_result |
485 | ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx) | 502 | ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx) |
486 | { | 503 | { |
487 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | 504 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; |
@@ -493,7 +510,7 @@ ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx) | |||
493 | int frag_threshold = tx->local->fragmentation_threshold; | 510 | int frag_threshold = tx->local->fragmentation_threshold; |
494 | 511 | ||
495 | if (!(tx->flags & IEEE80211_TXRXD_FRAGMENTED)) | 512 | if (!(tx->flags & IEEE80211_TXRXD_FRAGMENTED)) |
496 | return TXRX_CONTINUE; | 513 | return TX_CONTINUE; |
497 | 514 | ||
498 | first = tx->skb; | 515 | first = tx->skb; |
499 | 516 | ||
@@ -547,7 +564,7 @@ ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx) | |||
547 | tx->u.tx.num_extra_frag = num_fragm - 1; | 564 | tx->u.tx.num_extra_frag = num_fragm - 1; |
548 | tx->u.tx.extra_frag = frags; | 565 | tx->u.tx.extra_frag = frags; |
549 | 566 | ||
550 | return TXRX_CONTINUE; | 567 | return TX_CONTINUE; |
551 | 568 | ||
552 | fail: | 569 | fail: |
553 | printk(KERN_DEBUG "%s: failed to fragment frame\n", tx->dev->name); | 570 | printk(KERN_DEBUG "%s: failed to fragment frame\n", tx->dev->name); |
@@ -558,14 +575,14 @@ ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx) | |||
558 | kfree(frags); | 575 | kfree(frags); |
559 | } | 576 | } |
560 | I802_DEBUG_INC(tx->local->tx_handlers_drop_fragment); | 577 | I802_DEBUG_INC(tx->local->tx_handlers_drop_fragment); |
561 | return TXRX_DROP; | 578 | return TX_DROP; |
562 | } | 579 | } |
563 | 580 | ||
564 | static ieee80211_txrx_result | 581 | static ieee80211_tx_result |
565 | ieee80211_tx_h_encrypt(struct ieee80211_txrx_data *tx) | 582 | ieee80211_tx_h_encrypt(struct ieee80211_txrx_data *tx) |
566 | { | 583 | { |
567 | if (!tx->key) | 584 | if (!tx->key) |
568 | return TXRX_CONTINUE; | 585 | return TX_CONTINUE; |
569 | 586 | ||
570 | switch (tx->key->conf.alg) { | 587 | switch (tx->key->conf.alg) { |
571 | case ALG_WEP: | 588 | case ALG_WEP: |
@@ -578,33 +595,35 @@ ieee80211_tx_h_encrypt(struct ieee80211_txrx_data *tx) | |||
578 | 595 | ||
579 | /* not reached */ | 596 | /* not reached */ |
580 | WARN_ON(1); | 597 | WARN_ON(1); |
581 | return TXRX_DROP; | 598 | return TX_DROP; |
582 | } | 599 | } |
583 | 600 | ||
584 | static ieee80211_txrx_result | 601 | static ieee80211_tx_result |
585 | ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx) | 602 | ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx) |
586 | { | 603 | { |
587 | struct rate_selection rsel; | 604 | struct rate_selection rsel; |
605 | struct ieee80211_supported_band *sband; | ||
606 | |||
607 | sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band]; | ||
588 | 608 | ||
589 | if (likely(!tx->u.tx.rate)) { | 609 | if (likely(!tx->u.tx.rate)) { |
590 | rate_control_get_rate(tx->dev, tx->u.tx.mode, tx->skb, &rsel); | 610 | rate_control_get_rate(tx->dev, sband, tx->skb, &rsel); |
591 | tx->u.tx.rate = rsel.rate; | 611 | tx->u.tx.rate = rsel.rate; |
592 | if (unlikely(rsel.probe != NULL)) { | 612 | if (unlikely(rsel.probe)) { |
593 | tx->u.tx.control->flags |= | 613 | tx->u.tx.control->flags |= |
594 | IEEE80211_TXCTL_RATE_CTRL_PROBE; | 614 | IEEE80211_TXCTL_RATE_CTRL_PROBE; |
595 | tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; | 615 | tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; |
596 | tx->u.tx.control->alt_retry_rate = tx->u.tx.rate->val; | 616 | tx->u.tx.control->alt_retry_rate = tx->u.tx.rate; |
597 | tx->u.tx.rate = rsel.probe; | 617 | tx->u.tx.rate = rsel.probe; |
598 | } else | 618 | } else |
599 | tx->u.tx.control->alt_retry_rate = -1; | 619 | tx->u.tx.control->alt_retry_rate = NULL; |
600 | 620 | ||
601 | if (!tx->u.tx.rate) | 621 | if (!tx->u.tx.rate) |
602 | return TXRX_DROP; | 622 | return TX_DROP; |
603 | } else | 623 | } else |
604 | tx->u.tx.control->alt_retry_rate = -1; | 624 | tx->u.tx.control->alt_retry_rate = NULL; |
605 | 625 | ||
606 | if (tx->u.tx.mode->mode == MODE_IEEE80211G && | 626 | if (tx->sdata->bss_conf.use_cts_prot && |
607 | tx->sdata->bss_conf.use_cts_prot && | ||
608 | (tx->flags & IEEE80211_TXRXD_FRAGMENTED) && rsel.nonerp) { | 627 | (tx->flags & IEEE80211_TXRXD_FRAGMENTED) && rsel.nonerp) { |
609 | tx->u.tx.last_frag_rate = tx->u.tx.rate; | 628 | tx->u.tx.last_frag_rate = tx->u.tx.rate; |
610 | if (rsel.probe) | 629 | if (rsel.probe) |
@@ -612,25 +631,24 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx) | |||
612 | else | 631 | else |
613 | tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; | 632 | tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; |
614 | tx->u.tx.rate = rsel.nonerp; | 633 | tx->u.tx.rate = rsel.nonerp; |
615 | tx->u.tx.control->rate = rsel.nonerp; | 634 | tx->u.tx.control->tx_rate = rsel.nonerp; |
616 | tx->u.tx.control->flags &= ~IEEE80211_TXCTL_RATE_CTRL_PROBE; | 635 | tx->u.tx.control->flags &= ~IEEE80211_TXCTL_RATE_CTRL_PROBE; |
617 | } else { | 636 | } else { |
618 | tx->u.tx.last_frag_rate = tx->u.tx.rate; | 637 | tx->u.tx.last_frag_rate = tx->u.tx.rate; |
619 | tx->u.tx.control->rate = tx->u.tx.rate; | 638 | tx->u.tx.control->tx_rate = tx->u.tx.rate; |
620 | } | 639 | } |
621 | tx->u.tx.control->tx_rate = tx->u.tx.rate->val; | 640 | tx->u.tx.control->tx_rate = tx->u.tx.rate; |
622 | 641 | ||
623 | return TXRX_CONTINUE; | 642 | return TX_CONTINUE; |
624 | } | 643 | } |
625 | 644 | ||
626 | static ieee80211_txrx_result | 645 | static ieee80211_tx_result |
627 | ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) | 646 | ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) |
628 | { | 647 | { |
629 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | 648 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; |
630 | u16 fc = le16_to_cpu(hdr->frame_control); | 649 | u16 fc = le16_to_cpu(hdr->frame_control); |
631 | u16 dur; | 650 | u16 dur; |
632 | struct ieee80211_tx_control *control = tx->u.tx.control; | 651 | struct ieee80211_tx_control *control = tx->u.tx.control; |
633 | struct ieee80211_hw_mode *mode = tx->u.tx.mode; | ||
634 | 652 | ||
635 | if (!control->retry_limit) { | 653 | if (!control->retry_limit) { |
636 | if (!is_multicast_ether_addr(hdr->addr1)) { | 654 | if (!is_multicast_ether_addr(hdr->addr1)) { |
@@ -657,14 +675,14 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) | |||
657 | * frames. | 675 | * frames. |
658 | * TODO: The last fragment could still use multiple retry | 676 | * TODO: The last fragment could still use multiple retry |
659 | * rates. */ | 677 | * rates. */ |
660 | control->alt_retry_rate = -1; | 678 | control->alt_retry_rate = NULL; |
661 | } | 679 | } |
662 | 680 | ||
663 | /* Use CTS protection for unicast frames sent using extended rates if | 681 | /* Use CTS protection for unicast frames sent using extended rates if |
664 | * there are associated non-ERP stations and RTS/CTS is not configured | 682 | * there are associated non-ERP stations and RTS/CTS is not configured |
665 | * for the frame. */ | 683 | * for the frame. */ |
666 | if (mode->mode == MODE_IEEE80211G && | 684 | if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) && |
667 | (tx->u.tx.rate->flags & IEEE80211_RATE_ERP) && | 685 | (tx->u.tx.rate->flags & IEEE80211_RATE_ERP_G) && |
668 | (tx->flags & IEEE80211_TXRXD_TXUNICAST) && | 686 | (tx->flags & IEEE80211_TXRXD_TXUNICAST) && |
669 | tx->sdata->bss_conf.use_cts_prot && | 687 | tx->sdata->bss_conf.use_cts_prot && |
670 | !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS)) | 688 | !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS)) |
@@ -674,10 +692,10 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) | |||
674 | * short preambles at the selected rate and short preambles are | 692 | * short preambles at the selected rate and short preambles are |
675 | * available on the network at the current point in time. */ | 693 | * available on the network at the current point in time. */ |
676 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | 694 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && |
677 | (tx->u.tx.rate->flags & IEEE80211_RATE_PREAMBLE2) && | 695 | (tx->u.tx.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) && |
678 | tx->sdata->bss_conf.use_short_preamble && | 696 | tx->sdata->bss_conf.use_short_preamble && |
679 | (!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) { | 697 | (!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) { |
680 | tx->u.tx.control->tx_rate = tx->u.tx.rate->val2; | 698 | tx->u.tx.control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; |
681 | } | 699 | } |
682 | 700 | ||
683 | /* Setup duration field for the first fragment of the frame. Duration | 701 | /* Setup duration field for the first fragment of the frame. Duration |
@@ -690,19 +708,33 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) | |||
690 | 708 | ||
691 | if ((control->flags & IEEE80211_TXCTL_USE_RTS_CTS) || | 709 | if ((control->flags & IEEE80211_TXCTL_USE_RTS_CTS) || |
692 | (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { | 710 | (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { |
693 | struct ieee80211_rate *rate; | 711 | struct ieee80211_supported_band *sband; |
712 | struct ieee80211_rate *rate, *baserate; | ||
713 | int idx; | ||
714 | |||
715 | sband = tx->local->hw.wiphy->bands[ | ||
716 | tx->local->hw.conf.channel->band]; | ||
694 | 717 | ||
695 | /* Do not use multiple retry rates when using RTS/CTS */ | 718 | /* Do not use multiple retry rates when using RTS/CTS */ |
696 | control->alt_retry_rate = -1; | 719 | control->alt_retry_rate = NULL; |
697 | 720 | ||
698 | /* Use min(data rate, max base rate) as CTS/RTS rate */ | 721 | /* Use min(data rate, max base rate) as CTS/RTS rate */ |
699 | rate = tx->u.tx.rate; | 722 | rate = tx->u.tx.rate; |
700 | while (rate > mode->rates && | 723 | baserate = NULL; |
701 | !(rate->flags & IEEE80211_RATE_BASIC)) | ||
702 | rate--; | ||
703 | 724 | ||
704 | control->rts_cts_rate = rate->val; | 725 | for (idx = 0; idx < sband->n_bitrates; idx++) { |
705 | control->rts_rate = rate; | 726 | if (sband->bitrates[idx].bitrate > rate->bitrate) |
727 | continue; | ||
728 | if (tx->sdata->basic_rates & BIT(idx) && | ||
729 | (!baserate || | ||
730 | (baserate->bitrate < sband->bitrates[idx].bitrate))) | ||
731 | baserate = &sband->bitrates[idx]; | ||
732 | } | ||
733 | |||
734 | if (baserate) | ||
735 | control->rts_cts_rate = baserate; | ||
736 | else | ||
737 | control->rts_cts_rate = &sband->bitrates[0]; | ||
706 | } | 738 | } |
707 | 739 | ||
708 | if (tx->sta) { | 740 | if (tx->sta) { |
@@ -719,17 +751,17 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) | |||
719 | } | 751 | } |
720 | } | 752 | } |
721 | 753 | ||
722 | return TXRX_CONTINUE; | 754 | return TX_CONTINUE; |
723 | } | 755 | } |
724 | 756 | ||
725 | static ieee80211_txrx_result | 757 | static ieee80211_tx_result |
726 | ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx) | 758 | ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx) |
727 | { | 759 | { |
728 | struct ieee80211_local *local = tx->local; | 760 | struct ieee80211_local *local = tx->local; |
729 | struct ieee80211_hw_mode *mode = tx->u.tx.mode; | ||
730 | struct sk_buff *skb = tx->skb; | 761 | struct sk_buff *skb = tx->skb; |
731 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 762 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
732 | u32 load = 0, hdrtime; | 763 | u32 load = 0, hdrtime; |
764 | struct ieee80211_rate *rate = tx->u.tx.rate; | ||
733 | 765 | ||
734 | /* TODO: this could be part of tx_status handling, so that the number | 766 | /* TODO: this could be part of tx_status handling, so that the number |
735 | * of retries would be known; TX rate should in that case be stored | 767 | * of retries would be known; TX rate should in that case be stored |
@@ -740,9 +772,9 @@ ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx) | |||
740 | /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, | 772 | /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, |
741 | * 1 usec = 1/8 * (1080 / 10) = 13.5 */ | 773 | * 1 usec = 1/8 * (1080 / 10) = 13.5 */ |
742 | 774 | ||
743 | if (mode->mode == MODE_IEEE80211A || | 775 | if (tx->u.tx.channel->band == IEEE80211_BAND_5GHZ || |
744 | (mode->mode == MODE_IEEE80211G && | 776 | (tx->u.tx.channel->band == IEEE80211_BAND_2GHZ && |
745 | tx->u.tx.rate->flags & IEEE80211_RATE_ERP)) | 777 | rate->flags & IEEE80211_RATE_ERP_G)) |
746 | hdrtime = CHAN_UTIL_HDR_SHORT; | 778 | hdrtime = CHAN_UTIL_HDR_SHORT; |
747 | else | 779 | else |
748 | hdrtime = CHAN_UTIL_HDR_LONG; | 780 | hdrtime = CHAN_UTIL_HDR_LONG; |
@@ -756,14 +788,15 @@ ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx) | |||
756 | else if (tx->u.tx.control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | 788 | else if (tx->u.tx.control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) |
757 | load += hdrtime; | 789 | load += hdrtime; |
758 | 790 | ||
759 | load += skb->len * tx->u.tx.rate->rate_inv; | 791 | /* TODO: optimise again */ |
792 | load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate; | ||
760 | 793 | ||
761 | if (tx->u.tx.extra_frag) { | 794 | if (tx->u.tx.extra_frag) { |
762 | int i; | 795 | int i; |
763 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | 796 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { |
764 | load += 2 * hdrtime; | 797 | load += 2 * hdrtime; |
765 | load += tx->u.tx.extra_frag[i]->len * | 798 | load += tx->u.tx.extra_frag[i]->len * |
766 | tx->u.tx.rate->rate; | 799 | tx->u.tx.rate->bitrate; |
767 | } | 800 | } |
768 | } | 801 | } |
769 | 802 | ||
@@ -774,13 +807,12 @@ ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx) | |||
774 | tx->sta->channel_use_raw += load; | 807 | tx->sta->channel_use_raw += load; |
775 | tx->sdata->channel_use_raw += load; | 808 | tx->sdata->channel_use_raw += load; |
776 | 809 | ||
777 | return TXRX_CONTINUE; | 810 | return TX_CONTINUE; |
778 | } | 811 | } |
779 | 812 | ||
780 | /* TODO: implement register/unregister functions for adding TX/RX handlers | ||
781 | * into ordered list */ | ||
782 | 813 | ||
783 | ieee80211_tx_handler ieee80211_tx_handlers[] = | 814 | typedef ieee80211_tx_result (*ieee80211_tx_handler)(struct ieee80211_txrx_data *); |
815 | static ieee80211_tx_handler ieee80211_tx_handlers[] = | ||
784 | { | 816 | { |
785 | ieee80211_tx_h_check_assoc, | 817 | ieee80211_tx_h_check_assoc, |
786 | ieee80211_tx_h_sequence, | 818 | ieee80211_tx_h_sequence, |
@@ -801,7 +833,7 @@ ieee80211_tx_handler ieee80211_tx_handlers[] = | |||
801 | * deal with packet injection down monitor interface | 833 | * deal with packet injection down monitor interface |
802 | * with Radiotap Header -- only called for monitor mode interface | 834 | * with Radiotap Header -- only called for monitor mode interface |
803 | */ | 835 | */ |
804 | static ieee80211_txrx_result | 836 | static ieee80211_tx_result |
805 | __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, | 837 | __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, |
806 | struct sk_buff *skb) | 838 | struct sk_buff *skb) |
807 | { | 839 | { |
@@ -816,10 +848,12 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, | |||
816 | struct ieee80211_radiotap_iterator iterator; | 848 | struct ieee80211_radiotap_iterator iterator; |
817 | struct ieee80211_radiotap_header *rthdr = | 849 | struct ieee80211_radiotap_header *rthdr = |
818 | (struct ieee80211_radiotap_header *) skb->data; | 850 | (struct ieee80211_radiotap_header *) skb->data; |
819 | struct ieee80211_hw_mode *mode = tx->local->hw.conf.mode; | 851 | struct ieee80211_supported_band *sband; |
820 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); | 852 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); |
821 | struct ieee80211_tx_control *control = tx->u.tx.control; | 853 | struct ieee80211_tx_control *control = tx->u.tx.control; |
822 | 854 | ||
855 | sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band]; | ||
856 | |||
823 | control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | 857 | control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; |
824 | tx->flags |= IEEE80211_TXRXD_TX_INJECTED; | 858 | tx->flags |= IEEE80211_TXRXD_TX_INJECTED; |
825 | tx->flags &= ~IEEE80211_TXRXD_FRAGMENTED; | 859 | tx->flags &= ~IEEE80211_TXRXD_FRAGMENTED; |
@@ -852,10 +886,12 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, | |||
852 | * ieee80211 rate int is in 100kbps units eg, 0x0a=1Mbps | 886 | * ieee80211 rate int is in 100kbps units eg, 0x0a=1Mbps |
853 | */ | 887 | */ |
854 | target_rate = (*iterator.this_arg) * 5; | 888 | target_rate = (*iterator.this_arg) * 5; |
855 | for (i = 0; i < mode->num_rates; i++) { | 889 | for (i = 0; i < sband->n_bitrates; i++) { |
856 | struct ieee80211_rate *r = &mode->rates[i]; | 890 | struct ieee80211_rate *r; |
891 | |||
892 | r = &sband->bitrates[i]; | ||
857 | 893 | ||
858 | if (r->rate == target_rate) { | 894 | if (r->bitrate == target_rate) { |
859 | tx->u.tx.rate = r; | 895 | tx->u.tx.rate = r; |
860 | break; | 896 | break; |
861 | } | 897 | } |
@@ -870,9 +906,11 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, | |||
870 | control->antenna_sel_tx = (*iterator.this_arg) + 1; | 906 | control->antenna_sel_tx = (*iterator.this_arg) + 1; |
871 | break; | 907 | break; |
872 | 908 | ||
909 | #if 0 | ||
873 | case IEEE80211_RADIOTAP_DBM_TX_POWER: | 910 | case IEEE80211_RADIOTAP_DBM_TX_POWER: |
874 | control->power_level = *iterator.this_arg; | 911 | control->power_level = *iterator.this_arg; |
875 | break; | 912 | break; |
913 | #endif | ||
876 | 914 | ||
877 | case IEEE80211_RADIOTAP_FLAGS: | 915 | case IEEE80211_RADIOTAP_FLAGS: |
878 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { | 916 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { |
@@ -884,7 +922,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, | |||
884 | * on transmission | 922 | * on transmission |
885 | */ | 923 | */ |
886 | if (skb->len < (iterator.max_length + FCS_LEN)) | 924 | if (skb->len < (iterator.max_length + FCS_LEN)) |
887 | return TXRX_DROP; | 925 | return TX_DROP; |
888 | 926 | ||
889 | skb_trim(skb, skb->len - FCS_LEN); | 927 | skb_trim(skb, skb->len - FCS_LEN); |
890 | } | 928 | } |
@@ -907,7 +945,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, | |||
907 | } | 945 | } |
908 | 946 | ||
909 | if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ | 947 | if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ |
910 | return TXRX_DROP; | 948 | return TX_DROP; |
911 | 949 | ||
912 | /* | 950 | /* |
913 | * remove the radiotap header | 951 | * remove the radiotap header |
@@ -916,13 +954,13 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, | |||
916 | */ | 954 | */ |
917 | skb_pull(skb, iterator.max_length); | 955 | skb_pull(skb, iterator.max_length); |
918 | 956 | ||
919 | return TXRX_CONTINUE; | 957 | return TX_CONTINUE; |
920 | } | 958 | } |
921 | 959 | ||
922 | /* | 960 | /* |
923 | * initialises @tx | 961 | * initialises @tx |
924 | */ | 962 | */ |
925 | static ieee80211_txrx_result | 963 | static ieee80211_tx_result |
926 | __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | 964 | __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, |
927 | struct sk_buff *skb, | 965 | struct sk_buff *skb, |
928 | struct net_device *dev, | 966 | struct net_device *dev, |
@@ -949,8 +987,8 @@ __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | |||
949 | /* process and remove the injection radiotap header */ | 987 | /* process and remove the injection radiotap header */ |
950 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 988 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
951 | if (unlikely(sdata->vif.type == IEEE80211_IF_TYPE_MNTR)) { | 989 | if (unlikely(sdata->vif.type == IEEE80211_IF_TYPE_MNTR)) { |
952 | if (__ieee80211_parse_tx_radiotap(tx, skb) == TXRX_DROP) | 990 | if (__ieee80211_parse_tx_radiotap(tx, skb) == TX_DROP) |
953 | return TXRX_DROP; | 991 | return TX_DROP; |
954 | 992 | ||
955 | /* | 993 | /* |
956 | * __ieee80211_parse_tx_radiotap has now removed | 994 | * __ieee80211_parse_tx_radiotap has now removed |
@@ -982,10 +1020,10 @@ __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | |||
982 | } | 1020 | } |
983 | 1021 | ||
984 | if (!tx->sta) | 1022 | if (!tx->sta) |
985 | control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK; | 1023 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; |
986 | else if (tx->sta->clear_dst_mask) { | 1024 | else if (tx->sta->flags & WLAN_STA_CLEAR_PS_FILT) { |
987 | control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK; | 1025 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; |
988 | tx->sta->clear_dst_mask = 0; | 1026 | tx->sta->flags &= ~WLAN_STA_CLEAR_PS_FILT; |
989 | } | 1027 | } |
990 | 1028 | ||
991 | hdrlen = ieee80211_get_hdrlen(tx->fc); | 1029 | hdrlen = ieee80211_get_hdrlen(tx->fc); |
@@ -995,7 +1033,7 @@ __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | |||
995 | } | 1033 | } |
996 | control->flags |= IEEE80211_TXCTL_FIRST_FRAGMENT; | 1034 | control->flags |= IEEE80211_TXCTL_FIRST_FRAGMENT; |
997 | 1035 | ||
998 | return TXRX_CONTINUE; | 1036 | return TX_CONTINUE; |
999 | } | 1037 | } |
1000 | 1038 | ||
1001 | /* | 1039 | /* |
@@ -1046,7 +1084,7 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, | |||
1046 | if (tx->u.tx.extra_frag) { | 1084 | if (tx->u.tx.extra_frag) { |
1047 | control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS | | 1085 | control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS | |
1048 | IEEE80211_TXCTL_USE_CTS_PROTECT | | 1086 | IEEE80211_TXCTL_USE_CTS_PROTECT | |
1049 | IEEE80211_TXCTL_CLEAR_DST_MASK | | 1087 | IEEE80211_TXCTL_CLEAR_PS_FILT | |
1050 | IEEE80211_TXCTL_FIRST_FRAGMENT); | 1088 | IEEE80211_TXCTL_FIRST_FRAGMENT); |
1051 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | 1089 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { |
1052 | if (!tx->u.tx.extra_frag[i]) | 1090 | if (!tx->u.tx.extra_frag[i]) |
@@ -1054,8 +1092,8 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, | |||
1054 | if (__ieee80211_queue_stopped(local, control->queue)) | 1092 | if (__ieee80211_queue_stopped(local, control->queue)) |
1055 | return IEEE80211_TX_FRAG_AGAIN; | 1093 | return IEEE80211_TX_FRAG_AGAIN; |
1056 | if (i == tx->u.tx.num_extra_frag) { | 1094 | if (i == tx->u.tx.num_extra_frag) { |
1057 | control->tx_rate = tx->u.tx.last_frag_hwrate; | 1095 | control->tx_rate = tx->u.tx.last_frag_rate; |
1058 | control->rate = tx->u.tx.last_frag_rate; | 1096 | |
1059 | if (tx->flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG) | 1097 | if (tx->flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG) |
1060 | control->flags |= | 1098 | control->flags |= |
1061 | IEEE80211_TXCTL_RATE_CTRL_PROBE; | 1099 | IEEE80211_TXCTL_RATE_CTRL_PROBE; |
@@ -1089,7 +1127,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1089 | struct sta_info *sta; | 1127 | struct sta_info *sta; |
1090 | ieee80211_tx_handler *handler; | 1128 | ieee80211_tx_handler *handler; |
1091 | struct ieee80211_txrx_data tx; | 1129 | struct ieee80211_txrx_data tx; |
1092 | ieee80211_txrx_result res = TXRX_DROP, res_prepare; | 1130 | ieee80211_tx_result res = TX_DROP, res_prepare; |
1093 | int ret, i; | 1131 | int ret, i; |
1094 | 1132 | ||
1095 | WARN_ON(__ieee80211_queue_pending(local, control->queue)); | 1133 | WARN_ON(__ieee80211_queue_pending(local, control->queue)); |
@@ -1102,7 +1140,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1102 | /* initialises tx */ | 1140 | /* initialises tx */ |
1103 | res_prepare = __ieee80211_tx_prepare(&tx, skb, dev, control); | 1141 | res_prepare = __ieee80211_tx_prepare(&tx, skb, dev, control); |
1104 | 1142 | ||
1105 | if (res_prepare == TXRX_DROP) { | 1143 | if (res_prepare == TX_DROP) { |
1106 | dev_kfree_skb(skb); | 1144 | dev_kfree_skb(skb); |
1107 | return 0; | 1145 | return 0; |
1108 | } | 1146 | } |
@@ -1114,12 +1152,12 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1114 | rcu_read_lock(); | 1152 | rcu_read_lock(); |
1115 | 1153 | ||
1116 | sta = tx.sta; | 1154 | sta = tx.sta; |
1117 | tx.u.tx.mode = local->hw.conf.mode; | 1155 | tx.u.tx.channel = local->hw.conf.channel; |
1118 | 1156 | ||
1119 | for (handler = local->tx_handlers; *handler != NULL; | 1157 | for (handler = ieee80211_tx_handlers; *handler != NULL; |
1120 | handler++) { | 1158 | handler++) { |
1121 | res = (*handler)(&tx); | 1159 | res = (*handler)(&tx); |
1122 | if (res != TXRX_CONTINUE) | 1160 | if (res != TX_CONTINUE) |
1123 | break; | 1161 | break; |
1124 | } | 1162 | } |
1125 | 1163 | ||
@@ -1128,12 +1166,12 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1128 | if (sta) | 1166 | if (sta) |
1129 | sta_info_put(sta); | 1167 | sta_info_put(sta); |
1130 | 1168 | ||
1131 | if (unlikely(res == TXRX_DROP)) { | 1169 | if (unlikely(res == TX_DROP)) { |
1132 | I802_DEBUG_INC(local->tx_handlers_drop); | 1170 | I802_DEBUG_INC(local->tx_handlers_drop); |
1133 | goto drop; | 1171 | goto drop; |
1134 | } | 1172 | } |
1135 | 1173 | ||
1136 | if (unlikely(res == TXRX_QUEUED)) { | 1174 | if (unlikely(res == TX_QUEUED)) { |
1137 | I802_DEBUG_INC(local->tx_handlers_queued); | 1175 | I802_DEBUG_INC(local->tx_handlers_queued); |
1138 | rcu_read_unlock(); | 1176 | rcu_read_unlock(); |
1139 | return 0; | 1177 | return 0; |
@@ -1151,7 +1189,6 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1151 | } else { | 1189 | } else { |
1152 | next_len = 0; | 1190 | next_len = 0; |
1153 | tx.u.tx.rate = tx.u.tx.last_frag_rate; | 1191 | tx.u.tx.rate = tx.u.tx.last_frag_rate; |
1154 | tx.u.tx.last_frag_hwrate = tx.u.tx.rate->val; | ||
1155 | } | 1192 | } |
1156 | dur = ieee80211_duration(&tx, 0, next_len); | 1193 | dur = ieee80211_duration(&tx, 0, next_len); |
1157 | hdr->duration_id = cpu_to_le16(dur); | 1194 | hdr->duration_id = cpu_to_le16(dur); |
@@ -1188,7 +1225,6 @@ retry: | |||
1188 | store->skb = skb; | 1225 | store->skb = skb; |
1189 | store->extra_frag = tx.u.tx.extra_frag; | 1226 | store->extra_frag = tx.u.tx.extra_frag; |
1190 | store->num_extra_frag = tx.u.tx.num_extra_frag; | 1227 | store->num_extra_frag = tx.u.tx.num_extra_frag; |
1191 | store->last_frag_hwrate = tx.u.tx.last_frag_hwrate; | ||
1192 | store->last_frag_rate = tx.u.tx.last_frag_rate; | 1228 | store->last_frag_rate = tx.u.tx.last_frag_rate; |
1193 | store->last_frag_rate_ctrl_probe = | 1229 | store->last_frag_rate_ctrl_probe = |
1194 | !!(tx.flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG); | 1230 | !!(tx.flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG); |
@@ -1260,6 +1296,8 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, | |||
1260 | control.flags |= IEEE80211_TXCTL_REQUEUE; | 1296 | control.flags |= IEEE80211_TXCTL_REQUEUE; |
1261 | if (pkt_data->flags & IEEE80211_TXPD_EAPOL_FRAME) | 1297 | if (pkt_data->flags & IEEE80211_TXPD_EAPOL_FRAME) |
1262 | control.flags |= IEEE80211_TXCTL_EAPOL_FRAME; | 1298 | control.flags |= IEEE80211_TXCTL_EAPOL_FRAME; |
1299 | if (pkt_data->flags & IEEE80211_TXPD_AMPDU) | ||
1300 | control.flags |= IEEE80211_TXCTL_AMPDU; | ||
1263 | control.queue = pkt_data->queue; | 1301 | control.queue = pkt_data->queue; |
1264 | 1302 | ||
1265 | ret = ieee80211_tx(odev, skb, &control); | 1303 | ret = ieee80211_tx(odev, skb, &control); |
@@ -1409,10 +1447,17 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1409 | goto fail; | 1447 | goto fail; |
1410 | } | 1448 | } |
1411 | 1449 | ||
1412 | sta = sta_info_get(local, hdr.addr1); | 1450 | /* |
1413 | if (sta) { | 1451 | * There's no need to try to look up the destination |
1414 | sta_flags = sta->flags; | 1452 | * if it is a multicast address (which can only happen |
1415 | sta_info_put(sta); | 1453 | * in AP mode) |
1454 | */ | ||
1455 | if (!is_multicast_ether_addr(hdr.addr1)) { | ||
1456 | sta = sta_info_get(local, hdr.addr1); | ||
1457 | if (sta) { | ||
1458 | sta_flags = sta->flags; | ||
1459 | sta_info_put(sta); | ||
1460 | } | ||
1416 | } | 1461 | } |
1417 | 1462 | ||
1418 | /* receiver is QoS enabled, use a QoS type frame */ | 1463 | /* receiver is QoS enabled, use a QoS type frame */ |
@@ -1422,10 +1467,10 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1422 | } | 1467 | } |
1423 | 1468 | ||
1424 | /* | 1469 | /* |
1425 | * If port access control is enabled, drop frames to unauthorised | 1470 | * Drop unicast frames to unauthorised stations unless they are |
1426 | * stations unless they are EAPOL frames from the local station. | 1471 | * EAPOL frames from the local station. |
1427 | */ | 1472 | */ |
1428 | if (unlikely(sdata->ieee802_1x_pac && | 1473 | if (unlikely(!is_multicast_ether_addr(hdr.addr1) && |
1429 | !(sta_flags & WLAN_STA_AUTHORIZED) && | 1474 | !(sta_flags & WLAN_STA_AUTHORIZED) && |
1430 | !(ethertype == ETH_P_PAE && | 1475 | !(ethertype == ETH_P_PAE && |
1431 | compare_ether_addr(dev->dev_addr, | 1476 | compare_ether_addr(dev->dev_addr, |
@@ -1598,7 +1643,6 @@ void ieee80211_tx_pending(unsigned long data) | |||
1598 | tx.u.tx.control = &store->control; | 1643 | tx.u.tx.control = &store->control; |
1599 | tx.u.tx.extra_frag = store->extra_frag; | 1644 | tx.u.tx.extra_frag = store->extra_frag; |
1600 | tx.u.tx.num_extra_frag = store->num_extra_frag; | 1645 | tx.u.tx.num_extra_frag = store->num_extra_frag; |
1601 | tx.u.tx.last_frag_hwrate = store->last_frag_hwrate; | ||
1602 | tx.u.tx.last_frag_rate = store->last_frag_rate; | 1646 | tx.u.tx.last_frag_rate = store->last_frag_rate; |
1603 | tx.flags = 0; | 1647 | tx.flags = 0; |
1604 | if (store->last_frag_rate_ctrl_probe) | 1648 | if (store->last_frag_rate_ctrl_probe) |
@@ -1701,6 +1745,9 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1701 | struct ieee80211_if_ap *ap = NULL; | 1745 | struct ieee80211_if_ap *ap = NULL; |
1702 | struct rate_selection rsel; | 1746 | struct rate_selection rsel; |
1703 | struct beacon_data *beacon; | 1747 | struct beacon_data *beacon; |
1748 | struct ieee80211_supported_band *sband; | ||
1749 | |||
1750 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
1704 | 1751 | ||
1705 | rcu_read_lock(); | 1752 | rcu_read_lock(); |
1706 | 1753 | ||
@@ -1739,8 +1786,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1739 | beacon->tail_len); | 1786 | beacon->tail_len); |
1740 | 1787 | ||
1741 | if (control) { | 1788 | if (control) { |
1742 | rate_control_get_rate(local->mdev, local->oper_hw_mode, skb, | 1789 | rate_control_get_rate(local->mdev, sband, skb, &rsel); |
1743 | &rsel); | ||
1744 | if (!rsel.rate) { | 1790 | if (!rsel.rate) { |
1745 | if (net_ratelimit()) { | 1791 | if (net_ratelimit()) { |
1746 | printk(KERN_DEBUG "%s: ieee80211_beacon_get: " | 1792 | printk(KERN_DEBUG "%s: ieee80211_beacon_get: " |
@@ -1753,15 +1799,14 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1753 | } | 1799 | } |
1754 | 1800 | ||
1755 | control->vif = vif; | 1801 | control->vif = vif; |
1756 | control->tx_rate = | 1802 | control->tx_rate = rsel.rate; |
1757 | (sdata->bss_conf.use_short_preamble && | 1803 | if (sdata->bss_conf.use_short_preamble && |
1758 | (rsel.rate->flags & IEEE80211_RATE_PREAMBLE2)) ? | 1804 | rsel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) |
1759 | rsel.rate->val2 : rsel.rate->val; | 1805 | control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; |
1760 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; | 1806 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; |
1761 | control->power_level = local->hw.conf.power_level; | ||
1762 | control->flags |= IEEE80211_TXCTL_NO_ACK; | 1807 | control->flags |= IEEE80211_TXCTL_NO_ACK; |
1763 | control->retry_limit = 1; | 1808 | control->retry_limit = 1; |
1764 | control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK; | 1809 | control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; |
1765 | } | 1810 | } |
1766 | 1811 | ||
1767 | ap->num_beacons++; | 1812 | ap->num_beacons++; |
@@ -1815,7 +1860,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
1815 | struct sta_info *sta; | 1860 | struct sta_info *sta; |
1816 | ieee80211_tx_handler *handler; | 1861 | ieee80211_tx_handler *handler; |
1817 | struct ieee80211_txrx_data tx; | 1862 | struct ieee80211_txrx_data tx; |
1818 | ieee80211_txrx_result res = TXRX_DROP; | 1863 | ieee80211_tx_result res = TX_DROP; |
1819 | struct net_device *bdev; | 1864 | struct net_device *bdev; |
1820 | struct ieee80211_sub_if_data *sdata; | 1865 | struct ieee80211_sub_if_data *sdata; |
1821 | struct ieee80211_if_ap *bss = NULL; | 1866 | struct ieee80211_if_ap *bss = NULL; |
@@ -1863,20 +1908,20 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
1863 | } | 1908 | } |
1864 | sta = tx.sta; | 1909 | sta = tx.sta; |
1865 | tx.flags |= IEEE80211_TXRXD_TXPS_BUFFERED; | 1910 | tx.flags |= IEEE80211_TXRXD_TXPS_BUFFERED; |
1866 | tx.u.tx.mode = local->hw.conf.mode; | 1911 | tx.u.tx.channel = local->hw.conf.channel; |
1867 | 1912 | ||
1868 | for (handler = local->tx_handlers; *handler != NULL; handler++) { | 1913 | for (handler = ieee80211_tx_handlers; *handler != NULL; handler++) { |
1869 | res = (*handler)(&tx); | 1914 | res = (*handler)(&tx); |
1870 | if (res == TXRX_DROP || res == TXRX_QUEUED) | 1915 | if (res == TX_DROP || res == TX_QUEUED) |
1871 | break; | 1916 | break; |
1872 | } | 1917 | } |
1873 | skb = tx.skb; /* handlers are allowed to change skb */ | 1918 | skb = tx.skb; /* handlers are allowed to change skb */ |
1874 | 1919 | ||
1875 | if (res == TXRX_DROP) { | 1920 | if (res == TX_DROP) { |
1876 | I802_DEBUG_INC(local->tx_handlers_drop); | 1921 | I802_DEBUG_INC(local->tx_handlers_drop); |
1877 | dev_kfree_skb(skb); | 1922 | dev_kfree_skb(skb); |
1878 | skb = NULL; | 1923 | skb = NULL; |
1879 | } else if (res == TXRX_QUEUED) { | 1924 | } else if (res == TX_QUEUED) { |
1880 | I802_DEBUG_INC(local->tx_handlers_queued); | 1925 | I802_DEBUG_INC(local->tx_handlers_queued); |
1881 | skb = NULL; | 1926 | skb = NULL; |
1882 | } | 1927 | } |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 5e631ce98d7e..f64804fed0a9 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -41,92 +41,6 @@ const unsigned char bridge_tunnel_header[] = | |||
41 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; | 41 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; |
42 | 42 | ||
43 | 43 | ||
44 | static int rate_list_match(const int *rate_list, int rate) | ||
45 | { | ||
46 | int i; | ||
47 | |||
48 | if (!rate_list) | ||
49 | return 0; | ||
50 | |||
51 | for (i = 0; rate_list[i] >= 0; i++) | ||
52 | if (rate_list[i] == rate) | ||
53 | return 1; | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | void ieee80211_prepare_rates(struct ieee80211_local *local, | ||
59 | struct ieee80211_hw_mode *mode) | ||
60 | { | ||
61 | int i; | ||
62 | |||
63 | for (i = 0; i < mode->num_rates; i++) { | ||
64 | struct ieee80211_rate *rate = &mode->rates[i]; | ||
65 | |||
66 | rate->flags &= ~(IEEE80211_RATE_SUPPORTED | | ||
67 | IEEE80211_RATE_BASIC); | ||
68 | |||
69 | if (local->supp_rates[mode->mode]) { | ||
70 | if (!rate_list_match(local->supp_rates[mode->mode], | ||
71 | rate->rate)) | ||
72 | continue; | ||
73 | } | ||
74 | |||
75 | rate->flags |= IEEE80211_RATE_SUPPORTED; | ||
76 | |||
77 | /* Use configured basic rate set if it is available. If not, | ||
78 | * use defaults that are sane for most cases. */ | ||
79 | if (local->basic_rates[mode->mode]) { | ||
80 | if (rate_list_match(local->basic_rates[mode->mode], | ||
81 | rate->rate)) | ||
82 | rate->flags |= IEEE80211_RATE_BASIC; | ||
83 | } else switch (mode->mode) { | ||
84 | case MODE_IEEE80211A: | ||
85 | if (rate->rate == 60 || rate->rate == 120 || | ||
86 | rate->rate == 240) | ||
87 | rate->flags |= IEEE80211_RATE_BASIC; | ||
88 | break; | ||
89 | case MODE_IEEE80211B: | ||
90 | if (rate->rate == 10 || rate->rate == 20) | ||
91 | rate->flags |= IEEE80211_RATE_BASIC; | ||
92 | break; | ||
93 | case MODE_IEEE80211G: | ||
94 | if (rate->rate == 10 || rate->rate == 20 || | ||
95 | rate->rate == 55 || rate->rate == 110) | ||
96 | rate->flags |= IEEE80211_RATE_BASIC; | ||
97 | break; | ||
98 | case NUM_IEEE80211_MODES: | ||
99 | /* not useful */ | ||
100 | break; | ||
101 | } | ||
102 | |||
103 | /* Set ERP and MANDATORY flags based on phymode */ | ||
104 | switch (mode->mode) { | ||
105 | case MODE_IEEE80211A: | ||
106 | if (rate->rate == 60 || rate->rate == 120 || | ||
107 | rate->rate == 240) | ||
108 | rate->flags |= IEEE80211_RATE_MANDATORY; | ||
109 | break; | ||
110 | case MODE_IEEE80211B: | ||
111 | if (rate->rate == 10) | ||
112 | rate->flags |= IEEE80211_RATE_MANDATORY; | ||
113 | break; | ||
114 | case MODE_IEEE80211G: | ||
115 | if (rate->rate == 10 || rate->rate == 20 || | ||
116 | rate->rate == 55 || rate->rate == 110 || | ||
117 | rate->rate == 60 || rate->rate == 120 || | ||
118 | rate->rate == 240) | ||
119 | rate->flags |= IEEE80211_RATE_MANDATORY; | ||
120 | break; | ||
121 | case NUM_IEEE80211_MODES: | ||
122 | /* not useful */ | ||
123 | break; | ||
124 | } | ||
125 | if (ieee80211_is_erp_rate(mode->mode, rate->rate)) | ||
126 | rate->flags |= IEEE80211_RATE_ERP; | ||
127 | } | ||
128 | } | ||
129 | |||
130 | u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, | 44 | u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len, |
131 | enum ieee80211_if_types type) | 45 | enum ieee80211_if_types type) |
132 | { | 46 | { |
@@ -262,7 +176,7 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, | |||
262 | * DIV_ROUND_UP() operations. | 176 | * DIV_ROUND_UP() operations. |
263 | */ | 177 | */ |
264 | 178 | ||
265 | if (local->hw.conf.phymode == MODE_IEEE80211A || erp) { | 179 | if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ || erp) { |
266 | /* | 180 | /* |
267 | * OFDM: | 181 | * OFDM: |
268 | * | 182 | * |
@@ -304,15 +218,19 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, | |||
304 | /* Exported duration function for driver use */ | 218 | /* Exported duration function for driver use */ |
305 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, | 219 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, |
306 | struct ieee80211_vif *vif, | 220 | struct ieee80211_vif *vif, |
307 | size_t frame_len, int rate) | 221 | size_t frame_len, |
222 | struct ieee80211_rate *rate) | ||
308 | { | 223 | { |
309 | struct ieee80211_local *local = hw_to_local(hw); | 224 | struct ieee80211_local *local = hw_to_local(hw); |
310 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | 225 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
311 | u16 dur; | 226 | u16 dur; |
312 | int erp; | 227 | int erp; |
313 | 228 | ||
314 | erp = ieee80211_is_erp_rate(hw->conf.phymode, rate); | 229 | erp = 0; |
315 | dur = ieee80211_frame_duration(local, frame_len, rate, erp, | 230 | if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) |
231 | erp = rate->flags & IEEE80211_RATE_ERP_G; | ||
232 | |||
233 | dur = ieee80211_frame_duration(local, frame_len, rate->bitrate, erp, | ||
316 | sdata->bss_conf.use_short_preamble); | 234 | sdata->bss_conf.use_short_preamble); |
317 | 235 | ||
318 | return cpu_to_le16(dur); | 236 | return cpu_to_le16(dur); |
@@ -332,17 +250,20 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, | |||
332 | 250 | ||
333 | short_preamble = sdata->bss_conf.use_short_preamble; | 251 | short_preamble = sdata->bss_conf.use_short_preamble; |
334 | 252 | ||
335 | rate = frame_txctl->rts_rate; | 253 | rate = frame_txctl->rts_cts_rate; |
336 | erp = !!(rate->flags & IEEE80211_RATE_ERP); | 254 | |
255 | erp = 0; | ||
256 | if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) | ||
257 | erp = rate->flags & IEEE80211_RATE_ERP_G; | ||
337 | 258 | ||
338 | /* CTS duration */ | 259 | /* CTS duration */ |
339 | dur = ieee80211_frame_duration(local, 10, rate->rate, | 260 | dur = ieee80211_frame_duration(local, 10, rate->bitrate, |
340 | erp, short_preamble); | 261 | erp, short_preamble); |
341 | /* Data frame duration */ | 262 | /* Data frame duration */ |
342 | dur += ieee80211_frame_duration(local, frame_len, rate->rate, | 263 | dur += ieee80211_frame_duration(local, frame_len, rate->bitrate, |
343 | erp, short_preamble); | 264 | erp, short_preamble); |
344 | /* ACK duration */ | 265 | /* ACK duration */ |
345 | dur += ieee80211_frame_duration(local, 10, rate->rate, | 266 | dur += ieee80211_frame_duration(local, 10, rate->bitrate, |
346 | erp, short_preamble); | 267 | erp, short_preamble); |
347 | 268 | ||
348 | return cpu_to_le16(dur); | 269 | return cpu_to_le16(dur); |
@@ -363,15 +284,17 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, | |||
363 | 284 | ||
364 | short_preamble = sdata->bss_conf.use_short_preamble; | 285 | short_preamble = sdata->bss_conf.use_short_preamble; |
365 | 286 | ||
366 | rate = frame_txctl->rts_rate; | 287 | rate = frame_txctl->rts_cts_rate; |
367 | erp = !!(rate->flags & IEEE80211_RATE_ERP); | 288 | erp = 0; |
289 | if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) | ||
290 | erp = rate->flags & IEEE80211_RATE_ERP_G; | ||
368 | 291 | ||
369 | /* Data frame duration */ | 292 | /* Data frame duration */ |
370 | dur = ieee80211_frame_duration(local, frame_len, rate->rate, | 293 | dur = ieee80211_frame_duration(local, frame_len, rate->bitrate, |
371 | erp, short_preamble); | 294 | erp, short_preamble); |
372 | if (!(frame_txctl->flags & IEEE80211_TXCTL_NO_ACK)) { | 295 | if (!(frame_txctl->flags & IEEE80211_TXCTL_NO_ACK)) { |
373 | /* ACK duration */ | 296 | /* ACK duration */ |
374 | dur += ieee80211_frame_duration(local, 10, rate->rate, | 297 | dur += ieee80211_frame_duration(local, 10, rate->bitrate, |
375 | erp, short_preamble); | 298 | erp, short_preamble); |
376 | } | 299 | } |
377 | 300 | ||
@@ -379,27 +302,6 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, | |||
379 | } | 302 | } |
380 | EXPORT_SYMBOL(ieee80211_ctstoself_duration); | 303 | EXPORT_SYMBOL(ieee80211_ctstoself_duration); |
381 | 304 | ||
382 | struct ieee80211_rate * | ||
383 | ieee80211_get_rate(struct ieee80211_local *local, int phymode, int hw_rate) | ||
384 | { | ||
385 | struct ieee80211_hw_mode *mode; | ||
386 | int r; | ||
387 | |||
388 | list_for_each_entry(mode, &local->modes_list, list) { | ||
389 | if (mode->mode != phymode) | ||
390 | continue; | ||
391 | for (r = 0; r < mode->num_rates; r++) { | ||
392 | struct ieee80211_rate *rate = &mode->rates[r]; | ||
393 | if (rate->val == hw_rate || | ||
394 | (rate->flags & IEEE80211_RATE_PREAMBLE2 && | ||
395 | rate->val2 == hw_rate)) | ||
396 | return rate; | ||
397 | } | ||
398 | } | ||
399 | |||
400 | return NULL; | ||
401 | } | ||
402 | |||
403 | void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue) | 305 | void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue) |
404 | { | 306 | { |
405 | struct ieee80211_local *local = hw_to_local(hw); | 307 | struct ieee80211_local *local = hw_to_local(hw); |
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index a0cff72a580b..a33ef5cfa9ad 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c | |||
@@ -305,13 +305,13 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) | |||
305 | return NULL; | 305 | return NULL; |
306 | } | 306 | } |
307 | 307 | ||
308 | ieee80211_txrx_result | 308 | ieee80211_rx_result |
309 | ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx) | 309 | ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx) |
310 | { | 310 | { |
311 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA && | 311 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA && |
312 | ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || | 312 | ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || |
313 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) | 313 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) |
314 | return TXRX_CONTINUE; | 314 | return RX_CONTINUE; |
315 | 315 | ||
316 | if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { | 316 | if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { |
317 | if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) { | 317 | if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) { |
@@ -320,7 +320,7 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx) | |||
320 | printk(KERN_DEBUG "%s: RX WEP frame, decrypt " | 320 | printk(KERN_DEBUG "%s: RX WEP frame, decrypt " |
321 | "failed\n", rx->dev->name); | 321 | "failed\n", rx->dev->name); |
322 | #endif /* CONFIG_MAC80211_DEBUG */ | 322 | #endif /* CONFIG_MAC80211_DEBUG */ |
323 | return TXRX_DROP; | 323 | return RX_DROP_UNUSABLE; |
324 | } | 324 | } |
325 | } else if (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) { | 325 | } else if (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) { |
326 | ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); | 326 | ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); |
@@ -328,7 +328,7 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx) | |||
328 | skb_trim(rx->skb, rx->skb->len - 4); | 328 | skb_trim(rx->skb, rx->skb->len - 4); |
329 | } | 329 | } |
330 | 330 | ||
331 | return TXRX_CONTINUE; | 331 | return RX_CONTINUE; |
332 | } | 332 | } |
333 | 333 | ||
334 | static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb) | 334 | static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb) |
@@ -346,7 +346,7 @@ static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb) | |||
346 | return 0; | 346 | return 0; |
347 | } | 347 | } |
348 | 348 | ||
349 | ieee80211_txrx_result | 349 | ieee80211_tx_result |
350 | ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx) | 350 | ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx) |
351 | { | 351 | { |
352 | tx->u.tx.control->iv_len = WEP_IV_LEN; | 352 | tx->u.tx.control->iv_len = WEP_IV_LEN; |
@@ -355,7 +355,7 @@ ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx) | |||
355 | 355 | ||
356 | if (wep_encrypt_skb(tx, tx->skb) < 0) { | 356 | if (wep_encrypt_skb(tx, tx->skb) < 0) { |
357 | I802_DEBUG_INC(tx->local->tx_handlers_drop_wep); | 357 | I802_DEBUG_INC(tx->local->tx_handlers_drop_wep); |
358 | return TXRX_DROP; | 358 | return TX_DROP; |
359 | } | 359 | } |
360 | 360 | ||
361 | if (tx->u.tx.extra_frag) { | 361 | if (tx->u.tx.extra_frag) { |
@@ -364,10 +364,10 @@ ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx) | |||
364 | if (wep_encrypt_skb(tx, tx->u.tx.extra_frag[i]) < 0) { | 364 | if (wep_encrypt_skb(tx, tx->u.tx.extra_frag[i]) < 0) { |
365 | I802_DEBUG_INC(tx->local-> | 365 | I802_DEBUG_INC(tx->local-> |
366 | tx_handlers_drop_wep); | 366 | tx_handlers_drop_wep); |
367 | return TXRX_DROP; | 367 | return TX_DROP; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
372 | return TXRX_CONTINUE; | 372 | return TX_CONTINUE; |
373 | } | 373 | } |
diff --git a/net/mac80211/wep.h b/net/mac80211/wep.h index 785fbb4e0dd7..43aef50cd0d6 100644 --- a/net/mac80211/wep.h +++ b/net/mac80211/wep.h | |||
@@ -28,9 +28,9 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, | |||
28 | struct ieee80211_key *key); | 28 | struct ieee80211_key *key); |
29 | u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); | 29 | u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); |
30 | 30 | ||
31 | ieee80211_txrx_result | 31 | ieee80211_rx_result |
32 | ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx); | 32 | ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx); |
33 | ieee80211_txrx_result | 33 | ieee80211_tx_result |
34 | ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx); | 34 | ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx); |
35 | 35 | ||
36 | #endif /* WEP_H */ | 36 | #endif /* WEP_H */ |
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index 4e236599dd31..8cc036decc82 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c | |||
@@ -19,10 +19,13 @@ | |||
19 | #include "wme.h" | 19 | #include "wme.h" |
20 | 20 | ||
21 | /* maximum number of hardware queues we support. */ | 21 | /* maximum number of hardware queues we support. */ |
22 | #define TC_80211_MAX_QUEUES 8 | 22 | #define TC_80211_MAX_QUEUES 16 |
23 | |||
24 | const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; | ||
23 | 25 | ||
24 | struct ieee80211_sched_data | 26 | struct ieee80211_sched_data |
25 | { | 27 | { |
28 | unsigned long qdisc_pool[BITS_TO_LONGS(TC_80211_MAX_QUEUES)]; | ||
26 | struct tcf_proto *filter_list; | 29 | struct tcf_proto *filter_list; |
27 | struct Qdisc *queues[TC_80211_MAX_QUEUES]; | 30 | struct Qdisc *queues[TC_80211_MAX_QUEUES]; |
28 | struct sk_buff_head requeued[TC_80211_MAX_QUEUES]; | 31 | struct sk_buff_head requeued[TC_80211_MAX_QUEUES]; |
@@ -98,7 +101,6 @@ static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd) | |||
98 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 101 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
99 | unsigned short fc = le16_to_cpu(hdr->frame_control); | 102 | unsigned short fc = le16_to_cpu(hdr->frame_control); |
100 | int qos; | 103 | int qos; |
101 | const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; | ||
102 | 104 | ||
103 | /* see if frame is data or non data frame */ | 105 | /* see if frame is data or non data frame */ |
104 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) { | 106 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) { |
@@ -146,9 +148,25 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd) | |||
146 | unsigned short fc = le16_to_cpu(hdr->frame_control); | 148 | unsigned short fc = le16_to_cpu(hdr->frame_control); |
147 | struct Qdisc *qdisc; | 149 | struct Qdisc *qdisc; |
148 | int err, queue; | 150 | int err, queue; |
151 | struct sta_info *sta; | ||
152 | u8 tid; | ||
149 | 153 | ||
150 | if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) { | 154 | if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) { |
151 | skb_queue_tail(&q->requeued[pkt_data->queue], skb); | 155 | queue = pkt_data->queue; |
156 | sta = sta_info_get(local, hdr->addr1); | ||
157 | tid = skb->priority & QOS_CONTROL_TAG1D_MASK; | ||
158 | if (sta) { | ||
159 | int ampdu_queue = sta->tid_to_tx_q[tid]; | ||
160 | if ((ampdu_queue < local->hw.queues) && | ||
161 | test_bit(ampdu_queue, q->qdisc_pool)) { | ||
162 | queue = ampdu_queue; | ||
163 | pkt_data->flags |= IEEE80211_TXPD_AMPDU; | ||
164 | } else { | ||
165 | pkt_data->flags &= ~IEEE80211_TXPD_AMPDU; | ||
166 | } | ||
167 | sta_info_put(sta); | ||
168 | } | ||
169 | skb_queue_tail(&q->requeued[queue], skb); | ||
152 | qd->q.qlen++; | 170 | qd->q.qlen++; |
153 | return 0; | 171 | return 0; |
154 | } | 172 | } |
@@ -159,14 +177,28 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd) | |||
159 | */ | 177 | */ |
160 | if (WLAN_FC_IS_QOS_DATA(fc)) { | 178 | if (WLAN_FC_IS_QOS_DATA(fc)) { |
161 | u8 *p = skb->data + ieee80211_get_hdrlen(fc) - 2; | 179 | u8 *p = skb->data + ieee80211_get_hdrlen(fc) - 2; |
162 | u8 qos_hdr = skb->priority & QOS_CONTROL_TAG1D_MASK; | 180 | u8 ack_policy = 0; |
181 | tid = skb->priority & QOS_CONTROL_TAG1D_MASK; | ||
163 | if (local->wifi_wme_noack_test) | 182 | if (local->wifi_wme_noack_test) |
164 | qos_hdr |= QOS_CONTROL_ACK_POLICY_NOACK << | 183 | ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK << |
165 | QOS_CONTROL_ACK_POLICY_SHIFT; | 184 | QOS_CONTROL_ACK_POLICY_SHIFT; |
166 | /* qos header is 2 bytes, second reserved */ | 185 | /* qos header is 2 bytes, second reserved */ |
167 | *p = qos_hdr; | 186 | *p = ack_policy | tid; |
168 | p++; | 187 | p++; |
169 | *p = 0; | 188 | *p = 0; |
189 | |||
190 | sta = sta_info_get(local, hdr->addr1); | ||
191 | if (sta) { | ||
192 | int ampdu_queue = sta->tid_to_tx_q[tid]; | ||
193 | if ((ampdu_queue < local->hw.queues) && | ||
194 | test_bit(ampdu_queue, q->qdisc_pool)) { | ||
195 | queue = ampdu_queue; | ||
196 | pkt_data->flags |= IEEE80211_TXPD_AMPDU; | ||
197 | } else { | ||
198 | pkt_data->flags &= ~IEEE80211_TXPD_AMPDU; | ||
199 | } | ||
200 | sta_info_put(sta); | ||
201 | } | ||
170 | } | 202 | } |
171 | 203 | ||
172 | if (unlikely(queue >= local->hw.queues)) { | 204 | if (unlikely(queue >= local->hw.queues)) { |
@@ -184,6 +216,7 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd) | |||
184 | kfree_skb(skb); | 216 | kfree_skb(skb); |
185 | err = NET_XMIT_DROP; | 217 | err = NET_XMIT_DROP; |
186 | } else { | 218 | } else { |
219 | tid = skb->priority & QOS_CONTROL_TAG1D_MASK; | ||
187 | pkt_data->queue = (unsigned int) queue; | 220 | pkt_data->queue = (unsigned int) queue; |
188 | qdisc = q->queues[queue]; | 221 | qdisc = q->queues[queue]; |
189 | err = qdisc->enqueue(skb, qdisc); | 222 | err = qdisc->enqueue(skb, qdisc); |
@@ -235,10 +268,11 @@ static struct sk_buff *wme_qdiscop_dequeue(struct Qdisc* qd) | |||
235 | /* check all the h/w queues in numeric/priority order */ | 268 | /* check all the h/w queues in numeric/priority order */ |
236 | for (queue = 0; queue < hw->queues; queue++) { | 269 | for (queue = 0; queue < hw->queues; queue++) { |
237 | /* see if there is room in this hardware queue */ | 270 | /* see if there is room in this hardware queue */ |
238 | if (test_bit(IEEE80211_LINK_STATE_XOFF, | 271 | if ((test_bit(IEEE80211_LINK_STATE_XOFF, |
239 | &local->state[queue]) || | 272 | &local->state[queue])) || |
240 | test_bit(IEEE80211_LINK_STATE_PENDING, | 273 | (test_bit(IEEE80211_LINK_STATE_PENDING, |
241 | &local->state[queue])) | 274 | &local->state[queue])) || |
275 | (!test_bit(queue, q->qdisc_pool))) | ||
242 | continue; | 276 | continue; |
243 | 277 | ||
244 | /* there is space - try and get a frame */ | 278 | /* there is space - try and get a frame */ |
@@ -360,6 +394,10 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt) | |||
360 | } | 394 | } |
361 | } | 395 | } |
362 | 396 | ||
397 | /* reserve all legacy QoS queues */ | ||
398 | for (i = 0; i < min(IEEE80211_TX_QUEUE_DATA4, queues); i++) | ||
399 | set_bit(i, q->qdisc_pool); | ||
400 | |||
363 | return err; | 401 | return err; |
364 | } | 402 | } |
365 | 403 | ||
@@ -605,3 +643,80 @@ void ieee80211_wme_unregister(void) | |||
605 | { | 643 | { |
606 | unregister_qdisc(&wme_qdisc_ops); | 644 | unregister_qdisc(&wme_qdisc_ops); |
607 | } | 645 | } |
646 | |||
647 | int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, | ||
648 | struct sta_info *sta, u16 tid) | ||
649 | { | ||
650 | int i; | ||
651 | struct ieee80211_sched_data *q = | ||
652 | qdisc_priv(local->mdev->qdisc_sleeping); | ||
653 | DECLARE_MAC_BUF(mac); | ||
654 | |||
655 | /* prepare the filter and save it for the SW queue | ||
656 | * matching the recieved HW queue */ | ||
657 | |||
658 | /* try to get a Qdisc from the pool */ | ||
659 | for (i = IEEE80211_TX_QUEUE_BEACON; i < local->hw.queues; i++) | ||
660 | if (!test_and_set_bit(i, q->qdisc_pool)) { | ||
661 | ieee80211_stop_queue(local_to_hw(local), i); | ||
662 | sta->tid_to_tx_q[tid] = i; | ||
663 | |||
664 | /* IF there are already pending packets | ||
665 | * on this tid first we need to drain them | ||
666 | * on the previous queue | ||
667 | * since HT is strict in order */ | ||
668 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
669 | if (net_ratelimit()) | ||
670 | printk(KERN_DEBUG "allocated aggregation queue" | ||
671 | " %d tid %d addr %s pool=0x%lX", | ||
672 | i, tid, print_mac(mac, sta->addr), | ||
673 | q->qdisc_pool[0]); | ||
674 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
675 | return 0; | ||
676 | } | ||
677 | |||
678 | return -EAGAIN; | ||
679 | } | ||
680 | |||
681 | /** | ||
682 | * the caller needs to hold local->mdev->queue_lock | ||
683 | */ | ||
684 | void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, | ||
685 | struct sta_info *sta, u16 tid, | ||
686 | u8 requeue) | ||
687 | { | ||
688 | struct ieee80211_sched_data *q = | ||
689 | qdisc_priv(local->mdev->qdisc_sleeping); | ||
690 | int agg_queue = sta->tid_to_tx_q[tid]; | ||
691 | |||
692 | /* return the qdisc to the pool */ | ||
693 | clear_bit(agg_queue, q->qdisc_pool); | ||
694 | sta->tid_to_tx_q[tid] = local->hw.queues; | ||
695 | |||
696 | if (requeue) | ||
697 | ieee80211_requeue(local, agg_queue); | ||
698 | else | ||
699 | q->queues[agg_queue]->ops->reset(q->queues[agg_queue]); | ||
700 | } | ||
701 | |||
702 | void ieee80211_requeue(struct ieee80211_local *local, int queue) | ||
703 | { | ||
704 | struct Qdisc *root_qd = local->mdev->qdisc_sleeping; | ||
705 | struct ieee80211_sched_data *q = qdisc_priv(root_qd); | ||
706 | struct Qdisc *qdisc = q->queues[queue]; | ||
707 | struct sk_buff *skb = NULL; | ||
708 | u32 len = qdisc->q.qlen; | ||
709 | |||
710 | if (!qdisc || !qdisc->dequeue) | ||
711 | return; | ||
712 | |||
713 | printk(KERN_DEBUG "requeue: qlen = %d\n", qdisc->q.qlen); | ||
714 | for (len = qdisc->q.qlen; len > 0; len--) { | ||
715 | skb = qdisc->dequeue(qdisc); | ||
716 | root_qd->q.qlen--; | ||
717 | /* packet will be classified again and */ | ||
718 | /* skb->packet_data->queue will be overridden if needed */ | ||
719 | if (skb) | ||
720 | wme_qdiscop_enqueue(skb, root_qd); | ||
721 | } | ||
722 | } | ||
diff --git a/net/mac80211/wme.h b/net/mac80211/wme.h index 76c713a6450c..fcc6b05508cc 100644 --- a/net/mac80211/wme.h +++ b/net/mac80211/wme.h | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #define QOS_CONTROL_TAG1D_MASK 0x07 | 25 | #define QOS_CONTROL_TAG1D_MASK 0x07 |
26 | 26 | ||
27 | extern const int ieee802_1d_to_ac[8]; | ||
28 | |||
27 | static inline int WLAN_FC_IS_QOS_DATA(u16 fc) | 29 | static inline int WLAN_FC_IS_QOS_DATA(u16 fc) |
28 | { | 30 | { |
29 | return (fc & 0x8C) == 0x88; | 31 | return (fc & 0x8C) == 0x88; |
@@ -32,7 +34,12 @@ static inline int WLAN_FC_IS_QOS_DATA(u16 fc) | |||
32 | #ifdef CONFIG_NET_SCHED | 34 | #ifdef CONFIG_NET_SCHED |
33 | void ieee80211_install_qdisc(struct net_device *dev); | 35 | void ieee80211_install_qdisc(struct net_device *dev); |
34 | int ieee80211_qdisc_installed(struct net_device *dev); | 36 | int ieee80211_qdisc_installed(struct net_device *dev); |
35 | 37 | int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, | |
38 | struct sta_info *sta, u16 tid); | ||
39 | void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, | ||
40 | struct sta_info *sta, u16 tid, | ||
41 | u8 requeue); | ||
42 | void ieee80211_requeue(struct ieee80211_local *local, int queue); | ||
36 | int ieee80211_wme_register(void); | 43 | int ieee80211_wme_register(void); |
37 | void ieee80211_wme_unregister(void); | 44 | void ieee80211_wme_unregister(void); |
38 | #else | 45 | #else |
@@ -43,7 +50,19 @@ static inline int ieee80211_qdisc_installed(struct net_device *dev) | |||
43 | { | 50 | { |
44 | return 0; | 51 | return 0; |
45 | } | 52 | } |
46 | 53 | static inline int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, | |
54 | struct sta_info *sta, u16 tid) | ||
55 | { | ||
56 | return -EAGAIN; | ||
57 | } | ||
58 | static inline void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, | ||
59 | struct sta_info *sta, u16 tid, | ||
60 | u8 requeue) | ||
61 | { | ||
62 | } | ||
63 | static inline void ieee80211_requeue(struct ieee80211_local *local, int queue) | ||
64 | { | ||
65 | } | ||
47 | static inline int ieee80211_wme_register(void) | 66 | static inline int ieee80211_wme_register(void) |
48 | { | 67 | { |
49 | return 0; | 68 | return 0; |
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index 6f04311cf0a0..b35e51c6ce0c 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c | |||
@@ -70,7 +70,7 @@ static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da, | |||
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | ieee80211_txrx_result | 73 | ieee80211_tx_result |
74 | ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) | 74 | ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) |
75 | { | 75 | { |
76 | u8 *data, *sa, *da, *key, *mic, qos_tid; | 76 | u8 *data, *sa, *da, *key, *mic, qos_tid; |
@@ -84,10 +84,10 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) | |||
84 | 84 | ||
85 | if (!tx->key || tx->key->conf.alg != ALG_TKIP || skb->len < 24 || | 85 | if (!tx->key || tx->key->conf.alg != ALG_TKIP || skb->len < 24 || |
86 | !WLAN_FC_DATA_PRESENT(fc)) | 86 | !WLAN_FC_DATA_PRESENT(fc)) |
87 | return TXRX_CONTINUE; | 87 | return TX_CONTINUE; |
88 | 88 | ||
89 | if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len)) | 89 | if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len)) |
90 | return TXRX_DROP; | 90 | return TX_DROP; |
91 | 91 | ||
92 | if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && | 92 | if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && |
93 | !(tx->flags & IEEE80211_TXRXD_FRAGMENTED) && | 93 | !(tx->flags & IEEE80211_TXRXD_FRAGMENTED) && |
@@ -95,7 +95,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) | |||
95 | !wpa_test) { | 95 | !wpa_test) { |
96 | /* hwaccel - with no need for preallocated room for Michael MIC | 96 | /* hwaccel - with no need for preallocated room for Michael MIC |
97 | */ | 97 | */ |
98 | return TXRX_CONTINUE; | 98 | return TX_CONTINUE; |
99 | } | 99 | } |
100 | 100 | ||
101 | if (skb_tailroom(skb) < MICHAEL_MIC_LEN) { | 101 | if (skb_tailroom(skb) < MICHAEL_MIC_LEN) { |
@@ -105,7 +105,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) | |||
105 | GFP_ATOMIC))) { | 105 | GFP_ATOMIC))) { |
106 | printk(KERN_DEBUG "%s: failed to allocate more memory " | 106 | printk(KERN_DEBUG "%s: failed to allocate more memory " |
107 | "for Michael MIC\n", tx->dev->name); | 107 | "for Michael MIC\n", tx->dev->name); |
108 | return TXRX_DROP; | 108 | return TX_DROP; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
@@ -119,11 +119,11 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx) | |||
119 | mic = skb_put(skb, MICHAEL_MIC_LEN); | 119 | mic = skb_put(skb, MICHAEL_MIC_LEN); |
120 | michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); | 120 | michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); |
121 | 121 | ||
122 | return TXRX_CONTINUE; | 122 | return TX_CONTINUE; |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | ieee80211_txrx_result | 126 | ieee80211_rx_result |
127 | ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) | 127 | ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) |
128 | { | 128 | { |
129 | u8 *data, *sa, *da, *key = NULL, qos_tid; | 129 | u8 *data, *sa, *da, *key = NULL, qos_tid; |
@@ -140,15 +140,15 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) | |||
140 | * No way to verify the MIC if the hardware stripped it | 140 | * No way to verify the MIC if the hardware stripped it |
141 | */ | 141 | */ |
142 | if (rx->u.rx.status->flag & RX_FLAG_MMIC_STRIPPED) | 142 | if (rx->u.rx.status->flag & RX_FLAG_MMIC_STRIPPED) |
143 | return TXRX_CONTINUE; | 143 | return RX_CONTINUE; |
144 | 144 | ||
145 | if (!rx->key || rx->key->conf.alg != ALG_TKIP || | 145 | if (!rx->key || rx->key->conf.alg != ALG_TKIP || |
146 | !(rx->fc & IEEE80211_FCTL_PROTECTED) || !WLAN_FC_DATA_PRESENT(fc)) | 146 | !(rx->fc & IEEE80211_FCTL_PROTECTED) || !WLAN_FC_DATA_PRESENT(fc)) |
147 | return TXRX_CONTINUE; | 147 | return RX_CONTINUE; |
148 | 148 | ||
149 | if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len) | 149 | if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len) |
150 | || data_len < MICHAEL_MIC_LEN) | 150 | || data_len < MICHAEL_MIC_LEN) |
151 | return TXRX_DROP; | 151 | return RX_DROP_UNUSABLE; |
152 | 152 | ||
153 | data_len -= MICHAEL_MIC_LEN; | 153 | data_len -= MICHAEL_MIC_LEN; |
154 | 154 | ||
@@ -162,14 +162,14 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) | |||
162 | michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); | 162 | michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); |
163 | if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) { | 163 | if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) { |
164 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) | 164 | if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) |
165 | return TXRX_DROP; | 165 | return RX_DROP_UNUSABLE; |
166 | 166 | ||
167 | printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from " | 167 | printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from " |
168 | "%s\n", rx->dev->name, print_mac(mac, sa)); | 168 | "%s\n", rx->dev->name, print_mac(mac, sa)); |
169 | 169 | ||
170 | mac80211_ev_michael_mic_failure(rx->dev, rx->key->conf.keyidx, | 170 | mac80211_ev_michael_mic_failure(rx->dev, rx->key->conf.keyidx, |
171 | (void *) skb->data); | 171 | (void *) skb->data); |
172 | return TXRX_DROP; | 172 | return RX_DROP_UNUSABLE; |
173 | } | 173 | } |
174 | 174 | ||
175 | /* remove Michael MIC from payload */ | 175 | /* remove Michael MIC from payload */ |
@@ -179,7 +179,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx) | |||
179 | rx->key->u.tkip.iv32_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv32; | 179 | rx->key->u.tkip.iv32_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv32; |
180 | rx->key->u.tkip.iv16_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv16; | 180 | rx->key->u.tkip.iv16_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv16; |
181 | 181 | ||
182 | return TXRX_CONTINUE; | 182 | return RX_CONTINUE; |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
@@ -242,7 +242,7 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx, | |||
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | ieee80211_txrx_result | 245 | ieee80211_tx_result |
246 | ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx) | 246 | ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx) |
247 | { | 247 | { |
248 | struct sk_buff *skb = tx->skb; | 248 | struct sk_buff *skb = tx->skb; |
@@ -257,26 +257,26 @@ ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx) | |||
257 | !wpa_test) { | 257 | !wpa_test) { |
258 | /* hwaccel - with no need for preallocated room for IV/ICV */ | 258 | /* hwaccel - with no need for preallocated room for IV/ICV */ |
259 | tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; | 259 | tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; |
260 | return TXRX_CONTINUE; | 260 | return TX_CONTINUE; |
261 | } | 261 | } |
262 | 262 | ||
263 | if (tkip_encrypt_skb(tx, skb, test) < 0) | 263 | if (tkip_encrypt_skb(tx, skb, test) < 0) |
264 | return TXRX_DROP; | 264 | return TX_DROP; |
265 | 265 | ||
266 | if (tx->u.tx.extra_frag) { | 266 | if (tx->u.tx.extra_frag) { |
267 | int i; | 267 | int i; |
268 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | 268 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { |
269 | if (tkip_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) | 269 | if (tkip_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) |
270 | < 0) | 270 | < 0) |
271 | return TXRX_DROP; | 271 | return TX_DROP; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | return TXRX_CONTINUE; | 275 | return TX_CONTINUE; |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | ieee80211_txrx_result | 279 | ieee80211_rx_result |
280 | ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) | 280 | ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) |
281 | { | 281 | { |
282 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 282 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; |
@@ -290,10 +290,10 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) | |||
290 | hdrlen = ieee80211_get_hdrlen(fc); | 290 | hdrlen = ieee80211_get_hdrlen(fc); |
291 | 291 | ||
292 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) | 292 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) |
293 | return TXRX_CONTINUE; | 293 | return RX_CONTINUE; |
294 | 294 | ||
295 | if (!rx->sta || skb->len - hdrlen < 12) | 295 | if (!rx->sta || skb->len - hdrlen < 12) |
296 | return TXRX_DROP; | 296 | return RX_DROP_UNUSABLE; |
297 | 297 | ||
298 | if (rx->u.rx.status->flag & RX_FLAG_DECRYPTED) { | 298 | if (rx->u.rx.status->flag & RX_FLAG_DECRYPTED) { |
299 | if (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) { | 299 | if (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) { |
@@ -302,7 +302,7 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) | |||
302 | * replay protection, and stripped the ICV/IV so | 302 | * replay protection, and stripped the ICV/IV so |
303 | * we cannot do any checks here. | 303 | * we cannot do any checks here. |
304 | */ | 304 | */ |
305 | return TXRX_CONTINUE; | 305 | return RX_CONTINUE; |
306 | } | 306 | } |
307 | 307 | ||
308 | /* let TKIP code verify IV, but skip decryption */ | 308 | /* let TKIP code verify IV, but skip decryption */ |
@@ -322,7 +322,7 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) | |||
322 | "frame from %s (res=%d)\n", rx->dev->name, | 322 | "frame from %s (res=%d)\n", rx->dev->name, |
323 | print_mac(mac, rx->sta->addr), res); | 323 | print_mac(mac, rx->sta->addr), res); |
324 | #endif /* CONFIG_MAC80211_DEBUG */ | 324 | #endif /* CONFIG_MAC80211_DEBUG */ |
325 | return TXRX_DROP; | 325 | return RX_DROP_UNUSABLE; |
326 | } | 326 | } |
327 | 327 | ||
328 | /* Trim ICV */ | 328 | /* Trim ICV */ |
@@ -332,7 +332,7 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx) | |||
332 | memmove(skb->data + TKIP_IV_LEN, skb->data, hdrlen); | 332 | memmove(skb->data + TKIP_IV_LEN, skb->data, hdrlen); |
333 | skb_pull(skb, TKIP_IV_LEN); | 333 | skb_pull(skb, TKIP_IV_LEN); |
334 | 334 | ||
335 | return TXRX_CONTINUE; | 335 | return RX_CONTINUE; |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
@@ -491,7 +491,7 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx, | |||
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | ieee80211_txrx_result | 494 | ieee80211_tx_result |
495 | ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx) | 495 | ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx) |
496 | { | 496 | { |
497 | struct sk_buff *skb = tx->skb; | 497 | struct sk_buff *skb = tx->skb; |
@@ -506,26 +506,26 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx) | |||
506 | /* hwaccel - with no need for preallocated room for CCMP " | 506 | /* hwaccel - with no need for preallocated room for CCMP " |
507 | * header or MIC fields */ | 507 | * header or MIC fields */ |
508 | tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; | 508 | tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; |
509 | return TXRX_CONTINUE; | 509 | return TX_CONTINUE; |
510 | } | 510 | } |
511 | 511 | ||
512 | if (ccmp_encrypt_skb(tx, skb, test) < 0) | 512 | if (ccmp_encrypt_skb(tx, skb, test) < 0) |
513 | return TXRX_DROP; | 513 | return TX_DROP; |
514 | 514 | ||
515 | if (tx->u.tx.extra_frag) { | 515 | if (tx->u.tx.extra_frag) { |
516 | int i; | 516 | int i; |
517 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | 517 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { |
518 | if (ccmp_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) | 518 | if (ccmp_encrypt_skb(tx, tx->u.tx.extra_frag[i], test) |
519 | < 0) | 519 | < 0) |
520 | return TXRX_DROP; | 520 | return TX_DROP; |
521 | } | 521 | } |
522 | } | 522 | } |
523 | 523 | ||
524 | return TXRX_CONTINUE; | 524 | return TX_CONTINUE; |
525 | } | 525 | } |
526 | 526 | ||
527 | 527 | ||
528 | ieee80211_txrx_result | 528 | ieee80211_rx_result |
529 | ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) | 529 | ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) |
530 | { | 530 | { |
531 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 531 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; |
@@ -541,15 +541,15 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) | |||
541 | hdrlen = ieee80211_get_hdrlen(fc); | 541 | hdrlen = ieee80211_get_hdrlen(fc); |
542 | 542 | ||
543 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) | 543 | if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) |
544 | return TXRX_CONTINUE; | 544 | return RX_CONTINUE; |
545 | 545 | ||
546 | data_len = skb->len - hdrlen - CCMP_HDR_LEN - CCMP_MIC_LEN; | 546 | data_len = skb->len - hdrlen - CCMP_HDR_LEN - CCMP_MIC_LEN; |
547 | if (!rx->sta || data_len < 0) | 547 | if (!rx->sta || data_len < 0) |
548 | return TXRX_DROP; | 548 | return RX_DROP_UNUSABLE; |
549 | 549 | ||
550 | if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && | 550 | if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && |
551 | (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) | 551 | (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) |
552 | return TXRX_CONTINUE; | 552 | return RX_CONTINUE; |
553 | 553 | ||
554 | (void) ccmp_hdr2pn(pn, skb->data + hdrlen); | 554 | (void) ccmp_hdr2pn(pn, skb->data + hdrlen); |
555 | 555 | ||
@@ -565,7 +565,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) | |||
565 | ppn[0], ppn[1], ppn[2], ppn[3], ppn[4], ppn[5]); | 565 | ppn[0], ppn[1], ppn[2], ppn[3], ppn[4], ppn[5]); |
566 | #endif /* CONFIG_MAC80211_DEBUG */ | 566 | #endif /* CONFIG_MAC80211_DEBUG */ |
567 | key->u.ccmp.replays++; | 567 | key->u.ccmp.replays++; |
568 | return TXRX_DROP; | 568 | return RX_DROP_UNUSABLE; |
569 | } | 569 | } |
570 | 570 | ||
571 | if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { | 571 | if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) { |
@@ -589,7 +589,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) | |||
589 | "for RX frame from %s\n", rx->dev->name, | 589 | "for RX frame from %s\n", rx->dev->name, |
590 | print_mac(mac, rx->sta->addr)); | 590 | print_mac(mac, rx->sta->addr)); |
591 | #endif /* CONFIG_MAC80211_DEBUG */ | 591 | #endif /* CONFIG_MAC80211_DEBUG */ |
592 | return TXRX_DROP; | 592 | return RX_DROP_UNUSABLE; |
593 | } | 593 | } |
594 | } | 594 | } |
595 | 595 | ||
@@ -600,5 +600,5 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx) | |||
600 | memmove(skb->data + CCMP_HDR_LEN, skb->data, hdrlen); | 600 | memmove(skb->data + CCMP_HDR_LEN, skb->data, hdrlen); |
601 | skb_pull(skb, CCMP_HDR_LEN); | 601 | skb_pull(skb, CCMP_HDR_LEN); |
602 | 602 | ||
603 | return TXRX_CONTINUE; | 603 | return RX_CONTINUE; |
604 | } | 604 | } |
diff --git a/net/mac80211/wpa.h b/net/mac80211/wpa.h index 49d80cf0cd75..16e4dba4aa70 100644 --- a/net/mac80211/wpa.h +++ b/net/mac80211/wpa.h | |||
@@ -13,19 +13,19 @@ | |||
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include "ieee80211_i.h" | 14 | #include "ieee80211_i.h" |
15 | 15 | ||
16 | ieee80211_txrx_result | 16 | ieee80211_tx_result |
17 | ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx); | 17 | ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx); |
18 | ieee80211_txrx_result | 18 | ieee80211_rx_result |
19 | ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx); | 19 | ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx); |
20 | 20 | ||
21 | ieee80211_txrx_result | 21 | ieee80211_tx_result |
22 | ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx); | 22 | ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx); |
23 | ieee80211_txrx_result | 23 | ieee80211_rx_result |
24 | ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx); | 24 | ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx); |
25 | 25 | ||
26 | ieee80211_txrx_result | 26 | ieee80211_tx_result |
27 | ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx); | 27 | ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx); |
28 | ieee80211_txrx_result | 28 | ieee80211_rx_result |
29 | ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx); | 29 | ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx); |
30 | 30 | ||
31 | #endif /* WPA_H */ | 31 | #endif /* WPA_H */ |
diff --git a/net/wireless/Makefile b/net/wireless/Makefile index 65710a42e5a7..b9f943c45f3b 100644 --- a/net/wireless/Makefile +++ b/net/wireless/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | obj-$(CONFIG_WIRELESS_EXT) += wext.o | 1 | obj-$(CONFIG_WIRELESS_EXT) += wext.o |
2 | obj-$(CONFIG_CFG80211) += cfg80211.o | 2 | obj-$(CONFIG_CFG80211) += cfg80211.o |
3 | 3 | ||
4 | cfg80211-y += core.o sysfs.o radiotap.o | 4 | cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o |
5 | cfg80211-$(CONFIG_NL80211) += nl80211.o | 5 | cfg80211-$(CONFIG_NL80211) += nl80211.o |
diff --git a/net/wireless/core.c b/net/wireless/core.c index cfc5fc5f9e75..80afacdae46c 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -232,6 +232,47 @@ int wiphy_register(struct wiphy *wiphy) | |||
232 | { | 232 | { |
233 | struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy); | 233 | struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy); |
234 | int res; | 234 | int res; |
235 | enum ieee80211_band band; | ||
236 | struct ieee80211_supported_band *sband; | ||
237 | bool have_band = false; | ||
238 | int i; | ||
239 | |||
240 | /* sanity check supported bands/channels */ | ||
241 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
242 | sband = wiphy->bands[band]; | ||
243 | if (!sband) | ||
244 | continue; | ||
245 | |||
246 | sband->band = band; | ||
247 | |||
248 | if (!sband->n_channels || !sband->n_bitrates) { | ||
249 | WARN_ON(1); | ||
250 | return -EINVAL; | ||
251 | } | ||
252 | |||
253 | for (i = 0; i < sband->n_channels; i++) { | ||
254 | sband->channels[i].orig_flags = | ||
255 | sband->channels[i].flags; | ||
256 | sband->channels[i].orig_mag = | ||
257 | sband->channels[i].max_antenna_gain; | ||
258 | sband->channels[i].orig_mpwr = | ||
259 | sband->channels[i].max_power; | ||
260 | sband->channels[i].band = band; | ||
261 | } | ||
262 | |||
263 | have_band = true; | ||
264 | } | ||
265 | |||
266 | if (!have_band) { | ||
267 | WARN_ON(1); | ||
268 | return -EINVAL; | ||
269 | } | ||
270 | |||
271 | /* check and set up bitrates */ | ||
272 | ieee80211_set_bitrate_flags(wiphy); | ||
273 | |||
274 | /* set up regulatory info */ | ||
275 | wiphy_update_regulatory(wiphy); | ||
235 | 276 | ||
236 | mutex_lock(&cfg80211_drv_mutex); | 277 | mutex_lock(&cfg80211_drv_mutex); |
237 | 278 | ||
diff --git a/net/wireless/core.h b/net/wireless/core.h index eb0f846b40df..7a02c356d63d 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
@@ -78,4 +78,7 @@ extern void cfg80211_dev_free(struct cfg80211_registered_device *drv); | |||
78 | extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv, | 78 | extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv, |
79 | char *newname); | 79 | char *newname); |
80 | 80 | ||
81 | void ieee80211_set_bitrate_flags(struct wiphy *wiphy); | ||
82 | void wiphy_update_regulatory(struct wiphy *wiphy); | ||
83 | |||
81 | #endif /* __NET_WIRELESS_CORE_H */ | 84 | #endif /* __NET_WIRELESS_CORE_H */ |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index e3a214f63f91..5b3474798b8d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -82,6 +82,7 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = { | |||
82 | [NL80211_ATTR_STA_SUPPORTED_RATES] = { .type = NLA_BINARY, | 82 | [NL80211_ATTR_STA_SUPPORTED_RATES] = { .type = NLA_BINARY, |
83 | .len = NL80211_MAX_SUPP_RATES }, | 83 | .len = NL80211_MAX_SUPP_RATES }, |
84 | [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 }, | 84 | [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 }, |
85 | [NL80211_ATTR_MNTR_FLAGS] = { .type = NLA_NESTED }, | ||
85 | }; | 86 | }; |
86 | 87 | ||
87 | /* message building helper */ | 88 | /* message building helper */ |
@@ -98,6 +99,13 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
98 | struct cfg80211_registered_device *dev) | 99 | struct cfg80211_registered_device *dev) |
99 | { | 100 | { |
100 | void *hdr; | 101 | void *hdr; |
102 | struct nlattr *nl_bands, *nl_band; | ||
103 | struct nlattr *nl_freqs, *nl_freq; | ||
104 | struct nlattr *nl_rates, *nl_rate; | ||
105 | enum ieee80211_band band; | ||
106 | struct ieee80211_channel *chan; | ||
107 | struct ieee80211_rate *rate; | ||
108 | int i; | ||
101 | 109 | ||
102 | hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY); | 110 | hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY); |
103 | if (!hdr) | 111 | if (!hdr) |
@@ -105,6 +113,73 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
105 | 113 | ||
106 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx); | 114 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx); |
107 | NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); | 115 | NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); |
116 | |||
117 | nl_bands = nla_nest_start(msg, NL80211_ATTR_WIPHY_BANDS); | ||
118 | if (!nl_bands) | ||
119 | goto nla_put_failure; | ||
120 | |||
121 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
122 | if (!dev->wiphy.bands[band]) | ||
123 | continue; | ||
124 | |||
125 | nl_band = nla_nest_start(msg, band); | ||
126 | if (!nl_band) | ||
127 | goto nla_put_failure; | ||
128 | |||
129 | /* add frequencies */ | ||
130 | nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS); | ||
131 | if (!nl_freqs) | ||
132 | goto nla_put_failure; | ||
133 | |||
134 | for (i = 0; i < dev->wiphy.bands[band]->n_channels; i++) { | ||
135 | nl_freq = nla_nest_start(msg, i); | ||
136 | if (!nl_freq) | ||
137 | goto nla_put_failure; | ||
138 | |||
139 | chan = &dev->wiphy.bands[band]->channels[i]; | ||
140 | NLA_PUT_U32(msg, NL80211_FREQUENCY_ATTR_FREQ, | ||
141 | chan->center_freq); | ||
142 | |||
143 | if (chan->flags & IEEE80211_CHAN_DISABLED) | ||
144 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_DISABLED); | ||
145 | if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) | ||
146 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN); | ||
147 | if (chan->flags & IEEE80211_CHAN_NO_IBSS) | ||
148 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_NO_IBSS); | ||
149 | if (chan->flags & IEEE80211_CHAN_RADAR) | ||
150 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_RADAR); | ||
151 | |||
152 | nla_nest_end(msg, nl_freq); | ||
153 | } | ||
154 | |||
155 | nla_nest_end(msg, nl_freqs); | ||
156 | |||
157 | /* add bitrates */ | ||
158 | nl_rates = nla_nest_start(msg, NL80211_BAND_ATTR_RATES); | ||
159 | if (!nl_rates) | ||
160 | goto nla_put_failure; | ||
161 | |||
162 | for (i = 0; i < dev->wiphy.bands[band]->n_bitrates; i++) { | ||
163 | nl_rate = nla_nest_start(msg, i); | ||
164 | if (!nl_rate) | ||
165 | goto nla_put_failure; | ||
166 | |||
167 | rate = &dev->wiphy.bands[band]->bitrates[i]; | ||
168 | NLA_PUT_U32(msg, NL80211_BITRATE_ATTR_RATE, | ||
169 | rate->bitrate); | ||
170 | if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) | ||
171 | NLA_PUT_FLAG(msg, | ||
172 | NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE); | ||
173 | |||
174 | nla_nest_end(msg, nl_rate); | ||
175 | } | ||
176 | |||
177 | nla_nest_end(msg, nl_rates); | ||
178 | |||
179 | nla_nest_end(msg, nl_band); | ||
180 | } | ||
181 | nla_nest_end(msg, nl_bands); | ||
182 | |||
108 | return genlmsg_end(msg, hdr); | 183 | return genlmsg_end(msg, hdr); |
109 | 184 | ||
110 | nla_put_failure: | 185 | nla_put_failure: |
@@ -262,12 +337,42 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info) | |||
262 | return -ENOBUFS; | 337 | return -ENOBUFS; |
263 | } | 338 | } |
264 | 339 | ||
340 | static const struct nla_policy mntr_flags_policy[NL80211_MNTR_FLAG_MAX + 1] = { | ||
341 | [NL80211_MNTR_FLAG_FCSFAIL] = { .type = NLA_FLAG }, | ||
342 | [NL80211_MNTR_FLAG_PLCPFAIL] = { .type = NLA_FLAG }, | ||
343 | [NL80211_MNTR_FLAG_CONTROL] = { .type = NLA_FLAG }, | ||
344 | [NL80211_MNTR_FLAG_OTHER_BSS] = { .type = NLA_FLAG }, | ||
345 | [NL80211_MNTR_FLAG_COOK_FRAMES] = { .type = NLA_FLAG }, | ||
346 | }; | ||
347 | |||
348 | static int parse_monitor_flags(struct nlattr *nla, u32 *mntrflags) | ||
349 | { | ||
350 | struct nlattr *flags[NL80211_MNTR_FLAG_MAX + 1]; | ||
351 | int flag; | ||
352 | |||
353 | *mntrflags = 0; | ||
354 | |||
355 | if (!nla) | ||
356 | return -EINVAL; | ||
357 | |||
358 | if (nla_parse_nested(flags, NL80211_MNTR_FLAG_MAX, | ||
359 | nla, mntr_flags_policy)) | ||
360 | return -EINVAL; | ||
361 | |||
362 | for (flag = 1; flag <= NL80211_MNTR_FLAG_MAX; flag++) | ||
363 | if (flags[flag]) | ||
364 | *mntrflags |= (1<<flag); | ||
365 | |||
366 | return 0; | ||
367 | } | ||
368 | |||
265 | static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info) | 369 | static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info) |
266 | { | 370 | { |
267 | struct cfg80211_registered_device *drv; | 371 | struct cfg80211_registered_device *drv; |
268 | int err, ifindex; | 372 | int err, ifindex; |
269 | enum nl80211_iftype type; | 373 | enum nl80211_iftype type; |
270 | struct net_device *dev; | 374 | struct net_device *dev; |
375 | u32 flags; | ||
271 | 376 | ||
272 | if (info->attrs[NL80211_ATTR_IFTYPE]) { | 377 | if (info->attrs[NL80211_ATTR_IFTYPE]) { |
273 | type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]); | 378 | type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]); |
@@ -288,7 +393,11 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info) | |||
288 | } | 393 | } |
289 | 394 | ||
290 | rtnl_lock(); | 395 | rtnl_lock(); |
291 | err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex, type); | 396 | err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? |
397 | info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, | ||
398 | &flags); | ||
399 | err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex, | ||
400 | type, err ? NULL : &flags); | ||
292 | rtnl_unlock(); | 401 | rtnl_unlock(); |
293 | 402 | ||
294 | unlock: | 403 | unlock: |
@@ -301,6 +410,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) | |||
301 | struct cfg80211_registered_device *drv; | 410 | struct cfg80211_registered_device *drv; |
302 | int err; | 411 | int err; |
303 | enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; | 412 | enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; |
413 | u32 flags; | ||
304 | 414 | ||
305 | if (!info->attrs[NL80211_ATTR_IFNAME]) | 415 | if (!info->attrs[NL80211_ATTR_IFNAME]) |
306 | return -EINVAL; | 416 | return -EINVAL; |
@@ -321,8 +431,12 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) | |||
321 | } | 431 | } |
322 | 432 | ||
323 | rtnl_lock(); | 433 | rtnl_lock(); |
434 | err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? | ||
435 | info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, | ||
436 | &flags); | ||
324 | err = drv->ops->add_virtual_intf(&drv->wiphy, | 437 | err = drv->ops->add_virtual_intf(&drv->wiphy, |
325 | nla_data(info->attrs[NL80211_ATTR_IFNAME]), type); | 438 | nla_data(info->attrs[NL80211_ATTR_IFNAME]), |
439 | type, err ? NULL : &flags); | ||
326 | rtnl_unlock(); | 440 | rtnl_unlock(); |
327 | 441 | ||
328 | unlock: | 442 | unlock: |
diff --git a/net/wireless/reg.c b/net/wireless/reg.c new file mode 100644 index 000000000000..8cc6037eb2ae --- /dev/null +++ b/net/wireless/reg.c | |||
@@ -0,0 +1,159 @@ | |||
1 | /* | ||
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | ||
3 | * Copyright 2005-2006, Devicescape Software, Inc. | ||
4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This regulatory domain control implementation is highly incomplete, it | ||
13 | * only exists for the purpose of not regressing mac80211. | ||
14 | * | ||
15 | * For now, drivers can restrict the set of allowed channels by either | ||
16 | * not registering those channels or setting the IEEE80211_CHAN_DISABLED | ||
17 | * flag; that flag will only be *set* by this code, never *cleared. | ||
18 | * | ||
19 | * The usual implementation is for a driver to read a device EEPROM to | ||
20 | * determine which regulatory domain it should be operating under, then | ||
21 | * looking up the allowable channels in a driver-local table and finally | ||
22 | * registering those channels in the wiphy structure. | ||
23 | * | ||
24 | * Alternatively, drivers that trust the regulatory domain control here | ||
25 | * will register a complete set of capabilities and the control code | ||
26 | * will restrict the set by setting the IEEE80211_CHAN_* flags. | ||
27 | */ | ||
28 | #include <linux/kernel.h> | ||
29 | #include <net/wireless.h> | ||
30 | #include "core.h" | ||
31 | |||
32 | static char *ieee80211_regdom = "US"; | ||
33 | module_param(ieee80211_regdom, charp, 0444); | ||
34 | MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); | ||
35 | |||
36 | struct ieee80211_channel_range { | ||
37 | short start_freq; | ||
38 | short end_freq; | ||
39 | int max_power; | ||
40 | int max_antenna_gain; | ||
41 | u32 flags; | ||
42 | }; | ||
43 | |||
44 | struct ieee80211_regdomain { | ||
45 | const char *code; | ||
46 | const struct ieee80211_channel_range *ranges; | ||
47 | int n_ranges; | ||
48 | }; | ||
49 | |||
50 | #define RANGE_PWR(_start, _end, _pwr, _ag, _flags) \ | ||
51 | { _start, _end, _pwr, _ag, _flags } | ||
52 | |||
53 | |||
54 | /* | ||
55 | * Ideally, in the future, these definitions will be loaded from a | ||
56 | * userspace table via some daemon. | ||
57 | */ | ||
58 | static const struct ieee80211_channel_range ieee80211_US_channels[] = { | ||
59 | /* IEEE 802.11b/g, channels 1..11 */ | ||
60 | RANGE_PWR(2412, 2462, 27, 6, 0), | ||
61 | /* IEEE 802.11a, channel 36*/ | ||
62 | RANGE_PWR(5180, 5180, 23, 6, 0), | ||
63 | /* IEEE 802.11a, channel 40*/ | ||
64 | RANGE_PWR(5200, 5200, 23, 6, 0), | ||
65 | /* IEEE 802.11a, channel 44*/ | ||
66 | RANGE_PWR(5220, 5220, 23, 6, 0), | ||
67 | /* IEEE 802.11a, channels 48..64 */ | ||
68 | RANGE_PWR(5240, 5320, 23, 6, 0), | ||
69 | /* IEEE 802.11a, channels 149..165, outdoor */ | ||
70 | RANGE_PWR(5745, 5825, 30, 6, 0), | ||
71 | }; | ||
72 | |||
73 | static const struct ieee80211_channel_range ieee80211_JP_channels[] = { | ||
74 | /* IEEE 802.11b/g, channels 1..14 */ | ||
75 | RANGE_PWR(2412, 2484, 20, 6, 0), | ||
76 | /* IEEE 802.11a, channels 34..48 */ | ||
77 | RANGE_PWR(5170, 5240, 20, 6, IEEE80211_CHAN_PASSIVE_SCAN), | ||
78 | /* IEEE 802.11a, channels 52..64 */ | ||
79 | RANGE_PWR(5260, 5320, 20, 6, IEEE80211_CHAN_NO_IBSS | | ||
80 | IEEE80211_CHAN_RADAR), | ||
81 | }; | ||
82 | |||
83 | #define REGDOM(_code) \ | ||
84 | { \ | ||
85 | .code = __stringify(_code), \ | ||
86 | .ranges = ieee80211_ ##_code## _channels, \ | ||
87 | .n_ranges = ARRAY_SIZE(ieee80211_ ##_code## _channels), \ | ||
88 | } | ||
89 | |||
90 | static const struct ieee80211_regdomain ieee80211_regdoms[] = { | ||
91 | REGDOM(US), | ||
92 | REGDOM(JP), | ||
93 | }; | ||
94 | |||
95 | |||
96 | static const struct ieee80211_regdomain *get_regdom(void) | ||
97 | { | ||
98 | static const struct ieee80211_channel_range | ||
99 | ieee80211_world_channels[] = { | ||
100 | /* IEEE 802.11b/g, channels 1..11 */ | ||
101 | RANGE_PWR(2412, 2462, 27, 6, 0), | ||
102 | }; | ||
103 | static const struct ieee80211_regdomain regdom_world = REGDOM(world); | ||
104 | int i; | ||
105 | |||
106 | for (i = 0; i < ARRAY_SIZE(ieee80211_regdoms); i++) | ||
107 | if (strcmp(ieee80211_regdom, ieee80211_regdoms[i].code) == 0) | ||
108 | return &ieee80211_regdoms[i]; | ||
109 | |||
110 | return ®dom_world; | ||
111 | } | ||
112 | |||
113 | |||
114 | static void handle_channel(struct ieee80211_channel *chan, | ||
115 | const struct ieee80211_regdomain *rd) | ||
116 | { | ||
117 | int i; | ||
118 | u32 flags = chan->orig_flags; | ||
119 | const struct ieee80211_channel_range *rg = NULL; | ||
120 | |||
121 | for (i = 0; i < rd->n_ranges; i++) { | ||
122 | if (rd->ranges[i].start_freq <= chan->center_freq && | ||
123 | chan->center_freq <= rd->ranges[i].end_freq) { | ||
124 | rg = &rd->ranges[i]; | ||
125 | break; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | if (!rg) { | ||
130 | /* not found */ | ||
131 | flags |= IEEE80211_CHAN_DISABLED; | ||
132 | chan->flags = flags; | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | chan->flags = flags; | ||
137 | chan->max_antenna_gain = min(chan->orig_mag, | ||
138 | rg->max_antenna_gain); | ||
139 | chan->max_power = min(chan->orig_mpwr, rg->max_power); | ||
140 | } | ||
141 | |||
142 | static void handle_band(struct ieee80211_supported_band *sband, | ||
143 | const struct ieee80211_regdomain *rd) | ||
144 | { | ||
145 | int i; | ||
146 | |||
147 | for (i = 0; i < sband->n_channels; i++) | ||
148 | handle_channel(&sband->channels[i], rd); | ||
149 | } | ||
150 | |||
151 | void wiphy_update_regulatory(struct wiphy *wiphy) | ||
152 | { | ||
153 | enum ieee80211_band band; | ||
154 | const struct ieee80211_regdomain *rd = get_regdom(); | ||
155 | |||
156 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | ||
157 | if (wiphy->bands[band]) | ||
158 | handle_band(wiphy->bands[band], rd); | ||
159 | } | ||
diff --git a/net/wireless/util.c b/net/wireless/util.c new file mode 100644 index 000000000000..77336c22fcf2 --- /dev/null +++ b/net/wireless/util.c | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * Wireless utility functions | ||
3 | * | ||
4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> | ||
5 | */ | ||
6 | #include <net/wireless.h> | ||
7 | #include <asm/bitops.h> | ||
8 | #include "core.h" | ||
9 | |||
10 | int ieee80211_channel_to_frequency(int chan) | ||
11 | { | ||
12 | if (chan < 14) | ||
13 | return 2407 + chan * 5; | ||
14 | |||
15 | if (chan == 14) | ||
16 | return 2484; | ||
17 | |||
18 | /* FIXME: 802.11j 17.3.8.3.2 */ | ||
19 | return (chan + 1000) * 5; | ||
20 | } | ||
21 | EXPORT_SYMBOL(ieee80211_channel_to_frequency); | ||
22 | |||
23 | int ieee80211_frequency_to_channel(int freq) | ||
24 | { | ||
25 | if (freq == 2484) | ||
26 | return 14; | ||
27 | |||
28 | if (freq < 2484) | ||
29 | return (freq - 2407) / 5; | ||
30 | |||
31 | /* FIXME: 802.11j 17.3.8.3.2 */ | ||
32 | return freq/5 - 1000; | ||
33 | } | ||
34 | EXPORT_SYMBOL(ieee80211_frequency_to_channel); | ||
35 | |||
36 | static void set_mandatory_flags_band(struct ieee80211_supported_band *sband, | ||
37 | enum ieee80211_band band) | ||
38 | { | ||
39 | int i, want; | ||
40 | |||
41 | switch (band) { | ||
42 | case IEEE80211_BAND_5GHZ: | ||
43 | want = 3; | ||
44 | for (i = 0; i < sband->n_bitrates; i++) { | ||
45 | if (sband->bitrates[i].bitrate == 60 || | ||
46 | sband->bitrates[i].bitrate == 120 || | ||
47 | sband->bitrates[i].bitrate == 240) { | ||
48 | sband->bitrates[i].flags |= | ||
49 | IEEE80211_RATE_MANDATORY_A; | ||
50 | want--; | ||
51 | } | ||
52 | } | ||
53 | WARN_ON(want); | ||
54 | break; | ||
55 | case IEEE80211_BAND_2GHZ: | ||
56 | want = 7; | ||
57 | for (i = 0; i < sband->n_bitrates; i++) { | ||
58 | if (sband->bitrates[i].bitrate == 10) { | ||
59 | sband->bitrates[i].flags |= | ||
60 | IEEE80211_RATE_MANDATORY_B | | ||
61 | IEEE80211_RATE_MANDATORY_G; | ||
62 | want--; | ||
63 | } | ||
64 | |||
65 | if (sband->bitrates[i].bitrate == 20 || | ||
66 | sband->bitrates[i].bitrate == 55 || | ||
67 | sband->bitrates[i].bitrate == 110 || | ||
68 | sband->bitrates[i].bitrate == 60 || | ||
69 | sband->bitrates[i].bitrate == 120 || | ||
70 | sband->bitrates[i].bitrate == 240) { | ||
71 | sband->bitrates[i].flags |= | ||
72 | IEEE80211_RATE_MANDATORY_G; | ||
73 | want--; | ||
74 | } | ||
75 | |||
76 | if (sband->bitrates[i].bitrate != 10 && | ||
77 | sband->bitrates[i].bitrate != 20 && | ||
78 | sband->bitrates[i].bitrate != 55 && | ||
79 | sband->bitrates[i].bitrate != 110) | ||
80 | sband->bitrates[i].flags |= | ||
81 | IEEE80211_RATE_ERP_G; | ||
82 | } | ||
83 | WARN_ON(want != 0 && want != 3 && want != 6); | ||
84 | break; | ||
85 | case IEEE80211_NUM_BANDS: | ||
86 | WARN_ON(1); | ||
87 | break; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | void ieee80211_set_bitrate_flags(struct wiphy *wiphy) | ||
92 | { | ||
93 | enum ieee80211_band band; | ||
94 | |||
95 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | ||
96 | if (wiphy->bands[band]) | ||
97 | set_mandatory_flags_band(wiphy->bands[band], band); | ||
98 | } | ||