diff options
author | John W. Linville <linville@tuxdriver.com> | 2013-04-24 10:54:20 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-04-24 10:54:20 -0400 |
commit | 6ed0e321a0aef14a894e26658108bf7e895c36a6 (patch) | |
tree | f49428d68ebcb1beb757296ea1559079210babbe /net/mac80211 | |
parent | 3dec2246c2ff11beb24ca1950f074b2bcbc85953 (diff) | |
parent | b006ed545cbadf1ebd4683719554742d20dbcede (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next into for-davem
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/cfg.c | 57 | ||||
-rw-r--r-- | net/mac80211/chan.c | 54 | ||||
-rw-r--r-- | net/mac80211/debugfs_netdev.c | 11 | ||||
-rw-r--r-- | net/mac80211/debugfs_sta.c | 2 | ||||
-rw-r--r-- | net/mac80211/ibss.c | 146 | ||||
-rw-r--r-- | net/mac80211/ieee80211_i.h | 49 | ||||
-rw-r--r-- | net/mac80211/iface.c | 121 | ||||
-rw-r--r-- | net/mac80211/main.c | 82 | ||||
-rw-r--r-- | net/mac80211/mesh.c | 6 | ||||
-rw-r--r-- | net/mac80211/mesh.h | 3 | ||||
-rw-r--r-- | net/mac80211/mesh_hwmp.c | 28 | ||||
-rw-r--r-- | net/mac80211/mesh_pathtbl.c | 56 | ||||
-rw-r--r-- | net/mac80211/mesh_plink.c | 6 | ||||
-rw-r--r-- | net/mac80211/mlme.c | 442 | ||||
-rw-r--r-- | net/mac80211/offchannel.c | 6 | ||||
-rw-r--r-- | net/mac80211/pm.c | 11 | ||||
-rw-r--r-- | net/mac80211/rate.c | 324 | ||||
-rw-r--r-- | net/mac80211/rc80211_minstrel.c | 206 | ||||
-rw-r--r-- | net/mac80211/rc80211_minstrel.h | 7 | ||||
-rw-r--r-- | net/mac80211/rc80211_minstrel_debugfs.c | 4 | ||||
-rw-r--r-- | net/mac80211/rc80211_minstrel_ht.c | 172 | ||||
-rw-r--r-- | net/mac80211/rc80211_minstrel_ht.h | 2 | ||||
-rw-r--r-- | net/mac80211/rx.c | 24 | ||||
-rw-r--r-- | net/mac80211/scan.c | 13 | ||||
-rw-r--r-- | net/mac80211/trace.h | 51 | ||||
-rw-r--r-- | net/mac80211/tx.c | 153 | ||||
-rw-r--r-- | net/mac80211/util.c | 103 |
27 files changed, 1309 insertions, 830 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index c50c19402588..1a89c80e6407 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -805,8 +805,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy, | |||
805 | IEEE80211_CHANCTX_EXCLUSIVE); | 805 | IEEE80211_CHANCTX_EXCLUSIVE); |
806 | } | 806 | } |
807 | } else if (local->open_count == local->monitors) { | 807 | } else if (local->open_count == local->monitors) { |
808 | local->_oper_channel = chandef->chan; | 808 | local->_oper_chandef = *chandef; |
809 | local->_oper_channel_type = cfg80211_get_chandef_type(chandef); | ||
810 | ieee80211_hw_config(local, 0); | 809 | ieee80211_hw_config(local, 0); |
811 | } | 810 | } |
812 | 811 | ||
@@ -965,8 +964,13 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, | |||
965 | sdata->vif.bss_conf.hidden_ssid = | 964 | sdata->vif.bss_conf.hidden_ssid = |
966 | (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); | 965 | (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); |
967 | 966 | ||
968 | sdata->vif.bss_conf.p2p_ctwindow = params->p2p_ctwindow; | 967 | memset(&sdata->vif.bss_conf.p2p_noa_attr, 0, |
969 | sdata->vif.bss_conf.p2p_oppps = params->p2p_opp_ps; | 968 | sizeof(sdata->vif.bss_conf.p2p_noa_attr)); |
969 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow = | ||
970 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; | ||
971 | if (params->p2p_opp_ps) | ||
972 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= | ||
973 | IEEE80211_P2P_OPPPS_ENABLE_BIT; | ||
970 | 974 | ||
971 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon); | 975 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon); |
972 | if (err < 0) | 976 | if (err < 0) |
@@ -1039,6 +1043,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) | |||
1039 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) | 1043 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
1040 | sta_info_flush_defer(vlan); | 1044 | sta_info_flush_defer(vlan); |
1041 | sta_info_flush_defer(sdata); | 1045 | sta_info_flush_defer(sdata); |
1046 | synchronize_net(); | ||
1042 | rcu_barrier(); | 1047 | rcu_barrier(); |
1043 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { | 1048 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { |
1044 | sta_info_flush_cleanup(vlan); | 1049 | sta_info_flush_cleanup(vlan); |
@@ -1048,6 +1053,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) | |||
1048 | ieee80211_free_keys(sdata); | 1053 | ieee80211_free_keys(sdata); |
1049 | 1054 | ||
1050 | sdata->vif.bss_conf.enable_beacon = false; | 1055 | sdata->vif.bss_conf.enable_beacon = false; |
1056 | sdata->vif.bss_conf.ssid_len = 0; | ||
1051 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); | 1057 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); |
1052 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); | 1058 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
1053 | 1059 | ||
@@ -1536,7 +1542,6 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
1536 | struct ieee80211_sub_if_data *sdata; | 1542 | struct ieee80211_sub_if_data *sdata; |
1537 | struct mesh_path *mpath; | 1543 | struct mesh_path *mpath; |
1538 | struct sta_info *sta; | 1544 | struct sta_info *sta; |
1539 | int err; | ||
1540 | 1545 | ||
1541 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1546 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1542 | 1547 | ||
@@ -1547,17 +1552,12 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
1547 | return -ENOENT; | 1552 | return -ENOENT; |
1548 | } | 1553 | } |
1549 | 1554 | ||
1550 | err = mesh_path_add(sdata, dst); | 1555 | mpath = mesh_path_add(sdata, dst); |
1551 | if (err) { | 1556 | if (IS_ERR(mpath)) { |
1552 | rcu_read_unlock(); | 1557 | rcu_read_unlock(); |
1553 | return err; | 1558 | return PTR_ERR(mpath); |
1554 | } | 1559 | } |
1555 | 1560 | ||
1556 | mpath = mesh_path_lookup(sdata, dst); | ||
1557 | if (!mpath) { | ||
1558 | rcu_read_unlock(); | ||
1559 | return -ENXIO; | ||
1560 | } | ||
1561 | mesh_path_fix_nexthop(mpath, sta); | 1561 | mesh_path_fix_nexthop(mpath, sta); |
1562 | 1562 | ||
1563 | rcu_read_unlock(); | 1563 | rcu_read_unlock(); |
@@ -1961,12 +1961,20 @@ static int ieee80211_change_bss(struct wiphy *wiphy, | |||
1961 | } | 1961 | } |
1962 | 1962 | ||
1963 | if (params->p2p_ctwindow >= 0) { | 1963 | if (params->p2p_ctwindow >= 0) { |
1964 | sdata->vif.bss_conf.p2p_ctwindow = params->p2p_ctwindow; | 1964 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= |
1965 | ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK; | ||
1966 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= | ||
1967 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; | ||
1965 | changed |= BSS_CHANGED_P2P_PS; | 1968 | changed |= BSS_CHANGED_P2P_PS; |
1966 | } | 1969 | } |
1967 | 1970 | ||
1968 | if (params->p2p_opp_ps >= 0) { | 1971 | if (params->p2p_opp_ps > 0) { |
1969 | sdata->vif.bss_conf.p2p_oppps = params->p2p_opp_ps; | 1972 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= |
1973 | IEEE80211_P2P_OPPPS_ENABLE_BIT; | ||
1974 | changed |= BSS_CHANGED_P2P_PS; | ||
1975 | } else if (params->p2p_opp_ps == 0) { | ||
1976 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= | ||
1977 | ~IEEE80211_P2P_OPPPS_ENABLE_BIT; | ||
1970 | changed |= BSS_CHANGED_P2P_PS; | 1978 | changed |= BSS_CHANGED_P2P_PS; |
1971 | } | 1979 | } |
1972 | 1980 | ||
@@ -2410,9 +2418,22 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, | |||
2410 | } | 2418 | } |
2411 | 2419 | ||
2412 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) { | 2420 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) { |
2421 | struct ieee80211_supported_band *sband = wiphy->bands[i]; | ||
2422 | int j; | ||
2423 | |||
2413 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; | 2424 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
2414 | memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs, | 2425 | memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs, |
2415 | sizeof(mask->control[i].mcs)); | 2426 | sizeof(mask->control[i].mcs)); |
2427 | |||
2428 | sdata->rc_has_mcs_mask[i] = false; | ||
2429 | if (!sband) | ||
2430 | continue; | ||
2431 | |||
2432 | for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) | ||
2433 | if (~sdata->rc_rateidx_mcs_mask[i][j]) { | ||
2434 | sdata->rc_has_mcs_mask[i] = true; | ||
2435 | break; | ||
2436 | } | ||
2416 | } | 2437 | } |
2417 | 2438 | ||
2418 | return 0; | 2439 | return 0; |
@@ -3362,9 +3383,7 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy, | |||
3362 | if (local->use_chanctx) | 3383 | if (local->use_chanctx) |
3363 | *chandef = local->monitor_chandef; | 3384 | *chandef = local->monitor_chandef; |
3364 | else | 3385 | else |
3365 | cfg80211_chandef_create(chandef, | 3386 | *chandef = local->_oper_chandef; |
3366 | local->_oper_channel, | ||
3367 | local->_oper_channel_type); | ||
3368 | ret = 0; | 3387 | ret = 0; |
3369 | } | 3388 | } |
3370 | rcu_read_unlock(); | 3389 | rcu_read_unlock(); |
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 931be419ab5a..03e8d2e3270e 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c | |||
@@ -22,7 +22,7 @@ static void ieee80211_change_chanctx(struct ieee80211_local *local, | |||
22 | drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_WIDTH); | 22 | drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_WIDTH); |
23 | 23 | ||
24 | if (!local->use_chanctx) { | 24 | if (!local->use_chanctx) { |
25 | local->_oper_channel_type = cfg80211_get_chandef_type(chandef); | 25 | local->_oper_chandef = *chandef; |
26 | ieee80211_hw_config(local, 0); | 26 | ieee80211_hw_config(local, 0); |
27 | } | 27 | } |
28 | } | 28 | } |
@@ -57,6 +57,22 @@ ieee80211_find_chanctx(struct ieee80211_local *local, | |||
57 | return NULL; | 57 | return NULL; |
58 | } | 58 | } |
59 | 59 | ||
60 | static bool ieee80211_is_radar_required(struct ieee80211_local *local) | ||
61 | { | ||
62 | struct ieee80211_sub_if_data *sdata; | ||
63 | |||
64 | rcu_read_lock(); | ||
65 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
66 | if (sdata->radar_required) { | ||
67 | rcu_read_unlock(); | ||
68 | return true; | ||
69 | } | ||
70 | } | ||
71 | rcu_read_unlock(); | ||
72 | |||
73 | return false; | ||
74 | } | ||
75 | |||
60 | static struct ieee80211_chanctx * | 76 | static struct ieee80211_chanctx * |
61 | ieee80211_new_chanctx(struct ieee80211_local *local, | 77 | ieee80211_new_chanctx(struct ieee80211_local *local, |
62 | const struct cfg80211_chan_def *chandef, | 78 | const struct cfg80211_chan_def *chandef, |
@@ -76,6 +92,9 @@ ieee80211_new_chanctx(struct ieee80211_local *local, | |||
76 | ctx->conf.rx_chains_static = 1; | 92 | ctx->conf.rx_chains_static = 1; |
77 | ctx->conf.rx_chains_dynamic = 1; | 93 | ctx->conf.rx_chains_dynamic = 1; |
78 | ctx->mode = mode; | 94 | ctx->mode = mode; |
95 | ctx->conf.radar_enabled = ieee80211_is_radar_required(local); | ||
96 | if (!local->use_chanctx) | ||
97 | local->hw.conf.radar_enabled = ctx->conf.radar_enabled; | ||
79 | 98 | ||
80 | /* acquire mutex to prevent idle from changing */ | 99 | /* acquire mutex to prevent idle from changing */ |
81 | mutex_lock(&local->mtx); | 100 | mutex_lock(&local->mtx); |
@@ -85,9 +104,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local, | |||
85 | ieee80211_hw_config(local, changed); | 104 | ieee80211_hw_config(local, changed); |
86 | 105 | ||
87 | if (!local->use_chanctx) { | 106 | if (!local->use_chanctx) { |
88 | local->_oper_channel_type = | 107 | local->_oper_chandef = *chandef; |
89 | cfg80211_get_chandef_type(chandef); | ||
90 | local->_oper_channel = chandef->chan; | ||
91 | ieee80211_hw_config(local, 0); | 108 | ieee80211_hw_config(local, 0); |
92 | } else { | 109 | } else { |
93 | err = drv_add_chanctx(local, ctx); | 110 | err = drv_add_chanctx(local, ctx); |
@@ -112,12 +129,24 @@ ieee80211_new_chanctx(struct ieee80211_local *local, | |||
112 | static void ieee80211_free_chanctx(struct ieee80211_local *local, | 129 | static void ieee80211_free_chanctx(struct ieee80211_local *local, |
113 | struct ieee80211_chanctx *ctx) | 130 | struct ieee80211_chanctx *ctx) |
114 | { | 131 | { |
132 | bool check_single_channel = false; | ||
115 | lockdep_assert_held(&local->chanctx_mtx); | 133 | lockdep_assert_held(&local->chanctx_mtx); |
116 | 134 | ||
117 | WARN_ON_ONCE(ctx->refcount != 0); | 135 | WARN_ON_ONCE(ctx->refcount != 0); |
118 | 136 | ||
119 | if (!local->use_chanctx) { | 137 | if (!local->use_chanctx) { |
120 | local->_oper_channel_type = NL80211_CHAN_NO_HT; | 138 | struct cfg80211_chan_def *chandef = &local->_oper_chandef; |
139 | chandef->width = NL80211_CHAN_WIDTH_20_NOHT; | ||
140 | chandef->center_freq1 = chandef->chan->center_freq; | ||
141 | chandef->center_freq2 = 0; | ||
142 | |||
143 | /* NOTE: Disabling radar is only valid here for | ||
144 | * single channel context. To be sure, check it ... | ||
145 | */ | ||
146 | if (local->hw.conf.radar_enabled) | ||
147 | check_single_channel = true; | ||
148 | local->hw.conf.radar_enabled = false; | ||
149 | |||
121 | ieee80211_hw_config(local, 0); | 150 | ieee80211_hw_config(local, 0); |
122 | } else { | 151 | } else { |
123 | drv_remove_chanctx(local, ctx); | 152 | drv_remove_chanctx(local, ctx); |
@@ -126,6 +155,9 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local, | |||
126 | list_del_rcu(&ctx->list); | 155 | list_del_rcu(&ctx->list); |
127 | kfree_rcu(ctx, rcu_head); | 156 | kfree_rcu(ctx, rcu_head); |
128 | 157 | ||
158 | /* throw a warning if this wasn't the only channel context. */ | ||
159 | WARN_ON(check_single_channel && !list_empty(&local->chanctx_list)); | ||
160 | |||
129 | mutex_lock(&local->mtx); | 161 | mutex_lock(&local->mtx); |
130 | ieee80211_recalc_idle(local); | 162 | ieee80211_recalc_idle(local); |
131 | mutex_unlock(&local->mtx); | 163 | mutex_unlock(&local->mtx); |
@@ -237,19 +269,11 @@ static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata) | |||
237 | void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local, | 269 | void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local, |
238 | struct ieee80211_chanctx *chanctx) | 270 | struct ieee80211_chanctx *chanctx) |
239 | { | 271 | { |
240 | struct ieee80211_sub_if_data *sdata; | 272 | bool radar_enabled; |
241 | bool radar_enabled = false; | ||
242 | 273 | ||
243 | lockdep_assert_held(&local->chanctx_mtx); | 274 | lockdep_assert_held(&local->chanctx_mtx); |
244 | 275 | ||
245 | rcu_read_lock(); | 276 | radar_enabled = ieee80211_is_radar_required(local); |
246 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
247 | if (sdata->radar_required) { | ||
248 | radar_enabled = true; | ||
249 | break; | ||
250 | } | ||
251 | } | ||
252 | rcu_read_unlock(); | ||
253 | 277 | ||
254 | if (radar_enabled == chanctx->conf.radar_enabled) | 278 | if (radar_enabled == chanctx->conf.radar_enabled) |
255 | return; | 279 | return; |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index ddb426867904..14abcf44f974 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -124,6 +124,15 @@ static ssize_t ieee80211_if_fmt_##name( \ | |||
124 | return scnprintf(buf, buflen, "%d\n", sdata->field / 16); \ | 124 | return scnprintf(buf, buflen, "%d\n", sdata->field / 16); \ |
125 | } | 125 | } |
126 | 126 | ||
127 | #define IEEE80211_IF_FMT_JIFFIES_TO_MS(name, field) \ | ||
128 | static ssize_t ieee80211_if_fmt_##name( \ | ||
129 | const struct ieee80211_sub_if_data *sdata, \ | ||
130 | char *buf, int buflen) \ | ||
131 | { \ | ||
132 | return scnprintf(buf, buflen, "%d\n", \ | ||
133 | jiffies_to_msecs(sdata->field)); \ | ||
134 | } | ||
135 | |||
127 | #define __IEEE80211_IF_FILE(name, _write) \ | 136 | #define __IEEE80211_IF_FILE(name, _write) \ |
128 | static ssize_t ieee80211_if_read_##name(struct file *file, \ | 137 | static ssize_t ieee80211_if_read_##name(struct file *file, \ |
129 | char __user *userbuf, \ | 138 | char __user *userbuf, \ |
@@ -197,6 +206,7 @@ IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); | |||
197 | IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); | 206 | IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); |
198 | IEEE80211_IF_FILE(last_beacon, u.mgd.last_beacon_signal, DEC); | 207 | IEEE80211_IF_FILE(last_beacon, u.mgd.last_beacon_signal, DEC); |
199 | IEEE80211_IF_FILE(ave_beacon, u.mgd.ave_beacon_signal, DEC_DIV_16); | 208 | IEEE80211_IF_FILE(ave_beacon, u.mgd.ave_beacon_signal, DEC_DIV_16); |
209 | IEEE80211_IF_FILE(beacon_timeout, u.mgd.beacon_timeout, JIFFIES_TO_MS); | ||
200 | 210 | ||
201 | static int ieee80211_set_smps(struct ieee80211_sub_if_data *sdata, | 211 | static int ieee80211_set_smps(struct ieee80211_sub_if_data *sdata, |
202 | enum ieee80211_smps_mode smps_mode) | 212 | enum ieee80211_smps_mode smps_mode) |
@@ -542,6 +552,7 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata) | |||
542 | DEBUGFS_ADD(aid); | 552 | DEBUGFS_ADD(aid); |
543 | DEBUGFS_ADD(last_beacon); | 553 | DEBUGFS_ADD(last_beacon); |
544 | DEBUGFS_ADD(ave_beacon); | 554 | DEBUGFS_ADD(ave_beacon); |
555 | DEBUGFS_ADD(beacon_timeout); | ||
545 | DEBUGFS_ADD_MODE(smps, 0600); | 556 | DEBUGFS_ADD_MODE(smps, 0600); |
546 | DEBUGFS_ADD_MODE(tkip_mic_test, 0200); | 557 | DEBUGFS_ADD_MODE(tkip_mic_test, 0200); |
547 | DEBUGFS_ADD_MODE(uapsd_queues, 0600); | 558 | DEBUGFS_ADD_MODE(uapsd_queues, 0600); |
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c index 4f841fe559df..44e201d60a13 100644 --- a/net/mac80211/debugfs_sta.c +++ b/net/mac80211/debugfs_sta.c | |||
@@ -54,6 +54,7 @@ STA_FILE(aid, sta.aid, D); | |||
54 | STA_FILE(dev, sdata->name, S); | 54 | STA_FILE(dev, sdata->name, S); |
55 | STA_FILE(last_signal, last_signal, D); | 55 | STA_FILE(last_signal, last_signal, D); |
56 | STA_FILE(last_ack_signal, last_ack_signal, D); | 56 | STA_FILE(last_ack_signal, last_ack_signal, D); |
57 | STA_FILE(beacon_loss_count, beacon_loss_count, D); | ||
57 | 58 | ||
58 | static ssize_t sta_flags_read(struct file *file, char __user *userbuf, | 59 | static ssize_t sta_flags_read(struct file *file, char __user *userbuf, |
59 | size_t count, loff_t *ppos) | 60 | size_t count, loff_t *ppos) |
@@ -434,6 +435,7 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta) | |||
434 | DEBUGFS_ADD(agg_status); | 435 | DEBUGFS_ADD(agg_status); |
435 | DEBUGFS_ADD(dev); | 436 | DEBUGFS_ADD(dev); |
436 | DEBUGFS_ADD(last_signal); | 437 | DEBUGFS_ADD(last_signal); |
438 | DEBUGFS_ADD(beacon_loss_count); | ||
437 | DEBUGFS_ADD(ht_capa); | 439 | DEBUGFS_ADD(ht_capa); |
438 | DEBUGFS_ADD(vht_capa); | 440 | DEBUGFS_ADD(vht_capa); |
439 | DEBUGFS_ADD(last_ack_signal); | 441 | DEBUGFS_ADD(last_ack_signal); |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 539d4a11b47b..170f9a7fa319 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
@@ -44,7 +44,6 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
44 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | 44 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
45 | struct ieee80211_local *local = sdata->local; | 45 | struct ieee80211_local *local = sdata->local; |
46 | int rates, i; | 46 | int rates, i; |
47 | struct sk_buff *skb; | ||
48 | struct ieee80211_mgmt *mgmt; | 47 | struct ieee80211_mgmt *mgmt; |
49 | u8 *pos; | 48 | u8 *pos; |
50 | struct ieee80211_supported_band *sband; | 49 | struct ieee80211_supported_band *sband; |
@@ -52,20 +51,14 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
52 | u32 bss_change; | 51 | u32 bss_change; |
53 | u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; | 52 | u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; |
54 | struct cfg80211_chan_def chandef; | 53 | struct cfg80211_chan_def chandef; |
54 | struct beacon_data *presp; | ||
55 | int frame_len; | ||
55 | 56 | ||
56 | lockdep_assert_held(&ifibss->mtx); | 57 | lockdep_assert_held(&ifibss->mtx); |
57 | 58 | ||
58 | /* Reset own TSF to allow time synchronization work. */ | 59 | /* Reset own TSF to allow time synchronization work. */ |
59 | drv_reset_tsf(local, sdata); | 60 | drv_reset_tsf(local, sdata); |
60 | 61 | ||
61 | skb = ifibss->skb; | ||
62 | RCU_INIT_POINTER(ifibss->presp, NULL); | ||
63 | synchronize_rcu(); | ||
64 | skb->data = skb->head; | ||
65 | skb->len = 0; | ||
66 | skb_reset_tail_pointer(skb); | ||
67 | skb_reserve(skb, sdata->local->hw.extra_tx_headroom); | ||
68 | |||
69 | if (!ether_addr_equal(ifibss->bssid, bssid)) | 62 | if (!ether_addr_equal(ifibss->bssid, bssid)) |
70 | sta_info_flush(sdata); | 63 | sta_info_flush(sdata); |
71 | 64 | ||
@@ -73,10 +66,19 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
73 | if (sdata->vif.bss_conf.ibss_joined) { | 66 | if (sdata->vif.bss_conf.ibss_joined) { |
74 | sdata->vif.bss_conf.ibss_joined = false; | 67 | sdata->vif.bss_conf.ibss_joined = false; |
75 | sdata->vif.bss_conf.ibss_creator = false; | 68 | sdata->vif.bss_conf.ibss_creator = false; |
69 | sdata->vif.bss_conf.enable_beacon = false; | ||
76 | netif_carrier_off(sdata->dev); | 70 | netif_carrier_off(sdata->dev); |
77 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS); | 71 | ieee80211_bss_info_change_notify(sdata, |
72 | BSS_CHANGED_IBSS | | ||
73 | BSS_CHANGED_BEACON_ENABLED); | ||
78 | } | 74 | } |
79 | 75 | ||
76 | presp = rcu_dereference_protected(ifibss->presp, | ||
77 | lockdep_is_held(&ifibss->mtx)); | ||
78 | rcu_assign_pointer(ifibss->presp, NULL); | ||
79 | if (presp) | ||
80 | kfree_rcu(presp, rcu_head); | ||
81 | |||
80 | sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; | 82 | sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; |
81 | 83 | ||
82 | cfg80211_chandef_create(&chandef, chan, ifibss->channel_type); | 84 | cfg80211_chandef_create(&chandef, chan, ifibss->channel_type); |
@@ -98,19 +100,24 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
98 | 100 | ||
99 | sband = local->hw.wiphy->bands[chan->band]; | 101 | sband = local->hw.wiphy->bands[chan->band]; |
100 | 102 | ||
101 | /* build supported rates array */ | ||
102 | pos = supp_rates; | ||
103 | for (i = 0; i < sband->n_bitrates; i++) { | ||
104 | int rate = sband->bitrates[i].bitrate; | ||
105 | u8 basic = 0; | ||
106 | if (basic_rates & BIT(i)) | ||
107 | basic = 0x80; | ||
108 | *pos++ = basic | (u8) (rate / 5); | ||
109 | } | ||
110 | |||
111 | /* Build IBSS probe response */ | 103 | /* Build IBSS probe response */ |
112 | mgmt = (void *) skb_put(skb, 24 + sizeof(mgmt->u.beacon)); | 104 | frame_len = sizeof(struct ieee80211_hdr_3addr) + |
113 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); | 105 | 12 /* struct ieee80211_mgmt.u.beacon */ + |
106 | 2 + IEEE80211_MAX_SSID_LEN /* max SSID */ + | ||
107 | 2 + 8 /* max Supported Rates */ + | ||
108 | 3 /* max DS params */ + | ||
109 | 4 /* IBSS params */ + | ||
110 | 2 + (IEEE80211_MAX_SUPP_RATES - 8) + | ||
111 | 2 + sizeof(struct ieee80211_ht_cap) + | ||
112 | 2 + sizeof(struct ieee80211_ht_operation) + | ||
113 | ifibss->ie_len; | ||
114 | presp = kzalloc(sizeof(*presp) + frame_len, GFP_KERNEL); | ||
115 | if (!presp) | ||
116 | return; | ||
117 | |||
118 | presp->head = (void *)(presp + 1); | ||
119 | |||
120 | mgmt = (void *) presp->head; | ||
114 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 121 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
115 | IEEE80211_STYPE_PROBE_RESP); | 122 | IEEE80211_STYPE_PROBE_RESP); |
116 | eth_broadcast_addr(mgmt->da); | 123 | eth_broadcast_addr(mgmt->da); |
@@ -120,27 +127,30 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
120 | mgmt->u.beacon.timestamp = cpu_to_le64(tsf); | 127 | mgmt->u.beacon.timestamp = cpu_to_le64(tsf); |
121 | mgmt->u.beacon.capab_info = cpu_to_le16(capability); | 128 | mgmt->u.beacon.capab_info = cpu_to_le16(capability); |
122 | 129 | ||
123 | pos = skb_put(skb, 2 + ifibss->ssid_len); | 130 | pos = (u8 *)mgmt + offsetof(struct ieee80211_mgmt, u.beacon.variable); |
131 | |||
124 | *pos++ = WLAN_EID_SSID; | 132 | *pos++ = WLAN_EID_SSID; |
125 | *pos++ = ifibss->ssid_len; | 133 | *pos++ = ifibss->ssid_len; |
126 | memcpy(pos, ifibss->ssid, ifibss->ssid_len); | 134 | memcpy(pos, ifibss->ssid, ifibss->ssid_len); |
135 | pos += ifibss->ssid_len; | ||
127 | 136 | ||
128 | rates = sband->n_bitrates; | 137 | rates = min_t(int, 8, sband->n_bitrates); |
129 | if (rates > 8) | ||
130 | rates = 8; | ||
131 | pos = skb_put(skb, 2 + rates); | ||
132 | *pos++ = WLAN_EID_SUPP_RATES; | 138 | *pos++ = WLAN_EID_SUPP_RATES; |
133 | *pos++ = rates; | 139 | *pos++ = rates; |
134 | memcpy(pos, supp_rates, rates); | 140 | for (i = 0; i < rates; i++) { |
141 | int rate = sband->bitrates[i].bitrate; | ||
142 | u8 basic = 0; | ||
143 | if (basic_rates & BIT(i)) | ||
144 | basic = 0x80; | ||
145 | *pos++ = basic | (u8) (rate / 5); | ||
146 | } | ||
135 | 147 | ||
136 | if (sband->band == IEEE80211_BAND_2GHZ) { | 148 | if (sband->band == IEEE80211_BAND_2GHZ) { |
137 | pos = skb_put(skb, 2 + 1); | ||
138 | *pos++ = WLAN_EID_DS_PARAMS; | 149 | *pos++ = WLAN_EID_DS_PARAMS; |
139 | *pos++ = 1; | 150 | *pos++ = 1; |
140 | *pos++ = ieee80211_frequency_to_channel(chan->center_freq); | 151 | *pos++ = ieee80211_frequency_to_channel(chan->center_freq); |
141 | } | 152 | } |
142 | 153 | ||
143 | pos = skb_put(skb, 2 + 2); | ||
144 | *pos++ = WLAN_EID_IBSS_PARAMS; | 154 | *pos++ = WLAN_EID_IBSS_PARAMS; |
145 | *pos++ = 2; | 155 | *pos++ = 2; |
146 | /* FIX: set ATIM window based on scan results */ | 156 | /* FIX: set ATIM window based on scan results */ |
@@ -148,23 +158,25 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
148 | *pos++ = 0; | 158 | *pos++ = 0; |
149 | 159 | ||
150 | if (sband->n_bitrates > 8) { | 160 | if (sband->n_bitrates > 8) { |
151 | rates = sband->n_bitrates - 8; | ||
152 | pos = skb_put(skb, 2 + rates); | ||
153 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 161 | *pos++ = WLAN_EID_EXT_SUPP_RATES; |
154 | *pos++ = rates; | 162 | *pos++ = sband->n_bitrates - 8; |
155 | memcpy(pos, &supp_rates[8], rates); | 163 | for (i = 8; i < sband->n_bitrates; i++) { |
164 | int rate = sband->bitrates[i].bitrate; | ||
165 | u8 basic = 0; | ||
166 | if (basic_rates & BIT(i)) | ||
167 | basic = 0x80; | ||
168 | *pos++ = basic | (u8) (rate / 5); | ||
169 | } | ||
156 | } | 170 | } |
157 | 171 | ||
158 | if (ifibss->ie_len) | 172 | if (ifibss->ie_len) { |
159 | memcpy(skb_put(skb, ifibss->ie_len), | 173 | memcpy(pos, ifibss->ie, ifibss->ie_len); |
160 | ifibss->ie, ifibss->ie_len); | 174 | pos += ifibss->ie_len; |
175 | } | ||
161 | 176 | ||
162 | /* add HT capability and information IEs */ | 177 | /* add HT capability and information IEs */ |
163 | if (chandef.width != NL80211_CHAN_WIDTH_20_NOHT && | 178 | if (chandef.width != NL80211_CHAN_WIDTH_20_NOHT && |
164 | sband->ht_cap.ht_supported) { | 179 | sband->ht_cap.ht_supported) { |
165 | pos = skb_put(skb, 4 + | ||
166 | sizeof(struct ieee80211_ht_cap) + | ||
167 | sizeof(struct ieee80211_ht_operation)); | ||
168 | pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, | 180 | pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, |
169 | sband->ht_cap.cap); | 181 | sband->ht_cap.cap); |
170 | /* | 182 | /* |
@@ -177,7 +189,6 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
177 | } | 189 | } |
178 | 190 | ||
179 | if (local->hw.queues >= IEEE80211_NUM_ACS) { | 191 | if (local->hw.queues >= IEEE80211_NUM_ACS) { |
180 | pos = skb_put(skb, 9); | ||
181 | *pos++ = WLAN_EID_VENDOR_SPECIFIC; | 192 | *pos++ = WLAN_EID_VENDOR_SPECIFIC; |
182 | *pos++ = 7; /* len */ | 193 | *pos++ = 7; /* len */ |
183 | *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */ | 194 | *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */ |
@@ -189,11 +200,17 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
189 | *pos++ = 0; /* U-APSD no in use */ | 200 | *pos++ = 0; /* U-APSD no in use */ |
190 | } | 201 | } |
191 | 202 | ||
192 | rcu_assign_pointer(ifibss->presp, skb); | 203 | presp->head_len = pos - presp->head; |
204 | if (WARN_ON(presp->head_len > frame_len)) | ||
205 | return; | ||
206 | |||
207 | rcu_assign_pointer(ifibss->presp, presp); | ||
193 | 208 | ||
194 | sdata->vif.bss_conf.enable_beacon = true; | 209 | sdata->vif.bss_conf.enable_beacon = true; |
195 | sdata->vif.bss_conf.beacon_int = beacon_int; | 210 | sdata->vif.bss_conf.beacon_int = beacon_int; |
196 | sdata->vif.bss_conf.basic_rates = basic_rates; | 211 | sdata->vif.bss_conf.basic_rates = basic_rates; |
212 | sdata->vif.bss_conf.ssid_len = ifibss->ssid_len; | ||
213 | memcpy(sdata->vif.bss_conf.ssid, ifibss->ssid, ifibss->ssid_len); | ||
197 | bss_change = BSS_CHANGED_BEACON_INT; | 214 | bss_change = BSS_CHANGED_BEACON_INT; |
198 | bss_change |= ieee80211_reset_erp_info(sdata); | 215 | bss_change |= ieee80211_reset_erp_info(sdata); |
199 | bss_change |= BSS_CHANGED_BSSID; | 216 | bss_change |= BSS_CHANGED_BSSID; |
@@ -202,6 +219,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
202 | bss_change |= BSS_CHANGED_BASIC_RATES; | 219 | bss_change |= BSS_CHANGED_BASIC_RATES; |
203 | bss_change |= BSS_CHANGED_HT; | 220 | bss_change |= BSS_CHANGED_HT; |
204 | bss_change |= BSS_CHANGED_IBSS; | 221 | bss_change |= BSS_CHANGED_IBSS; |
222 | bss_change |= BSS_CHANGED_SSID; | ||
205 | 223 | ||
206 | /* | 224 | /* |
207 | * In 5 GHz/802.11a, we can always use short slot time. | 225 | * In 5 GHz/802.11a, we can always use short slot time. |
@@ -227,7 +245,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
227 | round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL)); | 245 | round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL)); |
228 | 246 | ||
229 | bss = cfg80211_inform_bss_frame(local->hw.wiphy, chan, | 247 | bss = cfg80211_inform_bss_frame(local->hw.wiphy, chan, |
230 | mgmt, skb->len, 0, GFP_KERNEL); | 248 | mgmt, presp->head_len, 0, GFP_KERNEL); |
231 | cfg80211_put_bss(local->hw.wiphy, bss); | 249 | cfg80211_put_bss(local->hw.wiphy, bss); |
232 | netif_carrier_on(sdata->dev); | 250 | netif_carrier_on(sdata->dev); |
233 | cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL); | 251 | cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL); |
@@ -448,7 +466,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
448 | struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band]; | 466 | struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band]; |
449 | bool rates_updated = false; | 467 | bool rates_updated = false; |
450 | 468 | ||
451 | if (elems->ds_params && elems->ds_params_len == 1) | 469 | if (elems->ds_params) |
452 | freq = ieee80211_channel_to_frequency(elems->ds_params[0], | 470 | freq = ieee80211_channel_to_frequency(elems->ds_params[0], |
453 | band); | 471 | band); |
454 | else | 472 | else |
@@ -822,8 +840,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
822 | struct ieee80211_local *local = sdata->local; | 840 | struct ieee80211_local *local = sdata->local; |
823 | int tx_last_beacon, len = req->len; | 841 | int tx_last_beacon, len = req->len; |
824 | struct sk_buff *skb; | 842 | struct sk_buff *skb; |
825 | struct ieee80211_mgmt *resp; | 843 | struct beacon_data *presp; |
826 | struct sk_buff *presp; | ||
827 | u8 *pos, *end; | 844 | u8 *pos, *end; |
828 | 845 | ||
829 | lockdep_assert_held(&ifibss->mtx); | 846 | lockdep_assert_held(&ifibss->mtx); |
@@ -864,13 +881,15 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
864 | } | 881 | } |
865 | 882 | ||
866 | /* Reply with ProbeResp */ | 883 | /* Reply with ProbeResp */ |
867 | skb = skb_copy(presp, GFP_KERNEL); | 884 | skb = dev_alloc_skb(local->tx_headroom + presp->head_len); |
868 | if (!skb) | 885 | if (!skb) |
869 | return; | 886 | return; |
870 | 887 | ||
871 | resp = (struct ieee80211_mgmt *) skb->data; | 888 | skb_reserve(skb, local->tx_headroom); |
872 | memcpy(resp->da, mgmt->sa, ETH_ALEN); | 889 | memcpy(skb_put(skb, presp->head_len), presp->head, presp->head_len); |
873 | ibss_dbg(sdata, "Sending ProbeResp to %pM\n", resp->da); | 890 | |
891 | memcpy(((struct ieee80211_mgmt *) skb->data)->da, mgmt->sa, ETH_ALEN); | ||
892 | ibss_dbg(sdata, "Sending ProbeResp to %pM\n", mgmt->sa); | ||
874 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 893 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
875 | ieee80211_tx_skb(sdata, skb); | 894 | ieee80211_tx_skb(sdata, skb); |
876 | } | 895 | } |
@@ -895,7 +914,7 @@ void ieee80211_rx_mgmt_probe_beacon(struct ieee80211_sub_if_data *sdata, | |||
895 | return; | 914 | return; |
896 | 915 | ||
897 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, | 916 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, |
898 | &elems); | 917 | false, &elems); |
899 | 918 | ||
900 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); | 919 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); |
901 | } | 920 | } |
@@ -1020,23 +1039,8 @@ void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local) | |||
1020 | int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | 1039 | int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, |
1021 | struct cfg80211_ibss_params *params) | 1040 | struct cfg80211_ibss_params *params) |
1022 | { | 1041 | { |
1023 | struct sk_buff *skb; | ||
1024 | u32 changed = 0; | 1042 | u32 changed = 0; |
1025 | 1043 | ||
1026 | skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + | ||
1027 | sizeof(struct ieee80211_hdr_3addr) + | ||
1028 | 12 /* struct ieee80211_mgmt.u.beacon */ + | ||
1029 | 2 + IEEE80211_MAX_SSID_LEN /* max SSID */ + | ||
1030 | 2 + 8 /* max Supported Rates */ + | ||
1031 | 3 /* max DS params */ + | ||
1032 | 4 /* IBSS params */ + | ||
1033 | 2 + (IEEE80211_MAX_SUPP_RATES - 8) + | ||
1034 | 2 + sizeof(struct ieee80211_ht_cap) + | ||
1035 | 2 + sizeof(struct ieee80211_ht_operation) + | ||
1036 | params->ie_len); | ||
1037 | if (!skb) | ||
1038 | return -ENOMEM; | ||
1039 | |||
1040 | mutex_lock(&sdata->u.ibss.mtx); | 1044 | mutex_lock(&sdata->u.ibss.mtx); |
1041 | 1045 | ||
1042 | if (params->bssid) { | 1046 | if (params->bssid) { |
@@ -1065,7 +1069,6 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | |||
1065 | sdata->u.ibss.ie_len = params->ie_len; | 1069 | sdata->u.ibss.ie_len = params->ie_len; |
1066 | } | 1070 | } |
1067 | 1071 | ||
1068 | sdata->u.ibss.skb = skb; | ||
1069 | sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH; | 1072 | sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH; |
1070 | sdata->u.ibss.ibss_join_req = jiffies; | 1073 | sdata->u.ibss.ibss_join_req = jiffies; |
1071 | 1074 | ||
@@ -1101,13 +1104,13 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | |||
1101 | 1104 | ||
1102 | int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) | 1105 | int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) |
1103 | { | 1106 | { |
1104 | struct sk_buff *skb; | ||
1105 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | 1107 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
1106 | struct ieee80211_local *local = sdata->local; | 1108 | struct ieee80211_local *local = sdata->local; |
1107 | struct cfg80211_bss *cbss; | 1109 | struct cfg80211_bss *cbss; |
1108 | u16 capability; | 1110 | u16 capability; |
1109 | int active_ibss; | 1111 | int active_ibss; |
1110 | struct sta_info *sta; | 1112 | struct sta_info *sta; |
1113 | struct beacon_data *presp; | ||
1111 | 1114 | ||
1112 | mutex_lock(&sdata->u.ibss.mtx); | 1115 | mutex_lock(&sdata->u.ibss.mtx); |
1113 | 1116 | ||
@@ -1153,17 +1156,18 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) | |||
1153 | 1156 | ||
1154 | /* remove beacon */ | 1157 | /* remove beacon */ |
1155 | kfree(sdata->u.ibss.ie); | 1158 | kfree(sdata->u.ibss.ie); |
1156 | skb = rcu_dereference_protected(sdata->u.ibss.presp, | 1159 | presp = rcu_dereference_protected(ifibss->presp, |
1157 | lockdep_is_held(&sdata->u.ibss.mtx)); | 1160 | lockdep_is_held(&sdata->u.ibss.mtx)); |
1158 | RCU_INIT_POINTER(sdata->u.ibss.presp, NULL); | 1161 | RCU_INIT_POINTER(sdata->u.ibss.presp, NULL); |
1159 | sdata->vif.bss_conf.ibss_joined = false; | 1162 | sdata->vif.bss_conf.ibss_joined = false; |
1160 | sdata->vif.bss_conf.ibss_creator = false; | 1163 | sdata->vif.bss_conf.ibss_creator = false; |
1161 | sdata->vif.bss_conf.enable_beacon = false; | 1164 | sdata->vif.bss_conf.enable_beacon = false; |
1165 | sdata->vif.bss_conf.ssid_len = 0; | ||
1162 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); | 1166 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); |
1163 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | | 1167 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | |
1164 | BSS_CHANGED_IBSS); | 1168 | BSS_CHANGED_IBSS); |
1165 | synchronize_rcu(); | 1169 | synchronize_rcu(); |
1166 | kfree_skb(skb); | 1170 | kfree(presp); |
1167 | 1171 | ||
1168 | skb_queue_purge(&sdata->skb_queue); | 1172 | skb_queue_purge(&sdata->skb_queue); |
1169 | 1173 | ||
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 0b09716d22ad..158e6eb188d3 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -156,6 +156,7 @@ struct ieee80211_tx_data { | |||
156 | struct ieee80211_sub_if_data *sdata; | 156 | struct ieee80211_sub_if_data *sdata; |
157 | struct sta_info *sta; | 157 | struct sta_info *sta; |
158 | struct ieee80211_key *key; | 158 | struct ieee80211_key *key; |
159 | struct ieee80211_tx_rate rate; | ||
159 | 160 | ||
160 | unsigned int flags; | 161 | unsigned int flags; |
161 | }; | 162 | }; |
@@ -443,7 +444,7 @@ struct ieee80211_if_managed { | |||
443 | 444 | ||
444 | u8 use_4addr; | 445 | u8 use_4addr; |
445 | 446 | ||
446 | u8 p2p_noa_index; | 447 | s16 p2p_noa_index; |
447 | 448 | ||
448 | /* Signal strength from the last Beacon frame in the current BSS. */ | 449 | /* Signal strength from the last Beacon frame in the current BSS. */ |
449 | int last_beacon_signal; | 450 | int last_beacon_signal; |
@@ -509,8 +510,7 @@ struct ieee80211_if_ibss { | |||
509 | 510 | ||
510 | unsigned long ibss_join_req; | 511 | unsigned long ibss_join_req; |
511 | /* probe response/beacon for IBSS */ | 512 | /* probe response/beacon for IBSS */ |
512 | struct sk_buff __rcu *presp; | 513 | struct beacon_data __rcu *presp; |
513 | struct sk_buff *skb; | ||
514 | 514 | ||
515 | spinlock_t incomplete_lock; | 515 | spinlock_t incomplete_lock; |
516 | struct list_head incomplete_stations; | 516 | struct list_head incomplete_stations; |
@@ -741,6 +741,8 @@ struct ieee80211_sub_if_data { | |||
741 | 741 | ||
742 | /* bitmap of allowed (non-MCS) rate indexes for rate control */ | 742 | /* bitmap of allowed (non-MCS) rate indexes for rate control */ |
743 | u32 rc_rateidx_mask[IEEE80211_NUM_BANDS]; | 743 | u32 rc_rateidx_mask[IEEE80211_NUM_BANDS]; |
744 | |||
745 | bool rc_has_mcs_mask[IEEE80211_NUM_BANDS]; | ||
744 | u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN]; | 746 | u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN]; |
745 | 747 | ||
746 | union { | 748 | union { |
@@ -1021,10 +1023,9 @@ struct ieee80211_local { | |||
1021 | enum mac80211_scan_state next_scan_state; | 1023 | enum mac80211_scan_state next_scan_state; |
1022 | struct delayed_work scan_work; | 1024 | struct delayed_work scan_work; |
1023 | struct ieee80211_sub_if_data __rcu *scan_sdata; | 1025 | struct ieee80211_sub_if_data __rcu *scan_sdata; |
1024 | struct ieee80211_channel *csa_channel; | 1026 | struct cfg80211_chan_def csa_chandef; |
1025 | /* For backward compatibility only -- do not use */ | 1027 | /* For backward compatibility only -- do not use */ |
1026 | struct ieee80211_channel *_oper_channel; | 1028 | struct cfg80211_chan_def _oper_chandef; |
1027 | enum nl80211_channel_type _oper_channel_type; | ||
1028 | 1029 | ||
1029 | /* Temporary remain-on-channel for off-channel operations */ | 1030 | /* Temporary remain-on-channel for off-channel operations */ |
1030 | struct ieee80211_channel *tmp_channel; | 1031 | struct ieee80211_channel *tmp_channel; |
@@ -1160,11 +1161,8 @@ struct ieee802_11_elems { | |||
1160 | /* pointers to IEs */ | 1161 | /* pointers to IEs */ |
1161 | const u8 *ssid; | 1162 | const u8 *ssid; |
1162 | const u8 *supp_rates; | 1163 | const u8 *supp_rates; |
1163 | const u8 *fh_params; | ||
1164 | const u8 *ds_params; | 1164 | const u8 *ds_params; |
1165 | const u8 *cf_params; | ||
1166 | const struct ieee80211_tim_ie *tim; | 1165 | const struct ieee80211_tim_ie *tim; |
1167 | const u8 *ibss_params; | ||
1168 | const u8 *challenge; | 1166 | const u8 *challenge; |
1169 | const u8 *rsn; | 1167 | const u8 *rsn; |
1170 | const u8 *erp_info; | 1168 | const u8 *erp_info; |
@@ -1184,23 +1182,20 @@ struct ieee802_11_elems { | |||
1184 | const u8 *perr; | 1182 | const u8 *perr; |
1185 | const struct ieee80211_rann_ie *rann; | 1183 | const struct ieee80211_rann_ie *rann; |
1186 | const struct ieee80211_channel_sw_ie *ch_switch_ie; | 1184 | const struct ieee80211_channel_sw_ie *ch_switch_ie; |
1185 | const struct ieee80211_ext_chansw_ie *ext_chansw_ie; | ||
1186 | const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie; | ||
1187 | const u8 *country_elem; | 1187 | const u8 *country_elem; |
1188 | const u8 *pwr_constr_elem; | 1188 | const u8 *pwr_constr_elem; |
1189 | const u8 *quiet_elem; /* first quite element */ | 1189 | const struct ieee80211_timeout_interval_ie *timeout_int; |
1190 | const u8 *timeout_int; | ||
1191 | const u8 *opmode_notif; | 1190 | const u8 *opmode_notif; |
1191 | const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; | ||
1192 | 1192 | ||
1193 | /* length of them, respectively */ | 1193 | /* length of them, respectively */ |
1194 | u8 ssid_len; | 1194 | u8 ssid_len; |
1195 | u8 supp_rates_len; | 1195 | u8 supp_rates_len; |
1196 | u8 fh_params_len; | ||
1197 | u8 ds_params_len; | ||
1198 | u8 cf_params_len; | ||
1199 | u8 tim_len; | 1196 | u8 tim_len; |
1200 | u8 ibss_params_len; | ||
1201 | u8 challenge_len; | 1197 | u8 challenge_len; |
1202 | u8 rsn_len; | 1198 | u8 rsn_len; |
1203 | u8 erp_info_len; | ||
1204 | u8 ext_supp_rates_len; | 1199 | u8 ext_supp_rates_len; |
1205 | u8 wmm_info_len; | 1200 | u8 wmm_info_len; |
1206 | u8 wmm_param_len; | 1201 | u8 wmm_param_len; |
@@ -1210,9 +1205,6 @@ struct ieee802_11_elems { | |||
1210 | u8 prep_len; | 1205 | u8 prep_len; |
1211 | u8 perr_len; | 1206 | u8 perr_len; |
1212 | u8 country_elem_len; | 1207 | u8 country_elem_len; |
1213 | u8 quiet_elem_len; | ||
1214 | u8 num_of_quiet_elem; /* can be more the one */ | ||
1215 | u8 timeout_int_len; | ||
1216 | 1208 | ||
1217 | /* whether a parse error occurred while retrieving these elements */ | 1209 | /* whether a parse error occurred while retrieving these elements */ |
1218 | bool parse_error; | 1210 | bool parse_error; |
@@ -1267,10 +1259,6 @@ void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata); | |||
1267 | int ieee80211_max_network_latency(struct notifier_block *nb, | 1259 | int ieee80211_max_network_latency(struct notifier_block *nb, |
1268 | unsigned long data, void *dummy); | 1260 | unsigned long data, void *dummy); |
1269 | int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata); | 1261 | int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata); |
1270 | void | ||
1271 | ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | ||
1272 | const struct ieee80211_channel_sw_ie *sw_elem, | ||
1273 | struct ieee80211_bss *bss, u64 timestamp); | ||
1274 | void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata); | 1262 | void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata); |
1275 | void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | 1263 | void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, |
1276 | struct sk_buff *skb); | 1264 | struct sk_buff *skb); |
@@ -1330,7 +1318,8 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local); | |||
1330 | void ieee80211_offchannel_return(struct ieee80211_local *local); | 1318 | void ieee80211_offchannel_return(struct ieee80211_local *local); |
1331 | void ieee80211_roc_setup(struct ieee80211_local *local); | 1319 | void ieee80211_roc_setup(struct ieee80211_local *local); |
1332 | void ieee80211_start_next_roc(struct ieee80211_local *local); | 1320 | void ieee80211_start_next_roc(struct ieee80211_local *local); |
1333 | void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata); | 1321 | void ieee80211_roc_purge(struct ieee80211_local *local, |
1322 | struct ieee80211_sub_if_data *sdata); | ||
1334 | void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free); | 1323 | void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc, bool free); |
1335 | void ieee80211_sw_roc_work(struct work_struct *work); | 1324 | void ieee80211_sw_roc_work(struct work_struct *work); |
1336 | void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc); | 1325 | void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc); |
@@ -1351,6 +1340,8 @@ void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata, | |||
1351 | const int offset); | 1340 | const int offset); |
1352 | int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up); | 1341 | int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up); |
1353 | void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata); | 1342 | void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata); |
1343 | int ieee80211_add_virtual_monitor(struct ieee80211_local *local); | ||
1344 | void ieee80211_del_virtual_monitor(struct ieee80211_local *local); | ||
1354 | 1345 | ||
1355 | bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); | 1346 | bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); |
1356 | void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); | 1347 | void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); |
@@ -1505,11 +1496,15 @@ static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, | |||
1505 | ieee80211_tx_skb_tid(sdata, skb, 7); | 1496 | ieee80211_tx_skb_tid(sdata, skb, 7); |
1506 | } | 1497 | } |
1507 | 1498 | ||
1508 | void ieee802_11_parse_elems(u8 *start, size_t len, | 1499 | u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action, |
1509 | struct ieee802_11_elems *elems); | ||
1510 | u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | ||
1511 | struct ieee802_11_elems *elems, | 1500 | struct ieee802_11_elems *elems, |
1512 | u64 filter, u32 crc); | 1501 | u64 filter, u32 crc); |
1502 | static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action, | ||
1503 | struct ieee802_11_elems *elems) | ||
1504 | { | ||
1505 | ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0); | ||
1506 | } | ||
1507 | |||
1513 | u32 ieee80211_mandatory_rates(struct ieee80211_local *local, | 1508 | u32 ieee80211_mandatory_rates(struct ieee80211_local *local, |
1514 | enum ieee80211_band band); | 1509 | enum ieee80211_band band); |
1515 | 1510 | ||
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index e8a260f53c16..60f1ce5e5e52 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Interface handling (except master interface) | 2 | * Interface handling |
3 | * | 3 | * |
4 | * Copyright 2002-2005, Instant802 Networks, Inc. | 4 | * Copyright 2002-2005, Instant802 Networks, Inc. |
5 | * Copyright 2005-2006, Devicescape Software, Inc. | 5 | * Copyright 2005-2006, Devicescape Software, Inc. |
@@ -357,7 +357,7 @@ static void ieee80211_set_default_queues(struct ieee80211_sub_if_data *sdata) | |||
357 | sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE; | 357 | sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE; |
358 | } | 358 | } |
359 | 359 | ||
360 | static int ieee80211_add_virtual_monitor(struct ieee80211_local *local) | 360 | int ieee80211_add_virtual_monitor(struct ieee80211_local *local) |
361 | { | 361 | { |
362 | struct ieee80211_sub_if_data *sdata; | 362 | struct ieee80211_sub_if_data *sdata; |
363 | int ret; | 363 | int ret; |
@@ -410,7 +410,7 @@ static int ieee80211_add_virtual_monitor(struct ieee80211_local *local) | |||
410 | return 0; | 410 | return 0; |
411 | } | 411 | } |
412 | 412 | ||
413 | static void ieee80211_del_virtual_monitor(struct ieee80211_local *local) | 413 | void ieee80211_del_virtual_monitor(struct ieee80211_local *local) |
414 | { | 414 | { |
415 | struct ieee80211_sub_if_data *sdata; | 415 | struct ieee80211_sub_if_data *sdata; |
416 | 416 | ||
@@ -595,7 +595,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up) | |||
595 | case NL80211_IFTYPE_P2P_DEVICE: | 595 | case NL80211_IFTYPE_P2P_DEVICE: |
596 | break; | 596 | break; |
597 | default: | 597 | default: |
598 | netif_carrier_on(dev); | 598 | /* not reached */ |
599 | WARN_ON(1); | ||
599 | } | 600 | } |
600 | 601 | ||
601 | /* | 602 | /* |
@@ -652,8 +653,28 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up) | |||
652 | 653 | ||
653 | ieee80211_recalc_ps(local, -1); | 654 | ieee80211_recalc_ps(local, -1); |
654 | 655 | ||
655 | if (dev) | 656 | if (dev) { |
656 | netif_tx_start_all_queues(dev); | 657 | unsigned long flags; |
658 | int n_acs = IEEE80211_NUM_ACS; | ||
659 | int ac; | ||
660 | |||
661 | if (local->hw.queues < IEEE80211_NUM_ACS) | ||
662 | n_acs = 1; | ||
663 | |||
664 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | ||
665 | if (sdata->vif.cab_queue == IEEE80211_INVAL_HW_QUEUE || | ||
666 | (local->queue_stop_reasons[sdata->vif.cab_queue] == 0 && | ||
667 | skb_queue_empty(&local->pending[sdata->vif.cab_queue]))) { | ||
668 | for (ac = 0; ac < n_acs; ac++) { | ||
669 | int ac_queue = sdata->vif.hw_queue[ac]; | ||
670 | |||
671 | if (local->queue_stop_reasons[ac_queue] == 0 && | ||
672 | skb_queue_empty(&local->pending[ac_queue])) | ||
673 | netif_start_subqueue(dev, ac); | ||
674 | } | ||
675 | } | ||
676 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
677 | } | ||
657 | 678 | ||
658 | return 0; | 679 | return 0; |
659 | err_del_interface: | 680 | err_del_interface: |
@@ -707,7 +728,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
707 | if (sdata->dev) | 728 | if (sdata->dev) |
708 | netif_tx_stop_all_queues(sdata->dev); | 729 | netif_tx_stop_all_queues(sdata->dev); |
709 | 730 | ||
710 | ieee80211_roc_purge(sdata); | 731 | ieee80211_roc_purge(local, sdata); |
711 | 732 | ||
712 | if (sdata->vif.type == NL80211_IFTYPE_STATION) | 733 | if (sdata->vif.type == NL80211_IFTYPE_STATION) |
713 | ieee80211_mgd_stop(sdata); | 734 | ieee80211_mgd_stop(sdata); |
@@ -732,12 +753,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
732 | WARN_ON_ONCE((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) || | 753 | WARN_ON_ONCE((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) || |
733 | (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1)); | 754 | (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1)); |
734 | 755 | ||
735 | /* | 756 | /* don't count this interface for promisc/allmulti while it is down */ |
736 | * Don't count this interface for promisc/allmulti while it | ||
737 | * is down. dev_mc_unsync() will invoke set_multicast_list | ||
738 | * on the master interface which will sync these down to the | ||
739 | * hardware as filter flags. | ||
740 | */ | ||
741 | if (sdata->flags & IEEE80211_SDATA_ALLMULTI) | 757 | if (sdata->flags & IEEE80211_SDATA_ALLMULTI) |
742 | atomic_dec(&local->iff_allmultis); | 758 | atomic_dec(&local->iff_allmultis); |
743 | 759 | ||
@@ -758,8 +774,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
758 | sdata->dev->addr_len); | 774 | sdata->dev->addr_len); |
759 | spin_unlock_bh(&local->filter_lock); | 775 | spin_unlock_bh(&local->filter_lock); |
760 | netif_addr_unlock_bh(sdata->dev); | 776 | netif_addr_unlock_bh(sdata->dev); |
761 | |||
762 | ieee80211_configure_filter(local); | ||
763 | } | 777 | } |
764 | 778 | ||
765 | del_timer_sync(&local->dynamic_ps_timer); | 779 | del_timer_sync(&local->dynamic_ps_timer); |
@@ -770,6 +784,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
770 | cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); | 784 | cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); |
771 | 785 | ||
772 | if (sdata->wdev.cac_started) { | 786 | if (sdata->wdev.cac_started) { |
787 | WARN_ON(local->suspended); | ||
773 | mutex_lock(&local->iflist_mtx); | 788 | mutex_lock(&local->iflist_mtx); |
774 | ieee80211_vif_release_channel(sdata); | 789 | ieee80211_vif_release_channel(sdata); |
775 | mutex_unlock(&local->iflist_mtx); | 790 | mutex_unlock(&local->iflist_mtx); |
@@ -820,14 +835,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
820 | if (local->monitors == 0) { | 835 | if (local->monitors == 0) { |
821 | local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR; | 836 | local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR; |
822 | hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR; | 837 | hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR; |
823 | ieee80211_del_virtual_monitor(local); | ||
824 | } | 838 | } |
825 | 839 | ||
826 | ieee80211_adjust_monitor_flags(sdata, -1); | 840 | ieee80211_adjust_monitor_flags(sdata, -1); |
827 | ieee80211_configure_filter(local); | ||
828 | mutex_lock(&local->mtx); | ||
829 | ieee80211_recalc_idle(local); | ||
830 | mutex_unlock(&local->mtx); | ||
831 | break; | 841 | break; |
832 | case NL80211_IFTYPE_P2P_DEVICE: | 842 | case NL80211_IFTYPE_P2P_DEVICE: |
833 | /* relies on synchronize_rcu() below */ | 843 | /* relies on synchronize_rcu() below */ |
@@ -840,11 +850,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
840 | * | 850 | * |
841 | * sta_info_flush_cleanup() requires rcu_barrier() | 851 | * sta_info_flush_cleanup() requires rcu_barrier() |
842 | * first to wait for the station call_rcu() calls | 852 | * first to wait for the station call_rcu() calls |
843 | * to complete, here we need at least sychronize_rcu() | 853 | * to complete, and we also need synchronize_rcu() |
844 | * it to wait for the RX path in case it is using the | 854 | * to wait for the RX path in case it is using the |
845 | * interface and enqueuing frames at this very time on | 855 | * interface and enqueuing frames at this very time on |
846 | * another CPU. | 856 | * another CPU. |
847 | */ | 857 | */ |
858 | synchronize_rcu(); | ||
848 | rcu_barrier(); | 859 | rcu_barrier(); |
849 | sta_info_flush_cleanup(sdata); | 860 | sta_info_flush_cleanup(sdata); |
850 | 861 | ||
@@ -857,27 +868,10 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
857 | /* fall through */ | 868 | /* fall through */ |
858 | case NL80211_IFTYPE_AP: | 869 | case NL80211_IFTYPE_AP: |
859 | skb_queue_purge(&sdata->skb_queue); | 870 | skb_queue_purge(&sdata->skb_queue); |
860 | |||
861 | if (going_down) | ||
862 | drv_remove_interface(local, sdata); | ||
863 | } | 871 | } |
864 | 872 | ||
865 | sdata->bss = NULL; | 873 | sdata->bss = NULL; |
866 | 874 | ||
867 | ieee80211_recalc_ps(local, -1); | ||
868 | |||
869 | if (local->open_count == 0) { | ||
870 | ieee80211_clear_tx_pending(local); | ||
871 | ieee80211_stop_device(local); | ||
872 | |||
873 | /* no reconfiguring after stop! */ | ||
874 | hw_reconf_flags = 0; | ||
875 | } | ||
876 | |||
877 | /* do after stop to avoid reconfiguring when we stop anyway */ | ||
878 | if (hw_reconf_flags) | ||
879 | ieee80211_hw_config(local, hw_reconf_flags); | ||
880 | |||
881 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 875 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
882 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { | 876 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { |
883 | skb_queue_walk_safe(&local->pending[i], skb, tmp) { | 877 | skb_queue_walk_safe(&local->pending[i], skb, tmp) { |
@@ -890,7 +884,54 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
890 | } | 884 | } |
891 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | 885 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); |
892 | 886 | ||
893 | if (local->monitors == local->open_count && local->monitors > 0) | 887 | if (local->open_count == 0) |
888 | ieee80211_clear_tx_pending(local); | ||
889 | |||
890 | /* | ||
891 | * If the interface goes down while suspended, presumably because | ||
892 | * the device was unplugged and that happens before our resume, | ||
893 | * then the driver is already unconfigured and the remainder of | ||
894 | * this function isn't needed. | ||
895 | * XXX: what about WoWLAN? If the device has software state, e.g. | ||
896 | * memory allocated, it might expect teardown commands from | ||
897 | * mac80211 here? | ||
898 | */ | ||
899 | if (local->suspended) { | ||
900 | WARN_ON(local->wowlan); | ||
901 | WARN_ON(rtnl_dereference(local->monitor_sdata)); | ||
902 | return; | ||
903 | } | ||
904 | |||
905 | switch (sdata->vif.type) { | ||
906 | case NL80211_IFTYPE_AP_VLAN: | ||
907 | break; | ||
908 | case NL80211_IFTYPE_MONITOR: | ||
909 | if (local->monitors == 0) | ||
910 | ieee80211_del_virtual_monitor(local); | ||
911 | |||
912 | mutex_lock(&local->mtx); | ||
913 | ieee80211_recalc_idle(local); | ||
914 | mutex_unlock(&local->mtx); | ||
915 | break; | ||
916 | default: | ||
917 | if (going_down) | ||
918 | drv_remove_interface(local, sdata); | ||
919 | } | ||
920 | |||
921 | ieee80211_recalc_ps(local, -1); | ||
922 | |||
923 | if (local->open_count == 0) { | ||
924 | ieee80211_stop_device(local); | ||
925 | |||
926 | /* no reconfiguring after stop! */ | ||
927 | return; | ||
928 | } | ||
929 | |||
930 | /* do after stop to avoid reconfiguring when we stop anyway */ | ||
931 | ieee80211_configure_filter(local); | ||
932 | ieee80211_hw_config(local, hw_reconf_flags); | ||
933 | |||
934 | if (local->monitors == local->open_count) | ||
894 | ieee80211_add_virtual_monitor(local); | 935 | ieee80211_add_virtual_monitor(local); |
895 | } | 936 | } |
896 | 937 | ||
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index c6f81ecc36a1..8a7bfc47d577 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -95,42 +95,47 @@ static void ieee80211_reconfig_filter(struct work_struct *work) | |||
95 | static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local) | 95 | static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local) |
96 | { | 96 | { |
97 | struct ieee80211_sub_if_data *sdata; | 97 | struct ieee80211_sub_if_data *sdata; |
98 | struct ieee80211_channel *chan; | 98 | struct cfg80211_chan_def chandef = {}; |
99 | u32 changed = 0; | 99 | u32 changed = 0; |
100 | int power; | 100 | int power; |
101 | enum nl80211_channel_type channel_type; | ||
102 | u32 offchannel_flag; | 101 | u32 offchannel_flag; |
103 | 102 | ||
104 | offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; | 103 | offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; |
104 | |||
105 | if (local->scan_channel) { | 105 | if (local->scan_channel) { |
106 | chan = local->scan_channel; | 106 | chandef.chan = local->scan_channel; |
107 | /* If scanning on oper channel, use whatever channel-type | 107 | /* If scanning on oper channel, use whatever channel-type |
108 | * is currently in use. | 108 | * is currently in use. |
109 | */ | 109 | */ |
110 | if (chan == local->_oper_channel) | 110 | if (chandef.chan == local->_oper_chandef.chan) { |
111 | channel_type = local->_oper_channel_type; | 111 | chandef = local->_oper_chandef; |
112 | else | 112 | } else { |
113 | channel_type = NL80211_CHAN_NO_HT; | 113 | chandef.width = NL80211_CHAN_WIDTH_20_NOHT; |
114 | chandef.center_freq1 = chandef.chan->center_freq; | ||
115 | } | ||
114 | } else if (local->tmp_channel) { | 116 | } else if (local->tmp_channel) { |
115 | chan = local->tmp_channel; | 117 | chandef.chan = local->tmp_channel; |
116 | channel_type = NL80211_CHAN_NO_HT; | 118 | chandef.width = NL80211_CHAN_WIDTH_20_NOHT; |
117 | } else { | 119 | chandef.center_freq1 = chandef.chan->center_freq; |
118 | chan = local->_oper_channel; | 120 | } else |
119 | channel_type = local->_oper_channel_type; | 121 | chandef = local->_oper_chandef; |
120 | } | 122 | |
121 | 123 | WARN(!cfg80211_chandef_valid(&chandef), | |
122 | if (chan != local->_oper_channel || | 124 | "control:%d MHz width:%d center: %d/%d MHz", |
123 | channel_type != local->_oper_channel_type) | 125 | chandef.chan->center_freq, chandef.width, |
126 | chandef.center_freq1, chandef.center_freq2); | ||
127 | |||
128 | if (!cfg80211_chandef_identical(&chandef, &local->_oper_chandef)) | ||
124 | local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; | 129 | local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; |
125 | else | 130 | else |
126 | local->hw.conf.flags &= ~IEEE80211_CONF_OFFCHANNEL; | 131 | local->hw.conf.flags &= ~IEEE80211_CONF_OFFCHANNEL; |
127 | 132 | ||
128 | offchannel_flag ^= local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; | 133 | offchannel_flag ^= local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; |
129 | 134 | ||
130 | if (offchannel_flag || chan != local->hw.conf.channel || | 135 | if (offchannel_flag || |
131 | channel_type != local->hw.conf.channel_type) { | 136 | !cfg80211_chandef_identical(&local->hw.conf.chandef, |
132 | local->hw.conf.channel = chan; | 137 | &local->_oper_chandef)) { |
133 | local->hw.conf.channel_type = channel_type; | 138 | local->hw.conf.chandef = chandef; |
134 | changed |= IEEE80211_CONF_CHANGE_CHANNEL; | 139 | changed |= IEEE80211_CONF_CHANGE_CHANNEL; |
135 | } | 140 | } |
136 | 141 | ||
@@ -146,7 +151,7 @@ static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local) | |||
146 | changed |= IEEE80211_CONF_CHANGE_SMPS; | 151 | changed |= IEEE80211_CONF_CHANGE_SMPS; |
147 | } | 152 | } |
148 | 153 | ||
149 | power = chan->max_power; | 154 | power = chandef.chan->max_power; |
150 | 155 | ||
151 | rcu_read_lock(); | 156 | rcu_read_lock(); |
152 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 157 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
@@ -587,6 +592,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
587 | IEEE80211_RADIOTAP_MCS_HAVE_BW; | 592 | IEEE80211_RADIOTAP_MCS_HAVE_BW; |
588 | local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI | | 593 | local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI | |
589 | IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH; | 594 | IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH; |
595 | local->hw.uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; | ||
596 | local->hw.uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; | ||
590 | local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; | 597 | local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; |
591 | wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask; | 598 | wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask; |
592 | wiphy->vht_capa_mod_mask = &mac80211_vht_capa_mod_mask; | 599 | wiphy->vht_capa_mod_mask = &mac80211_vht_capa_mod_mask; |
@@ -661,6 +668,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
661 | int channels, max_bitrates; | 668 | int channels, max_bitrates; |
662 | bool supp_ht, supp_vht; | 669 | bool supp_ht, supp_vht; |
663 | netdev_features_t feature_whitelist; | 670 | netdev_features_t feature_whitelist; |
671 | struct cfg80211_chan_def dflt_chandef = {}; | ||
664 | static const u32 cipher_suites[] = { | 672 | static const u32 cipher_suites[] = { |
665 | /* keep WEP first, it may be removed below */ | 673 | /* keep WEP first, it may be removed below */ |
666 | WLAN_CIPHER_SUITE_WEP40, | 674 | WLAN_CIPHER_SUITE_WEP40, |
@@ -738,15 +746,19 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
738 | sband = local->hw.wiphy->bands[band]; | 746 | sband = local->hw.wiphy->bands[band]; |
739 | if (!sband) | 747 | if (!sband) |
740 | continue; | 748 | continue; |
741 | if (!local->use_chanctx && !local->_oper_channel) { | 749 | |
750 | if (!dflt_chandef.chan) { | ||
751 | cfg80211_chandef_create(&dflt_chandef, | ||
752 | &sband->channels[0], | ||
753 | NL80211_CHAN_NO_HT); | ||
742 | /* init channel we're on */ | 754 | /* init channel we're on */ |
743 | local->hw.conf.channel = | 755 | if (!local->use_chanctx && !local->_oper_chandef.chan) { |
744 | local->_oper_channel = &sband->channels[0]; | 756 | local->hw.conf.chandef = dflt_chandef; |
745 | local->hw.conf.channel_type = NL80211_CHAN_NO_HT; | 757 | local->_oper_chandef = dflt_chandef; |
758 | } | ||
759 | local->monitor_chandef = dflt_chandef; | ||
746 | } | 760 | } |
747 | cfg80211_chandef_create(&local->monitor_chandef, | 761 | |
748 | &sband->channels[0], | ||
749 | NL80211_CHAN_NO_HT); | ||
750 | channels += sband->n_channels; | 762 | channels += sband->n_channels; |
751 | 763 | ||
752 | if (max_bitrates < sband->n_bitrates) | 764 | if (max_bitrates < sband->n_bitrates) |
@@ -829,22 +841,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
829 | if (supp_ht) | 841 | if (supp_ht) |
830 | local->scan_ies_len += 2 + sizeof(struct ieee80211_ht_cap); | 842 | local->scan_ies_len += 2 + sizeof(struct ieee80211_ht_cap); |
831 | 843 | ||
832 | if (supp_vht) { | 844 | if (supp_vht) |
833 | local->scan_ies_len += | 845 | local->scan_ies_len += |
834 | 2 + sizeof(struct ieee80211_vht_cap); | 846 | 2 + sizeof(struct ieee80211_vht_cap); |
835 | 847 | ||
836 | /* | ||
837 | * (for now at least), drivers wanting to use VHT must | ||
838 | * support channel contexts, as they contain all the | ||
839 | * necessary VHT information and the global hw config | ||
840 | * doesn't (yet) | ||
841 | */ | ||
842 | if (WARN_ON(!local->use_chanctx)) { | ||
843 | result = -EINVAL; | ||
844 | goto fail_wiphy_register; | ||
845 | } | ||
846 | } | ||
847 | |||
848 | if (!local->ops->hw_scan) { | 848 | if (!local->ops->hw_scan) { |
849 | /* For hw_scan, driver needs to set these up. */ | 849 | /* For hw_scan, driver needs to set these up. */ |
850 | local->hw.wiphy->max_scan_ssids = 4; | 850 | local->hw.wiphy->max_scan_ssids = 4; |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 123a300cef57..6952760881c8 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -838,7 +838,7 @@ ieee80211_mesh_rx_probe_req(struct ieee80211_sub_if_data *sdata, | |||
838 | if (baselen > len) | 838 | if (baselen > len) |
839 | return; | 839 | return; |
840 | 840 | ||
841 | ieee802_11_parse_elems(pos, len - baselen, &elems); | 841 | ieee802_11_parse_elems(pos, len - baselen, false, &elems); |
842 | 842 | ||
843 | /* 802.11-2012 10.1.4.3.2 */ | 843 | /* 802.11-2012 10.1.4.3.2 */ |
844 | if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) && | 844 | if ((!ether_addr_equal(mgmt->da, sdata->vif.addr) && |
@@ -899,7 +899,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
899 | return; | 899 | return; |
900 | 900 | ||
901 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, | 901 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, |
902 | &elems); | 902 | false, &elems); |
903 | 903 | ||
904 | /* ignore non-mesh or secure / unsecure mismatch */ | 904 | /* ignore non-mesh or secure / unsecure mismatch */ |
905 | if ((!elems.mesh_id || !elems.mesh_config) || | 905 | if ((!elems.mesh_id || !elems.mesh_config) || |
@@ -907,7 +907,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
907 | (!elems.rsn && sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)) | 907 | (!elems.rsn && sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)) |
908 | return; | 908 | return; |
909 | 909 | ||
910 | if (elems.ds_params && elems.ds_params_len == 1) | 910 | if (elems.ds_params) |
911 | freq = ieee80211_channel_to_frequency(elems.ds_params[0], band); | 911 | freq = ieee80211_channel_to_frequency(elems.ds_params[0], band); |
912 | else | 912 | else |
913 | freq = rx_status->freq; | 913 | freq = rx_status->freq; |
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 6ffabbe99c46..da158774eebb 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h | |||
@@ -275,7 +275,8 @@ void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop); | |||
275 | void mesh_path_expire(struct ieee80211_sub_if_data *sdata); | 275 | void mesh_path_expire(struct ieee80211_sub_if_data *sdata); |
276 | void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, | 276 | void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, |
277 | struct ieee80211_mgmt *mgmt, size_t len); | 277 | struct ieee80211_mgmt *mgmt, size_t len); |
278 | int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst); | 278 | struct mesh_path * |
279 | mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst); | ||
279 | 280 | ||
280 | int mesh_path_add_gate(struct mesh_path *mpath); | 281 | int mesh_path_add_gate(struct mesh_path *mpath); |
281 | int mesh_path_send_to_gates(struct mesh_path *mpath); | 282 | int mesh_path_send_to_gates(struct mesh_path *mpath); |
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index bdb8d3b14587..486819cd02cd 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -144,7 +144,7 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, | |||
144 | *pos++ = WLAN_EID_PREQ; | 144 | *pos++ = WLAN_EID_PREQ; |
145 | break; | 145 | break; |
146 | case MPATH_PREP: | 146 | case MPATH_PREP: |
147 | mhwmp_dbg(sdata, "sending PREP to %pM\n", target); | 147 | mhwmp_dbg(sdata, "sending PREP to %pM\n", orig_addr); |
148 | ie_len = 31; | 148 | ie_len = 31; |
149 | pos = skb_put(skb, 2 + ie_len); | 149 | pos = skb_put(skb, 2 + ie_len); |
150 | *pos++ = WLAN_EID_PREP; | 150 | *pos++ = WLAN_EID_PREP; |
@@ -445,9 +445,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
445 | } | 445 | } |
446 | } | 446 | } |
447 | } else { | 447 | } else { |
448 | mesh_path_add(sdata, orig_addr); | 448 | mpath = mesh_path_add(sdata, orig_addr); |
449 | mpath = mesh_path_lookup(sdata, orig_addr); | 449 | if (IS_ERR(mpath)) { |
450 | if (!mpath) { | ||
451 | rcu_read_unlock(); | 450 | rcu_read_unlock(); |
452 | return 0; | 451 | return 0; |
453 | } | 452 | } |
@@ -486,9 +485,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
486 | (last_hop_metric > mpath->metric))) | 485 | (last_hop_metric > mpath->metric))) |
487 | fresh_info = false; | 486 | fresh_info = false; |
488 | } else { | 487 | } else { |
489 | mesh_path_add(sdata, ta); | 488 | mpath = mesh_path_add(sdata, ta); |
490 | mpath = mesh_path_lookup(sdata, ta); | 489 | if (IS_ERR(mpath)) { |
491 | if (!mpath) { | ||
492 | rcu_read_unlock(); | 490 | rcu_read_unlock(); |
493 | return 0; | 491 | return 0; |
494 | } | 492 | } |
@@ -661,7 +659,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
661 | u32 target_sn, orig_sn, lifetime; | 659 | u32 target_sn, orig_sn, lifetime; |
662 | 660 | ||
663 | mhwmp_dbg(sdata, "received PREP from %pM\n", | 661 | mhwmp_dbg(sdata, "received PREP from %pM\n", |
664 | PREP_IE_ORIG_ADDR(prep_elem)); | 662 | PREP_IE_TARGET_ADDR(prep_elem)); |
665 | 663 | ||
666 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); | 664 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); |
667 | if (ether_addr_equal(orig_addr, sdata->vif.addr)) | 665 | if (ether_addr_equal(orig_addr, sdata->vif.addr)) |
@@ -804,9 +802,8 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, | |||
804 | 802 | ||
805 | mpath = mesh_path_lookup(sdata, orig_addr); | 803 | mpath = mesh_path_lookup(sdata, orig_addr); |
806 | if (!mpath) { | 804 | if (!mpath) { |
807 | mesh_path_add(sdata, orig_addr); | 805 | mpath = mesh_path_add(sdata, orig_addr); |
808 | mpath = mesh_path_lookup(sdata, orig_addr); | 806 | if (IS_ERR(mpath)) { |
809 | if (!mpath) { | ||
810 | rcu_read_unlock(); | 807 | rcu_read_unlock(); |
811 | sdata->u.mesh.mshstats.dropped_frames_no_route++; | 808 | sdata->u.mesh.mshstats.dropped_frames_no_route++; |
812 | return; | 809 | return; |
@@ -883,7 +880,7 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, | |||
883 | 880 | ||
884 | baselen = (u8 *) mgmt->u.action.u.mesh_action.variable - (u8 *) mgmt; | 881 | baselen = (u8 *) mgmt->u.action.u.mesh_action.variable - (u8 *) mgmt; |
885 | ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable, | 882 | ieee802_11_parse_elems(mgmt->u.action.u.mesh_action.variable, |
886 | len - baselen, &elems); | 883 | len - baselen, false, &elems); |
887 | 884 | ||
888 | if (elems.preq) { | 885 | if (elems.preq) { |
889 | if (elems.preq_len != 37) | 886 | if (elems.preq_len != 37) |
@@ -1098,11 +1095,10 @@ int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata, | |||
1098 | /* no nexthop found, start resolving */ | 1095 | /* no nexthop found, start resolving */ |
1099 | mpath = mesh_path_lookup(sdata, target_addr); | 1096 | mpath = mesh_path_lookup(sdata, target_addr); |
1100 | if (!mpath) { | 1097 | if (!mpath) { |
1101 | mesh_path_add(sdata, target_addr); | 1098 | mpath = mesh_path_add(sdata, target_addr); |
1102 | mpath = mesh_path_lookup(sdata, target_addr); | 1099 | if (IS_ERR(mpath)) { |
1103 | if (!mpath) { | ||
1104 | mesh_path_discard_frame(sdata, skb); | 1100 | mesh_path_discard_frame(sdata, skb); |
1105 | err = -ENOSPC; | 1101 | err = PTR_ERR(mpath); |
1106 | goto endlookup; | 1102 | goto endlookup; |
1107 | } | 1103 | } |
1108 | } | 1104 | } |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index dc7c8df40c2c..89aacfd2756d 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -493,7 +493,8 @@ int mesh_gate_num(struct ieee80211_sub_if_data *sdata) | |||
493 | * | 493 | * |
494 | * State: the initial state of the new path is set to 0 | 494 | * State: the initial state of the new path is set to 0 |
495 | */ | 495 | */ |
496 | int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst) | 496 | struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, |
497 | const u8 *dst) | ||
497 | { | 498 | { |
498 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 499 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
499 | struct ieee80211_local *local = sdata->local; | 500 | struct ieee80211_local *local = sdata->local; |
@@ -502,18 +503,33 @@ int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst) | |||
502 | struct mpath_node *node, *new_node; | 503 | struct mpath_node *node, *new_node; |
503 | struct hlist_head *bucket; | 504 | struct hlist_head *bucket; |
504 | int grow = 0; | 505 | int grow = 0; |
505 | int err = 0; | 506 | int err; |
506 | u32 hash_idx; | 507 | u32 hash_idx; |
507 | 508 | ||
508 | if (ether_addr_equal(dst, sdata->vif.addr)) | 509 | if (ether_addr_equal(dst, sdata->vif.addr)) |
509 | /* never add ourselves as neighbours */ | 510 | /* never add ourselves as neighbours */ |
510 | return -ENOTSUPP; | 511 | return ERR_PTR(-ENOTSUPP); |
511 | 512 | ||
512 | if (is_multicast_ether_addr(dst)) | 513 | if (is_multicast_ether_addr(dst)) |
513 | return -ENOTSUPP; | 514 | return ERR_PTR(-ENOTSUPP); |
514 | 515 | ||
515 | if (atomic_add_unless(&sdata->u.mesh.mpaths, 1, MESH_MAX_MPATHS) == 0) | 516 | if (atomic_add_unless(&sdata->u.mesh.mpaths, 1, MESH_MAX_MPATHS) == 0) |
516 | return -ENOSPC; | 517 | return ERR_PTR(-ENOSPC); |
518 | |||
519 | read_lock_bh(&pathtbl_resize_lock); | ||
520 | tbl = resize_dereference_mesh_paths(); | ||
521 | |||
522 | hash_idx = mesh_table_hash(dst, sdata, tbl); | ||
523 | bucket = &tbl->hash_buckets[hash_idx]; | ||
524 | |||
525 | spin_lock(&tbl->hashwlock[hash_idx]); | ||
526 | |||
527 | hlist_for_each_entry(node, bucket, list) { | ||
528 | mpath = node->mpath; | ||
529 | if (mpath->sdata == sdata && | ||
530 | ether_addr_equal(dst, mpath->dst)) | ||
531 | goto found; | ||
532 | } | ||
517 | 533 | ||
518 | err = -ENOMEM; | 534 | err = -ENOMEM; |
519 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC); | 535 | new_mpath = kzalloc(sizeof(struct mesh_path), GFP_ATOMIC); |
@@ -524,7 +540,6 @@ int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst) | |||
524 | if (!new_node) | 540 | if (!new_node) |
525 | goto err_node_alloc; | 541 | goto err_node_alloc; |
526 | 542 | ||
527 | read_lock_bh(&pathtbl_resize_lock); | ||
528 | memcpy(new_mpath->dst, dst, ETH_ALEN); | 543 | memcpy(new_mpath->dst, dst, ETH_ALEN); |
529 | eth_broadcast_addr(new_mpath->rann_snd_addr); | 544 | eth_broadcast_addr(new_mpath->rann_snd_addr); |
530 | new_mpath->is_root = false; | 545 | new_mpath->is_root = false; |
@@ -538,21 +553,6 @@ int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst) | |||
538 | spin_lock_init(&new_mpath->state_lock); | 553 | spin_lock_init(&new_mpath->state_lock); |
539 | init_timer(&new_mpath->timer); | 554 | init_timer(&new_mpath->timer); |
540 | 555 | ||
541 | tbl = resize_dereference_mesh_paths(); | ||
542 | |||
543 | hash_idx = mesh_table_hash(dst, sdata, tbl); | ||
544 | bucket = &tbl->hash_buckets[hash_idx]; | ||
545 | |||
546 | spin_lock(&tbl->hashwlock[hash_idx]); | ||
547 | |||
548 | err = -EEXIST; | ||
549 | hlist_for_each_entry(node, bucket, list) { | ||
550 | mpath = node->mpath; | ||
551 | if (mpath->sdata == sdata && | ||
552 | ether_addr_equal(dst, mpath->dst)) | ||
553 | goto err_exists; | ||
554 | } | ||
555 | |||
556 | hlist_add_head_rcu(&new_node->list, bucket); | 556 | hlist_add_head_rcu(&new_node->list, bucket); |
557 | if (atomic_inc_return(&tbl->entries) >= | 557 | if (atomic_inc_return(&tbl->entries) >= |
558 | tbl->mean_chain_len * (tbl->hash_mask + 1)) | 558 | tbl->mean_chain_len * (tbl->hash_mask + 1)) |
@@ -560,23 +560,23 @@ int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst) | |||
560 | 560 | ||
561 | mesh_paths_generation++; | 561 | mesh_paths_generation++; |
562 | 562 | ||
563 | spin_unlock(&tbl->hashwlock[hash_idx]); | ||
564 | read_unlock_bh(&pathtbl_resize_lock); | ||
565 | if (grow) { | 563 | if (grow) { |
566 | set_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags); | 564 | set_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags); |
567 | ieee80211_queue_work(&local->hw, &sdata->work); | 565 | ieee80211_queue_work(&local->hw, &sdata->work); |
568 | } | 566 | } |
569 | return 0; | 567 | mpath = new_mpath; |
570 | 568 | found: | |
571 | err_exists: | ||
572 | spin_unlock(&tbl->hashwlock[hash_idx]); | 569 | spin_unlock(&tbl->hashwlock[hash_idx]); |
573 | read_unlock_bh(&pathtbl_resize_lock); | 570 | read_unlock_bh(&pathtbl_resize_lock); |
574 | kfree(new_node); | 571 | return mpath; |
572 | |||
575 | err_node_alloc: | 573 | err_node_alloc: |
576 | kfree(new_mpath); | 574 | kfree(new_mpath); |
577 | err_path_alloc: | 575 | err_path_alloc: |
578 | atomic_dec(&sdata->u.mesh.mpaths); | 576 | atomic_dec(&sdata->u.mesh.mpaths); |
579 | return err; | 577 | spin_unlock(&tbl->hashwlock[hash_idx]); |
578 | read_unlock_bh(&pathtbl_resize_lock); | ||
579 | return ERR_PTR(err); | ||
580 | } | 580 | } |
581 | 581 | ||
582 | static void mesh_table_free_rcu(struct rcu_head *rcu) | 582 | static void mesh_table_free_rcu(struct rcu_head *rcu) |
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 937e06fe8f2a..09bebed99416 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -544,8 +544,8 @@ static void mesh_plink_timer(unsigned long data) | |||
544 | return; | 544 | return; |
545 | } | 545 | } |
546 | mpl_dbg(sta->sdata, | 546 | mpl_dbg(sta->sdata, |
547 | "Mesh plink timer for %pM fired on state %d\n", | 547 | "Mesh plink timer for %pM fired on state %s\n", |
548 | sta->sta.addr, sta->plink_state); | 548 | sta->sta.addr, mplstates[sta->plink_state]); |
549 | reason = 0; | 549 | reason = 0; |
550 | llid = sta->llid; | 550 | llid = sta->llid; |
551 | plid = sta->plid; | 551 | plid = sta->plid; |
@@ -687,7 +687,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
687 | baseaddr += 4; | 687 | baseaddr += 4; |
688 | baselen += 4; | 688 | baselen += 4; |
689 | } | 689 | } |
690 | ieee802_11_parse_elems(baseaddr, len - baselen, &elems); | 690 | ieee802_11_parse_elems(baseaddr, len - baselen, true, &elems); |
691 | 691 | ||
692 | if (!elems.peering) { | 692 | if (!elems.peering) { |
693 | mpl_dbg(sdata, | 693 | mpl_dbg(sdata, |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index dec42ab1fa91..29620bfc7a69 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -56,7 +56,10 @@ MODULE_PARM_DESC(max_probe_tries, | |||
56 | * probe on beacon miss before declaring the connection lost | 56 | * probe on beacon miss before declaring the connection lost |
57 | * default to what we want. | 57 | * default to what we want. |
58 | */ | 58 | */ |
59 | #define IEEE80211_BEACON_LOSS_COUNT 7 | 59 | static int beacon_loss_count = 7; |
60 | module_param(beacon_loss_count, int, 0644); | ||
61 | MODULE_PARM_DESC(beacon_loss_count, | ||
62 | "Number of beacon intervals before we decide beacon was lost."); | ||
60 | 63 | ||
61 | /* | 64 | /* |
62 | * Time the connection can be idle before we probe | 65 | * Time the connection can be idle before we probe |
@@ -286,6 +289,8 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
286 | } else { | 289 | } else { |
287 | /* 40 MHz (and 80 MHz) must be supported for VHT */ | 290 | /* 40 MHz (and 80 MHz) must be supported for VHT */ |
288 | ret = IEEE80211_STA_DISABLE_VHT; | 291 | ret = IEEE80211_STA_DISABLE_VHT; |
292 | /* also mark 40 MHz disabled */ | ||
293 | ret |= IEEE80211_STA_DISABLE_40MHZ; | ||
289 | goto out; | 294 | goto out; |
290 | } | 295 | } |
291 | 296 | ||
@@ -300,12 +305,6 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
300 | channel->band); | 305 | channel->band); |
301 | vht_chandef.center_freq2 = 0; | 306 | vht_chandef.center_freq2 = 0; |
302 | 307 | ||
303 | if (vht_oper->center_freq_seg2_idx) | ||
304 | vht_chandef.center_freq2 = | ||
305 | ieee80211_channel_to_frequency( | ||
306 | vht_oper->center_freq_seg2_idx, | ||
307 | channel->band); | ||
308 | |||
309 | switch (vht_oper->chan_width) { | 308 | switch (vht_oper->chan_width) { |
310 | case IEEE80211_VHT_CHANWIDTH_USE_HT: | 309 | case IEEE80211_VHT_CHANWIDTH_USE_HT: |
311 | vht_chandef.width = chandef->width; | 310 | vht_chandef.width = chandef->width; |
@@ -318,6 +317,10 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, | |||
318 | break; | 317 | break; |
319 | case IEEE80211_VHT_CHANWIDTH_80P80MHZ: | 318 | case IEEE80211_VHT_CHANWIDTH_80P80MHZ: |
320 | vht_chandef.width = NL80211_CHAN_WIDTH_80P80; | 319 | vht_chandef.width = NL80211_CHAN_WIDTH_80P80; |
320 | vht_chandef.center_freq2 = | ||
321 | ieee80211_channel_to_frequency( | ||
322 | vht_oper->center_freq_seg2_idx, | ||
323 | channel->band); | ||
321 | break; | 324 | break; |
322 | default: | 325 | default: |
323 | if (verbose) | 326 | if (verbose) |
@@ -601,7 +604,6 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, | |||
601 | u8 *pos; | 604 | u8 *pos; |
602 | u32 cap; | 605 | u32 cap; |
603 | struct ieee80211_sta_vht_cap vht_cap; | 606 | struct ieee80211_sta_vht_cap vht_cap; |
604 | int i; | ||
605 | 607 | ||
606 | BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap)); | 608 | BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap)); |
607 | 609 | ||
@@ -629,37 +631,6 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, | |||
629 | cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE))) | 631 | cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE))) |
630 | cap &= ~IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; | 632 | cap &= ~IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
631 | 633 | ||
632 | if (!(ap_vht_cap->vht_cap_info & | ||
633 | cpu_to_le32(IEEE80211_VHT_CAP_TXSTBC))) | ||
634 | cap &= ~(IEEE80211_VHT_CAP_RXSTBC_1 | | ||
635 | IEEE80211_VHT_CAP_RXSTBC_3 | | ||
636 | IEEE80211_VHT_CAP_RXSTBC_4); | ||
637 | |||
638 | for (i = 0; i < 8; i++) { | ||
639 | int shift = i * 2; | ||
640 | u16 mask = IEEE80211_VHT_MCS_NOT_SUPPORTED << shift; | ||
641 | u16 ap_mcs, our_mcs; | ||
642 | |||
643 | ap_mcs = (le16_to_cpu(ap_vht_cap->supp_mcs.tx_mcs_map) & | ||
644 | mask) >> shift; | ||
645 | our_mcs = (le16_to_cpu(vht_cap.vht_mcs.rx_mcs_map) & | ||
646 | mask) >> shift; | ||
647 | |||
648 | if (our_mcs == IEEE80211_VHT_MCS_NOT_SUPPORTED) | ||
649 | continue; | ||
650 | |||
651 | switch (ap_mcs) { | ||
652 | default: | ||
653 | if (our_mcs <= ap_mcs) | ||
654 | break; | ||
655 | /* fall through */ | ||
656 | case IEEE80211_VHT_MCS_NOT_SUPPORTED: | ||
657 | vht_cap.vht_mcs.rx_mcs_map &= cpu_to_le16(~mask); | ||
658 | vht_cap.vht_mcs.rx_mcs_map |= | ||
659 | cpu_to_le16(ap_mcs << shift); | ||
660 | } | ||
661 | } | ||
662 | |||
663 | /* reserve and fill IE */ | 634 | /* reserve and fill IE */ |
664 | pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2); | 635 | pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2); |
665 | ieee80211_ie_build_vht_cap(pos, &vht_cap, cap); | 636 | ieee80211_ie_build_vht_cap(pos, &vht_cap, cap); |
@@ -985,6 +956,7 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
985 | { | 956 | { |
986 | struct ieee80211_sub_if_data *sdata = | 957 | struct ieee80211_sub_if_data *sdata = |
987 | container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); | 958 | container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); |
959 | struct ieee80211_local *local = sdata->local; | ||
988 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 960 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
989 | 961 | ||
990 | if (!ieee80211_sdata_running(sdata)) | 962 | if (!ieee80211_sdata_running(sdata)) |
@@ -994,21 +966,21 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
994 | if (!ifmgd->associated) | 966 | if (!ifmgd->associated) |
995 | goto out; | 967 | goto out; |
996 | 968 | ||
997 | sdata->local->_oper_channel = sdata->local->csa_channel; | 969 | local->_oper_chandef = local->csa_chandef; |
998 | if (!sdata->local->ops->channel_switch) { | 970 | |
971 | if (!local->ops->channel_switch) { | ||
999 | /* call "hw_config" only if doing sw channel switch */ | 972 | /* call "hw_config" only if doing sw channel switch */ |
1000 | ieee80211_hw_config(sdata->local, | 973 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
1001 | IEEE80211_CONF_CHANGE_CHANNEL); | ||
1002 | } else { | 974 | } else { |
1003 | /* update the device channel directly */ | 975 | /* update the device channel directly */ |
1004 | sdata->local->hw.conf.channel = sdata->local->_oper_channel; | 976 | local->hw.conf.chandef = local->_oper_chandef; |
1005 | } | 977 | } |
1006 | 978 | ||
1007 | /* XXX: shouldn't really modify cfg80211-owned data! */ | 979 | /* XXX: shouldn't really modify cfg80211-owned data! */ |
1008 | ifmgd->associated->channel = sdata->local->_oper_channel; | 980 | ifmgd->associated->channel = local->_oper_chandef.chan; |
1009 | 981 | ||
1010 | /* XXX: wait for a beacon first? */ | 982 | /* XXX: wait for a beacon first? */ |
1011 | ieee80211_wake_queues_by_reason(&sdata->local->hw, | 983 | ieee80211_wake_queues_by_reason(&local->hw, |
1012 | IEEE80211_MAX_QUEUE_MAP, | 984 | IEEE80211_MAX_QUEUE_MAP, |
1013 | IEEE80211_QUEUE_STOP_REASON_CSA); | 985 | IEEE80211_QUEUE_STOP_REASON_CSA); |
1014 | out: | 986 | out: |
@@ -1041,56 +1013,193 @@ static void ieee80211_chswitch_timer(unsigned long data) | |||
1041 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work); | 1013 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work); |
1042 | } | 1014 | } |
1043 | 1015 | ||
1044 | void | 1016 | static void |
1045 | ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | 1017 | ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, |
1046 | const struct ieee80211_channel_sw_ie *sw_elem, | 1018 | u64 timestamp, struct ieee802_11_elems *elems) |
1047 | struct ieee80211_bss *bss, u64 timestamp) | ||
1048 | { | 1019 | { |
1049 | struct cfg80211_bss *cbss = | 1020 | struct ieee80211_local *local = sdata->local; |
1050 | container_of((void *)bss, struct cfg80211_bss, priv); | ||
1051 | struct ieee80211_channel *new_ch; | ||
1052 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1021 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1053 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num, | 1022 | struct cfg80211_bss *cbss = ifmgd->associated; |
1054 | cbss->channel->band); | 1023 | struct ieee80211_bss *bss; |
1055 | struct ieee80211_chanctx *chanctx; | 1024 | struct ieee80211_chanctx *chanctx; |
1025 | enum ieee80211_band new_band; | ||
1026 | int new_freq; | ||
1027 | u8 new_chan_no; | ||
1028 | u8 count; | ||
1029 | u8 mode; | ||
1030 | struct ieee80211_channel *new_chan; | ||
1031 | struct cfg80211_chan_def new_chandef = {}; | ||
1032 | struct cfg80211_chan_def new_vht_chandef = {}; | ||
1033 | const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; | ||
1034 | const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie; | ||
1035 | int secondary_channel_offset = -1; | ||
1056 | 1036 | ||
1057 | ASSERT_MGD_MTX(ifmgd); | 1037 | ASSERT_MGD_MTX(ifmgd); |
1058 | 1038 | ||
1059 | if (!ifmgd->associated) | 1039 | if (!cbss) |
1060 | return; | 1040 | return; |
1061 | 1041 | ||
1062 | if (sdata->local->scanning) | 1042 | if (local->scanning) |
1063 | return; | 1043 | return; |
1064 | 1044 | ||
1065 | /* Disregard subsequent beacons if we are already running a timer | 1045 | /* disregard subsequent announcements if we are already processing */ |
1066 | processing a CSA */ | ||
1067 | |||
1068 | if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED) | 1046 | if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED) |
1069 | return; | 1047 | return; |
1070 | 1048 | ||
1071 | new_ch = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq); | 1049 | sec_chan_offs = elems->sec_chan_offs; |
1072 | if (!new_ch || new_ch->flags & IEEE80211_CHAN_DISABLED) { | 1050 | wide_bw_chansw_ie = elems->wide_bw_chansw_ie; |
1051 | |||
1052 | if (ifmgd->flags & (IEEE80211_STA_DISABLE_HT | | ||
1053 | IEEE80211_STA_DISABLE_40MHZ)) { | ||
1054 | sec_chan_offs = NULL; | ||
1055 | wide_bw_chansw_ie = NULL; | ||
1056 | } | ||
1057 | |||
1058 | if (ifmgd->flags & IEEE80211_STA_DISABLE_VHT) | ||
1059 | wide_bw_chansw_ie = NULL; | ||
1060 | |||
1061 | if (elems->ext_chansw_ie) { | ||
1062 | if (!ieee80211_operating_class_to_band( | ||
1063 | elems->ext_chansw_ie->new_operating_class, | ||
1064 | &new_band)) { | ||
1065 | sdata_info(sdata, | ||
1066 | "cannot understand ECSA IE operating class %d, disconnecting\n", | ||
1067 | elems->ext_chansw_ie->new_operating_class); | ||
1068 | ieee80211_queue_work(&local->hw, | ||
1069 | &ifmgd->csa_connection_drop_work); | ||
1070 | } | ||
1071 | new_chan_no = elems->ext_chansw_ie->new_ch_num; | ||
1072 | count = elems->ext_chansw_ie->count; | ||
1073 | mode = elems->ext_chansw_ie->mode; | ||
1074 | } else if (elems->ch_switch_ie) { | ||
1075 | new_band = cbss->channel->band; | ||
1076 | new_chan_no = elems->ch_switch_ie->new_ch_num; | ||
1077 | count = elems->ch_switch_ie->count; | ||
1078 | mode = elems->ch_switch_ie->mode; | ||
1079 | } else { | ||
1080 | /* nothing here we understand */ | ||
1081 | return; | ||
1082 | } | ||
1083 | |||
1084 | bss = (void *)cbss->priv; | ||
1085 | |||
1086 | new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band); | ||
1087 | new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq); | ||
1088 | if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) { | ||
1073 | sdata_info(sdata, | 1089 | sdata_info(sdata, |
1074 | "AP %pM switches to unsupported channel (%d MHz), disconnecting\n", | 1090 | "AP %pM switches to unsupported channel (%d MHz), disconnecting\n", |
1075 | ifmgd->associated->bssid, new_freq); | 1091 | ifmgd->associated->bssid, new_freq); |
1076 | ieee80211_queue_work(&sdata->local->hw, | 1092 | ieee80211_queue_work(&local->hw, |
1093 | &ifmgd->csa_connection_drop_work); | ||
1094 | return; | ||
1095 | } | ||
1096 | |||
1097 | if (sec_chan_offs) { | ||
1098 | secondary_channel_offset = sec_chan_offs->sec_chan_offs; | ||
1099 | } else if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) { | ||
1100 | /* if HT is enabled and the IE not present, it's still HT */ | ||
1101 | secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; | ||
1102 | } | ||
1103 | |||
1104 | switch (secondary_channel_offset) { | ||
1105 | default: | ||
1106 | /* secondary_channel_offset was present but is invalid */ | ||
1107 | case IEEE80211_HT_PARAM_CHA_SEC_NONE: | ||
1108 | cfg80211_chandef_create(&new_chandef, new_chan, | ||
1109 | NL80211_CHAN_HT20); | ||
1110 | break; | ||
1111 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: | ||
1112 | cfg80211_chandef_create(&new_chandef, new_chan, | ||
1113 | NL80211_CHAN_HT40PLUS); | ||
1114 | break; | ||
1115 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: | ||
1116 | cfg80211_chandef_create(&new_chandef, new_chan, | ||
1117 | NL80211_CHAN_HT40MINUS); | ||
1118 | break; | ||
1119 | case -1: | ||
1120 | cfg80211_chandef_create(&new_chandef, new_chan, | ||
1121 | NL80211_CHAN_NO_HT); | ||
1122 | break; | ||
1123 | } | ||
1124 | |||
1125 | if (wide_bw_chansw_ie) { | ||
1126 | new_vht_chandef.chan = new_chan; | ||
1127 | new_vht_chandef.center_freq1 = | ||
1128 | ieee80211_channel_to_frequency( | ||
1129 | wide_bw_chansw_ie->new_center_freq_seg0, | ||
1130 | new_band); | ||
1131 | |||
1132 | switch (wide_bw_chansw_ie->new_channel_width) { | ||
1133 | default: | ||
1134 | /* hmmm, ignore VHT and use HT if present */ | ||
1135 | case IEEE80211_VHT_CHANWIDTH_USE_HT: | ||
1136 | new_vht_chandef.chan = NULL; | ||
1137 | break; | ||
1138 | case IEEE80211_VHT_CHANWIDTH_80MHZ: | ||
1139 | new_vht_chandef.width = NL80211_CHAN_WIDTH_80; | ||
1140 | break; | ||
1141 | case IEEE80211_VHT_CHANWIDTH_160MHZ: | ||
1142 | new_vht_chandef.width = NL80211_CHAN_WIDTH_160; | ||
1143 | break; | ||
1144 | case IEEE80211_VHT_CHANWIDTH_80P80MHZ: | ||
1145 | /* field is otherwise reserved */ | ||
1146 | new_vht_chandef.center_freq2 = | ||
1147 | ieee80211_channel_to_frequency( | ||
1148 | wide_bw_chansw_ie->new_center_freq_seg1, | ||
1149 | new_band); | ||
1150 | new_vht_chandef.width = NL80211_CHAN_WIDTH_80P80; | ||
1151 | break; | ||
1152 | } | ||
1153 | if (ifmgd->flags & IEEE80211_STA_DISABLE_80P80MHZ && | ||
1154 | new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80) | ||
1155 | chandef_downgrade(&new_vht_chandef); | ||
1156 | if (ifmgd->flags & IEEE80211_STA_DISABLE_160MHZ && | ||
1157 | new_vht_chandef.width == NL80211_CHAN_WIDTH_160) | ||
1158 | chandef_downgrade(&new_vht_chandef); | ||
1159 | if (ifmgd->flags & IEEE80211_STA_DISABLE_40MHZ && | ||
1160 | new_vht_chandef.width > NL80211_CHAN_WIDTH_20) | ||
1161 | chandef_downgrade(&new_vht_chandef); | ||
1162 | } | ||
1163 | |||
1164 | /* if VHT data is there validate & use it */ | ||
1165 | if (new_vht_chandef.chan) { | ||
1166 | if (!cfg80211_chandef_compatible(&new_vht_chandef, | ||
1167 | &new_chandef)) { | ||
1168 | sdata_info(sdata, | ||
1169 | "AP %pM CSA has inconsistent channel data, disconnecting\n", | ||
1170 | ifmgd->associated->bssid); | ||
1171 | ieee80211_queue_work(&local->hw, | ||
1172 | &ifmgd->csa_connection_drop_work); | ||
1173 | return; | ||
1174 | } | ||
1175 | new_chandef = new_vht_chandef; | ||
1176 | } | ||
1177 | |||
1178 | if (!cfg80211_chandef_usable(local->hw.wiphy, &new_chandef, | ||
1179 | IEEE80211_CHAN_DISABLED)) { | ||
1180 | sdata_info(sdata, | ||
1181 | "AP %pM switches to unsupported channel (%d MHz, width:%d, CF1/2: %d/%d MHz), disconnecting\n", | ||
1182 | ifmgd->associated->bssid, new_freq, | ||
1183 | new_chandef.width, new_chandef.center_freq1, | ||
1184 | new_chandef.center_freq2); | ||
1185 | ieee80211_queue_work(&local->hw, | ||
1077 | &ifmgd->csa_connection_drop_work); | 1186 | &ifmgd->csa_connection_drop_work); |
1078 | return; | 1187 | return; |
1079 | } | 1188 | } |
1080 | 1189 | ||
1081 | ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; | 1190 | ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; |
1082 | 1191 | ||
1083 | if (sdata->local->use_chanctx) { | 1192 | if (local->use_chanctx) { |
1084 | sdata_info(sdata, | 1193 | sdata_info(sdata, |
1085 | "not handling channel switch with channel contexts\n"); | 1194 | "not handling channel switch with channel contexts\n"); |
1086 | ieee80211_queue_work(&sdata->local->hw, | 1195 | ieee80211_queue_work(&local->hw, |
1087 | &ifmgd->csa_connection_drop_work); | 1196 | &ifmgd->csa_connection_drop_work); |
1088 | return; | 1197 | return; |
1089 | } | 1198 | } |
1090 | 1199 | ||
1091 | mutex_lock(&sdata->local->chanctx_mtx); | 1200 | mutex_lock(&local->chanctx_mtx); |
1092 | if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) { | 1201 | if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) { |
1093 | mutex_unlock(&sdata->local->chanctx_mtx); | 1202 | mutex_unlock(&local->chanctx_mtx); |
1094 | return; | 1203 | return; |
1095 | } | 1204 | } |
1096 | chanctx = container_of(rcu_access_pointer(sdata->vif.chanctx_conf), | 1205 | chanctx = container_of(rcu_access_pointer(sdata->vif.chanctx_conf), |
@@ -1098,40 +1207,39 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
1098 | if (chanctx->refcount > 1) { | 1207 | if (chanctx->refcount > 1) { |
1099 | sdata_info(sdata, | 1208 | sdata_info(sdata, |
1100 | "channel switch with multiple interfaces on the same channel, disconnecting\n"); | 1209 | "channel switch with multiple interfaces on the same channel, disconnecting\n"); |
1101 | ieee80211_queue_work(&sdata->local->hw, | 1210 | ieee80211_queue_work(&local->hw, |
1102 | &ifmgd->csa_connection_drop_work); | 1211 | &ifmgd->csa_connection_drop_work); |
1103 | mutex_unlock(&sdata->local->chanctx_mtx); | 1212 | mutex_unlock(&local->chanctx_mtx); |
1104 | return; | 1213 | return; |
1105 | } | 1214 | } |
1106 | mutex_unlock(&sdata->local->chanctx_mtx); | 1215 | mutex_unlock(&local->chanctx_mtx); |
1107 | 1216 | ||
1108 | sdata->local->csa_channel = new_ch; | 1217 | local->csa_chandef = new_chandef; |
1109 | 1218 | ||
1110 | if (sw_elem->mode) | 1219 | if (mode) |
1111 | ieee80211_stop_queues_by_reason(&sdata->local->hw, | 1220 | ieee80211_stop_queues_by_reason(&local->hw, |
1112 | IEEE80211_MAX_QUEUE_MAP, | 1221 | IEEE80211_MAX_QUEUE_MAP, |
1113 | IEEE80211_QUEUE_STOP_REASON_CSA); | 1222 | IEEE80211_QUEUE_STOP_REASON_CSA); |
1114 | 1223 | ||
1115 | if (sdata->local->ops->channel_switch) { | 1224 | if (local->ops->channel_switch) { |
1116 | /* use driver's channel switch callback */ | 1225 | /* use driver's channel switch callback */ |
1117 | struct ieee80211_channel_switch ch_switch = { | 1226 | struct ieee80211_channel_switch ch_switch = { |
1118 | .timestamp = timestamp, | 1227 | .timestamp = timestamp, |
1119 | .block_tx = sw_elem->mode, | 1228 | .block_tx = mode, |
1120 | .channel = new_ch, | 1229 | .chandef = new_chandef, |
1121 | .count = sw_elem->count, | 1230 | .count = count, |
1122 | }; | 1231 | }; |
1123 | 1232 | ||
1124 | drv_channel_switch(sdata->local, &ch_switch); | 1233 | drv_channel_switch(local, &ch_switch); |
1125 | return; | 1234 | return; |
1126 | } | 1235 | } |
1127 | 1236 | ||
1128 | /* channel switch handled in software */ | 1237 | /* channel switch handled in software */ |
1129 | if (sw_elem->count <= 1) | 1238 | if (count <= 1) |
1130 | ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); | 1239 | ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work); |
1131 | else | 1240 | else |
1132 | mod_timer(&ifmgd->chswitch_timer, | 1241 | mod_timer(&ifmgd->chswitch_timer, |
1133 | TU_TO_EXP_TIME(sw_elem->count * | 1242 | TU_TO_EXP_TIME(count * cbss->beacon_interval)); |
1134 | cbss->beacon_interval)); | ||
1135 | } | 1243 | } |
1136 | 1244 | ||
1137 | static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, | 1245 | static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, |
@@ -1430,13 +1538,11 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work) | |||
1430 | 1538 | ||
1431 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && | 1539 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && |
1432 | !(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { | 1540 | !(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { |
1433 | netif_tx_stop_all_queues(sdata->dev); | 1541 | if (drv_tx_frames_pending(local)) { |
1434 | |||
1435 | if (drv_tx_frames_pending(local)) | ||
1436 | mod_timer(&local->dynamic_ps_timer, jiffies + | 1542 | mod_timer(&local->dynamic_ps_timer, jiffies + |
1437 | msecs_to_jiffies( | 1543 | msecs_to_jiffies( |
1438 | local->hw.conf.dynamic_ps_timeout)); | 1544 | local->hw.conf.dynamic_ps_timeout)); |
1439 | else { | 1545 | } else { |
1440 | ieee80211_send_nullfunc(local, sdata, 1); | 1546 | ieee80211_send_nullfunc(local, sdata, 1); |
1441 | /* Flush to get the tx status of nullfunc frame */ | 1547 | /* Flush to get the tx status of nullfunc frame */ |
1442 | ieee80211_flush_queues(local, sdata); | 1548 | ieee80211_flush_queues(local, sdata); |
@@ -1450,9 +1556,6 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work) | |||
1450 | local->hw.conf.flags |= IEEE80211_CONF_PS; | 1556 | local->hw.conf.flags |= IEEE80211_CONF_PS; |
1451 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | 1557 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
1452 | } | 1558 | } |
1453 | |||
1454 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) | ||
1455 | netif_tx_wake_all_queues(sdata->dev); | ||
1456 | } | 1559 | } |
1457 | 1560 | ||
1458 | void ieee80211_dynamic_ps_timer(unsigned long data) | 1561 | void ieee80211_dynamic_ps_timer(unsigned long data) |
@@ -1558,6 +1661,7 @@ static bool ieee80211_sta_wmm_params(struct ieee80211_local *local, | |||
1558 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); | 1661 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); |
1559 | params.cw_min = ecw2cw(pos[1] & 0x0f); | 1662 | params.cw_min = ecw2cw(pos[1] & 0x0f); |
1560 | params.txop = get_unaligned_le16(pos + 2); | 1663 | params.txop = get_unaligned_le16(pos + 2); |
1664 | params.acm = acm; | ||
1561 | params.uapsd = uapsd; | 1665 | params.uapsd = uapsd; |
1562 | 1666 | ||
1563 | mlme_dbg(sdata, | 1667 | mlme_dbg(sdata, |
@@ -1645,7 +1749,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
1645 | bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value); | 1749 | bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value); |
1646 | 1750 | ||
1647 | sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec( | 1751 | sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec( |
1648 | IEEE80211_BEACON_LOSS_COUNT * bss_conf->beacon_int)); | 1752 | beacon_loss_count * bss_conf->beacon_int)); |
1649 | 1753 | ||
1650 | sdata->u.mgd.associated = cbss; | 1754 | sdata->u.mgd.associated = cbss; |
1651 | memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN); | 1755 | memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN); |
@@ -1658,18 +1762,17 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
1658 | rcu_read_lock(); | 1762 | rcu_read_lock(); |
1659 | ies = rcu_dereference(cbss->ies); | 1763 | ies = rcu_dereference(cbss->ies); |
1660 | if (ies) { | 1764 | if (ies) { |
1661 | u8 noa[2]; | ||
1662 | int ret; | 1765 | int ret; |
1663 | 1766 | ||
1664 | ret = cfg80211_get_p2p_attr( | 1767 | ret = cfg80211_get_p2p_attr( |
1665 | ies->data, ies->len, | 1768 | ies->data, ies->len, |
1666 | IEEE80211_P2P_ATTR_ABSENCE_NOTICE, | 1769 | IEEE80211_P2P_ATTR_ABSENCE_NOTICE, |
1667 | noa, sizeof(noa)); | 1770 | (u8 *) &bss_conf->p2p_noa_attr, |
1771 | sizeof(bss_conf->p2p_noa_attr)); | ||
1668 | if (ret >= 2) { | 1772 | if (ret >= 2) { |
1669 | bss_conf->p2p_oppps = noa[1] & 0x80; | 1773 | sdata->u.mgd.p2p_noa_index = |
1670 | bss_conf->p2p_ctwindow = noa[1] & 0x7f; | 1774 | bss_conf->p2p_noa_attr.index; |
1671 | bss_info_changed |= BSS_CHANGED_P2P_PS; | 1775 | bss_info_changed |= BSS_CHANGED_P2P_PS; |
1672 | sdata->u.mgd.p2p_noa_index = noa[0]; | ||
1673 | } | 1776 | } |
1674 | } | 1777 | } |
1675 | rcu_read_unlock(); | 1778 | rcu_read_unlock(); |
@@ -1713,7 +1816,6 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
1713 | ieee80211_recalc_smps(sdata); | 1816 | ieee80211_recalc_smps(sdata); |
1714 | ieee80211_recalc_ps_vif(sdata); | 1817 | ieee80211_recalc_ps_vif(sdata); |
1715 | 1818 | ||
1716 | netif_tx_start_all_queues(sdata->dev); | ||
1717 | netif_carrier_on(sdata->dev); | 1819 | netif_carrier_on(sdata->dev); |
1718 | } | 1820 | } |
1719 | 1821 | ||
@@ -1736,22 +1838,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1736 | ieee80211_stop_poll(sdata); | 1838 | ieee80211_stop_poll(sdata); |
1737 | 1839 | ||
1738 | ifmgd->associated = NULL; | 1840 | ifmgd->associated = NULL; |
1739 | |||
1740 | /* | ||
1741 | * we need to commit the associated = NULL change because the | ||
1742 | * scan code uses that to determine whether this iface should | ||
1743 | * go to/wake up from powersave or not -- and could otherwise | ||
1744 | * wake the queues erroneously. | ||
1745 | */ | ||
1746 | smp_mb(); | ||
1747 | |||
1748 | /* | ||
1749 | * Thus, we can only afterwards stop the queues -- to account | ||
1750 | * for the case where another CPU is finishing a scan at this | ||
1751 | * time -- we don't want the scan code to enable queues. | ||
1752 | */ | ||
1753 | |||
1754 | netif_tx_stop_all_queues(sdata->dev); | ||
1755 | netif_carrier_off(sdata->dev); | 1841 | netif_carrier_off(sdata->dev); |
1756 | 1842 | ||
1757 | /* | 1843 | /* |
@@ -1794,8 +1880,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1794 | changed |= BSS_CHANGED_ASSOC; | 1880 | changed |= BSS_CHANGED_ASSOC; |
1795 | sdata->vif.bss_conf.assoc = false; | 1881 | sdata->vif.bss_conf.assoc = false; |
1796 | 1882 | ||
1797 | sdata->vif.bss_conf.p2p_ctwindow = 0; | 1883 | ifmgd->p2p_noa_index = -1; |
1798 | sdata->vif.bss_conf.p2p_oppps = false; | 1884 | memset(&sdata->vif.bss_conf.p2p_noa_attr, 0, |
1885 | sizeof(sdata->vif.bss_conf.p2p_noa_attr)); | ||
1799 | 1886 | ||
1800 | /* on the next assoc, re-program HT/VHT parameters */ | 1887 | /* on the next assoc, re-program HT/VHT parameters */ |
1801 | memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); | 1888 | memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); |
@@ -1975,12 +2062,15 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata, | |||
1975 | goto out; | 2062 | goto out; |
1976 | } | 2063 | } |
1977 | 2064 | ||
1978 | if (beacon) | 2065 | if (beacon) { |
1979 | mlme_dbg_ratelimited(sdata, | 2066 | mlme_dbg_ratelimited(sdata, |
1980 | "detected beacon loss from AP - probing\n"); | 2067 | "detected beacon loss from AP (missed %d beacons) - probing\n", |
2068 | beacon_loss_count); | ||
1981 | 2069 | ||
1982 | ieee80211_cqm_rssi_notify(&sdata->vif, | 2070 | ieee80211_cqm_rssi_notify(&sdata->vif, |
1983 | NL80211_CQM_RSSI_BEACON_LOSS_EVENT, GFP_KERNEL); | 2071 | NL80211_CQM_RSSI_BEACON_LOSS_EVENT, |
2072 | GFP_KERNEL); | ||
2073 | } | ||
1984 | 2074 | ||
1985 | /* | 2075 | /* |
1986 | * The driver/our work has already reported this event or the | 2076 | * The driver/our work has already reported this event or the |
@@ -2126,7 +2216,6 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif) | |||
2126 | 2216 | ||
2127 | trace_api_beacon_loss(sdata); | 2217 | trace_api_beacon_loss(sdata); |
2128 | 2218 | ||
2129 | WARN_ON(hw->flags & IEEE80211_HW_CONNECTION_MONITOR); | ||
2130 | sdata->u.mgd.connection_loss = false; | 2219 | sdata->u.mgd.connection_loss = false; |
2131 | ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); | 2220 | ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); |
2132 | } | 2221 | } |
@@ -2176,7 +2265,7 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | |||
2176 | u32 tx_flags = 0; | 2265 | u32 tx_flags = 0; |
2177 | 2266 | ||
2178 | pos = mgmt->u.auth.variable; | 2267 | pos = mgmt->u.auth.variable; |
2179 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | 2268 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems); |
2180 | if (!elems.challenge) | 2269 | if (!elems.challenge) |
2181 | return; | 2270 | return; |
2182 | auth_data->expected_transaction = 4; | 2271 | auth_data->expected_transaction = 4; |
@@ -2441,7 +2530,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, | |||
2441 | } | 2530 | } |
2442 | 2531 | ||
2443 | pos = mgmt->u.assoc_resp.variable; | 2532 | pos = mgmt->u.assoc_resp.variable; |
2444 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | 2533 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems); |
2445 | 2534 | ||
2446 | if (!elems.supp_rates) { | 2535 | if (!elems.supp_rates) { |
2447 | sdata_info(sdata, "no SuppRates element in AssocResp\n"); | 2536 | sdata_info(sdata, "no SuppRates element in AssocResp\n"); |
@@ -2610,13 +2699,13 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2610 | capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); | 2699 | capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); |
2611 | 2700 | ||
2612 | pos = mgmt->u.assoc_resp.variable; | 2701 | pos = mgmt->u.assoc_resp.variable; |
2613 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | 2702 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), false, &elems); |
2614 | 2703 | ||
2615 | if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && | 2704 | if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && |
2616 | elems.timeout_int && elems.timeout_int_len == 5 && | 2705 | elems.timeout_int && |
2617 | elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { | 2706 | elems.timeout_int->type == WLAN_TIMEOUT_ASSOC_COMEBACK) { |
2618 | u32 tu, ms; | 2707 | u32 tu, ms; |
2619 | tu = get_unaligned_le32(elems.timeout_int + 1); | 2708 | tu = le32_to_cpu(elems.timeout_int->value); |
2620 | ms = tu * 1024 / 1000; | 2709 | ms = tu * 1024 / 1000; |
2621 | sdata_info(sdata, | 2710 | sdata_info(sdata, |
2622 | "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n", | 2711 | "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n", |
@@ -2665,6 +2754,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
2665 | struct ieee80211_channel *channel; | 2754 | struct ieee80211_channel *channel; |
2666 | bool need_ps = false; | 2755 | bool need_ps = false; |
2667 | 2756 | ||
2757 | lockdep_assert_held(&sdata->u.mgd.mtx); | ||
2758 | |||
2668 | if ((sdata->u.mgd.associated && | 2759 | if ((sdata->u.mgd.associated && |
2669 | ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) || | 2760 | ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) || |
2670 | (sdata->u.mgd.assoc_data && | 2761 | (sdata->u.mgd.assoc_data && |
@@ -2679,7 +2770,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
2679 | } | 2770 | } |
2680 | } | 2771 | } |
2681 | 2772 | ||
2682 | if (elems->ds_params && elems->ds_params_len == 1) | 2773 | if (elems->ds_params) |
2683 | freq = ieee80211_channel_to_frequency(elems->ds_params[0], | 2774 | freq = ieee80211_channel_to_frequency(elems->ds_params[0], |
2684 | rx_status->band); | 2775 | rx_status->band); |
2685 | else | 2776 | else |
@@ -2695,7 +2786,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
2695 | if (bss) | 2786 | if (bss) |
2696 | ieee80211_rx_bss_put(local, bss); | 2787 | ieee80211_rx_bss_put(local, bss); |
2697 | 2788 | ||
2698 | if (!sdata->u.mgd.associated) | 2789 | if (!sdata->u.mgd.associated || |
2790 | !ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) | ||
2699 | return; | 2791 | return; |
2700 | 2792 | ||
2701 | if (need_ps) { | 2793 | if (need_ps) { |
@@ -2704,10 +2796,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
2704 | mutex_unlock(&local->iflist_mtx); | 2796 | mutex_unlock(&local->iflist_mtx); |
2705 | } | 2797 | } |
2706 | 2798 | ||
2707 | if (elems->ch_switch_ie && | 2799 | ieee80211_sta_process_chanswitch(sdata, rx_status->mactime, elems); |
2708 | memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, ETH_ALEN) == 0) | 2800 | |
2709 | ieee80211_sta_process_chanswitch(sdata, elems->ch_switch_ie, | ||
2710 | bss, rx_status->mactime); | ||
2711 | } | 2801 | } |
2712 | 2802 | ||
2713 | 2803 | ||
@@ -2732,7 +2822,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, | |||
2732 | return; | 2822 | return; |
2733 | 2823 | ||
2734 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, | 2824 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, |
2735 | &elems); | 2825 | false, &elems); |
2736 | 2826 | ||
2737 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); | 2827 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); |
2738 | 2828 | ||
@@ -2815,7 +2905,7 @@ ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2815 | if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon && | 2905 | if (ifmgd->assoc_data && ifmgd->assoc_data->need_beacon && |
2816 | ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { | 2906 | ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { |
2817 | ieee802_11_parse_elems(mgmt->u.beacon.variable, | 2907 | ieee802_11_parse_elems(mgmt->u.beacon.variable, |
2818 | len - baselen, &elems); | 2908 | len - baselen, false, &elems); |
2819 | 2909 | ||
2820 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); | 2910 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems); |
2821 | ifmgd->assoc_data->have_beacon = true; | 2911 | ifmgd->assoc_data->have_beacon = true; |
@@ -2925,7 +3015,7 @@ ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2925 | 3015 | ||
2926 | ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); | 3016 | ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); |
2927 | ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable, | 3017 | ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable, |
2928 | len - baselen, &elems, | 3018 | len - baselen, false, &elems, |
2929 | care_about_ies, ncrc); | 3019 | care_about_ies, ncrc); |
2930 | 3020 | ||
2931 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) { | 3021 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) { |
@@ -2957,22 +3047,30 @@ ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2957 | } | 3047 | } |
2958 | 3048 | ||
2959 | if (sdata->vif.p2p) { | 3049 | if (sdata->vif.p2p) { |
2960 | u8 noa[2]; | 3050 | struct ieee80211_p2p_noa_attr noa = {}; |
2961 | int ret; | 3051 | int ret; |
2962 | 3052 | ||
2963 | ret = cfg80211_get_p2p_attr(mgmt->u.beacon.variable, | 3053 | ret = cfg80211_get_p2p_attr(mgmt->u.beacon.variable, |
2964 | len - baselen, | 3054 | len - baselen, |
2965 | IEEE80211_P2P_ATTR_ABSENCE_NOTICE, | 3055 | IEEE80211_P2P_ATTR_ABSENCE_NOTICE, |
2966 | noa, sizeof(noa)); | 3056 | (u8 *) &noa, sizeof(noa)); |
2967 | if (ret >= 2 && sdata->u.mgd.p2p_noa_index != noa[0]) { | 3057 | if (ret >= 2) { |
2968 | bss_conf->p2p_oppps = noa[1] & 0x80; | 3058 | if (sdata->u.mgd.p2p_noa_index != noa.index) { |
2969 | bss_conf->p2p_ctwindow = noa[1] & 0x7f; | 3059 | /* valid noa_attr and index changed */ |
3060 | sdata->u.mgd.p2p_noa_index = noa.index; | ||
3061 | memcpy(&bss_conf->p2p_noa_attr, &noa, sizeof(noa)); | ||
3062 | changed |= BSS_CHANGED_P2P_PS; | ||
3063 | /* | ||
3064 | * make sure we update all information, the CRC | ||
3065 | * mechanism doesn't look at P2P attributes. | ||
3066 | */ | ||
3067 | ifmgd->beacon_crc_valid = false; | ||
3068 | } | ||
3069 | } else if (sdata->u.mgd.p2p_noa_index != -1) { | ||
3070 | /* noa_attr not found and we had valid noa_attr before */ | ||
3071 | sdata->u.mgd.p2p_noa_index = -1; | ||
3072 | memset(&bss_conf->p2p_noa_attr, 0, sizeof(bss_conf->p2p_noa_attr)); | ||
2970 | changed |= BSS_CHANGED_P2P_PS; | 3073 | changed |= BSS_CHANGED_P2P_PS; |
2971 | sdata->u.mgd.p2p_noa_index = noa[0]; | ||
2972 | /* | ||
2973 | * make sure we update all information, the CRC | ||
2974 | * mechanism doesn't look at P2P attributes. | ||
2975 | */ | ||
2976 | ifmgd->beacon_crc_valid = false; | 3074 | ifmgd->beacon_crc_valid = false; |
2977 | } | 3075 | } |
2978 | } | 3076 | } |
@@ -3014,7 +3112,7 @@ ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
3014 | changed |= BSS_CHANGED_DTIM_PERIOD; | 3112 | changed |= BSS_CHANGED_DTIM_PERIOD; |
3015 | } | 3113 | } |
3016 | 3114 | ||
3017 | if (elems.erp_info && elems.erp_info_len >= 1) { | 3115 | if (elems.erp_info) { |
3018 | erp_valid = true; | 3116 | erp_valid = true; |
3019 | erp_value = elems.erp_info[0]; | 3117 | erp_value = elems.erp_info[0]; |
3020 | } else { | 3118 | } else { |
@@ -3064,6 +3162,8 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
3064 | enum rx_mgmt_action rma = RX_MGMT_NONE; | 3162 | enum rx_mgmt_action rma = RX_MGMT_NONE; |
3065 | u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN]; | 3163 | u8 deauth_buf[IEEE80211_DEAUTH_FRAME_LEN]; |
3066 | u16 fc; | 3164 | u16 fc; |
3165 | struct ieee802_11_elems elems; | ||
3166 | int ies_len; | ||
3067 | 3167 | ||
3068 | rx_status = (struct ieee80211_rx_status *) skb->cb; | 3168 | rx_status = (struct ieee80211_rx_status *) skb->cb; |
3069 | mgmt = (struct ieee80211_mgmt *) skb->data; | 3169 | mgmt = (struct ieee80211_mgmt *) skb->data; |
@@ -3093,14 +3193,48 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, | |||
3093 | rma = ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, &bss); | 3193 | rma = ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, &bss); |
3094 | break; | 3194 | break; |
3095 | case IEEE80211_STYPE_ACTION: | 3195 | case IEEE80211_STYPE_ACTION: |
3096 | switch (mgmt->u.action.category) { | 3196 | if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) { |
3097 | case WLAN_CATEGORY_SPECTRUM_MGMT: | 3197 | ies_len = skb->len - |
3198 | offsetof(struct ieee80211_mgmt, | ||
3199 | u.action.u.chan_switch.variable); | ||
3200 | |||
3201 | if (ies_len < 0) | ||
3202 | break; | ||
3203 | |||
3204 | ieee802_11_parse_elems( | ||
3205 | mgmt->u.action.u.chan_switch.variable, | ||
3206 | ies_len, true, &elems); | ||
3207 | |||
3208 | if (elems.parse_error) | ||
3209 | break; | ||
3210 | |||
3098 | ieee80211_sta_process_chanswitch(sdata, | 3211 | ieee80211_sta_process_chanswitch(sdata, |
3099 | &mgmt->u.action.u.chan_switch.sw_elem, | 3212 | rx_status->mactime, |
3100 | (void *)ifmgd->associated->priv, | 3213 | &elems); |
3101 | rx_status->mactime); | 3214 | } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) { |
3102 | break; | 3215 | ies_len = skb->len - |
3216 | offsetof(struct ieee80211_mgmt, | ||
3217 | u.action.u.ext_chan_switch.variable); | ||
3218 | |||
3219 | if (ies_len < 0) | ||
3220 | break; | ||
3221 | |||
3222 | ieee802_11_parse_elems( | ||
3223 | mgmt->u.action.u.ext_chan_switch.variable, | ||
3224 | ies_len, true, &elems); | ||
3225 | |||
3226 | if (elems.parse_error) | ||
3227 | break; | ||
3228 | |||
3229 | /* for the handling code pretend this was also an IE */ | ||
3230 | elems.ext_chansw_ie = | ||
3231 | &mgmt->u.action.u.ext_chan_switch.data; | ||
3232 | |||
3233 | ieee80211_sta_process_chanswitch(sdata, | ||
3234 | rx_status->mactime, | ||
3235 | &elems); | ||
3103 | } | 3236 | } |
3237 | break; | ||
3104 | } | 3238 | } |
3105 | mutex_unlock(&ifmgd->mtx); | 3239 | mutex_unlock(&ifmgd->mtx); |
3106 | 3240 | ||
@@ -3513,8 +3647,9 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) | |||
3513 | 3647 | ||
3514 | ifmgd->flags = 0; | 3648 | ifmgd->flags = 0; |
3515 | ifmgd->powersave = sdata->wdev.ps; | 3649 | ifmgd->powersave = sdata->wdev.ps; |
3516 | ifmgd->uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; | 3650 | ifmgd->uapsd_queues = sdata->local->hw.uapsd_queues; |
3517 | ifmgd->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; | 3651 | ifmgd->uapsd_max_sp_len = sdata->local->hw.uapsd_max_sp_len; |
3652 | ifmgd->p2p_noa_index = -1; | ||
3518 | 3653 | ||
3519 | mutex_init(&ifmgd->mtx); | 3654 | mutex_init(&ifmgd->mtx); |
3520 | 3655 | ||
@@ -4079,7 +4214,8 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | |||
4079 | rcu_read_unlock(); | 4214 | rcu_read_unlock(); |
4080 | 4215 | ||
4081 | if (bss->wmm_used && bss->uapsd_supported && | 4216 | if (bss->wmm_used && bss->uapsd_supported && |
4082 | (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)) { | 4217 | (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD) && |
4218 | sdata->wmm_acm != 0xff) { | ||
4083 | assoc_data->uapsd = true; | 4219 | assoc_data->uapsd = true; |
4084 | ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; | 4220 | ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; |
4085 | } else { | 4221 | } else { |
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c index cce795871ab1..acd1f71adc03 100644 --- a/net/mac80211/offchannel.c +++ b/net/mac80211/offchannel.c | |||
@@ -445,15 +445,15 @@ void ieee80211_roc_setup(struct ieee80211_local *local) | |||
445 | INIT_LIST_HEAD(&local->roc_list); | 445 | INIT_LIST_HEAD(&local->roc_list); |
446 | } | 446 | } |
447 | 447 | ||
448 | void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata) | 448 | void ieee80211_roc_purge(struct ieee80211_local *local, |
449 | struct ieee80211_sub_if_data *sdata) | ||
449 | { | 450 | { |
450 | struct ieee80211_local *local = sdata->local; | ||
451 | struct ieee80211_roc_work *roc, *tmp; | 451 | struct ieee80211_roc_work *roc, *tmp; |
452 | LIST_HEAD(tmp_list); | 452 | LIST_HEAD(tmp_list); |
453 | 453 | ||
454 | mutex_lock(&local->mtx); | 454 | mutex_lock(&local->mtx); |
455 | list_for_each_entry_safe(roc, tmp, &local->roc_list, list) { | 455 | list_for_each_entry_safe(roc, tmp, &local->roc_list, list) { |
456 | if (roc->sdata != sdata) | 456 | if (sdata && roc->sdata != sdata) |
457 | continue; | 457 | continue; |
458 | 458 | ||
459 | if (roc->started && local->ops->remain_on_channel) { | 459 | if (roc->started && local->ops->remain_on_channel) { |
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 3d16f4e61743..7fc5d0d8149a 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c | |||
@@ -19,6 +19,10 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) | |||
19 | 19 | ||
20 | ieee80211_dfs_cac_cancel(local); | 20 | ieee80211_dfs_cac_cancel(local); |
21 | 21 | ||
22 | ieee80211_roc_purge(local, NULL); | ||
23 | |||
24 | ieee80211_del_virtual_monitor(local); | ||
25 | |||
22 | if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) { | 26 | if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) { |
23 | mutex_lock(&local->sta_mtx); | 27 | mutex_lock(&local->sta_mtx); |
24 | list_for_each_entry(sta, &local->sta_list, list) { | 28 | list_for_each_entry(sta, &local->sta_list, list) { |
@@ -33,8 +37,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) | |||
33 | IEEE80211_MAX_QUEUE_MAP, | 37 | IEEE80211_MAX_QUEUE_MAP, |
34 | IEEE80211_QUEUE_STOP_REASON_SUSPEND); | 38 | IEEE80211_QUEUE_STOP_REASON_SUSPEND); |
35 | 39 | ||
36 | /* flush out all packets */ | 40 | /* flush out all packets and station cleanup call_rcu()s */ |
37 | synchronize_net(); | 41 | synchronize_net(); |
42 | rcu_barrier(); | ||
38 | 43 | ||
39 | ieee80211_flush_queues(local, NULL); | 44 | ieee80211_flush_queues(local, NULL); |
40 | 45 | ||
@@ -101,10 +106,6 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) | |||
101 | drv_remove_interface(local, sdata); | 106 | drv_remove_interface(local, sdata); |
102 | } | 107 | } |
103 | 108 | ||
104 | sdata = rtnl_dereference(local->monitor_sdata); | ||
105 | if (sdata) | ||
106 | drv_remove_interface(local, sdata); | ||
107 | |||
108 | /* | 109 | /* |
109 | * We disconnected on all interfaces before suspend, all channel | 110 | * We disconnected on all interfaces before suspend, all channel |
110 | * contexts should be released. | 111 | * contexts should be released. |
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index dd88381c53b7..0d51877efdb7 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c | |||
@@ -252,6 +252,25 @@ rate_lowest_non_cck_index(struct ieee80211_supported_band *sband, | |||
252 | return 0; | 252 | return 0; |
253 | } | 253 | } |
254 | 254 | ||
255 | static void __rate_control_send_low(struct ieee80211_hw *hw, | ||
256 | struct ieee80211_supported_band *sband, | ||
257 | struct ieee80211_sta *sta, | ||
258 | struct ieee80211_tx_info *info) | ||
259 | { | ||
260 | if ((sband->band != IEEE80211_BAND_2GHZ) || | ||
261 | !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE)) | ||
262 | info->control.rates[0].idx = rate_lowest_index(sband, sta); | ||
263 | else | ||
264 | info->control.rates[0].idx = | ||
265 | rate_lowest_non_cck_index(sband, sta); | ||
266 | |||
267 | info->control.rates[0].count = | ||
268 | (info->flags & IEEE80211_TX_CTL_NO_ACK) ? | ||
269 | 1 : hw->max_rate_tries; | ||
270 | |||
271 | info->control.skip_table = 1; | ||
272 | } | ||
273 | |||
255 | 274 | ||
256 | bool rate_control_send_low(struct ieee80211_sta *sta, | 275 | bool rate_control_send_low(struct ieee80211_sta *sta, |
257 | void *priv_sta, | 276 | void *priv_sta, |
@@ -262,16 +281,8 @@ bool rate_control_send_low(struct ieee80211_sta *sta, | |||
262 | int mcast_rate; | 281 | int mcast_rate; |
263 | 282 | ||
264 | if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) { | 283 | if (!sta || !priv_sta || rc_no_data_or_no_ack_use_min(txrc)) { |
265 | if ((sband->band != IEEE80211_BAND_2GHZ) || | 284 | __rate_control_send_low(txrc->hw, sband, sta, info); |
266 | !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE)) | 285 | |
267 | info->control.rates[0].idx = | ||
268 | rate_lowest_index(txrc->sband, sta); | ||
269 | else | ||
270 | info->control.rates[0].idx = | ||
271 | rate_lowest_non_cck_index(txrc->sband, sta); | ||
272 | info->control.rates[0].count = | ||
273 | (info->flags & IEEE80211_TX_CTL_NO_ACK) ? | ||
274 | 1 : txrc->hw->max_rate_tries; | ||
275 | if (!sta && txrc->bss) { | 286 | if (!sta && txrc->bss) { |
276 | mcast_rate = txrc->bss_conf->mcast_rate[sband->band]; | 287 | mcast_rate = txrc->bss_conf->mcast_rate[sband->band]; |
277 | if (mcast_rate > 0) { | 288 | if (mcast_rate > 0) { |
@@ -355,7 +366,8 @@ static bool rate_idx_match_mcs_mask(struct ieee80211_tx_rate *rate, | |||
355 | 366 | ||
356 | 367 | ||
357 | static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, | 368 | static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, |
358 | struct ieee80211_tx_rate_control *txrc, | 369 | struct ieee80211_supported_band *sband, |
370 | enum nl80211_chan_width chan_width, | ||
359 | u32 mask, | 371 | u32 mask, |
360 | u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]) | 372 | u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]) |
361 | { | 373 | { |
@@ -375,27 +387,17 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, | |||
375 | IEEE80211_TX_RC_USE_SHORT_PREAMBLE); | 387 | IEEE80211_TX_RC_USE_SHORT_PREAMBLE); |
376 | alt_rate.count = rate->count; | 388 | alt_rate.count = rate->count; |
377 | if (rate_idx_match_legacy_mask(&alt_rate, | 389 | if (rate_idx_match_legacy_mask(&alt_rate, |
378 | txrc->sband->n_bitrates, | 390 | sband->n_bitrates, mask)) { |
379 | mask)) { | ||
380 | *rate = alt_rate; | 391 | *rate = alt_rate; |
381 | return; | 392 | return; |
382 | } | 393 | } |
383 | } else { | 394 | } else { |
384 | struct sk_buff *skb = txrc->skb; | ||
385 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
386 | __le16 fc; | ||
387 | |||
388 | /* handle legacy rates */ | 395 | /* handle legacy rates */ |
389 | if (rate_idx_match_legacy_mask(rate, txrc->sband->n_bitrates, | 396 | if (rate_idx_match_legacy_mask(rate, sband->n_bitrates, mask)) |
390 | mask)) | ||
391 | return; | 397 | return; |
392 | 398 | ||
393 | /* if HT BSS, and we handle a data frame, also try HT rates */ | 399 | /* if HT BSS, and we handle a data frame, also try HT rates */ |
394 | if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT) | 400 | if (chan_width == NL80211_CHAN_WIDTH_20_NOHT) |
395 | return; | ||
396 | |||
397 | fc = hdr->frame_control; | ||
398 | if (!ieee80211_is_data(fc)) | ||
399 | return; | 401 | return; |
400 | 402 | ||
401 | alt_rate.idx = 0; | 403 | alt_rate.idx = 0; |
@@ -408,7 +410,7 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, | |||
408 | 410 | ||
409 | alt_rate.flags |= IEEE80211_TX_RC_MCS; | 411 | alt_rate.flags |= IEEE80211_TX_RC_MCS; |
410 | 412 | ||
411 | if (txrc->bss_conf->chandef.width == NL80211_CHAN_WIDTH_40) | 413 | if (chan_width == NL80211_CHAN_WIDTH_40) |
412 | alt_rate.flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; | 414 | alt_rate.flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; |
413 | 415 | ||
414 | if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) { | 416 | if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) { |
@@ -426,6 +428,228 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, | |||
426 | */ | 428 | */ |
427 | } | 429 | } |
428 | 430 | ||
431 | static void rate_fixup_ratelist(struct ieee80211_vif *vif, | ||
432 | struct ieee80211_supported_band *sband, | ||
433 | struct ieee80211_tx_info *info, | ||
434 | struct ieee80211_tx_rate *rates, | ||
435 | int max_rates) | ||
436 | { | ||
437 | struct ieee80211_rate *rate; | ||
438 | bool inval = false; | ||
439 | int i; | ||
440 | |||
441 | /* | ||
442 | * Set up the RTS/CTS rate as the fastest basic rate | ||
443 | * that is not faster than the data rate unless there | ||
444 | * is no basic rate slower than the data rate, in which | ||
445 | * case we pick the slowest basic rate | ||
446 | * | ||
447 | * XXX: Should this check all retry rates? | ||
448 | */ | ||
449 | if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) { | ||
450 | u32 basic_rates = vif->bss_conf.basic_rates; | ||
451 | s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0; | ||
452 | |||
453 | rate = &sband->bitrates[rates[0].idx]; | ||
454 | |||
455 | for (i = 0; i < sband->n_bitrates; i++) { | ||
456 | /* must be a basic rate */ | ||
457 | if (!(basic_rates & BIT(i))) | ||
458 | continue; | ||
459 | /* must not be faster than the data rate */ | ||
460 | if (sband->bitrates[i].bitrate > rate->bitrate) | ||
461 | continue; | ||
462 | /* maximum */ | ||
463 | if (sband->bitrates[baserate].bitrate < | ||
464 | sband->bitrates[i].bitrate) | ||
465 | baserate = i; | ||
466 | } | ||
467 | |||
468 | info->control.rts_cts_rate_idx = baserate; | ||
469 | } | ||
470 | |||
471 | for (i = 0; i < max_rates; i++) { | ||
472 | /* | ||
473 | * make sure there's no valid rate following | ||
474 | * an invalid one, just in case drivers don't | ||
475 | * take the API seriously to stop at -1. | ||
476 | */ | ||
477 | if (inval) { | ||
478 | rates[i].idx = -1; | ||
479 | continue; | ||
480 | } | ||
481 | if (rates[i].idx < 0) { | ||
482 | inval = true; | ||
483 | continue; | ||
484 | } | ||
485 | |||
486 | /* | ||
487 | * For now assume MCS is already set up correctly, this | ||
488 | * needs to be fixed. | ||
489 | */ | ||
490 | if (rates[i].flags & IEEE80211_TX_RC_MCS) { | ||
491 | WARN_ON(rates[i].idx > 76); | ||
492 | |||
493 | if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) && | ||
494 | info->control.use_cts_prot) | ||
495 | rates[i].flags |= | ||
496 | IEEE80211_TX_RC_USE_CTS_PROTECT; | ||
497 | continue; | ||
498 | } | ||
499 | |||
500 | if (rates[i].flags & IEEE80211_TX_RC_VHT_MCS) { | ||
501 | WARN_ON(ieee80211_rate_get_vht_mcs(&rates[i]) > 9); | ||
502 | continue; | ||
503 | } | ||
504 | |||
505 | /* set up RTS protection if desired */ | ||
506 | if (info->control.use_rts) { | ||
507 | rates[i].flags |= IEEE80211_TX_RC_USE_RTS_CTS; | ||
508 | info->control.use_cts_prot = false; | ||
509 | } | ||
510 | |||
511 | /* RC is busted */ | ||
512 | if (WARN_ON_ONCE(rates[i].idx >= sband->n_bitrates)) { | ||
513 | rates[i].idx = -1; | ||
514 | continue; | ||
515 | } | ||
516 | |||
517 | rate = &sband->bitrates[rates[i].idx]; | ||
518 | |||
519 | /* set up short preamble */ | ||
520 | if (info->control.short_preamble && | ||
521 | rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) | ||
522 | rates[i].flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE; | ||
523 | |||
524 | /* set up G protection */ | ||
525 | if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) && | ||
526 | info->control.use_cts_prot && | ||
527 | rate->flags & IEEE80211_RATE_ERP_G) | ||
528 | rates[i].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT; | ||
529 | } | ||
530 | } | ||
531 | |||
532 | |||
533 | static void rate_control_fill_sta_table(struct ieee80211_sta *sta, | ||
534 | struct ieee80211_tx_info *info, | ||
535 | struct ieee80211_tx_rate *rates, | ||
536 | int max_rates) | ||
537 | { | ||
538 | struct ieee80211_sta_rates *ratetbl = NULL; | ||
539 | int i; | ||
540 | |||
541 | if (sta && !info->control.skip_table) | ||
542 | ratetbl = rcu_dereference(sta->rates); | ||
543 | |||
544 | /* Fill remaining rate slots with data from the sta rate table. */ | ||
545 | max_rates = min_t(int, max_rates, IEEE80211_TX_RATE_TABLE_SIZE); | ||
546 | for (i = 0; i < max_rates; i++) { | ||
547 | if (i < ARRAY_SIZE(info->control.rates) && | ||
548 | info->control.rates[i].idx >= 0 && | ||
549 | info->control.rates[i].count) { | ||
550 | if (rates != info->control.rates) | ||
551 | rates[i] = info->control.rates[i]; | ||
552 | } else if (ratetbl) { | ||
553 | rates[i].idx = ratetbl->rate[i].idx; | ||
554 | rates[i].flags = ratetbl->rate[i].flags; | ||
555 | if (info->control.use_rts) | ||
556 | rates[i].count = ratetbl->rate[i].count_rts; | ||
557 | else if (info->control.use_cts_prot) | ||
558 | rates[i].count = ratetbl->rate[i].count_cts; | ||
559 | else | ||
560 | rates[i].count = ratetbl->rate[i].count; | ||
561 | } else { | ||
562 | rates[i].idx = -1; | ||
563 | rates[i].count = 0; | ||
564 | } | ||
565 | |||
566 | if (rates[i].idx < 0 || !rates[i].count) | ||
567 | break; | ||
568 | } | ||
569 | } | ||
570 | |||
571 | static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata, | ||
572 | struct ieee80211_sta *sta, | ||
573 | struct ieee80211_supported_band *sband, | ||
574 | struct ieee80211_tx_info *info, | ||
575 | struct ieee80211_tx_rate *rates, | ||
576 | int max_rates) | ||
577 | { | ||
578 | enum nl80211_chan_width chan_width; | ||
579 | u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; | ||
580 | bool has_mcs_mask; | ||
581 | u32 mask; | ||
582 | int i; | ||
583 | |||
584 | /* | ||
585 | * Try to enforce the rateidx mask the user wanted. skip this if the | ||
586 | * default mask (allow all rates) is used to save some processing for | ||
587 | * the common case. | ||
588 | */ | ||
589 | mask = sdata->rc_rateidx_mask[info->band]; | ||
590 | has_mcs_mask = sdata->rc_has_mcs_mask[info->band]; | ||
591 | if (mask == (1 << sband->n_bitrates) - 1 && !has_mcs_mask) | ||
592 | return; | ||
593 | |||
594 | if (has_mcs_mask) | ||
595 | memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band], | ||
596 | sizeof(mcs_mask)); | ||
597 | else | ||
598 | memset(mcs_mask, 0xff, sizeof(mcs_mask)); | ||
599 | |||
600 | if (sta) { | ||
601 | /* Filter out rates that the STA does not support */ | ||
602 | mask &= sta->supp_rates[info->band]; | ||
603 | for (i = 0; i < sizeof(mcs_mask); i++) | ||
604 | mcs_mask[i] &= sta->ht_cap.mcs.rx_mask[i]; | ||
605 | } | ||
606 | |||
607 | /* | ||
608 | * Make sure the rate index selected for each TX rate is | ||
609 | * included in the configured mask and change the rate indexes | ||
610 | * if needed. | ||
611 | */ | ||
612 | chan_width = sdata->vif.bss_conf.chandef.width; | ||
613 | for (i = 0; i < max_rates; i++) { | ||
614 | /* Skip invalid rates */ | ||
615 | if (rates[i].idx < 0) | ||
616 | break; | ||
617 | |||
618 | rate_idx_match_mask(&rates[i], sband, mask, chan_width, | ||
619 | mcs_mask); | ||
620 | } | ||
621 | } | ||
622 | |||
623 | void ieee80211_get_tx_rates(struct ieee80211_vif *vif, | ||
624 | struct ieee80211_sta *sta, | ||
625 | struct sk_buff *skb, | ||
626 | struct ieee80211_tx_rate *dest, | ||
627 | int max_rates) | ||
628 | { | ||
629 | struct ieee80211_sub_if_data *sdata; | ||
630 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
631 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
632 | struct ieee80211_supported_band *sband; | ||
633 | |||
634 | rate_control_fill_sta_table(sta, info, dest, max_rates); | ||
635 | |||
636 | if (!vif) | ||
637 | return; | ||
638 | |||
639 | sdata = vif_to_sdata(vif); | ||
640 | sband = sdata->local->hw.wiphy->bands[info->band]; | ||
641 | |||
642 | if (ieee80211_is_data(hdr->frame_control)) | ||
643 | rate_control_apply_mask(sdata, sta, sband, info, dest, max_rates); | ||
644 | |||
645 | if (dest[0].idx < 0) | ||
646 | __rate_control_send_low(&sdata->local->hw, sband, sta, info); | ||
647 | |||
648 | if (sta) | ||
649 | rate_fixup_ratelist(vif, sband, info, dest, max_rates); | ||
650 | } | ||
651 | EXPORT_SYMBOL(ieee80211_get_tx_rates); | ||
652 | |||
429 | void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | 653 | void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, |
430 | struct sta_info *sta, | 654 | struct sta_info *sta, |
431 | struct ieee80211_tx_rate_control *txrc) | 655 | struct ieee80211_tx_rate_control *txrc) |
@@ -435,8 +659,6 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | |||
435 | struct ieee80211_sta *ista = NULL; | 659 | struct ieee80211_sta *ista = NULL; |
436 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); | 660 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); |
437 | int i; | 661 | int i; |
438 | u32 mask; | ||
439 | u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; | ||
440 | 662 | ||
441 | if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) { | 663 | if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) { |
442 | ista = &sta->sta; | 664 | ista = &sta->sta; |
@@ -454,37 +676,27 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, | |||
454 | 676 | ||
455 | ref->ops->get_rate(ref->priv, ista, priv_sta, txrc); | 677 | ref->ops->get_rate(ref->priv, ista, priv_sta, txrc); |
456 | 678 | ||
457 | /* | 679 | if (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_RC_TABLE) |
458 | * Try to enforce the rateidx mask the user wanted. skip this if the | 680 | return; |
459 | * default mask (allow all rates) is used to save some processing for | 681 | |
460 | * the common case. | 682 | ieee80211_get_tx_rates(&sdata->vif, ista, txrc->skb, |
461 | */ | 683 | info->control.rates, |
462 | mask = sdata->rc_rateidx_mask[info->band]; | 684 | ARRAY_SIZE(info->control.rates)); |
463 | memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band], | 685 | } |
464 | sizeof(mcs_mask)); | ||
465 | if (mask != (1 << txrc->sband->n_bitrates) - 1) { | ||
466 | if (sta) { | ||
467 | /* Filter out rates that the STA does not support */ | ||
468 | mask &= sta->sta.supp_rates[info->band]; | ||
469 | for (i = 0; i < sizeof(mcs_mask); i++) | ||
470 | mcs_mask[i] &= sta->sta.ht_cap.mcs.rx_mask[i]; | ||
471 | } | ||
472 | /* | ||
473 | * Make sure the rate index selected for each TX rate is | ||
474 | * included in the configured mask and change the rate indexes | ||
475 | * if needed. | ||
476 | */ | ||
477 | for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { | ||
478 | /* Skip invalid rates */ | ||
479 | if (info->control.rates[i].idx < 0) | ||
480 | break; | ||
481 | rate_idx_match_mask(&info->control.rates[i], txrc, | ||
482 | mask, mcs_mask); | ||
483 | } | ||
484 | } | ||
485 | 686 | ||
486 | BUG_ON(info->control.rates[0].idx < 0); | 687 | int rate_control_set_rates(struct ieee80211_hw *hw, |
688 | struct ieee80211_sta *pubsta, | ||
689 | struct ieee80211_sta_rates *rates) | ||
690 | { | ||
691 | struct ieee80211_sta_rates *old = rcu_dereference(pubsta->rates); | ||
692 | |||
693 | rcu_assign_pointer(pubsta->rates, rates); | ||
694 | if (old) | ||
695 | kfree_rcu(old, rcu_head); | ||
696 | |||
697 | return 0; | ||
487 | } | 698 | } |
699 | EXPORT_SYMBOL(rate_control_set_rates); | ||
488 | 700 | ||
489 | int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, | 701 | int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, |
490 | const char *name) | 702 | const char *name) |
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c index 1c36c9b4fa4a..ac7ef5414bde 100644 --- a/net/mac80211/rc80211_minstrel.c +++ b/net/mac80211/rc80211_minstrel.c | |||
@@ -84,6 +84,50 @@ minstrel_sort_best_tp_rates(struct minstrel_sta_info *mi, int i, u8 *tp_list) | |||
84 | } | 84 | } |
85 | 85 | ||
86 | static void | 86 | static void |
87 | minstrel_set_rate(struct minstrel_sta_info *mi, struct ieee80211_sta_rates *ratetbl, | ||
88 | int offset, int idx) | ||
89 | { | ||
90 | struct minstrel_rate *r = &mi->r[idx]; | ||
91 | |||
92 | ratetbl->rate[offset].idx = r->rix; | ||
93 | ratetbl->rate[offset].count = r->adjusted_retry_count; | ||
94 | ratetbl->rate[offset].count_cts = r->retry_count_cts; | ||
95 | ratetbl->rate[offset].count_rts = r->retry_count_rtscts; | ||
96 | } | ||
97 | |||
98 | static void | ||
99 | minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi) | ||
100 | { | ||
101 | struct ieee80211_sta_rates *ratetbl; | ||
102 | int i = 0; | ||
103 | |||
104 | ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC); | ||
105 | if (!ratetbl) | ||
106 | return; | ||
107 | |||
108 | /* Start with max_tp_rate */ | ||
109 | minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]); | ||
110 | |||
111 | if (mp->hw->max_rates >= 3) { | ||
112 | /* At least 3 tx rates supported, use max_tp_rate2 next */ | ||
113 | minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[1]); | ||
114 | } | ||
115 | |||
116 | if (mp->hw->max_rates >= 2) { | ||
117 | /* At least 2 tx rates supported, use max_prob_rate next */ | ||
118 | minstrel_set_rate(mi, ratetbl, i++, mi->max_prob_rate); | ||
119 | } | ||
120 | |||
121 | /* Use lowest rate last */ | ||
122 | ratetbl->rate[i].idx = mi->lowest_rix; | ||
123 | ratetbl->rate[i].count = mp->max_retry; | ||
124 | ratetbl->rate[i].count_cts = mp->max_retry; | ||
125 | ratetbl->rate[i].count_rts = mp->max_retry; | ||
126 | |||
127 | rate_control_set_rates(mp->hw, mi->sta, ratetbl); | ||
128 | } | ||
129 | |||
130 | static void | ||
87 | minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) | 131 | minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) |
88 | { | 132 | { |
89 | u8 tmp_tp_rate[MAX_THR_RATES]; | 133 | u8 tmp_tp_rate[MAX_THR_RATES]; |
@@ -161,6 +205,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) | |||
161 | 205 | ||
162 | /* Reset update timer */ | 206 | /* Reset update timer */ |
163 | mi->stats_update = jiffies; | 207 | mi->stats_update = jiffies; |
208 | |||
209 | minstrel_update_rates(mp, mi); | ||
164 | } | 210 | } |
165 | 211 | ||
166 | static void | 212 | static void |
@@ -209,9 +255,9 @@ minstrel_get_retry_count(struct minstrel_rate *mr, | |||
209 | { | 255 | { |
210 | unsigned int retry = mr->adjusted_retry_count; | 256 | unsigned int retry = mr->adjusted_retry_count; |
211 | 257 | ||
212 | if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) | 258 | if (info->control.use_rts) |
213 | retry = max(2U, min(mr->retry_count_rtscts, retry)); | 259 | retry = max(2U, min(mr->retry_count_rtscts, retry)); |
214 | else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) | 260 | else if (info->control.use_cts_prot) |
215 | retry = max(2U, min(mr->retry_count_cts, retry)); | 261 | retry = max(2U, min(mr->retry_count_cts, retry)); |
216 | return retry; | 262 | return retry; |
217 | } | 263 | } |
@@ -240,13 +286,12 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, | |||
240 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 286 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
241 | struct minstrel_sta_info *mi = priv_sta; | 287 | struct minstrel_sta_info *mi = priv_sta; |
242 | struct minstrel_priv *mp = priv; | 288 | struct minstrel_priv *mp = priv; |
243 | struct ieee80211_tx_rate *ar = info->control.rates; | 289 | struct ieee80211_tx_rate *rate = &info->control.rates[0]; |
244 | unsigned int ndx, sample_ndx = 0; | 290 | struct minstrel_rate *msr, *mr; |
291 | unsigned int ndx; | ||
245 | bool mrr_capable; | 292 | bool mrr_capable; |
246 | bool indirect_rate_sampling = false; | 293 | bool prev_sample = mi->prev_sample; |
247 | bool rate_sampling = false; | 294 | int delta; |
248 | int i, delta; | ||
249 | int mrr_ndx[3]; | ||
250 | int sampling_ratio; | 295 | int sampling_ratio; |
251 | 296 | ||
252 | /* management/no-ack frames do not use rate control */ | 297 | /* management/no-ack frames do not use rate control */ |
@@ -262,107 +307,75 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, | |||
262 | else | 307 | else |
263 | sampling_ratio = mp->lookaround_rate; | 308 | sampling_ratio = mp->lookaround_rate; |
264 | 309 | ||
265 | /* init rateindex [ndx] with max throughput rate */ | ||
266 | ndx = mi->max_tp_rate[0]; | ||
267 | |||
268 | /* increase sum packet counter */ | 310 | /* increase sum packet counter */ |
269 | mi->packet_count++; | 311 | mi->packet_count++; |
270 | 312 | ||
271 | delta = (mi->packet_count * sampling_ratio / 100) - | 313 | delta = (mi->packet_count * sampling_ratio / 100) - |
272 | (mi->sample_count + mi->sample_deferred / 2); | 314 | (mi->sample_count + mi->sample_deferred / 2); |
273 | 315 | ||
274 | /* delta > 0: sampling required */ | 316 | /* delta < 0: no sampling required */ |
275 | if ((delta > 0) && (mrr_capable || !mi->prev_sample)) { | 317 | mi->prev_sample = false; |
276 | struct minstrel_rate *msr; | 318 | if (delta < 0 || (!mrr_capable && prev_sample)) |
277 | if (mi->packet_count >= 10000) { | 319 | return; |
278 | mi->sample_deferred = 0; | ||
279 | mi->sample_count = 0; | ||
280 | mi->packet_count = 0; | ||
281 | } else if (delta > mi->n_rates * 2) { | ||
282 | /* With multi-rate retry, not every planned sample | ||
283 | * attempt actually gets used, due to the way the retry | ||
284 | * chain is set up - [max_tp,sample,prob,lowest] for | ||
285 | * sample_rate < max_tp. | ||
286 | * | ||
287 | * If there's too much sampling backlog and the link | ||
288 | * starts getting worse, minstrel would start bursting | ||
289 | * out lots of sampling frames, which would result | ||
290 | * in a large throughput loss. */ | ||
291 | mi->sample_count += (delta - mi->n_rates * 2); | ||
292 | } | ||
293 | 320 | ||
294 | /* get next random rate sample */ | 321 | if (mi->packet_count >= 10000) { |
295 | sample_ndx = minstrel_get_next_sample(mi); | 322 | mi->sample_deferred = 0; |
296 | msr = &mi->r[sample_ndx]; | 323 | mi->sample_count = 0; |
297 | rate_sampling = true; | 324 | mi->packet_count = 0; |
298 | 325 | } else if (delta > mi->n_rates * 2) { | |
299 | /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage) | 326 | /* With multi-rate retry, not every planned sample |
300 | * rate sampling method should be used. | 327 | * attempt actually gets used, due to the way the retry |
301 | * Respect such rates that are not sampled for 20 interations. | 328 | * chain is set up - [max_tp,sample,prob,lowest] for |
302 | */ | 329 | * sample_rate < max_tp. |
303 | if (mrr_capable && | 330 | * |
304 | msr->perfect_tx_time > mi->r[ndx].perfect_tx_time && | 331 | * If there's too much sampling backlog and the link |
305 | msr->sample_skipped < 20) | 332 | * starts getting worse, minstrel would start bursting |
306 | indirect_rate_sampling = true; | 333 | * out lots of sampling frames, which would result |
307 | 334 | * in a large throughput loss. */ | |
308 | if (!indirect_rate_sampling) { | 335 | mi->sample_count += (delta - mi->n_rates * 2); |
309 | if (msr->sample_limit != 0) { | 336 | } |
310 | ndx = sample_ndx; | 337 | |
311 | mi->sample_count++; | 338 | /* get next random rate sample */ |
312 | if (msr->sample_limit > 0) | 339 | ndx = minstrel_get_next_sample(mi); |
313 | msr->sample_limit--; | 340 | msr = &mi->r[ndx]; |
314 | } else | 341 | mr = &mi->r[mi->max_tp_rate[0]]; |
315 | rate_sampling = false; | 342 | |
316 | } else { | 343 | /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage) |
317 | /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark | 344 | * rate sampling method should be used. |
318 | * packets that have the sampling rate deferred to the | 345 | * Respect such rates that are not sampled for 20 interations. |
319 | * second MRR stage. Increase the sample counter only | 346 | */ |
320 | * if the deferred sample rate was actually used. | 347 | if (mrr_capable && |
321 | * Use the sample_deferred counter to make sure that | 348 | msr->perfect_tx_time > mr->perfect_tx_time && |
322 | * the sampling is not done in large bursts */ | 349 | msr->sample_skipped < 20) { |
323 | info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; | 350 | /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark |
324 | mi->sample_deferred++; | 351 | * packets that have the sampling rate deferred to the |
325 | } | 352 | * second MRR stage. Increase the sample counter only |
353 | * if the deferred sample rate was actually used. | ||
354 | * Use the sample_deferred counter to make sure that | ||
355 | * the sampling is not done in large bursts */ | ||
356 | info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; | ||
357 | rate++; | ||
358 | mi->sample_deferred++; | ||
359 | } else { | ||
360 | if (!msr->sample_limit != 0) | ||
361 | return; | ||
362 | |||
363 | mi->sample_count++; | ||
364 | if (msr->sample_limit > 0) | ||
365 | msr->sample_limit--; | ||
326 | } | 366 | } |
327 | mi->prev_sample = rate_sampling; | ||
328 | 367 | ||
329 | /* If we're not using MRR and the sampling rate already | 368 | /* If we're not using MRR and the sampling rate already |
330 | * has a probability of >95%, we shouldn't be attempting | 369 | * has a probability of >95%, we shouldn't be attempting |
331 | * to use it, as this only wastes precious airtime */ | 370 | * to use it, as this only wastes precious airtime */ |
332 | if (!mrr_capable && rate_sampling && | 371 | if (!mrr_capable && |
333 | (mi->r[ndx].probability > MINSTREL_FRAC(95, 100))) | 372 | (mi->r[ndx].probability > MINSTREL_FRAC(95, 100))) |
334 | ndx = mi->max_tp_rate[0]; | ||
335 | |||
336 | /* mrr setup for 1st stage */ | ||
337 | ar[0].idx = mi->r[ndx].rix; | ||
338 | ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info); | ||
339 | |||
340 | /* non mrr setup for 2nd stage */ | ||
341 | if (!mrr_capable) { | ||
342 | if (!rate_sampling) | ||
343 | ar[0].count = mp->max_retry; | ||
344 | ar[1].idx = mi->lowest_rix; | ||
345 | ar[1].count = mp->max_retry; | ||
346 | return; | 373 | return; |
347 | } | ||
348 | 374 | ||
349 | /* mrr setup for 2nd stage */ | 375 | mi->prev_sample = true; |
350 | if (rate_sampling) { | ||
351 | if (indirect_rate_sampling) | ||
352 | mrr_ndx[0] = sample_ndx; | ||
353 | else | ||
354 | mrr_ndx[0] = mi->max_tp_rate[0]; | ||
355 | } else { | ||
356 | mrr_ndx[0] = mi->max_tp_rate[1]; | ||
357 | } | ||
358 | 376 | ||
359 | /* mrr setup for 3rd & 4th stage */ | 377 | rate->idx = mi->r[ndx].rix; |
360 | mrr_ndx[1] = mi->max_prob_rate; | 378 | rate->count = minstrel_get_retry_count(&mi->r[ndx], info); |
361 | mrr_ndx[2] = 0; | ||
362 | for (i = 1; i < 4; i++) { | ||
363 | ar[i].idx = mi->r[mrr_ndx[i - 1]].rix; | ||
364 | ar[i].count = mi->r[mrr_ndx[i - 1]].adjusted_retry_count; | ||
365 | } | ||
366 | } | 379 | } |
367 | 380 | ||
368 | 381 | ||
@@ -412,12 +425,16 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, | |||
412 | unsigned int i, n = 0; | 425 | unsigned int i, n = 0; |
413 | unsigned int t_slot = 9; /* FIXME: get real slot time */ | 426 | unsigned int t_slot = 9; /* FIXME: get real slot time */ |
414 | 427 | ||
428 | mi->sta = sta; | ||
415 | mi->lowest_rix = rate_lowest_index(sband, sta); | 429 | mi->lowest_rix = rate_lowest_index(sband, sta); |
416 | ctl_rate = &sband->bitrates[mi->lowest_rix]; | 430 | ctl_rate = &sband->bitrates[mi->lowest_rix]; |
417 | mi->sp_ack_dur = ieee80211_frame_duration(sband->band, 10, | 431 | mi->sp_ack_dur = ieee80211_frame_duration(sband->band, 10, |
418 | ctl_rate->bitrate, | 432 | ctl_rate->bitrate, |
419 | !!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1); | 433 | !!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1); |
420 | 434 | ||
435 | memset(mi->max_tp_rate, 0, sizeof(mi->max_tp_rate)); | ||
436 | mi->max_prob_rate = 0; | ||
437 | |||
421 | for (i = 0; i < sband->n_bitrates; i++) { | 438 | for (i = 0; i < sband->n_bitrates; i++) { |
422 | struct minstrel_rate *mr = &mi->r[n]; | 439 | struct minstrel_rate *mr = &mi->r[n]; |
423 | unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0; | 440 | unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0; |
@@ -460,6 +477,8 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, | |||
460 | } while ((tx_time < mp->segment_size) && | 477 | } while ((tx_time < mp->segment_size) && |
461 | (++mr->retry_count < mp->max_retry)); | 478 | (++mr->retry_count < mp->max_retry)); |
462 | mr->adjusted_retry_count = mr->retry_count; | 479 | mr->adjusted_retry_count = mr->retry_count; |
480 | if (!(sband->bitrates[i].flags & IEEE80211_RATE_ERP_G)) | ||
481 | mr->retry_count_cts = mr->retry_count; | ||
463 | } | 482 | } |
464 | 483 | ||
465 | for (i = n; i < sband->n_bitrates; i++) { | 484 | for (i = n; i < sband->n_bitrates; i++) { |
@@ -471,6 +490,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, | |||
471 | mi->stats_update = jiffies; | 490 | mi->stats_update = jiffies; |
472 | 491 | ||
473 | init_sample_table(mi); | 492 | init_sample_table(mi); |
493 | minstrel_update_rates(mp, mi); | ||
474 | } | 494 | } |
475 | 495 | ||
476 | static void * | 496 | static void * |
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h index 85ebf42cb46d..f4301f4b2e41 100644 --- a/net/mac80211/rc80211_minstrel.h +++ b/net/mac80211/rc80211_minstrel.h | |||
@@ -9,7 +9,8 @@ | |||
9 | #ifndef __RC_MINSTREL_H | 9 | #ifndef __RC_MINSTREL_H |
10 | #define __RC_MINSTREL_H | 10 | #define __RC_MINSTREL_H |
11 | 11 | ||
12 | #define EWMA_LEVEL 75 /* ewma weighting factor [%] */ | 12 | #define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */ |
13 | #define EWMA_DIV 128 | ||
13 | #define SAMPLE_COLUMNS 10 /* number of columns in sample table */ | 14 | #define SAMPLE_COLUMNS 10 /* number of columns in sample table */ |
14 | 15 | ||
15 | 16 | ||
@@ -27,7 +28,7 @@ | |||
27 | static inline int | 28 | static inline int |
28 | minstrel_ewma(int old, int new, int weight) | 29 | minstrel_ewma(int old, int new, int weight) |
29 | { | 30 | { |
30 | return (new * (100 - weight) + old * weight) / 100; | 31 | return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV; |
31 | } | 32 | } |
32 | 33 | ||
33 | 34 | ||
@@ -62,6 +63,8 @@ struct minstrel_rate { | |||
62 | }; | 63 | }; |
63 | 64 | ||
64 | struct minstrel_sta_info { | 65 | struct minstrel_sta_info { |
66 | struct ieee80211_sta *sta; | ||
67 | |||
65 | unsigned long stats_update; | 68 | unsigned long stats_update; |
66 | unsigned int sp_ack_dur; | 69 | unsigned int sp_ack_dur; |
67 | unsigned int rate_avg; | 70 | unsigned int rate_avg; |
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c index d1048348d399..fd0b9ca1570e 100644 --- a/net/mac80211/rc80211_minstrel_debugfs.c +++ b/net/mac80211/rc80211_minstrel_debugfs.c | |||
@@ -68,7 +68,7 @@ minstrel_stats_open(struct inode *inode, struct file *file) | |||
68 | 68 | ||
69 | file->private_data = ms; | 69 | file->private_data = ms; |
70 | p = ms->buf; | 70 | p = ms->buf; |
71 | p += sprintf(p, "rate throughput ewma prob this prob " | 71 | p += sprintf(p, "rate throughput ewma prob this prob " |
72 | "this succ/attempt success attempts\n"); | 72 | "this succ/attempt success attempts\n"); |
73 | for (i = 0; i < mi->n_rates; i++) { | 73 | for (i = 0; i < mi->n_rates; i++) { |
74 | struct minstrel_rate *mr = &mi->r[i]; | 74 | struct minstrel_rate *mr = &mi->r[i]; |
@@ -86,7 +86,7 @@ minstrel_stats_open(struct inode *inode, struct file *file) | |||
86 | eprob = MINSTREL_TRUNC(mr->probability * 1000); | 86 | eprob = MINSTREL_TRUNC(mr->probability * 1000); |
87 | 87 | ||
88 | p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " | 88 | p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " |
89 | "%3u(%3u) %8llu %8llu\n", | 89 | " %3u(%3u) %8llu %8llu\n", |
90 | tp / 10, tp % 10, | 90 | tp / 10, tp % 10, |
91 | eprob / 10, eprob % 10, | 91 | eprob / 10, eprob % 10, |
92 | prob / 10, prob % 10, | 92 | prob / 10, prob % 10, |
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index d2b264d1311d..5b2d3012b983 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c | |||
@@ -126,6 +126,9 @@ const struct mcs_group minstrel_mcs_groups[] = { | |||
126 | 126 | ||
127 | static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES]; | 127 | static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES]; |
128 | 128 | ||
129 | static void | ||
130 | minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi); | ||
131 | |||
129 | /* | 132 | /* |
130 | * Look up an MCS group index based on mac80211 rate information | 133 | * Look up an MCS group index based on mac80211 rate information |
131 | */ | 134 | */ |
@@ -244,6 +247,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) | |||
244 | struct minstrel_rate_stats *mr; | 247 | struct minstrel_rate_stats *mr; |
245 | int cur_prob, cur_prob_tp, cur_tp, cur_tp2; | 248 | int cur_prob, cur_prob_tp, cur_tp, cur_tp2; |
246 | int group, i, index; | 249 | int group, i, index; |
250 | bool mi_rates_valid = false; | ||
247 | 251 | ||
248 | if (mi->ampdu_packets > 0) { | 252 | if (mi->ampdu_packets > 0) { |
249 | mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len, | 253 | mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len, |
@@ -254,11 +258,10 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) | |||
254 | 258 | ||
255 | mi->sample_slow = 0; | 259 | mi->sample_slow = 0; |
256 | mi->sample_count = 0; | 260 | mi->sample_count = 0; |
257 | mi->max_tp_rate = 0; | ||
258 | mi->max_tp_rate2 = 0; | ||
259 | mi->max_prob_rate = 0; | ||
260 | 261 | ||
261 | for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { | 262 | for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { |
263 | bool mg_rates_valid = false; | ||
264 | |||
262 | cur_prob = 0; | 265 | cur_prob = 0; |
263 | cur_prob_tp = 0; | 266 | cur_prob_tp = 0; |
264 | cur_tp = 0; | 267 | cur_tp = 0; |
@@ -268,15 +271,24 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) | |||
268 | if (!mg->supported) | 271 | if (!mg->supported) |
269 | continue; | 272 | continue; |
270 | 273 | ||
271 | mg->max_tp_rate = 0; | ||
272 | mg->max_tp_rate2 = 0; | ||
273 | mg->max_prob_rate = 0; | ||
274 | mi->sample_count++; | 274 | mi->sample_count++; |
275 | 275 | ||
276 | for (i = 0; i < MCS_GROUP_RATES; i++) { | 276 | for (i = 0; i < MCS_GROUP_RATES; i++) { |
277 | if (!(mg->supported & BIT(i))) | 277 | if (!(mg->supported & BIT(i))) |
278 | continue; | 278 | continue; |
279 | 279 | ||
280 | /* initialize rates selections starting indexes */ | ||
281 | if (!mg_rates_valid) { | ||
282 | mg->max_tp_rate = mg->max_tp_rate2 = | ||
283 | mg->max_prob_rate = i; | ||
284 | if (!mi_rates_valid) { | ||
285 | mi->max_tp_rate = mi->max_tp_rate2 = | ||
286 | mi->max_prob_rate = i; | ||
287 | mi_rates_valid = true; | ||
288 | } | ||
289 | mg_rates_valid = true; | ||
290 | } | ||
291 | |||
280 | mr = &mg->rates[i]; | 292 | mr = &mg->rates[i]; |
281 | mr->retry_updated = false; | 293 | mr->retry_updated = false; |
282 | index = MCS_GROUP_RATES * group + i; | 294 | index = MCS_GROUP_RATES * group + i; |
@@ -456,7 +468,7 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, | |||
456 | struct ieee80211_tx_rate *ar = info->status.rates; | 468 | struct ieee80211_tx_rate *ar = info->status.rates; |
457 | struct minstrel_rate_stats *rate, *rate2; | 469 | struct minstrel_rate_stats *rate, *rate2; |
458 | struct minstrel_priv *mp = priv; | 470 | struct minstrel_priv *mp = priv; |
459 | bool last; | 471 | bool last, update = false; |
460 | int i; | 472 | int i; |
461 | 473 | ||
462 | if (!msp->is_ht) | 474 | if (!msp->is_ht) |
@@ -505,21 +517,29 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, | |||
505 | rate = minstrel_get_ratestats(mi, mi->max_tp_rate); | 517 | rate = minstrel_get_ratestats(mi, mi->max_tp_rate); |
506 | if (rate->attempts > 30 && | 518 | if (rate->attempts > 30 && |
507 | MINSTREL_FRAC(rate->success, rate->attempts) < | 519 | MINSTREL_FRAC(rate->success, rate->attempts) < |
508 | MINSTREL_FRAC(20, 100)) | 520 | MINSTREL_FRAC(20, 100)) { |
509 | minstrel_downgrade_rate(mi, &mi->max_tp_rate, true); | 521 | minstrel_downgrade_rate(mi, &mi->max_tp_rate, true); |
522 | update = true; | ||
523 | } | ||
510 | 524 | ||
511 | rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2); | 525 | rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2); |
512 | if (rate2->attempts > 30 && | 526 | if (rate2->attempts > 30 && |
513 | MINSTREL_FRAC(rate2->success, rate2->attempts) < | 527 | MINSTREL_FRAC(rate2->success, rate2->attempts) < |
514 | MINSTREL_FRAC(20, 100)) | 528 | MINSTREL_FRAC(20, 100)) { |
515 | minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false); | 529 | minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false); |
530 | update = true; | ||
531 | } | ||
516 | 532 | ||
517 | if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) { | 533 | if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) { |
534 | update = true; | ||
518 | minstrel_ht_update_stats(mp, mi); | 535 | minstrel_ht_update_stats(mp, mi); |
519 | if (!(info->flags & IEEE80211_TX_CTL_AMPDU) && | 536 | if (!(info->flags & IEEE80211_TX_CTL_AMPDU) && |
520 | mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP) | 537 | mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP) |
521 | minstrel_aggr_check(sta, skb); | 538 | minstrel_aggr_check(sta, skb); |
522 | } | 539 | } |
540 | |||
541 | if (update) | ||
542 | minstrel_ht_update_rates(mp, mi); | ||
523 | } | 543 | } |
524 | 544 | ||
525 | static void | 545 | static void |
@@ -583,36 +603,71 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, | |||
583 | 603 | ||
584 | static void | 604 | static void |
585 | minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, | 605 | minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, |
586 | struct ieee80211_tx_rate *rate, int index, | 606 | struct ieee80211_sta_rates *ratetbl, int offset, int index) |
587 | bool sample, bool rtscts) | ||
588 | { | 607 | { |
589 | const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; | 608 | const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; |
590 | struct minstrel_rate_stats *mr; | 609 | struct minstrel_rate_stats *mr; |
610 | u8 idx; | ||
611 | u16 flags; | ||
591 | 612 | ||
592 | mr = minstrel_get_ratestats(mi, index); | 613 | mr = minstrel_get_ratestats(mi, index); |
593 | if (!mr->retry_updated) | 614 | if (!mr->retry_updated) |
594 | minstrel_calc_retransmit(mp, mi, index); | 615 | minstrel_calc_retransmit(mp, mi, index); |
595 | 616 | ||
596 | if (sample) | 617 | if (mr->probability < MINSTREL_FRAC(20, 100) || !mr->retry_count) { |
597 | rate->count = 1; | 618 | ratetbl->rate[offset].count = 2; |
598 | else if (mr->probability < MINSTREL_FRAC(20, 100)) | 619 | ratetbl->rate[offset].count_rts = 2; |
599 | rate->count = 2; | 620 | ratetbl->rate[offset].count_cts = 2; |
600 | else if (rtscts) | 621 | } else { |
601 | rate->count = mr->retry_count_rtscts; | 622 | ratetbl->rate[offset].count = mr->retry_count; |
602 | else | 623 | ratetbl->rate[offset].count_cts = mr->retry_count; |
603 | rate->count = mr->retry_count; | 624 | ratetbl->rate[offset].count_rts = mr->retry_count_rtscts; |
604 | 625 | } | |
605 | rate->flags = 0; | ||
606 | if (rtscts) | ||
607 | rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS; | ||
608 | 626 | ||
609 | if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) { | 627 | if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) { |
610 | rate->idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)]; | 628 | idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)]; |
629 | flags = 0; | ||
630 | } else { | ||
631 | idx = index % MCS_GROUP_RATES + | ||
632 | (group->streams - 1) * MCS_GROUP_RATES; | ||
633 | flags = IEEE80211_TX_RC_MCS | group->flags; | ||
634 | } | ||
635 | |||
636 | if (offset > 0) { | ||
637 | ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts; | ||
638 | flags |= IEEE80211_TX_RC_USE_RTS_CTS; | ||
639 | } | ||
640 | |||
641 | ratetbl->rate[offset].idx = idx; | ||
642 | ratetbl->rate[offset].flags = flags; | ||
643 | } | ||
644 | |||
645 | static void | ||
646 | minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) | ||
647 | { | ||
648 | struct ieee80211_sta_rates *rates; | ||
649 | int i = 0; | ||
650 | |||
651 | rates = kzalloc(sizeof(*rates), GFP_ATOMIC); | ||
652 | if (!rates) | ||
611 | return; | 653 | return; |
654 | |||
655 | /* Start with max_tp_rate */ | ||
656 | minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate); | ||
657 | |||
658 | if (mp->hw->max_rates >= 3) { | ||
659 | /* At least 3 tx rates supported, use max_tp_rate2 next */ | ||
660 | minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate2); | ||
661 | } | ||
662 | |||
663 | if (mp->hw->max_rates >= 2) { | ||
664 | /* | ||
665 | * At least 2 tx rates supported, use max_prob_rate next */ | ||
666 | minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate); | ||
612 | } | 667 | } |
613 | 668 | ||
614 | rate->flags |= IEEE80211_TX_RC_MCS | group->flags; | 669 | rates->rate[i].idx = -1; |
615 | rate->idx = index % MCS_GROUP_RATES + (group->streams - 1) * MCS_GROUP_RATES; | 670 | rate_control_set_rates(mp->hw, mi->sta, rates); |
616 | } | 671 | } |
617 | 672 | ||
618 | static inline int | 673 | static inline int |
@@ -702,13 +757,13 @@ static void | |||
702 | minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, | 757 | minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, |
703 | struct ieee80211_tx_rate_control *txrc) | 758 | struct ieee80211_tx_rate_control *txrc) |
704 | { | 759 | { |
760 | const struct mcs_group *sample_group; | ||
705 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); | 761 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); |
706 | struct ieee80211_tx_rate *ar = info->status.rates; | 762 | struct ieee80211_tx_rate *rate = &info->status.rates[0]; |
707 | struct minstrel_ht_sta_priv *msp = priv_sta; | 763 | struct minstrel_ht_sta_priv *msp = priv_sta; |
708 | struct minstrel_ht_sta *mi = &msp->ht; | 764 | struct minstrel_ht_sta *mi = &msp->ht; |
709 | struct minstrel_priv *mp = priv; | 765 | struct minstrel_priv *mp = priv; |
710 | int sample_idx; | 766 | int sample_idx; |
711 | bool sample = false; | ||
712 | 767 | ||
713 | if (rate_control_send_low(sta, priv_sta, txrc)) | 768 | if (rate_control_send_low(sta, priv_sta, txrc)) |
714 | return; | 769 | return; |
@@ -736,51 +791,6 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, | |||
736 | } | 791 | } |
737 | #endif | 792 | #endif |
738 | 793 | ||
739 | if (sample_idx >= 0) { | ||
740 | sample = true; | ||
741 | minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx, | ||
742 | true, false); | ||
743 | info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; | ||
744 | } else { | ||
745 | minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate, | ||
746 | false, false); | ||
747 | } | ||
748 | |||
749 | if (mp->hw->max_rates >= 3) { | ||
750 | /* | ||
751 | * At least 3 tx rates supported, use | ||
752 | * sample_rate -> max_tp_rate -> max_prob_rate for sampling and | ||
753 | * max_tp_rate -> max_tp_rate2 -> max_prob_rate by default. | ||
754 | */ | ||
755 | if (sample_idx >= 0) | ||
756 | minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate, | ||
757 | false, false); | ||
758 | else | ||
759 | minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2, | ||
760 | false, true); | ||
761 | |||
762 | minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate, | ||
763 | false, !sample); | ||
764 | |||
765 | ar[3].count = 0; | ||
766 | ar[3].idx = -1; | ||
767 | } else if (mp->hw->max_rates == 2) { | ||
768 | /* | ||
769 | * Only 2 tx rates supported, use | ||
770 | * sample_rate -> max_prob_rate for sampling and | ||
771 | * max_tp_rate -> max_prob_rate by default. | ||
772 | */ | ||
773 | minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_prob_rate, | ||
774 | false, !sample); | ||
775 | |||
776 | ar[2].count = 0; | ||
777 | ar[2].idx = -1; | ||
778 | } else { | ||
779 | /* Not using MRR, only use the first rate */ | ||
780 | ar[1].count = 0; | ||
781 | ar[1].idx = -1; | ||
782 | } | ||
783 | |||
784 | mi->total_packets++; | 794 | mi->total_packets++; |
785 | 795 | ||
786 | /* wraparound */ | 796 | /* wraparound */ |
@@ -788,6 +798,16 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, | |||
788 | mi->total_packets = 0; | 798 | mi->total_packets = 0; |
789 | mi->sample_packets = 0; | 799 | mi->sample_packets = 0; |
790 | } | 800 | } |
801 | |||
802 | if (sample_idx < 0) | ||
803 | return; | ||
804 | |||
805 | sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES]; | ||
806 | info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; | ||
807 | rate->idx = sample_idx % MCS_GROUP_RATES + | ||
808 | (sample_group->streams - 1) * MCS_GROUP_RATES; | ||
809 | rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags; | ||
810 | rate->count = 1; | ||
791 | } | 811 | } |
792 | 812 | ||
793 | static void | 813 | static void |
@@ -837,6 +857,8 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, | |||
837 | 857 | ||
838 | msp->is_ht = true; | 858 | msp->is_ht = true; |
839 | memset(mi, 0, sizeof(*mi)); | 859 | memset(mi, 0, sizeof(*mi)); |
860 | |||
861 | mi->sta = sta; | ||
840 | mi->stats_update = jiffies; | 862 | mi->stats_update = jiffies; |
841 | 863 | ||
842 | ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1); | 864 | ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1); |
@@ -898,6 +920,10 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, | |||
898 | if (!n_supported) | 920 | if (!n_supported) |
899 | goto use_legacy; | 921 | goto use_legacy; |
900 | 922 | ||
923 | /* create an initial rate table with the lowest supported rates */ | ||
924 | minstrel_ht_update_stats(mp, mi); | ||
925 | minstrel_ht_update_rates(mp, mi); | ||
926 | |||
901 | return; | 927 | return; |
902 | 928 | ||
903 | use_legacy: | 929 | use_legacy: |
diff --git a/net/mac80211/rc80211_minstrel_ht.h b/net/mac80211/rc80211_minstrel_ht.h index 9b16e9de9923..d655586773ac 100644 --- a/net/mac80211/rc80211_minstrel_ht.h +++ b/net/mac80211/rc80211_minstrel_ht.h | |||
@@ -65,6 +65,8 @@ struct minstrel_mcs_group_data { | |||
65 | }; | 65 | }; |
66 | 66 | ||
67 | struct minstrel_ht_sta { | 67 | struct minstrel_ht_sta { |
68 | struct ieee80211_sta *sta; | ||
69 | |||
68 | /* ampdu length (average, per sampling interval) */ | 70 | /* ampdu length (average, per sampling interval) */ |
69 | unsigned int ampdu_len; | 71 | unsigned int ampdu_len; |
70 | unsigned int ampdu_packets; | 72 | unsigned int ampdu_packets; |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 2528b5a4d6d4..c8447af76ead 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -2085,6 +2085,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
2085 | } | 2085 | } |
2086 | 2086 | ||
2087 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; | 2087 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; |
2088 | fwd_hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_RETRY); | ||
2088 | info = IEEE80211_SKB_CB(fwd_skb); | 2089 | info = IEEE80211_SKB_CB(fwd_skb); |
2089 | memset(info, 0, sizeof(*info)); | 2090 | memset(info, 0, sizeof(*info)); |
2090 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 2091 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
@@ -2423,6 +2424,22 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
2423 | } | 2424 | } |
2424 | 2425 | ||
2425 | break; | 2426 | break; |
2427 | case WLAN_CATEGORY_PUBLIC: | ||
2428 | if (len < IEEE80211_MIN_ACTION_SIZE + 1) | ||
2429 | goto invalid; | ||
2430 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
2431 | break; | ||
2432 | if (!rx->sta) | ||
2433 | break; | ||
2434 | if (!ether_addr_equal(mgmt->bssid, sdata->u.mgd.bssid)) | ||
2435 | break; | ||
2436 | if (mgmt->u.action.u.ext_chan_switch.action_code != | ||
2437 | WLAN_PUB_ACTION_EXT_CHANSW_ANN) | ||
2438 | break; | ||
2439 | if (len < offsetof(struct ieee80211_mgmt, | ||
2440 | u.action.u.ext_chan_switch.variable)) | ||
2441 | goto invalid; | ||
2442 | goto queue; | ||
2426 | case WLAN_CATEGORY_VHT: | 2443 | case WLAN_CATEGORY_VHT: |
2427 | if (sdata->vif.type != NL80211_IFTYPE_STATION && | 2444 | if (sdata->vif.type != NL80211_IFTYPE_STATION && |
2428 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT && | 2445 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT && |
@@ -2506,10 +2523,6 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
2506 | ieee80211_process_measurement_req(sdata, mgmt, len); | 2523 | ieee80211_process_measurement_req(sdata, mgmt, len); |
2507 | goto handled; | 2524 | goto handled; |
2508 | case WLAN_ACTION_SPCT_CHL_SWITCH: | 2525 | case WLAN_ACTION_SPCT_CHL_SWITCH: |
2509 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2510 | sizeof(mgmt->u.action.u.chan_switch))) | ||
2511 | break; | ||
2512 | |||
2513 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 2526 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
2514 | break; | 2527 | break; |
2515 | 2528 | ||
@@ -3042,7 +3055,8 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, | |||
3042 | !ieee80211_is_probe_resp(hdr->frame_control) && | 3055 | !ieee80211_is_probe_resp(hdr->frame_control) && |
3043 | !ieee80211_is_beacon(hdr->frame_control)) | 3056 | !ieee80211_is_beacon(hdr->frame_control)) |
3044 | return 0; | 3057 | return 0; |
3045 | if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) | 3058 | if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) && |
3059 | !multicast) | ||
3046 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; | 3060 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; |
3047 | break; | 3061 | break; |
3048 | default: | 3062 | default: |
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index cb34cbbaa20c..99b103921a4b 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -98,9 +98,8 @@ ieee80211_bss_info_update(struct ieee80211_local *local, | |||
98 | } | 98 | } |
99 | 99 | ||
100 | /* save the ERP value so that it is available at association time */ | 100 | /* save the ERP value so that it is available at association time */ |
101 | if (elems->erp_info && elems->erp_info_len >= 1 && | 101 | if (elems->erp_info && (!elems->parse_error || |
102 | (!elems->parse_error || | 102 | !(bss->valid_data & IEEE80211_BSS_VALID_ERP))) { |
103 | !(bss->valid_data & IEEE80211_BSS_VALID_ERP))) { | ||
104 | bss->erp_value = elems->erp_info[0]; | 103 | bss->erp_value = elems->erp_info[0]; |
105 | bss->has_erp_value = true; | 104 | bss->has_erp_value = true; |
106 | if (!elems->parse_error) | 105 | if (!elems->parse_error) |
@@ -182,7 +181,7 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) | |||
182 | if (baselen > skb->len) | 181 | if (baselen > skb->len) |
183 | return; | 182 | return; |
184 | 183 | ||
185 | ieee802_11_parse_elems(elements, skb->len - baselen, &elems); | 184 | ieee802_11_parse_elems(elements, skb->len - baselen, false, &elems); |
186 | 185 | ||
187 | channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq); | 186 | channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq); |
188 | 187 | ||
@@ -384,7 +383,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local, | |||
384 | { | 383 | { |
385 | int i; | 384 | int i; |
386 | struct ieee80211_sub_if_data *sdata; | 385 | struct ieee80211_sub_if_data *sdata; |
387 | enum ieee80211_band band = local->hw.conf.channel->band; | 386 | enum ieee80211_band band = local->hw.conf.chandef.chan->band; |
388 | u32 tx_flags; | 387 | u32 tx_flags; |
389 | 388 | ||
390 | tx_flags = IEEE80211_TX_INTFL_OFFCHAN_TX_OK; | 389 | tx_flags = IEEE80211_TX_INTFL_OFFCHAN_TX_OK; |
@@ -401,7 +400,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local, | |||
401 | local->scan_req->ssids[i].ssid_len, | 400 | local->scan_req->ssids[i].ssid_len, |
402 | local->scan_req->ie, local->scan_req->ie_len, | 401 | local->scan_req->ie, local->scan_req->ie_len, |
403 | local->scan_req->rates[band], false, | 402 | local->scan_req->rates[band], false, |
404 | tx_flags, local->hw.conf.channel, true); | 403 | tx_flags, local->hw.conf.chandef.chan, true); |
405 | 404 | ||
406 | /* | 405 | /* |
407 | * After sending probe requests, wait for probe responses | 406 | * After sending probe requests, wait for probe responses |
@@ -467,7 +466,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
467 | if (local->ops->hw_scan) { | 466 | if (local->ops->hw_scan) { |
468 | __set_bit(SCAN_HW_SCANNING, &local->scanning); | 467 | __set_bit(SCAN_HW_SCANNING, &local->scanning); |
469 | } else if ((req->n_channels == 1) && | 468 | } else if ((req->n_channels == 1) && |
470 | (req->channels[0] == local->_oper_channel)) { | 469 | (req->channels[0] == local->_oper_chandef.chan)) { |
471 | /* | 470 | /* |
472 | * If we are scanning only on the operating channel | 471 | * If we are scanning only on the operating channel |
473 | * then we do not need to stop normal activities | 472 | * then we do not need to stop normal activities |
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index c5899797a8d4..c215fafd7a2f 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h | |||
@@ -28,27 +28,27 @@ | |||
28 | #define VIF_PR_FMT " vif:%s(%d%s)" | 28 | #define VIF_PR_FMT " vif:%s(%d%s)" |
29 | #define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" | 29 | #define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" |
30 | 30 | ||
31 | #define CHANDEF_ENTRY __field(u32, control_freq) \ | 31 | #define CHANDEF_ENTRY __field(u32, control_freq) \ |
32 | __field(u32, chan_width) \ | 32 | __field(u32, chan_width) \ |
33 | __field(u32, center_freq1) \ | 33 | __field(u32, center_freq1) \ |
34 | __field(u32, center_freq2) | 34 | __field(u32, center_freq2) |
35 | #define CHANDEF_ASSIGN(c) \ | 35 | #define CHANDEF_ASSIGN(c) \ |
36 | __entry->control_freq = (c)->chan->center_freq; \ | 36 | __entry->control_freq = (c)->chan ? (c)->chan->center_freq : 0; \ |
37 | __entry->chan_width = (c)->width; \ | 37 | __entry->chan_width = (c)->width; \ |
38 | __entry->center_freq1 = (c)->center_freq1; \ | 38 | __entry->center_freq1 = (c)->center_freq1; \ |
39 | __entry->center_freq2 = (c)->center_freq2; | 39 | __entry->center_freq2 = (c)->center_freq2; |
40 | #define CHANDEF_PR_FMT " control:%d MHz width:%d center: %d/%d MHz" | 40 | #define CHANDEF_PR_FMT " control:%d MHz width:%d center: %d/%d MHz" |
41 | #define CHANDEF_PR_ARG __entry->control_freq, __entry->chan_width, \ | 41 | #define CHANDEF_PR_ARG __entry->control_freq, __entry->chan_width, \ |
42 | __entry->center_freq1, __entry->center_freq2 | 42 | __entry->center_freq1, __entry->center_freq2 |
43 | 43 | ||
44 | #define CHANCTX_ENTRY CHANDEF_ENTRY \ | 44 | #define CHANCTX_ENTRY CHANDEF_ENTRY \ |
45 | __field(u8, rx_chains_static) \ | 45 | __field(u8, rx_chains_static) \ |
46 | __field(u8, rx_chains_dynamic) | 46 | __field(u8, rx_chains_dynamic) |
47 | #define CHANCTX_ASSIGN CHANDEF_ASSIGN(&ctx->conf.def) \ | 47 | #define CHANCTX_ASSIGN CHANDEF_ASSIGN(&ctx->conf.def) \ |
48 | __entry->rx_chains_static = ctx->conf.rx_chains_static; \ | 48 | __entry->rx_chains_static = ctx->conf.rx_chains_static; \ |
49 | __entry->rx_chains_dynamic = ctx->conf.rx_chains_dynamic | 49 | __entry->rx_chains_dynamic = ctx->conf.rx_chains_dynamic |
50 | #define CHANCTX_PR_FMT CHANDEF_PR_FMT " chains:%d/%d" | 50 | #define CHANCTX_PR_FMT CHANDEF_PR_FMT " chains:%d/%d" |
51 | #define CHANCTX_PR_ARG CHANDEF_PR_ARG, \ | 51 | #define CHANCTX_PR_ARG CHANDEF_PR_ARG, \ |
52 | __entry->rx_chains_static, __entry->rx_chains_dynamic | 52 | __entry->rx_chains_static, __entry->rx_chains_dynamic |
53 | 53 | ||
54 | 54 | ||
@@ -286,8 +286,7 @@ TRACE_EVENT(drv_config, | |||
286 | __field(u16, listen_interval) | 286 | __field(u16, listen_interval) |
287 | __field(u8, long_frame_max_tx_count) | 287 | __field(u8, long_frame_max_tx_count) |
288 | __field(u8, short_frame_max_tx_count) | 288 | __field(u8, short_frame_max_tx_count) |
289 | __field(int, center_freq) | 289 | CHANDEF_ENTRY |
290 | __field(int, channel_type) | ||
291 | __field(int, smps) | 290 | __field(int, smps) |
292 | ), | 291 | ), |
293 | 292 | ||
@@ -303,15 +302,13 @@ TRACE_EVENT(drv_config, | |||
303 | local->hw.conf.long_frame_max_tx_count; | 302 | local->hw.conf.long_frame_max_tx_count; |
304 | __entry->short_frame_max_tx_count = | 303 | __entry->short_frame_max_tx_count = |
305 | local->hw.conf.short_frame_max_tx_count; | 304 | local->hw.conf.short_frame_max_tx_count; |
306 | __entry->center_freq = local->hw.conf.channel ? | 305 | CHANDEF_ASSIGN(&local->hw.conf.chandef) |
307 | local->hw.conf.channel->center_freq : 0; | ||
308 | __entry->channel_type = local->hw.conf.channel_type; | ||
309 | __entry->smps = local->hw.conf.smps_mode; | 306 | __entry->smps = local->hw.conf.smps_mode; |
310 | ), | 307 | ), |
311 | 308 | ||
312 | TP_printk( | 309 | TP_printk( |
313 | LOCAL_PR_FMT " ch:%#x freq:%d", | 310 | LOCAL_PR_FMT " ch:%#x" CHANDEF_PR_FMT, |
314 | LOCAL_PR_ARG, __entry->changed, __entry->center_freq | 311 | LOCAL_PR_ARG, __entry->changed, CHANDEF_PR_ARG |
315 | ) | 312 | ) |
316 | ); | 313 | ); |
317 | 314 | ||
@@ -359,8 +356,7 @@ TRACE_EVENT(drv_bss_info_changed, | |||
359 | __dynamic_array(u8, ssid, info->ssid_len); | 356 | __dynamic_array(u8, ssid, info->ssid_len); |
360 | __field(bool, hidden_ssid); | 357 | __field(bool, hidden_ssid); |
361 | __field(int, txpower) | 358 | __field(int, txpower) |
362 | __field(u8, p2p_ctwindow) | 359 | __field(u8, p2p_oppps_ctwindow) |
363 | __field(bool, p2p_oppps) | ||
364 | ), | 360 | ), |
365 | 361 | ||
366 | TP_fast_assign( | 362 | TP_fast_assign( |
@@ -400,8 +396,7 @@ TRACE_EVENT(drv_bss_info_changed, | |||
400 | memcpy(__get_dynamic_array(ssid), info->ssid, info->ssid_len); | 396 | memcpy(__get_dynamic_array(ssid), info->ssid, info->ssid_len); |
401 | __entry->hidden_ssid = info->hidden_ssid; | 397 | __entry->hidden_ssid = info->hidden_ssid; |
402 | __entry->txpower = info->txpower; | 398 | __entry->txpower = info->txpower; |
403 | __entry->p2p_ctwindow = info->p2p_ctwindow; | 399 | __entry->p2p_oppps_ctwindow = info->p2p_noa_attr.oppps_ctwindow; |
404 | __entry->p2p_oppps = info->p2p_oppps; | ||
405 | ), | 400 | ), |
406 | 401 | ||
407 | TP_printk( | 402 | TP_printk( |
@@ -995,23 +990,23 @@ TRACE_EVENT(drv_channel_switch, | |||
995 | 990 | ||
996 | TP_STRUCT__entry( | 991 | TP_STRUCT__entry( |
997 | LOCAL_ENTRY | 992 | LOCAL_ENTRY |
993 | CHANDEF_ENTRY | ||
998 | __field(u64, timestamp) | 994 | __field(u64, timestamp) |
999 | __field(bool, block_tx) | 995 | __field(bool, block_tx) |
1000 | __field(u16, freq) | ||
1001 | __field(u8, count) | 996 | __field(u8, count) |
1002 | ), | 997 | ), |
1003 | 998 | ||
1004 | TP_fast_assign( | 999 | TP_fast_assign( |
1005 | LOCAL_ASSIGN; | 1000 | LOCAL_ASSIGN; |
1001 | CHANDEF_ASSIGN(&ch_switch->chandef) | ||
1006 | __entry->timestamp = ch_switch->timestamp; | 1002 | __entry->timestamp = ch_switch->timestamp; |
1007 | __entry->block_tx = ch_switch->block_tx; | 1003 | __entry->block_tx = ch_switch->block_tx; |
1008 | __entry->freq = ch_switch->channel->center_freq; | ||
1009 | __entry->count = ch_switch->count; | 1004 | __entry->count = ch_switch->count; |
1010 | ), | 1005 | ), |
1011 | 1006 | ||
1012 | TP_printk( | 1007 | TP_printk( |
1013 | LOCAL_PR_FMT " new freq:%u count:%d", | 1008 | LOCAL_PR_FMT " new " CHANDEF_PR_FMT " count:%d", |
1014 | LOCAL_PR_ARG, __entry->freq, __entry->count | 1009 | LOCAL_PR_ARG, CHANDEF_PR_ARG, __entry->count |
1015 | ) | 1010 | ) |
1016 | ); | 1011 | ); |
1017 | 1012 | ||
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 9e67cc97b87b..9972e07a2f96 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -48,15 +48,15 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, | |||
48 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 48 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
49 | 49 | ||
50 | /* assume HW handles this */ | 50 | /* assume HW handles this */ |
51 | if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS) | 51 | if (tx->rate.flags & IEEE80211_TX_RC_MCS) |
52 | return 0; | 52 | return 0; |
53 | 53 | ||
54 | /* uh huh? */ | 54 | /* uh huh? */ |
55 | if (WARN_ON_ONCE(info->control.rates[0].idx < 0)) | 55 | if (WARN_ON_ONCE(tx->rate.idx < 0)) |
56 | return 0; | 56 | return 0; |
57 | 57 | ||
58 | sband = local->hw.wiphy->bands[info->band]; | 58 | sband = local->hw.wiphy->bands[info->band]; |
59 | txrate = &sband->bitrates[info->control.rates[0].idx]; | 59 | txrate = &sband->bitrates[tx->rate.idx]; |
60 | 60 | ||
61 | erp = txrate->flags & IEEE80211_RATE_ERP_G; | 61 | erp = txrate->flags & IEEE80211_RATE_ERP_G; |
62 | 62 | ||
@@ -617,11 +617,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
617 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 617 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
618 | struct ieee80211_hdr *hdr = (void *)tx->skb->data; | 618 | struct ieee80211_hdr *hdr = (void *)tx->skb->data; |
619 | struct ieee80211_supported_band *sband; | 619 | struct ieee80211_supported_band *sband; |
620 | struct ieee80211_rate *rate; | ||
621 | int i; | ||
622 | u32 len; | 620 | u32 len; |
623 | bool inval = false, rts = false, short_preamble = false; | ||
624 | struct ieee80211_tx_rate_control txrc; | 621 | struct ieee80211_tx_rate_control txrc; |
622 | struct ieee80211_sta_rates *ratetbl = NULL; | ||
625 | bool assoc = false; | 623 | bool assoc = false; |
626 | 624 | ||
627 | memset(&txrc, 0, sizeof(txrc)); | 625 | memset(&txrc, 0, sizeof(txrc)); |
@@ -642,18 +640,23 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
642 | txrc.max_rate_idx = -1; | 640 | txrc.max_rate_idx = -1; |
643 | else | 641 | else |
644 | txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; | 642 | txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; |
645 | memcpy(txrc.rate_idx_mcs_mask, | 643 | |
646 | tx->sdata->rc_rateidx_mcs_mask[info->band], | 644 | if (tx->sdata->rc_has_mcs_mask[info->band]) |
647 | sizeof(txrc.rate_idx_mcs_mask)); | 645 | txrc.rate_idx_mcs_mask = |
646 | tx->sdata->rc_rateidx_mcs_mask[info->band]; | ||
647 | |||
648 | txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || | 648 | txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || |
649 | tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || | 649 | tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || |
650 | tx->sdata->vif.type == NL80211_IFTYPE_ADHOC); | 650 | tx->sdata->vif.type == NL80211_IFTYPE_ADHOC); |
651 | 651 | ||
652 | /* set up RTS protection if desired */ | 652 | /* set up RTS protection if desired */ |
653 | if (len > tx->local->hw.wiphy->rts_threshold) { | 653 | if (len > tx->local->hw.wiphy->rts_threshold) { |
654 | txrc.rts = rts = true; | 654 | txrc.rts = true; |
655 | } | 655 | } |
656 | 656 | ||
657 | info->control.use_rts = txrc.rts; | ||
658 | info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot; | ||
659 | |||
657 | /* | 660 | /* |
658 | * Use short preamble if the BSS can handle it, but not for | 661 | * Use short preamble if the BSS can handle it, but not for |
659 | * management frames unless we know the receiver can handle | 662 | * management frames unless we know the receiver can handle |
@@ -663,7 +666,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
663 | if (tx->sdata->vif.bss_conf.use_short_preamble && | 666 | if (tx->sdata->vif.bss_conf.use_short_preamble && |
664 | (ieee80211_is_data(hdr->frame_control) || | 667 | (ieee80211_is_data(hdr->frame_control) || |
665 | (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) | 668 | (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) |
666 | txrc.short_preamble = short_preamble = true; | 669 | txrc.short_preamble = true; |
670 | |||
671 | info->control.short_preamble = txrc.short_preamble; | ||
667 | 672 | ||
668 | if (tx->sta) | 673 | if (tx->sta) |
669 | assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); | 674 | assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); |
@@ -687,16 +692,38 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
687 | */ | 692 | */ |
688 | rate_control_get_rate(tx->sdata, tx->sta, &txrc); | 693 | rate_control_get_rate(tx->sdata, tx->sta, &txrc); |
689 | 694 | ||
690 | if (unlikely(info->control.rates[0].idx < 0)) | 695 | if (tx->sta && !info->control.skip_table) |
691 | return TX_DROP; | 696 | ratetbl = rcu_dereference(tx->sta->sta.rates); |
697 | |||
698 | if (unlikely(info->control.rates[0].idx < 0)) { | ||
699 | if (ratetbl) { | ||
700 | struct ieee80211_tx_rate rate = { | ||
701 | .idx = ratetbl->rate[0].idx, | ||
702 | .flags = ratetbl->rate[0].flags, | ||
703 | .count = ratetbl->rate[0].count | ||
704 | }; | ||
705 | |||
706 | if (ratetbl->rate[0].idx < 0) | ||
707 | return TX_DROP; | ||
708 | |||
709 | tx->rate = rate; | ||
710 | } else { | ||
711 | return TX_DROP; | ||
712 | } | ||
713 | } else { | ||
714 | tx->rate = info->control.rates[0]; | ||
715 | } | ||
692 | 716 | ||
693 | if (txrc.reported_rate.idx < 0) { | 717 | if (txrc.reported_rate.idx < 0) { |
694 | txrc.reported_rate = info->control.rates[0]; | 718 | txrc.reported_rate = tx->rate; |
695 | if (tx->sta && ieee80211_is_data(hdr->frame_control)) | 719 | if (tx->sta && ieee80211_is_data(hdr->frame_control)) |
696 | tx->sta->last_tx_rate = txrc.reported_rate; | 720 | tx->sta->last_tx_rate = txrc.reported_rate; |
697 | } else if (tx->sta) | 721 | } else if (tx->sta) |
698 | tx->sta->last_tx_rate = txrc.reported_rate; | 722 | tx->sta->last_tx_rate = txrc.reported_rate; |
699 | 723 | ||
724 | if (ratetbl) | ||
725 | return TX_CONTINUE; | ||
726 | |||
700 | if (unlikely(!info->control.rates[0].count)) | 727 | if (unlikely(!info->control.rates[0].count)) |
701 | info->control.rates[0].count = 1; | 728 | info->control.rates[0].count = 1; |
702 | 729 | ||
@@ -704,91 +731,6 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
704 | (info->flags & IEEE80211_TX_CTL_NO_ACK))) | 731 | (info->flags & IEEE80211_TX_CTL_NO_ACK))) |
705 | info->control.rates[0].count = 1; | 732 | info->control.rates[0].count = 1; |
706 | 733 | ||
707 | if (is_multicast_ether_addr(hdr->addr1)) { | ||
708 | /* | ||
709 | * XXX: verify the rate is in the basic rateset | ||
710 | */ | ||
711 | return TX_CONTINUE; | ||
712 | } | ||
713 | |||
714 | /* | ||
715 | * set up the RTS/CTS rate as the fastest basic rate | ||
716 | * that is not faster than the data rate | ||
717 | * | ||
718 | * XXX: Should this check all retry rates? | ||
719 | */ | ||
720 | if (!(info->control.rates[0].flags & IEEE80211_TX_RC_MCS)) { | ||
721 | s8 baserate = 0; | ||
722 | |||
723 | rate = &sband->bitrates[info->control.rates[0].idx]; | ||
724 | |||
725 | for (i = 0; i < sband->n_bitrates; i++) { | ||
726 | /* must be a basic rate */ | ||
727 | if (!(tx->sdata->vif.bss_conf.basic_rates & BIT(i))) | ||
728 | continue; | ||
729 | /* must not be faster than the data rate */ | ||
730 | if (sband->bitrates[i].bitrate > rate->bitrate) | ||
731 | continue; | ||
732 | /* maximum */ | ||
733 | if (sband->bitrates[baserate].bitrate < | ||
734 | sband->bitrates[i].bitrate) | ||
735 | baserate = i; | ||
736 | } | ||
737 | |||
738 | info->control.rts_cts_rate_idx = baserate; | ||
739 | } | ||
740 | |||
741 | for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { | ||
742 | /* | ||
743 | * make sure there's no valid rate following | ||
744 | * an invalid one, just in case drivers don't | ||
745 | * take the API seriously to stop at -1. | ||
746 | */ | ||
747 | if (inval) { | ||
748 | info->control.rates[i].idx = -1; | ||
749 | continue; | ||
750 | } | ||
751 | if (info->control.rates[i].idx < 0) { | ||
752 | inval = true; | ||
753 | continue; | ||
754 | } | ||
755 | |||
756 | /* | ||
757 | * For now assume MCS is already set up correctly, this | ||
758 | * needs to be fixed. | ||
759 | */ | ||
760 | if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) { | ||
761 | WARN_ON(info->control.rates[i].idx > 76); | ||
762 | continue; | ||
763 | } | ||
764 | |||
765 | /* set up RTS protection if desired */ | ||
766 | if (rts) | ||
767 | info->control.rates[i].flags |= | ||
768 | IEEE80211_TX_RC_USE_RTS_CTS; | ||
769 | |||
770 | /* RC is busted */ | ||
771 | if (WARN_ON_ONCE(info->control.rates[i].idx >= | ||
772 | sband->n_bitrates)) { | ||
773 | info->control.rates[i].idx = -1; | ||
774 | continue; | ||
775 | } | ||
776 | |||
777 | rate = &sband->bitrates[info->control.rates[i].idx]; | ||
778 | |||
779 | /* set up short preamble */ | ||
780 | if (short_preamble && | ||
781 | rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) | ||
782 | info->control.rates[i].flags |= | ||
783 | IEEE80211_TX_RC_USE_SHORT_PREAMBLE; | ||
784 | |||
785 | /* set up G protection */ | ||
786 | if (!rts && tx->sdata->vif.bss_conf.use_cts_prot && | ||
787 | rate->flags & IEEE80211_RATE_ERP_G) | ||
788 | info->control.rates[i].flags |= | ||
789 | IEEE80211_TX_RC_USE_CTS_PROTECT; | ||
790 | } | ||
791 | |||
792 | return TX_CONTINUE; | 734 | return TX_CONTINUE; |
793 | } | 735 | } |
794 | 736 | ||
@@ -1709,7 +1651,7 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1709 | if (chanctx_conf) | 1651 | if (chanctx_conf) |
1710 | chan = chanctx_conf->def.chan; | 1652 | chan = chanctx_conf->def.chan; |
1711 | else if (!local->use_chanctx) | 1653 | else if (!local->use_chanctx) |
1712 | chan = local->_oper_channel; | 1654 | chan = local->_oper_chandef.chan; |
1713 | else | 1655 | else |
1714 | goto fail_rcu; | 1656 | goto fail_rcu; |
1715 | 1657 | ||
@@ -1843,7 +1785,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1843 | * This is the exception! WDS style interfaces are prohibited | 1785 | * This is the exception! WDS style interfaces are prohibited |
1844 | * when channel contexts are in used so this must be valid | 1786 | * when channel contexts are in used so this must be valid |
1845 | */ | 1787 | */ |
1846 | band = local->hw.conf.channel->band; | 1788 | band = local->hw.conf.chandef.chan->band; |
1847 | break; | 1789 | break; |
1848 | #ifdef CONFIG_MAC80211_MESH | 1790 | #ifdef CONFIG_MAC80211_MESH |
1849 | case NL80211_IFTYPE_MESH_POINT: | 1791 | case NL80211_IFTYPE_MESH_POINT: |
@@ -2442,14 +2384,17 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2442 | } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { | 2384 | } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
2443 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | 2385 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
2444 | struct ieee80211_hdr *hdr; | 2386 | struct ieee80211_hdr *hdr; |
2445 | struct sk_buff *presp = rcu_dereference(ifibss->presp); | 2387 | struct beacon_data *presp = rcu_dereference(ifibss->presp); |
2446 | 2388 | ||
2447 | if (!presp) | 2389 | if (!presp) |
2448 | goto out; | 2390 | goto out; |
2449 | 2391 | ||
2450 | skb = skb_copy(presp, GFP_ATOMIC); | 2392 | skb = dev_alloc_skb(local->tx_headroom + presp->head_len); |
2451 | if (!skb) | 2393 | if (!skb) |
2452 | goto out; | 2394 | goto out; |
2395 | skb_reserve(skb, local->tx_headroom); | ||
2396 | memcpy(skb_put(skb, presp->head_len), presp->head, | ||
2397 | presp->head_len); | ||
2453 | 2398 | ||
2454 | hdr = (struct ieee80211_hdr *) skb->data; | 2399 | hdr = (struct ieee80211_hdr *) skb->data; |
2455 | hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 2400 | hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
@@ -2499,8 +2444,6 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2499 | txrc.max_rate_idx = -1; | 2444 | txrc.max_rate_idx = -1; |
2500 | else | 2445 | else |
2501 | txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; | 2446 | txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; |
2502 | memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band], | ||
2503 | sizeof(txrc.rate_idx_mcs_mask)); | ||
2504 | txrc.bss = true; | 2447 | txrc.bss = true; |
2505 | rate_control_get_rate(sdata, NULL, &txrc); | 2448 | rate_control_get_rate(sdata, NULL, &txrc); |
2506 | 2449 | ||
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index a7368870c8ee..3f87fa468b1f 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -485,7 +485,8 @@ int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue) | |||
485 | return true; | 485 | return true; |
486 | 486 | ||
487 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 487 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
488 | ret = !!local->queue_stop_reasons[queue]; | 488 | ret = test_bit(IEEE80211_QUEUE_STOP_REASON_DRIVER, |
489 | &local->queue_stop_reasons[queue]); | ||
489 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | 490 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); |
490 | return ret; | 491 | return ret; |
491 | } | 492 | } |
@@ -660,7 +661,7 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw, | |||
660 | } | 661 | } |
661 | EXPORT_SYMBOL(ieee80211_queue_delayed_work); | 662 | EXPORT_SYMBOL(ieee80211_queue_delayed_work); |
662 | 663 | ||
663 | u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | 664 | u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, bool action, |
664 | struct ieee802_11_elems *elems, | 665 | struct ieee802_11_elems *elems, |
665 | u64 filter, u32 crc) | 666 | u64 filter, u32 crc) |
666 | { | 667 | { |
@@ -668,6 +669,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
668 | u8 *pos = start; | 669 | u8 *pos = start; |
669 | bool calc_crc = filter != 0; | 670 | bool calc_crc = filter != 0; |
670 | DECLARE_BITMAP(seen_elems, 256); | 671 | DECLARE_BITMAP(seen_elems, 256); |
672 | const u8 *ie; | ||
671 | 673 | ||
672 | bitmap_zero(seen_elems, 256); | 674 | bitmap_zero(seen_elems, 256); |
673 | memset(elems, 0, sizeof(*elems)); | 675 | memset(elems, 0, sizeof(*elems)); |
@@ -715,6 +717,12 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
715 | case WLAN_EID_COUNTRY: | 717 | case WLAN_EID_COUNTRY: |
716 | case WLAN_EID_PWR_CONSTRAINT: | 718 | case WLAN_EID_PWR_CONSTRAINT: |
717 | case WLAN_EID_TIMEOUT_INTERVAL: | 719 | case WLAN_EID_TIMEOUT_INTERVAL: |
720 | case WLAN_EID_SECONDARY_CHANNEL_OFFSET: | ||
721 | case WLAN_EID_WIDE_BW_CHANNEL_SWITCH: | ||
722 | /* | ||
723 | * not listing WLAN_EID_CHANNEL_SWITCH_WRAPPER -- it seems possible | ||
724 | * that if the content gets bigger it might be needed more than once | ||
725 | */ | ||
718 | if (test_bit(id, seen_elems)) { | 726 | if (test_bit(id, seen_elems)) { |
719 | elems->parse_error = true; | 727 | elems->parse_error = true; |
720 | left -= elen; | 728 | left -= elen; |
@@ -738,17 +746,11 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
738 | elems->supp_rates = pos; | 746 | elems->supp_rates = pos; |
739 | elems->supp_rates_len = elen; | 747 | elems->supp_rates_len = elen; |
740 | break; | 748 | break; |
741 | case WLAN_EID_FH_PARAMS: | ||
742 | elems->fh_params = pos; | ||
743 | elems->fh_params_len = elen; | ||
744 | break; | ||
745 | case WLAN_EID_DS_PARAMS: | 749 | case WLAN_EID_DS_PARAMS: |
746 | elems->ds_params = pos; | 750 | if (elen >= 1) |
747 | elems->ds_params_len = elen; | 751 | elems->ds_params = pos; |
748 | break; | 752 | else |
749 | case WLAN_EID_CF_PARAMS: | 753 | elem_parse_failed = true; |
750 | elems->cf_params = pos; | ||
751 | elems->cf_params_len = elen; | ||
752 | break; | 754 | break; |
753 | case WLAN_EID_TIM: | 755 | case WLAN_EID_TIM: |
754 | if (elen >= sizeof(struct ieee80211_tim_ie)) { | 756 | if (elen >= sizeof(struct ieee80211_tim_ie)) { |
@@ -757,10 +759,6 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
757 | } else | 759 | } else |
758 | elem_parse_failed = true; | 760 | elem_parse_failed = true; |
759 | break; | 761 | break; |
760 | case WLAN_EID_IBSS_PARAMS: | ||
761 | elems->ibss_params = pos; | ||
762 | elems->ibss_params_len = elen; | ||
763 | break; | ||
764 | case WLAN_EID_CHALLENGE: | 762 | case WLAN_EID_CHALLENGE: |
765 | elems->challenge = pos; | 763 | elems->challenge = pos; |
766 | elems->challenge_len = elen; | 764 | elems->challenge_len = elen; |
@@ -790,8 +788,10 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
790 | elems->rsn_len = elen; | 788 | elems->rsn_len = elen; |
791 | break; | 789 | break; |
792 | case WLAN_EID_ERP_INFO: | 790 | case WLAN_EID_ERP_INFO: |
793 | elems->erp_info = pos; | 791 | if (elen >= 1) |
794 | elems->erp_info_len = elen; | 792 | elems->erp_info = pos; |
793 | else | ||
794 | elem_parse_failed = true; | ||
795 | break; | 795 | break; |
796 | case WLAN_EID_EXT_SUPP_RATES: | 796 | case WLAN_EID_EXT_SUPP_RATES: |
797 | elems->ext_supp_rates = pos; | 797 | elems->ext_supp_rates = pos; |
@@ -870,12 +870,47 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
870 | } | 870 | } |
871 | elems->ch_switch_ie = (void *)pos; | 871 | elems->ch_switch_ie = (void *)pos; |
872 | break; | 872 | break; |
873 | case WLAN_EID_QUIET: | 873 | case WLAN_EID_EXT_CHANSWITCH_ANN: |
874 | if (!elems->quiet_elem) { | 874 | if (elen != sizeof(struct ieee80211_ext_chansw_ie)) { |
875 | elems->quiet_elem = pos; | 875 | elem_parse_failed = true; |
876 | elems->quiet_elem_len = elen; | 876 | break; |
877 | } | ||
878 | elems->ext_chansw_ie = (void *)pos; | ||
879 | break; | ||
880 | case WLAN_EID_SECONDARY_CHANNEL_OFFSET: | ||
881 | if (elen != sizeof(struct ieee80211_sec_chan_offs_ie)) { | ||
882 | elem_parse_failed = true; | ||
883 | break; | ||
884 | } | ||
885 | elems->sec_chan_offs = (void *)pos; | ||
886 | break; | ||
887 | case WLAN_EID_WIDE_BW_CHANNEL_SWITCH: | ||
888 | if (!action || | ||
889 | elen != sizeof(*elems->wide_bw_chansw_ie)) { | ||
890 | elem_parse_failed = true; | ||
891 | break; | ||
892 | } | ||
893 | elems->wide_bw_chansw_ie = (void *)pos; | ||
894 | break; | ||
895 | case WLAN_EID_CHANNEL_SWITCH_WRAPPER: | ||
896 | if (action) { | ||
897 | elem_parse_failed = true; | ||
898 | break; | ||
899 | } | ||
900 | /* | ||
901 | * This is a bit tricky, but as we only care about | ||
902 | * the wide bandwidth channel switch element, so | ||
903 | * just parse it out manually. | ||
904 | */ | ||
905 | ie = cfg80211_find_ie(WLAN_EID_WIDE_BW_CHANNEL_SWITCH, | ||
906 | pos, elen); | ||
907 | if (ie) { | ||
908 | if (ie[1] == sizeof(*elems->wide_bw_chansw_ie)) | ||
909 | elems->wide_bw_chansw_ie = | ||
910 | (void *)(ie + 2); | ||
911 | else | ||
912 | elem_parse_failed = true; | ||
877 | } | 913 | } |
878 | elems->num_of_quiet_elem++; | ||
879 | break; | 914 | break; |
880 | case WLAN_EID_COUNTRY: | 915 | case WLAN_EID_COUNTRY: |
881 | elems->country_elem = pos; | 916 | elems->country_elem = pos; |
@@ -889,8 +924,10 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
889 | elems->pwr_constr_elem = pos; | 924 | elems->pwr_constr_elem = pos; |
890 | break; | 925 | break; |
891 | case WLAN_EID_TIMEOUT_INTERVAL: | 926 | case WLAN_EID_TIMEOUT_INTERVAL: |
892 | elems->timeout_int = pos; | 927 | if (elen >= sizeof(struct ieee80211_timeout_interval_ie)) |
893 | elems->timeout_int_len = elen; | 928 | elems->timeout_int = (void *)pos; |
929 | else | ||
930 | elem_parse_failed = true; | ||
894 | break; | 931 | break; |
895 | default: | 932 | default: |
896 | break; | 933 | break; |
@@ -911,12 +948,6 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
911 | return crc; | 948 | return crc; |
912 | } | 949 | } |
913 | 950 | ||
914 | void ieee802_11_parse_elems(u8 *start, size_t len, | ||
915 | struct ieee802_11_elems *elems) | ||
916 | { | ||
917 | ieee802_11_parse_elems_crc(start, len, elems, 0, 0); | ||
918 | } | ||
919 | |||
920 | void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, | 951 | void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, |
921 | bool bss_notify) | 952 | bool bss_notify) |
922 | { | 953 | { |
@@ -1474,6 +1505,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1474 | /* add interfaces */ | 1505 | /* add interfaces */ |
1475 | sdata = rtnl_dereference(local->monitor_sdata); | 1506 | sdata = rtnl_dereference(local->monitor_sdata); |
1476 | if (sdata) { | 1507 | if (sdata) { |
1508 | /* in HW restart it exists already */ | ||
1509 | WARN_ON(local->resuming); | ||
1477 | res = drv_add_interface(local, sdata); | 1510 | res = drv_add_interface(local, sdata); |
1478 | if (WARN_ON(res)) { | 1511 | if (WARN_ON(res)) { |
1479 | rcu_assign_pointer(local->monitor_sdata, NULL); | 1512 | rcu_assign_pointer(local->monitor_sdata, NULL); |
@@ -1663,6 +1696,9 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1663 | local->in_reconfig = false; | 1696 | local->in_reconfig = false; |
1664 | barrier(); | 1697 | barrier(); |
1665 | 1698 | ||
1699 | if (local->monitors == local->open_count && local->monitors > 0) | ||
1700 | ieee80211_add_virtual_monitor(local); | ||
1701 | |||
1666 | /* | 1702 | /* |
1667 | * Clear the WLAN_STA_BLOCK_BA flag so new aggregation | 1703 | * Clear the WLAN_STA_BLOCK_BA flag so new aggregation |
1668 | * sessions can be established after a resume. | 1704 | * sessions can be established after a resume. |
@@ -2056,7 +2092,7 @@ int ieee80211_ave_rssi(struct ieee80211_vif *vif) | |||
2056 | /* non-managed type inferfaces */ | 2092 | /* non-managed type inferfaces */ |
2057 | return 0; | 2093 | return 0; |
2058 | } | 2094 | } |
2059 | return ifmgd->ave_beacon_signal; | 2095 | return ifmgd->ave_beacon_signal / 16; |
2060 | } | 2096 | } |
2061 | EXPORT_SYMBOL_GPL(ieee80211_ave_rssi); | 2097 | EXPORT_SYMBOL_GPL(ieee80211_ave_rssi); |
2062 | 2098 | ||
@@ -2171,8 +2207,7 @@ void ieee80211_dfs_radar_detected_work(struct work_struct *work) | |||
2171 | /* currently not handled */ | 2207 | /* currently not handled */ |
2172 | WARN_ON(1); | 2208 | WARN_ON(1); |
2173 | else { | 2209 | else { |
2174 | cfg80211_chandef_create(&chandef, local->hw.conf.channel, | 2210 | chandef = local->hw.conf.chandef; |
2175 | local->hw.conf.channel_type); | ||
2176 | cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL); | 2211 | cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL); |
2177 | } | 2212 | } |
2178 | } | 2213 | } |