Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * BSS client mode implementation |
Jouni Malinen | 5394af4 | 2009-01-08 13:31:59 +0200 | [diff] [blame] | 3 | * Copyright 2003-2008, Jouni Malinen <j@w1.fi> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 4 | * Copyright 2004, Instant802 Networks, Inc. |
| 5 | * Copyright 2005, Devicescape Software, Inc. |
| 6 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> |
| 7 | * Copyright 2007, Michael Wu <flamingice@sourmilk.net> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
Geert Uytterhoeven | 5b323ed | 2007-05-08 18:40:27 -0700 | [diff] [blame] | 14 | #include <linux/delay.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 15 | #include <linux/if_ether.h> |
| 16 | #include <linux/skbuff.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 17 | #include <linux/if_arp.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 18 | #include <linux/etherdevice.h> |
Paul Gortmaker | d9b9384 | 2011-09-18 13:21:27 -0400 | [diff] [blame] | 19 | #include <linux/moduleparam.h> |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 20 | #include <linux/rtnetlink.h> |
Jean Pihet | e8db0be | 2011-08-25 15:35:03 +0200 | [diff] [blame] | 21 | #include <linux/pm_qos.h> |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 22 | #include <linux/crc32.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 23 | #include <linux/slab.h> |
Paul Gortmaker | bc3b2d7 | 2011-07-15 11:47:34 -0400 | [diff] [blame] | 24 | #include <linux/export.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 25 | #include <net/mac80211.h> |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 26 | #include <asm/unaligned.h> |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 27 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 28 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 29 | #include "driver-ops.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 30 | #include "rate.h" |
| 31 | #include "led.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 32 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 33 | #define IEEE80211_AUTH_TIMEOUT (HZ / 5) |
| 34 | #define IEEE80211_AUTH_MAX_TRIES 3 |
| 35 | #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5) |
| 36 | #define IEEE80211_ASSOC_TIMEOUT (HZ / 5) |
| 37 | #define IEEE80211_ASSOC_MAX_TRIES 3 |
| 38 | |
Ben Greear | 180205b | 2011-02-04 15:30:24 -0800 | [diff] [blame] | 39 | static int max_nullfunc_tries = 2; |
| 40 | module_param(max_nullfunc_tries, int, 0644); |
| 41 | MODULE_PARM_DESC(max_nullfunc_tries, |
| 42 | "Maximum nullfunc tx tries before disconnecting (reason 4)."); |
| 43 | |
| 44 | static int max_probe_tries = 5; |
| 45 | module_param(max_probe_tries, int, 0644); |
| 46 | MODULE_PARM_DESC(max_probe_tries, |
| 47 | "Maximum probe tries before disconnecting (reason 4)."); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 48 | |
| 49 | /* |
Felix Fietkau | 7ccc8bd | 2010-11-19 22:55:38 +0100 | [diff] [blame] | 50 | * Beacon loss timeout is calculated as N frames times the |
| 51 | * advertised beacon interval. This may need to be somewhat |
| 52 | * higher than what hardware might detect to account for |
| 53 | * delays in the host processing frames. But since we also |
| 54 | * probe on beacon miss before declaring the connection lost |
| 55 | * default to what we want. |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 56 | */ |
Felix Fietkau | 7ccc8bd | 2010-11-19 22:55:38 +0100 | [diff] [blame] | 57 | #define IEEE80211_BEACON_LOSS_COUNT 7 |
| 58 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 59 | /* |
| 60 | * Time the connection can be idle before we probe |
| 61 | * it to see if we can still talk to the AP. |
| 62 | */ |
Maxim Levitsky | d1c5091 | 2009-07-31 18:54:23 +0300 | [diff] [blame] | 63 | #define IEEE80211_CONNECTION_IDLE_TIME (30 * HZ) |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 64 | /* |
| 65 | * Time we wait for a probe response after sending |
| 66 | * a probe request because of beacon loss or for |
| 67 | * checking the connection still works. |
| 68 | */ |
Ben Greear | 180205b | 2011-02-04 15:30:24 -0800 | [diff] [blame] | 69 | static int probe_wait_ms = 500; |
| 70 | module_param(probe_wait_ms, int, 0644); |
| 71 | MODULE_PARM_DESC(probe_wait_ms, |
| 72 | "Maximum time(ms) to wait for probe response" |
| 73 | " before disconnecting (reason 4)."); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 74 | |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 75 | /* |
| 76 | * Weight given to the latest Beacon frame when calculating average signal |
| 77 | * strength for Beacon frames received in the current BSS. This must be |
| 78 | * between 1 and 15. |
| 79 | */ |
| 80 | #define IEEE80211_SIGNAL_AVE_WEIGHT 3 |
| 81 | |
Jouni Malinen | 391a200 | 2010-08-27 22:22:00 +0300 | [diff] [blame] | 82 | /* |
| 83 | * How many Beacon frames need to have been used in average signal strength |
| 84 | * before starting to indicate signal change events. |
| 85 | */ |
| 86 | #define IEEE80211_SIGNAL_AVE_MIN_COUNT 4 |
| 87 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 88 | #define TMR_RUNNING_TIMER 0 |
| 89 | #define TMR_RUNNING_CHANSW 1 |
| 90 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 91 | /* |
| 92 | * All cfg80211 functions have to be called outside a locked |
| 93 | * section so that they can acquire a lock themselves... This |
| 94 | * is much simpler than queuing up things in cfg80211, but we |
| 95 | * do need some indirection for that here. |
| 96 | */ |
| 97 | enum rx_mgmt_action { |
| 98 | /* no action required */ |
| 99 | RX_MGMT_NONE, |
| 100 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 101 | /* caller must call cfg80211_send_deauth() */ |
| 102 | RX_MGMT_CFG80211_DEAUTH, |
| 103 | |
| 104 | /* caller must call cfg80211_send_disassoc() */ |
| 105 | RX_MGMT_CFG80211_DISASSOC, |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 106 | |
| 107 | /* caller must call cfg80211_send_rx_auth() */ |
| 108 | RX_MGMT_CFG80211_RX_AUTH, |
| 109 | |
| 110 | /* caller must call cfg80211_send_rx_assoc() */ |
| 111 | RX_MGMT_CFG80211_RX_ASSOC, |
| 112 | |
| 113 | /* caller must call cfg80211_send_assoc_timeout() */ |
| 114 | RX_MGMT_CFG80211_ASSOC_TIMEOUT, |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 115 | }; |
| 116 | |
Johannes Berg | 5484e23 | 2008-09-08 17:44:27 +0200 | [diff] [blame] | 117 | /* utils */ |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 118 | static inline void ASSERT_MGD_MTX(struct ieee80211_if_managed *ifmgd) |
| 119 | { |
Johannes Berg | 46a5eba | 2010-09-15 13:28:15 +0200 | [diff] [blame] | 120 | lockdep_assert_held(&ifmgd->mtx); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 121 | } |
| 122 | |
Johannes Berg | ca386f3 | 2009-07-10 02:39:48 +0200 | [diff] [blame] | 123 | /* |
| 124 | * We can have multiple work items (and connection probing) |
| 125 | * scheduling this timer, but we need to take care to only |
| 126 | * reschedule it when it should fire _earlier_ than it was |
| 127 | * asked for before, or if it's not pending right now. This |
| 128 | * function ensures that. Note that it then is required to |
| 129 | * run this function for all timeouts after the first one |
| 130 | * has happened -- the work that runs from this timer will |
| 131 | * do that. |
| 132 | */ |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 133 | static void run_again(struct ieee80211_if_managed *ifmgd, unsigned long timeout) |
Johannes Berg | ca386f3 | 2009-07-10 02:39:48 +0200 | [diff] [blame] | 134 | { |
| 135 | ASSERT_MGD_MTX(ifmgd); |
| 136 | |
| 137 | if (!timer_pending(&ifmgd->timer) || |
| 138 | time_before(timeout, ifmgd->timer.expires)) |
| 139 | mod_timer(&ifmgd->timer, timeout); |
| 140 | } |
| 141 | |
Luis R. Rodriguez | d3a910a | 2010-09-16 15:12:32 -0400 | [diff] [blame] | 142 | void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata) |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 143 | { |
Johannes Berg | c1288b1 | 2012-01-19 09:29:57 +0100 | [diff] [blame] | 144 | if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 145 | return; |
| 146 | |
Johannes Berg | 7eeff74 | 2012-07-18 10:27:27 +0200 | [diff] [blame] | 147 | if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) |
| 148 | return; |
| 149 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 150 | mod_timer(&sdata->u.mgd.bcn_mon_timer, |
Felix Fietkau | 7ccc8bd | 2010-11-19 22:55:38 +0100 | [diff] [blame] | 151 | round_jiffies_up(jiffies + sdata->u.mgd.beacon_timeout)); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 152 | } |
| 153 | |
Luis R. Rodriguez | be099e8 | 2010-09-16 15:12:29 -0400 | [diff] [blame] | 154 | void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata) |
| 155 | { |
Luis R. Rodriguez | 0c699c3 | 2010-09-16 15:12:30 -0400 | [diff] [blame] | 156 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 157 | |
Stanislaw Gruszka | 8628172 | 2011-02-25 14:46:02 +0100 | [diff] [blame] | 158 | if (unlikely(!sdata->u.mgd.associated)) |
| 159 | return; |
| 160 | |
Luis R. Rodriguez | be099e8 | 2010-09-16 15:12:29 -0400 | [diff] [blame] | 161 | if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) |
| 162 | return; |
| 163 | |
| 164 | mod_timer(&sdata->u.mgd.conn_mon_timer, |
| 165 | round_jiffies_up(jiffies + IEEE80211_CONNECTION_IDLE_TIME)); |
Luis R. Rodriguez | 0c699c3 | 2010-09-16 15:12:30 -0400 | [diff] [blame] | 166 | |
| 167 | ifmgd->probe_send_count = 0; |
Luis R. Rodriguez | be099e8 | 2010-09-16 15:12:29 -0400 | [diff] [blame] | 168 | } |
| 169 | |
Johannes Berg | 5484e23 | 2008-09-08 17:44:27 +0200 | [diff] [blame] | 170 | static int ecw2cw(int ecw) |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 171 | { |
Johannes Berg | 5484e23 | 2008-09-08 17:44:27 +0200 | [diff] [blame] | 172 | return (1 << ecw) - 1; |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 173 | } |
| 174 | |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 175 | static u32 ieee80211_config_ht_tx(struct ieee80211_sub_if_data *sdata, |
| 176 | struct ieee80211_ht_operation *ht_oper, |
| 177 | const u8 *bssid, bool reconfig) |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 178 | { |
| 179 | struct ieee80211_local *local = sdata->local; |
| 180 | struct ieee80211_supported_band *sband; |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 181 | struct sta_info *sta; |
| 182 | u32 changed = 0; |
Johannes Berg | 9ed6bcc | 2009-05-08 20:47:39 +0200 | [diff] [blame] | 183 | u16 ht_opmode; |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 184 | bool disable_40 = false; |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 185 | |
Johannes Berg | 568d6e2 | 2012-07-23 14:29:21 +0200 | [diff] [blame] | 186 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 187 | |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 188 | switch (sdata->vif.bss_conf.channel_type) { |
| 189 | case NL80211_CHAN_HT40PLUS: |
Johannes Berg | 568d6e2 | 2012-07-23 14:29:21 +0200 | [diff] [blame] | 190 | if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40PLUS) |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 191 | disable_40 = true; |
| 192 | break; |
| 193 | case NL80211_CHAN_HT40MINUS: |
Johannes Berg | 568d6e2 | 2012-07-23 14:29:21 +0200 | [diff] [blame] | 194 | if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40MINUS) |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 195 | disable_40 = true; |
| 196 | break; |
| 197 | default: |
| 198 | break; |
| 199 | } |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 200 | |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 201 | /* This can change during the lifetime of the BSS */ |
| 202 | if (!(ht_oper->ht_param & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)) |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 203 | disable_40 = true; |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 204 | |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 205 | mutex_lock(&local->sta_mtx); |
| 206 | sta = sta_info_get(sdata, bssid); |
| 207 | |
| 208 | WARN_ON_ONCE(!sta); |
| 209 | |
| 210 | if (sta && !sta->supports_40mhz) |
| 211 | disable_40 = true; |
| 212 | |
| 213 | if (sta && (!reconfig || |
Rajkumar Manoharan | 91a0099 | 2012-04-25 20:24:24 +0530 | [diff] [blame] | 214 | (disable_40 != !(sta->sta.ht_cap.cap & |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 215 | IEEE80211_HT_CAP_SUP_WIDTH_20_40)))) { |
Rajkumar Manoharan | 7cc44ed | 2011-09-16 15:32:34 +0530 | [diff] [blame] | 216 | |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 217 | if (disable_40) |
| 218 | sta->sta.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 219 | else |
| 220 | sta->sta.ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
Rajkumar Manoharan | 7cc44ed | 2011-09-16 15:32:34 +0530 | [diff] [blame] | 221 | |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 222 | rate_control_rate_update(local, sband, sta, |
Johannes Berg | 8f727ef | 2012-03-30 08:43:32 +0200 | [diff] [blame] | 223 | IEEE80211_RC_BW_CHANGED); |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 224 | } |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 225 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 226 | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 227 | ht_opmode = le16_to_cpu(ht_oper->operation_mode); |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 228 | |
| 229 | /* if bss configuration changed store the new one */ |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 230 | if (!reconfig || (sdata->vif.bss_conf.ht_operation_mode != ht_opmode)) { |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 231 | changed |= BSS_CHANGED_HT; |
Johannes Berg | 9ed6bcc | 2009-05-08 20:47:39 +0200 | [diff] [blame] | 232 | sdata->vif.bss_conf.ht_operation_mode = ht_opmode; |
Johannes Berg | d5522e0 | 2009-03-30 13:23:35 +0200 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | return changed; |
| 236 | } |
| 237 | |
Johannes Berg | 9c6bd79 | 2008-09-11 00:01:52 +0200 | [diff] [blame] | 238 | /* frame sending functions */ |
| 239 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 240 | static int ieee80211_compatible_rates(const u8 *supp_rates, int supp_rates_len, |
| 241 | struct ieee80211_supported_band *sband, |
| 242 | u32 *rates) |
| 243 | { |
| 244 | int i, j, count; |
| 245 | *rates = 0; |
| 246 | count = 0; |
| 247 | for (i = 0; i < supp_rates_len; i++) { |
| 248 | int rate = (supp_rates[i] & 0x7F) * 5; |
| 249 | |
| 250 | for (j = 0; j < sband->n_bitrates; j++) |
| 251 | if (sband->bitrates[j].bitrate == rate) { |
| 252 | *rates |= BIT(j); |
| 253 | count++; |
| 254 | break; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | return count; |
| 259 | } |
| 260 | |
| 261 | static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 9dde642 | 2012-05-16 23:43:19 +0200 | [diff] [blame] | 262 | struct sk_buff *skb, u8 ap_ht_param, |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 263 | struct ieee80211_supported_band *sband, |
| 264 | struct ieee80211_channel *channel, |
| 265 | enum ieee80211_smps_mode smps) |
| 266 | { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 267 | u8 *pos; |
| 268 | u32 flags = channel->flags; |
| 269 | u16 cap; |
| 270 | struct ieee80211_sta_ht_cap ht_cap; |
| 271 | |
| 272 | BUILD_BUG_ON(sizeof(ht_cap) != sizeof(sband->ht_cap)); |
| 273 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 274 | memcpy(&ht_cap, &sband->ht_cap, sizeof(ht_cap)); |
| 275 | ieee80211_apply_htcap_overrides(sdata, &ht_cap); |
| 276 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 277 | /* determine capability flags */ |
| 278 | cap = ht_cap.cap; |
| 279 | |
Johannes Berg | 9dde642 | 2012-05-16 23:43:19 +0200 | [diff] [blame] | 280 | switch (ap_ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 281 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
| 282 | if (flags & IEEE80211_CHAN_NO_HT40PLUS) { |
| 283 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 284 | cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 285 | } |
| 286 | break; |
| 287 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
| 288 | if (flags & IEEE80211_CHAN_NO_HT40MINUS) { |
| 289 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 290 | cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 291 | } |
| 292 | break; |
| 293 | } |
| 294 | |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 295 | /* |
| 296 | * If 40 MHz was disabled associate as though we weren't |
| 297 | * capable of 40 MHz -- some broken APs will never fall |
| 298 | * back to trying to transmit in 20 MHz. |
| 299 | */ |
| 300 | if (sdata->u.mgd.flags & IEEE80211_STA_DISABLE_40MHZ) { |
| 301 | cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 302 | cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 303 | } |
| 304 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 305 | /* set SM PS mode properly */ |
| 306 | cap &= ~IEEE80211_HT_CAP_SM_PS; |
| 307 | switch (smps) { |
| 308 | case IEEE80211_SMPS_AUTOMATIC: |
| 309 | case IEEE80211_SMPS_NUM_MODES: |
| 310 | WARN_ON(1); |
| 311 | case IEEE80211_SMPS_OFF: |
| 312 | cap |= WLAN_HT_CAP_SM_PS_DISABLED << |
| 313 | IEEE80211_HT_CAP_SM_PS_SHIFT; |
| 314 | break; |
| 315 | case IEEE80211_SMPS_STATIC: |
| 316 | cap |= WLAN_HT_CAP_SM_PS_STATIC << |
| 317 | IEEE80211_HT_CAP_SM_PS_SHIFT; |
| 318 | break; |
| 319 | case IEEE80211_SMPS_DYNAMIC: |
| 320 | cap |= WLAN_HT_CAP_SM_PS_DYNAMIC << |
| 321 | IEEE80211_HT_CAP_SM_PS_SHIFT; |
| 322 | break; |
| 323 | } |
| 324 | |
| 325 | /* reserve and fill IE */ |
| 326 | pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2); |
| 327 | ieee80211_ie_build_ht_cap(pos, &ht_cap, cap); |
| 328 | } |
| 329 | |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 330 | static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, |
| 331 | struct sk_buff *skb, |
| 332 | struct ieee80211_supported_band *sband) |
| 333 | { |
| 334 | u8 *pos; |
| 335 | u32 cap; |
| 336 | struct ieee80211_sta_vht_cap vht_cap; |
| 337 | |
| 338 | BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap)); |
| 339 | |
| 340 | memcpy(&vht_cap, &sband->vht_cap, sizeof(vht_cap)); |
| 341 | |
| 342 | /* determine capability flags */ |
| 343 | cap = vht_cap.cap; |
| 344 | |
| 345 | /* reserve and fill IE */ |
| 346 | pos = skb_put(skb, sizeof(struct ieee80211_vht_capabilities) + 2); |
| 347 | ieee80211_ie_build_vht_cap(pos, &vht_cap, cap); |
| 348 | } |
| 349 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 350 | static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) |
| 351 | { |
| 352 | struct ieee80211_local *local = sdata->local; |
| 353 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 354 | struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; |
| 355 | struct sk_buff *skb; |
| 356 | struct ieee80211_mgmt *mgmt; |
| 357 | u8 *pos, qos_info; |
| 358 | size_t offset = 0, noffset; |
| 359 | int i, count, rates_len, supp_rates_len; |
| 360 | u16 capab; |
| 361 | struct ieee80211_supported_band *sband; |
| 362 | u32 rates = 0; |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 363 | |
| 364 | lockdep_assert_held(&ifmgd->mtx); |
| 365 | |
| 366 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
| 367 | |
| 368 | if (assoc_data->supp_rates_len) { |
| 369 | /* |
| 370 | * Get all rates supported by the device and the AP as |
| 371 | * some APs don't like getting a superset of their rates |
| 372 | * in the association request (e.g. D-Link DAP 1353 in |
| 373 | * b-only mode)... |
| 374 | */ |
| 375 | rates_len = ieee80211_compatible_rates(assoc_data->supp_rates, |
| 376 | assoc_data->supp_rates_len, |
| 377 | sband, &rates); |
| 378 | } else { |
| 379 | /* |
| 380 | * In case AP not provide any supported rates information |
| 381 | * before association, we send information element(s) with |
| 382 | * all rates that we support. |
| 383 | */ |
| 384 | rates = ~0; |
| 385 | rates_len = sband->n_bitrates; |
| 386 | } |
| 387 | |
| 388 | skb = alloc_skb(local->hw.extra_tx_headroom + |
| 389 | sizeof(*mgmt) + /* bit too much but doesn't matter */ |
| 390 | 2 + assoc_data->ssid_len + /* SSID */ |
| 391 | 4 + rates_len + /* (extended) rates */ |
| 392 | 4 + /* power capability */ |
| 393 | 2 + 2 * sband->n_channels + /* supported channels */ |
| 394 | 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 395 | 2 + sizeof(struct ieee80211_vht_capabilities) + /* VHT */ |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 396 | assoc_data->ie_len + /* extra IEs */ |
| 397 | 9, /* WMM */ |
| 398 | GFP_KERNEL); |
| 399 | if (!skb) |
| 400 | return; |
| 401 | |
| 402 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 403 | |
| 404 | capab = WLAN_CAPABILITY_ESS; |
| 405 | |
| 406 | if (sband->band == IEEE80211_BAND_2GHZ) { |
| 407 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) |
| 408 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; |
| 409 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) |
| 410 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; |
| 411 | } |
| 412 | |
| 413 | if (assoc_data->capability & WLAN_CAPABILITY_PRIVACY) |
| 414 | capab |= WLAN_CAPABILITY_PRIVACY; |
| 415 | |
| 416 | if ((assoc_data->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && |
| 417 | (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) |
| 418 | capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; |
| 419 | |
| 420 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); |
| 421 | memset(mgmt, 0, 24); |
| 422 | memcpy(mgmt->da, assoc_data->bss->bssid, ETH_ALEN); |
| 423 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
| 424 | memcpy(mgmt->bssid, assoc_data->bss->bssid, ETH_ALEN); |
| 425 | |
| 426 | if (!is_zero_ether_addr(assoc_data->prev_bssid)) { |
| 427 | skb_put(skb, 10); |
| 428 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 429 | IEEE80211_STYPE_REASSOC_REQ); |
| 430 | mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); |
| 431 | mgmt->u.reassoc_req.listen_interval = |
| 432 | cpu_to_le16(local->hw.conf.listen_interval); |
| 433 | memcpy(mgmt->u.reassoc_req.current_ap, assoc_data->prev_bssid, |
| 434 | ETH_ALEN); |
| 435 | } else { |
| 436 | skb_put(skb, 4); |
| 437 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 438 | IEEE80211_STYPE_ASSOC_REQ); |
| 439 | mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); |
| 440 | mgmt->u.assoc_req.listen_interval = |
| 441 | cpu_to_le16(local->hw.conf.listen_interval); |
| 442 | } |
| 443 | |
| 444 | /* SSID */ |
| 445 | pos = skb_put(skb, 2 + assoc_data->ssid_len); |
| 446 | *pos++ = WLAN_EID_SSID; |
| 447 | *pos++ = assoc_data->ssid_len; |
| 448 | memcpy(pos, assoc_data->ssid, assoc_data->ssid_len); |
| 449 | |
| 450 | /* add all rates which were marked to be used above */ |
| 451 | supp_rates_len = rates_len; |
| 452 | if (supp_rates_len > 8) |
| 453 | supp_rates_len = 8; |
| 454 | |
| 455 | pos = skb_put(skb, supp_rates_len + 2); |
| 456 | *pos++ = WLAN_EID_SUPP_RATES; |
| 457 | *pos++ = supp_rates_len; |
| 458 | |
| 459 | count = 0; |
| 460 | for (i = 0; i < sband->n_bitrates; i++) { |
| 461 | if (BIT(i) & rates) { |
| 462 | int rate = sband->bitrates[i].bitrate; |
| 463 | *pos++ = (u8) (rate / 5); |
| 464 | if (++count == 8) |
| 465 | break; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | if (rates_len > count) { |
| 470 | pos = skb_put(skb, rates_len - count + 2); |
| 471 | *pos++ = WLAN_EID_EXT_SUPP_RATES; |
| 472 | *pos++ = rates_len - count; |
| 473 | |
| 474 | for (i++; i < sband->n_bitrates; i++) { |
| 475 | if (BIT(i) & rates) { |
| 476 | int rate = sband->bitrates[i].bitrate; |
| 477 | *pos++ = (u8) (rate / 5); |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) { |
| 483 | /* 1. power capabilities */ |
| 484 | pos = skb_put(skb, 4); |
| 485 | *pos++ = WLAN_EID_PWR_CAPABILITY; |
| 486 | *pos++ = 2; |
| 487 | *pos++ = 0; /* min tx power */ |
| 488 | *pos++ = local->oper_channel->max_power; /* max tx power */ |
| 489 | |
| 490 | /* 2. supported channels */ |
| 491 | /* TODO: get this in reg domain format */ |
| 492 | pos = skb_put(skb, 2 * sband->n_channels + 2); |
| 493 | *pos++ = WLAN_EID_SUPPORTED_CHANNELS; |
| 494 | *pos++ = 2 * sband->n_channels; |
| 495 | for (i = 0; i < sband->n_channels; i++) { |
| 496 | *pos++ = ieee80211_frequency_to_channel( |
| 497 | sband->channels[i].center_freq); |
| 498 | *pos++ = 1; /* one channel in the subband*/ |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | /* if present, add any custom IEs that go before HT */ |
| 503 | if (assoc_data->ie_len && assoc_data->ie) { |
| 504 | static const u8 before_ht[] = { |
| 505 | WLAN_EID_SSID, |
| 506 | WLAN_EID_SUPP_RATES, |
| 507 | WLAN_EID_EXT_SUPP_RATES, |
| 508 | WLAN_EID_PWR_CAPABILITY, |
| 509 | WLAN_EID_SUPPORTED_CHANNELS, |
| 510 | WLAN_EID_RSN, |
| 511 | WLAN_EID_QOS_CAPA, |
| 512 | WLAN_EID_RRM_ENABLED_CAPABILITIES, |
| 513 | WLAN_EID_MOBILITY_DOMAIN, |
| 514 | WLAN_EID_SUPPORTED_REGULATORY_CLASSES, |
| 515 | }; |
| 516 | noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len, |
| 517 | before_ht, ARRAY_SIZE(before_ht), |
| 518 | offset); |
| 519 | pos = skb_put(skb, noffset - offset); |
| 520 | memcpy(pos, assoc_data->ie + offset, noffset - offset); |
| 521 | offset = noffset; |
| 522 | } |
| 523 | |
Johannes Berg | 4e74bfd | 2012-03-08 15:02:04 +0100 | [diff] [blame] | 524 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
Johannes Berg | 9dde642 | 2012-05-16 23:43:19 +0200 | [diff] [blame] | 525 | ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param, |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 526 | sband, local->oper_channel, ifmgd->ap_smps); |
| 527 | |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 528 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) |
| 529 | ieee80211_add_vht_ie(sdata, skb, sband); |
| 530 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 531 | /* if present, add any custom non-vendor IEs that go after HT */ |
| 532 | if (assoc_data->ie_len && assoc_data->ie) { |
| 533 | noffset = ieee80211_ie_split_vendor(assoc_data->ie, |
| 534 | assoc_data->ie_len, |
| 535 | offset); |
| 536 | pos = skb_put(skb, noffset - offset); |
| 537 | memcpy(pos, assoc_data->ie + offset, noffset - offset); |
| 538 | offset = noffset; |
| 539 | } |
| 540 | |
Johannes Berg | 76f0303 | 2012-03-08 15:02:05 +0100 | [diff] [blame] | 541 | if (assoc_data->wmm) { |
| 542 | if (assoc_data->uapsd) { |
Eliad Peller | dc41e4d | 2012-03-14 16:15:03 +0200 | [diff] [blame] | 543 | qos_info = ifmgd->uapsd_queues; |
| 544 | qos_info |= (ifmgd->uapsd_max_sp_len << |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 545 | IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT); |
| 546 | } else { |
| 547 | qos_info = 0; |
| 548 | } |
| 549 | |
| 550 | pos = skb_put(skb, 9); |
| 551 | *pos++ = WLAN_EID_VENDOR_SPECIFIC; |
| 552 | *pos++ = 7; /* len */ |
| 553 | *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */ |
| 554 | *pos++ = 0x50; |
| 555 | *pos++ = 0xf2; |
| 556 | *pos++ = 2; /* WME */ |
| 557 | *pos++ = 0; /* WME info */ |
| 558 | *pos++ = 1; /* WME ver */ |
| 559 | *pos++ = qos_info; |
| 560 | } |
| 561 | |
| 562 | /* add any remaining custom (i.e. vendor specific here) IEs */ |
| 563 | if (assoc_data->ie_len && assoc_data->ie) { |
| 564 | noffset = assoc_data->ie_len; |
| 565 | pos = skb_put(skb, noffset - offset); |
| 566 | memcpy(pos, assoc_data->ie + offset, noffset - offset); |
| 567 | } |
| 568 | |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 569 | drv_mgd_prepare_tx(local, sdata); |
| 570 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 571 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
| 572 | ieee80211_tx_skb(sdata, skb); |
| 573 | } |
| 574 | |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 575 | void ieee80211_send_pspoll(struct ieee80211_local *local, |
| 576 | struct ieee80211_sub_if_data *sdata) |
| 577 | { |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 578 | struct ieee80211_pspoll *pspoll; |
| 579 | struct sk_buff *skb; |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 580 | |
Kalle Valo | d8cd189 | 2010-01-05 20:16:26 +0200 | [diff] [blame] | 581 | skb = ieee80211_pspoll_get(&local->hw, &sdata->vif); |
| 582 | if (!skb) |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 583 | return; |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 584 | |
Kalle Valo | d8cd189 | 2010-01-05 20:16:26 +0200 | [diff] [blame] | 585 | pspoll = (struct ieee80211_pspoll *) skb->data; |
| 586 | pspoll->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 587 | |
Johannes Berg | 62ae67b | 2009-11-18 18:42:05 +0100 | [diff] [blame] | 588 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
| 589 | ieee80211_tx_skb(sdata, skb); |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 590 | } |
| 591 | |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 592 | void ieee80211_send_nullfunc(struct ieee80211_local *local, |
| 593 | struct ieee80211_sub_if_data *sdata, |
| 594 | int powersave) |
| 595 | { |
| 596 | struct sk_buff *skb; |
Kalle Valo | d8cd189 | 2010-01-05 20:16:26 +0200 | [diff] [blame] | 597 | struct ieee80211_hdr_3addr *nullfunc; |
Rajkumar Manoharan | b6f3530 | 2011-09-29 20:34:04 +0530 | [diff] [blame] | 598 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 599 | |
Kalle Valo | d8cd189 | 2010-01-05 20:16:26 +0200 | [diff] [blame] | 600 | skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif); |
| 601 | if (!skb) |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 602 | return; |
| 603 | |
Kalle Valo | d8cd189 | 2010-01-05 20:16:26 +0200 | [diff] [blame] | 604 | nullfunc = (struct ieee80211_hdr_3addr *) skb->data; |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 605 | if (powersave) |
Kalle Valo | d8cd189 | 2010-01-05 20:16:26 +0200 | [diff] [blame] | 606 | nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 607 | |
Johannes Berg | 62ae67b | 2009-11-18 18:42:05 +0100 | [diff] [blame] | 608 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
Rajkumar Manoharan | b6f3530 | 2011-09-29 20:34:04 +0530 | [diff] [blame] | 609 | if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | |
| 610 | IEEE80211_STA_CONNECTION_POLL)) |
| 611 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE; |
| 612 | |
Johannes Berg | 62ae67b | 2009-11-18 18:42:05 +0100 | [diff] [blame] | 613 | ieee80211_tx_skb(sdata, skb); |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 614 | } |
| 615 | |
Felix Fietkau | d524215 | 2010-01-08 18:06:26 +0100 | [diff] [blame] | 616 | static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, |
| 617 | struct ieee80211_sub_if_data *sdata) |
| 618 | { |
| 619 | struct sk_buff *skb; |
| 620 | struct ieee80211_hdr *nullfunc; |
| 621 | __le16 fc; |
| 622 | |
| 623 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) |
| 624 | return; |
| 625 | |
| 626 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30); |
Joe Perches | d15b845 | 2011-08-29 14:17:31 -0700 | [diff] [blame] | 627 | if (!skb) |
Felix Fietkau | d524215 | 2010-01-08 18:06:26 +0100 | [diff] [blame] | 628 | return; |
Joe Perches | d15b845 | 2011-08-29 14:17:31 -0700 | [diff] [blame] | 629 | |
Felix Fietkau | d524215 | 2010-01-08 18:06:26 +0100 | [diff] [blame] | 630 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 631 | |
| 632 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 30); |
| 633 | memset(nullfunc, 0, 30); |
| 634 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | |
| 635 | IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
| 636 | nullfunc->frame_control = fc; |
| 637 | memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN); |
| 638 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); |
| 639 | memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN); |
| 640 | memcpy(nullfunc->addr4, sdata->vif.addr, ETH_ALEN); |
| 641 | |
| 642 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
| 643 | ieee80211_tx_skb(sdata, skb); |
| 644 | } |
| 645 | |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 646 | /* spectrum management related things */ |
| 647 | static void ieee80211_chswitch_work(struct work_struct *work) |
| 648 | { |
| 649 | struct ieee80211_sub_if_data *sdata = |
| 650 | container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 651 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 652 | |
Johannes Berg | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 653 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 654 | return; |
| 655 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 656 | mutex_lock(&ifmgd->mtx); |
| 657 | if (!ifmgd->associated) |
| 658 | goto out; |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 659 | |
| 660 | sdata->local->oper_channel = sdata->local->csa_channel; |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 661 | if (!sdata->local->ops->channel_switch) { |
| 662 | /* call "hw_config" only if doing sw channel switch */ |
| 663 | ieee80211_hw_config(sdata->local, |
| 664 | IEEE80211_CONF_CHANGE_CHANNEL); |
Shahar Levi | 1ea57b1 | 2011-09-08 08:44:05 +0300 | [diff] [blame] | 665 | } else { |
| 666 | /* update the device channel directly */ |
| 667 | sdata->local->hw.conf.channel = sdata->local->oper_channel; |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 668 | } |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 669 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 670 | /* XXX: shouldn't really modify cfg80211-owned data! */ |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 671 | ifmgd->associated->channel = sdata->local->oper_channel; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 672 | |
Johannes Berg | 57eebdf | 2012-08-01 15:50:46 +0200 | [diff] [blame] | 673 | /* XXX: wait for a beacon first? */ |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 674 | ieee80211_wake_queues_by_reason(&sdata->local->hw, |
| 675 | IEEE80211_QUEUE_STOP_REASON_CSA); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 676 | out: |
| 677 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; |
| 678 | mutex_unlock(&ifmgd->mtx); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 679 | } |
| 680 | |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 681 | void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success) |
| 682 | { |
| 683 | struct ieee80211_sub_if_data *sdata; |
| 684 | struct ieee80211_if_managed *ifmgd; |
| 685 | |
| 686 | sdata = vif_to_sdata(vif); |
| 687 | ifmgd = &sdata->u.mgd; |
| 688 | |
| 689 | trace_api_chswitch_done(sdata, success); |
| 690 | if (!success) { |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 691 | sdata_info(sdata, |
| 692 | "driver channel switch failed, disconnecting\n"); |
| 693 | ieee80211_queue_work(&sdata->local->hw, |
| 694 | &ifmgd->csa_connection_drop_work); |
| 695 | } else { |
| 696 | ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 697 | } |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 698 | } |
| 699 | EXPORT_SYMBOL(ieee80211_chswitch_done); |
| 700 | |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 701 | static void ieee80211_chswitch_timer(unsigned long data) |
| 702 | { |
| 703 | struct ieee80211_sub_if_data *sdata = |
| 704 | (struct ieee80211_sub_if_data *) data; |
| 705 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 706 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 707 | if (sdata->local->quiescing) { |
| 708 | set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running); |
| 709 | return; |
| 710 | } |
| 711 | |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 712 | ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, |
| 716 | struct ieee80211_channel_sw_ie *sw_elem, |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 717 | struct ieee80211_bss *bss, |
| 718 | u64 timestamp) |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 719 | { |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 720 | struct cfg80211_bss *cbss = |
| 721 | container_of((void *)bss, struct cfg80211_bss, priv); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 722 | struct ieee80211_channel *new_ch; |
| 723 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Bruno Randolf | 59eb21a | 2011-01-17 13:37:28 +0900 | [diff] [blame] | 724 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num, |
| 725 | cbss->channel->band); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 726 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 727 | ASSERT_MGD_MTX(ifmgd); |
| 728 | |
| 729 | if (!ifmgd->associated) |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 730 | return; |
| 731 | |
Helmut Schaa | fbe9c42 | 2009-07-23 12:14:04 +0200 | [diff] [blame] | 732 | if (sdata->local->scanning) |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 733 | return; |
| 734 | |
| 735 | /* Disregard subsequent beacons if we are already running a timer |
| 736 | processing a CSA */ |
| 737 | |
| 738 | if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED) |
| 739 | return; |
| 740 | |
| 741 | new_ch = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq); |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 742 | if (!new_ch || new_ch->flags & IEEE80211_CHAN_DISABLED) { |
| 743 | sdata_info(sdata, |
| 744 | "AP %pM switches to unsupported channel (%d MHz), disconnecting\n", |
| 745 | ifmgd->associated->bssid, new_freq); |
| 746 | ieee80211_queue_work(&sdata->local->hw, |
| 747 | &ifmgd->csa_connection_drop_work); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 748 | return; |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 749 | } |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 750 | |
| 751 | sdata->local->csa_channel = new_ch; |
| 752 | |
Johannes Berg | 57eebdf | 2012-08-01 15:50:46 +0200 | [diff] [blame] | 753 | ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; |
| 754 | |
| 755 | if (sw_elem->mode) |
| 756 | ieee80211_stop_queues_by_reason(&sdata->local->hw, |
| 757 | IEEE80211_QUEUE_STOP_REASON_CSA); |
| 758 | |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 759 | if (sdata->local->ops->channel_switch) { |
| 760 | /* use driver's channel switch callback */ |
Johannes Berg | 57eebdf | 2012-08-01 15:50:46 +0200 | [diff] [blame] | 761 | struct ieee80211_channel_switch ch_switch = { |
| 762 | .timestamp = timestamp, |
| 763 | .block_tx = sw_elem->mode, |
| 764 | .channel = new_ch, |
| 765 | .count = sw_elem->count, |
| 766 | }; |
| 767 | |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 768 | drv_channel_switch(sdata->local, &ch_switch); |
| 769 | return; |
| 770 | } |
| 771 | |
| 772 | /* channel switch handled in software */ |
Johannes Berg | 57eebdf | 2012-08-01 15:50:46 +0200 | [diff] [blame] | 773 | if (sw_elem->count <= 1) |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 774 | ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); |
Johannes Berg | 57eebdf | 2012-08-01 15:50:46 +0200 | [diff] [blame] | 775 | else |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 776 | mod_timer(&ifmgd->chswitch_timer, |
Johannes Berg | 3049000 | 2012-08-01 15:53:45 +0200 | [diff] [blame] | 777 | TU_TO_EXP_TIME(sw_elem->count * |
| 778 | cbss->beacon_interval)); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 04b7b2f | 2012-09-05 13:41:37 +0200 | [diff] [blame] | 782 | struct ieee80211_channel *channel, |
| 783 | const u8 *country_ie, u8 country_ie_len, |
| 784 | const u8 *pwr_constr_elem) |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 785 | { |
Johannes Berg | 04b7b2f | 2012-09-05 13:41:37 +0200 | [diff] [blame] | 786 | struct ieee80211_country_ie_triplet *triplet; |
| 787 | int chan = ieee80211_frequency_to_channel(channel->center_freq); |
| 788 | int i, chan_pwr, chan_increment, new_ap_level; |
| 789 | bool have_chan_pwr = false; |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 790 | |
Johannes Berg | 04b7b2f | 2012-09-05 13:41:37 +0200 | [diff] [blame] | 791 | /* Invalid IE */ |
| 792 | if (country_ie_len % 2 || country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 793 | return; |
| 794 | |
Johannes Berg | 04b7b2f | 2012-09-05 13:41:37 +0200 | [diff] [blame] | 795 | triplet = (void *)(country_ie + 3); |
| 796 | country_ie_len -= 3; |
| 797 | |
| 798 | switch (channel->band) { |
| 799 | default: |
| 800 | WARN_ON_ONCE(1); |
| 801 | /* fall through */ |
| 802 | case IEEE80211_BAND_2GHZ: |
| 803 | case IEEE80211_BAND_60GHZ: |
| 804 | chan_increment = 1; |
| 805 | break; |
| 806 | case IEEE80211_BAND_5GHZ: |
| 807 | chan_increment = 4; |
| 808 | break; |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 809 | } |
Johannes Berg | 04b7b2f | 2012-09-05 13:41:37 +0200 | [diff] [blame] | 810 | |
| 811 | /* find channel */ |
| 812 | while (country_ie_len >= 3) { |
| 813 | u8 first_channel = triplet->chans.first_channel; |
| 814 | |
| 815 | if (first_channel >= IEEE80211_COUNTRY_EXTENSION_ID) |
| 816 | goto next; |
| 817 | |
| 818 | for (i = 0; i < triplet->chans.num_channels; i++) { |
| 819 | if (first_channel + i * chan_increment == chan) { |
| 820 | have_chan_pwr = true; |
| 821 | chan_pwr = triplet->chans.max_power; |
| 822 | break; |
| 823 | } |
| 824 | } |
| 825 | if (have_chan_pwr) |
| 826 | break; |
| 827 | |
| 828 | next: |
| 829 | triplet++; |
| 830 | country_ie_len -= 3; |
| 831 | } |
| 832 | |
| 833 | if (!have_chan_pwr) |
| 834 | return; |
| 835 | |
| 836 | new_ap_level = max_t(int, 0, chan_pwr - *pwr_constr_elem); |
| 837 | |
| 838 | if (sdata->local->ap_power_level == new_ap_level) |
| 839 | return; |
| 840 | |
| 841 | sdata_info(sdata, |
| 842 | "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n", |
| 843 | new_ap_level, chan_pwr, *pwr_constr_elem, |
| 844 | sdata->u.mgd.bssid); |
| 845 | sdata->local->ap_power_level = new_ap_level; |
| 846 | ieee80211_hw_config(sdata->local, 0); |
Johannes Berg | cc32abd | 2009-05-15 11:52:31 +0200 | [diff] [blame] | 847 | } |
| 848 | |
Juuso Oikarinen | f90754c | 2010-06-21 08:59:39 +0300 | [diff] [blame] | 849 | void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif) |
| 850 | { |
| 851 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
| 852 | struct ieee80211_local *local = sdata->local; |
| 853 | struct ieee80211_conf *conf = &local->hw.conf; |
| 854 | |
| 855 | WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION || |
| 856 | !(local->hw.flags & IEEE80211_HW_SUPPORTS_PS) || |
| 857 | (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)); |
| 858 | |
| 859 | local->disable_dynamic_ps = false; |
| 860 | conf->dynamic_ps_timeout = local->dynamic_ps_user_timeout; |
| 861 | } |
| 862 | EXPORT_SYMBOL(ieee80211_enable_dyn_ps); |
| 863 | |
| 864 | void ieee80211_disable_dyn_ps(struct ieee80211_vif *vif) |
| 865 | { |
| 866 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
| 867 | struct ieee80211_local *local = sdata->local; |
| 868 | struct ieee80211_conf *conf = &local->hw.conf; |
| 869 | |
| 870 | WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION || |
| 871 | !(local->hw.flags & IEEE80211_HW_SUPPORTS_PS) || |
| 872 | (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)); |
| 873 | |
| 874 | local->disable_dynamic_ps = true; |
| 875 | conf->dynamic_ps_timeout = 0; |
| 876 | del_timer_sync(&local->dynamic_ps_timer); |
| 877 | ieee80211_queue_work(&local->hw, |
| 878 | &local->dynamic_ps_enable_work); |
| 879 | } |
| 880 | EXPORT_SYMBOL(ieee80211_disable_dyn_ps); |
| 881 | |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 882 | /* powersave */ |
| 883 | static void ieee80211_enable_ps(struct ieee80211_local *local, |
| 884 | struct ieee80211_sub_if_data *sdata) |
| 885 | { |
| 886 | struct ieee80211_conf *conf = &local->hw.conf; |
| 887 | |
Johannes Berg | d5edaed | 2009-04-22 23:02:51 +0200 | [diff] [blame] | 888 | /* |
| 889 | * If we are scanning right now then the parameters will |
| 890 | * take effect when scan finishes. |
| 891 | */ |
Helmut Schaa | fbe9c42 | 2009-07-23 12:14:04 +0200 | [diff] [blame] | 892 | if (local->scanning) |
Johannes Berg | d5edaed | 2009-04-22 23:02:51 +0200 | [diff] [blame] | 893 | return; |
| 894 | |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 895 | if (conf->dynamic_ps_timeout > 0 && |
| 896 | !(local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)) { |
| 897 | mod_timer(&local->dynamic_ps_timer, jiffies + |
| 898 | msecs_to_jiffies(conf->dynamic_ps_timeout)); |
| 899 | } else { |
| 900 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) |
| 901 | ieee80211_send_nullfunc(local, sdata, 1); |
Vivek Natarajan | 375177b | 2010-02-09 14:50:28 +0530 | [diff] [blame] | 902 | |
Juuso Oikarinen | 2a13052 | 2010-03-09 14:25:02 +0200 | [diff] [blame] | 903 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && |
| 904 | (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)) |
| 905 | return; |
| 906 | |
| 907 | conf->flags |= IEEE80211_CONF_PS; |
| 908 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 909 | } |
| 910 | } |
| 911 | |
| 912 | static void ieee80211_change_ps(struct ieee80211_local *local) |
| 913 | { |
| 914 | struct ieee80211_conf *conf = &local->hw.conf; |
| 915 | |
| 916 | if (local->ps_sdata) { |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 917 | ieee80211_enable_ps(local, local->ps_sdata); |
| 918 | } else if (conf->flags & IEEE80211_CONF_PS) { |
| 919 | conf->flags &= ~IEEE80211_CONF_PS; |
| 920 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 921 | del_timer_sync(&local->dynamic_ps_timer); |
| 922 | cancel_work_sync(&local->dynamic_ps_enable_work); |
| 923 | } |
| 924 | } |
| 925 | |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 926 | static bool ieee80211_powersave_allowed(struct ieee80211_sub_if_data *sdata) |
| 927 | { |
| 928 | struct ieee80211_if_managed *mgd = &sdata->u.mgd; |
| 929 | struct sta_info *sta = NULL; |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 930 | bool authorized = false; |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 931 | |
| 932 | if (!mgd->powersave) |
| 933 | return false; |
| 934 | |
Johannes Berg | 05cb910 | 2011-10-28 11:59:47 +0200 | [diff] [blame] | 935 | if (mgd->broken_ap) |
| 936 | return false; |
| 937 | |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 938 | if (!mgd->associated) |
| 939 | return false; |
| 940 | |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 941 | if (mgd->flags & (IEEE80211_STA_BEACON_POLL | |
| 942 | IEEE80211_STA_CONNECTION_POLL)) |
| 943 | return false; |
| 944 | |
| 945 | rcu_read_lock(); |
| 946 | sta = sta_info_get(sdata, mgd->bssid); |
| 947 | if (sta) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 948 | authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 949 | rcu_read_unlock(); |
| 950 | |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 951 | return authorized; |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 952 | } |
| 953 | |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 954 | /* need to hold RTNL or interface lock */ |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 955 | void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency) |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 956 | { |
| 957 | struct ieee80211_sub_if_data *sdata, *found = NULL; |
| 958 | int count = 0; |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 959 | int timeout; |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 960 | |
| 961 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) { |
| 962 | local->ps_sdata = NULL; |
| 963 | return; |
| 964 | } |
| 965 | |
| 966 | list_for_each_entry(sdata, &local->interfaces, list) { |
Johannes Berg | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 967 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 968 | continue; |
Rajkumar Manoharan | 8c7914d | 2011-02-01 00:28:59 +0530 | [diff] [blame] | 969 | if (sdata->vif.type == NL80211_IFTYPE_AP) { |
| 970 | /* If an AP vif is found, then disable PS |
| 971 | * by setting the count to zero thereby setting |
| 972 | * ps_sdata to NULL. |
| 973 | */ |
| 974 | count = 0; |
| 975 | break; |
| 976 | } |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 977 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 978 | continue; |
| 979 | found = sdata; |
| 980 | count++; |
| 981 | } |
| 982 | |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 983 | if (count == 1 && ieee80211_powersave_allowed(found)) { |
Juuso Oikarinen | f90754c | 2010-06-21 08:59:39 +0300 | [diff] [blame] | 984 | struct ieee80211_conf *conf = &local->hw.conf; |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 985 | s32 beaconint_us; |
| 986 | |
| 987 | if (latency < 0) |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 988 | latency = pm_qos_request(PM_QOS_NETWORK_LATENCY); |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 989 | |
| 990 | beaconint_us = ieee80211_tu_to_usec( |
| 991 | found->vif.bss_conf.beacon_int); |
| 992 | |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 993 | timeout = local->dynamic_ps_forced_timeout; |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 994 | if (timeout < 0) { |
| 995 | /* |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 996 | * Go to full PSM if the user configures a very low |
| 997 | * latency requirement. |
Eliad Peller | 0ab82b0 | 2010-12-03 02:16:23 +0200 | [diff] [blame] | 998 | * The 2000 second value is there for compatibility |
| 999 | * until the PM_QOS_NETWORK_LATENCY is configured |
| 1000 | * with real values. |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 1001 | */ |
Eliad Peller | 0ab82b0 | 2010-12-03 02:16:23 +0200 | [diff] [blame] | 1002 | if (latency > (1900 * USEC_PER_MSEC) && |
| 1003 | latency != (2000 * USEC_PER_SEC)) |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 1004 | timeout = 0; |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 1005 | else |
| 1006 | timeout = 100; |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 1007 | } |
Juuso Oikarinen | f90754c | 2010-06-21 08:59:39 +0300 | [diff] [blame] | 1008 | local->dynamic_ps_user_timeout = timeout; |
| 1009 | if (!local->disable_dynamic_ps) |
| 1010 | conf->dynamic_ps_timeout = |
| 1011 | local->dynamic_ps_user_timeout; |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 1012 | |
Johannes Berg | 04fe203 | 2009-04-22 18:44:37 +0200 | [diff] [blame] | 1013 | if (beaconint_us > latency) { |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 1014 | local->ps_sdata = NULL; |
Johannes Berg | 04fe203 | 2009-04-22 18:44:37 +0200 | [diff] [blame] | 1015 | } else { |
Johannes Berg | 56007a0 | 2010-01-26 14:19:52 +0100 | [diff] [blame] | 1016 | struct ieee80211_bss *bss; |
Johannes Berg | 04fe203 | 2009-04-22 18:44:37 +0200 | [diff] [blame] | 1017 | int maxslp = 1; |
Johannes Berg | 56007a0 | 2010-01-26 14:19:52 +0100 | [diff] [blame] | 1018 | u8 dtimper; |
Johannes Berg | 04fe203 | 2009-04-22 18:44:37 +0200 | [diff] [blame] | 1019 | |
Johannes Berg | 56007a0 | 2010-01-26 14:19:52 +0100 | [diff] [blame] | 1020 | bss = (void *)found->u.mgd.associated->priv; |
| 1021 | dtimper = bss->dtim_period; |
| 1022 | |
| 1023 | /* If the TIM IE is invalid, pretend the value is 1 */ |
| 1024 | if (!dtimper) |
| 1025 | dtimper = 1; |
| 1026 | else if (dtimper > 1) |
Johannes Berg | 04fe203 | 2009-04-22 18:44:37 +0200 | [diff] [blame] | 1027 | maxslp = min_t(int, dtimper, |
| 1028 | latency / beaconint_us); |
| 1029 | |
Johannes Berg | 9ccebe6 | 2009-04-23 10:32:36 +0200 | [diff] [blame] | 1030 | local->hw.conf.max_sleep_period = maxslp; |
Johannes Berg | 56007a0 | 2010-01-26 14:19:52 +0100 | [diff] [blame] | 1031 | local->hw.conf.ps_dtim_period = dtimper; |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 1032 | local->ps_sdata = found; |
Johannes Berg | 04fe203 | 2009-04-22 18:44:37 +0200 | [diff] [blame] | 1033 | } |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 1034 | } else { |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1035 | local->ps_sdata = NULL; |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 1036 | } |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1037 | |
| 1038 | ieee80211_change_ps(local); |
| 1039 | } |
| 1040 | |
Eliad Peller | ab09587 | 2012-07-27 12:33:22 +0300 | [diff] [blame] | 1041 | void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data *sdata) |
| 1042 | { |
| 1043 | bool ps_allowed = ieee80211_powersave_allowed(sdata); |
| 1044 | |
| 1045 | if (sdata->vif.bss_conf.ps != ps_allowed) { |
| 1046 | sdata->vif.bss_conf.ps = ps_allowed; |
| 1047 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_PS); |
| 1048 | } |
| 1049 | } |
| 1050 | |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1051 | void ieee80211_dynamic_ps_disable_work(struct work_struct *work) |
| 1052 | { |
| 1053 | struct ieee80211_local *local = |
| 1054 | container_of(work, struct ieee80211_local, |
| 1055 | dynamic_ps_disable_work); |
| 1056 | |
| 1057 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { |
| 1058 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; |
| 1059 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 1060 | } |
| 1061 | |
| 1062 | ieee80211_wake_queues_by_reason(&local->hw, |
| 1063 | IEEE80211_QUEUE_STOP_REASON_PS); |
| 1064 | } |
| 1065 | |
| 1066 | void ieee80211_dynamic_ps_enable_work(struct work_struct *work) |
| 1067 | { |
| 1068 | struct ieee80211_local *local = |
| 1069 | container_of(work, struct ieee80211_local, |
| 1070 | dynamic_ps_enable_work); |
| 1071 | struct ieee80211_sub_if_data *sdata = local->ps_sdata; |
Christian Lamparter | 5e34069 | 2011-06-30 21:08:43 +0200 | [diff] [blame] | 1072 | struct ieee80211_if_managed *ifmgd; |
Rajkumar Manoharan | 1ddc286 | 2011-05-03 17:03:59 +0530 | [diff] [blame] | 1073 | unsigned long flags; |
| 1074 | int q; |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1075 | |
| 1076 | /* can only happen when PS was just disabled anyway */ |
| 1077 | if (!sdata) |
| 1078 | return; |
| 1079 | |
Christian Lamparter | 5e34069 | 2011-06-30 21:08:43 +0200 | [diff] [blame] | 1080 | ifmgd = &sdata->u.mgd; |
| 1081 | |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1082 | if (local->hw.conf.flags & IEEE80211_CONF_PS) |
| 1083 | return; |
| 1084 | |
Arik Nemtsov | 77b7023 | 2011-06-26 12:06:54 +0300 | [diff] [blame] | 1085 | if (!local->disable_dynamic_ps && |
| 1086 | local->hw.conf.dynamic_ps_timeout > 0) { |
| 1087 | /* don't enter PS if TX frames are pending */ |
| 1088 | if (drv_tx_frames_pending(local)) { |
Rajkumar Manoharan | 1ddc286 | 2011-05-03 17:03:59 +0530 | [diff] [blame] | 1089 | mod_timer(&local->dynamic_ps_timer, jiffies + |
| 1090 | msecs_to_jiffies( |
| 1091 | local->hw.conf.dynamic_ps_timeout)); |
| 1092 | return; |
| 1093 | } |
Arik Nemtsov | 77b7023 | 2011-06-26 12:06:54 +0300 | [diff] [blame] | 1094 | |
| 1095 | /* |
| 1096 | * transmission can be stopped by others which leads to |
| 1097 | * dynamic_ps_timer expiry. Postpone the ps timer if it |
| 1098 | * is not the actual idle state. |
| 1099 | */ |
| 1100 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
| 1101 | for (q = 0; q < local->hw.queues; q++) { |
| 1102 | if (local->queue_stop_reasons[q]) { |
| 1103 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, |
| 1104 | flags); |
| 1105 | mod_timer(&local->dynamic_ps_timer, jiffies + |
| 1106 | msecs_to_jiffies( |
| 1107 | local->hw.conf.dynamic_ps_timeout)); |
| 1108 | return; |
| 1109 | } |
| 1110 | } |
| 1111 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); |
Rajkumar Manoharan | 1ddc286 | 2011-05-03 17:03:59 +0530 | [diff] [blame] | 1112 | } |
Rajkumar Manoharan | 1ddc286 | 2011-05-03 17:03:59 +0530 | [diff] [blame] | 1113 | |
Vivek Natarajan | 375177b | 2010-02-09 14:50:28 +0530 | [diff] [blame] | 1114 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && |
Mohammed Shafi Shajakhan | 9c38a8b | 2011-12-14 19:46:07 +0530 | [diff] [blame] | 1115 | !(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { |
Vivek Natarajan | f3e85b9 | 2011-02-23 13:04:32 +0530 | [diff] [blame] | 1116 | netif_tx_stop_all_queues(sdata->dev); |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1117 | |
Vivek Natarajan | e8306f9 | 2011-04-06 11:41:10 +0530 | [diff] [blame] | 1118 | if (drv_tx_frames_pending(local)) |
| 1119 | mod_timer(&local->dynamic_ps_timer, jiffies + |
| 1120 | msecs_to_jiffies( |
| 1121 | local->hw.conf.dynamic_ps_timeout)); |
| 1122 | else { |
| 1123 | ieee80211_send_nullfunc(local, sdata, 1); |
| 1124 | /* Flush to get the tx status of nullfunc frame */ |
| 1125 | drv_flush(local, false); |
| 1126 | } |
Vivek Natarajan | f3e85b9 | 2011-02-23 13:04:32 +0530 | [diff] [blame] | 1127 | } |
| 1128 | |
Juuso Oikarinen | 2a13052 | 2010-03-09 14:25:02 +0200 | [diff] [blame] | 1129 | if (!((local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) && |
| 1130 | (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)) || |
Vivek Natarajan | 375177b | 2010-02-09 14:50:28 +0530 | [diff] [blame] | 1131 | (ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED)) { |
| 1132 | ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; |
| 1133 | local->hw.conf.flags |= IEEE80211_CONF_PS; |
| 1134 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 1135 | } |
Vivek Natarajan | f3e85b9 | 2011-02-23 13:04:32 +0530 | [diff] [blame] | 1136 | |
Arik Nemtsov | 77b7023 | 2011-06-26 12:06:54 +0300 | [diff] [blame] | 1137 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) |
| 1138 | netif_tx_wake_all_queues(sdata->dev); |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | void ieee80211_dynamic_ps_timer(unsigned long data) |
| 1142 | { |
| 1143 | struct ieee80211_local *local = (void *) data; |
| 1144 | |
Luis R. Rodriguez | 78f1a8b | 2009-07-27 08:38:25 -0700 | [diff] [blame] | 1145 | if (local->quiescing || local->suspended) |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 1146 | return; |
| 1147 | |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 1148 | ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work); |
Johannes Berg | 965beda | 2009-04-16 13:17:24 +0200 | [diff] [blame] | 1149 | } |
| 1150 | |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 1151 | /* MLME */ |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1152 | static bool ieee80211_sta_wmm_params(struct ieee80211_local *local, |
Johannes Berg | 4ced3f7 | 2010-07-19 16:39:04 +0200 | [diff] [blame] | 1153 | struct ieee80211_sub_if_data *sdata, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1154 | u8 *wmm_param, size_t wmm_param_len) |
| 1155 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1156 | struct ieee80211_tx_queue_params params; |
Johannes Berg | 4ced3f7 | 2010-07-19 16:39:04 +0200 | [diff] [blame] | 1157 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1158 | size_t left; |
| 1159 | int count; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1160 | u8 *pos, uapsd_queues = 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1161 | |
Stanislaw Gruszka | e1b3ec1 | 2010-03-29 12:18:34 +0200 | [diff] [blame] | 1162 | if (!local->ops->conf_tx) |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1163 | return false; |
Stanislaw Gruszka | e1b3ec1 | 2010-03-29 12:18:34 +0200 | [diff] [blame] | 1164 | |
Johannes Berg | 32c5057 | 2012-03-28 11:04:29 +0200 | [diff] [blame] | 1165 | if (local->hw.queues < IEEE80211_NUM_ACS) |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1166 | return false; |
Johannes Berg | 3434fbd | 2008-05-03 00:59:37 +0200 | [diff] [blame] | 1167 | |
| 1168 | if (!wmm_param) |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1169 | return false; |
Johannes Berg | 3434fbd | 2008-05-03 00:59:37 +0200 | [diff] [blame] | 1170 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1171 | if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1172 | return false; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1173 | |
| 1174 | if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) |
Eliad Peller | dc41e4d | 2012-03-14 16:15:03 +0200 | [diff] [blame] | 1175 | uapsd_queues = ifmgd->uapsd_queues; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1176 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1177 | count = wmm_param[6] & 0x0f; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 1178 | if (count == ifmgd->wmm_last_param_set) |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1179 | return false; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 1180 | ifmgd->wmm_last_param_set = count; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1181 | |
| 1182 | pos = wmm_param + 8; |
| 1183 | left = wmm_param_len - 8; |
| 1184 | |
| 1185 | memset(¶ms, 0, sizeof(params)); |
| 1186 | |
Yoni Divinsky | 00e96de | 2012-06-20 15:39:13 +0300 | [diff] [blame] | 1187 | sdata->wmm_acm = 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1188 | for (; left >= 4; left -= 4, pos += 4) { |
| 1189 | int aci = (pos[0] >> 5) & 0x03; |
| 1190 | int acm = (pos[0] >> 4) & 0x01; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1191 | bool uapsd = false; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1192 | int queue; |
| 1193 | |
| 1194 | switch (aci) { |
Jouni Malinen | 0eeb59f | 2009-03-05 17:23:46 +0200 | [diff] [blame] | 1195 | case 1: /* AC_BK */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 1196 | queue = 3; |
Johannes Berg | 988c0f7 | 2008-04-17 19:21:22 +0200 | [diff] [blame] | 1197 | if (acm) |
Yoni Divinsky | 00e96de | 2012-06-20 15:39:13 +0300 | [diff] [blame] | 1198 | sdata->wmm_acm |= BIT(1) | BIT(2); /* BK/- */ |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1199 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) |
| 1200 | uapsd = true; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1201 | break; |
Jouni Malinen | 0eeb59f | 2009-03-05 17:23:46 +0200 | [diff] [blame] | 1202 | case 2: /* AC_VI */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 1203 | queue = 1; |
Johannes Berg | 988c0f7 | 2008-04-17 19:21:22 +0200 | [diff] [blame] | 1204 | if (acm) |
Yoni Divinsky | 00e96de | 2012-06-20 15:39:13 +0300 | [diff] [blame] | 1205 | sdata->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */ |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1206 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) |
| 1207 | uapsd = true; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1208 | break; |
Jouni Malinen | 0eeb59f | 2009-03-05 17:23:46 +0200 | [diff] [blame] | 1209 | case 3: /* AC_VO */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 1210 | queue = 0; |
Johannes Berg | 988c0f7 | 2008-04-17 19:21:22 +0200 | [diff] [blame] | 1211 | if (acm) |
Yoni Divinsky | 00e96de | 2012-06-20 15:39:13 +0300 | [diff] [blame] | 1212 | sdata->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */ |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1213 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) |
| 1214 | uapsd = true; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1215 | break; |
Jouni Malinen | 0eeb59f | 2009-03-05 17:23:46 +0200 | [diff] [blame] | 1216 | case 0: /* AC_BE */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1217 | default: |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 1218 | queue = 2; |
Johannes Berg | 988c0f7 | 2008-04-17 19:21:22 +0200 | [diff] [blame] | 1219 | if (acm) |
Yoni Divinsky | 00e96de | 2012-06-20 15:39:13 +0300 | [diff] [blame] | 1220 | sdata->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */ |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1221 | if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) |
| 1222 | uapsd = true; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1223 | break; |
| 1224 | } |
| 1225 | |
| 1226 | params.aifs = pos[0] & 0x0f; |
| 1227 | params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4); |
| 1228 | params.cw_min = ecw2cw(pos[1] & 0x0f); |
Johannes Berg | f434b2d | 2008-07-10 11:22:31 +0200 | [diff] [blame] | 1229 | params.txop = get_unaligned_le16(pos + 2); |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1230 | params.uapsd = uapsd; |
| 1231 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1232 | mlme_dbg(sdata, |
| 1233 | "WMM queue=%d aci=%d acm=%d aifs=%d cWmin=%d cWmax=%d txop=%d uapsd=%d\n", |
| 1234 | queue, aci, acm, |
| 1235 | params.aifs, params.cw_min, params.cw_max, |
| 1236 | params.txop, params.uapsd); |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 1237 | sdata->tx_conf[queue] = params; |
| 1238 | if (drv_conf_tx(local, sdata, queue, ¶ms)) |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1239 | sdata_err(sdata, |
| 1240 | "failed to set TX queue parameters for queue %d\n", |
| 1241 | queue); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1242 | } |
Stanislaw Gruszka | e1b3ec1 | 2010-03-29 12:18:34 +0200 | [diff] [blame] | 1243 | |
| 1244 | /* enable WMM or activate new settings */ |
Johannes Berg | 4ced3f7 | 2010-07-19 16:39:04 +0200 | [diff] [blame] | 1245 | sdata->vif.bss_conf.qos = true; |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1246 | return true; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1247 | } |
| 1248 | |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 1249 | static void __ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata) |
| 1250 | { |
| 1251 | lockdep_assert_held(&sdata->local->mtx); |
| 1252 | |
| 1253 | sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL | |
| 1254 | IEEE80211_STA_BEACON_POLL); |
| 1255 | ieee80211_run_deferred_scan(sdata->local); |
| 1256 | } |
| 1257 | |
| 1258 | static void ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata) |
| 1259 | { |
| 1260 | mutex_lock(&sdata->local->mtx); |
| 1261 | __ieee80211_stop_poll(sdata); |
| 1262 | mutex_unlock(&sdata->local->mtx); |
| 1263 | } |
| 1264 | |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 1265 | static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, |
| 1266 | u16 capab, bool erp_valid, u8 erp) |
Daniel Drake | 5628221 | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 1267 | { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1268 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1269 | u32 changed = 0; |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 1270 | bool use_protection; |
| 1271 | bool use_short_preamble; |
| 1272 | bool use_short_slot; |
| 1273 | |
| 1274 | if (erp_valid) { |
| 1275 | use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0; |
| 1276 | use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0; |
| 1277 | } else { |
| 1278 | use_protection = false; |
| 1279 | use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE); |
| 1280 | } |
| 1281 | |
| 1282 | use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); |
Johannes Berg | 568d6e2 | 2012-07-23 14:29:21 +0200 | [diff] [blame] | 1283 | if (sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ) |
Felix Fietkau | 43d3534 | 2010-01-15 03:00:48 +0100 | [diff] [blame] | 1284 | use_short_slot = true; |
Daniel Drake | 5628221 | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 1285 | |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1286 | if (use_protection != bss_conf->use_cts_prot) { |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1287 | bss_conf->use_cts_prot = use_protection; |
| 1288 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
Daniel Drake | 5628221 | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 1289 | } |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1290 | |
Vladimir Koutny | d43c7b3 | 2008-03-31 17:05:03 +0200 | [diff] [blame] | 1291 | if (use_short_preamble != bss_conf->use_short_preamble) { |
Vladimir Koutny | d43c7b3 | 2008-03-31 17:05:03 +0200 | [diff] [blame] | 1292 | bss_conf->use_short_preamble = use_short_preamble; |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1293 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1294 | } |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1295 | |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 1296 | if (use_short_slot != bss_conf->use_short_slot) { |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 1297 | bss_conf->use_short_slot = use_short_slot; |
| 1298 | changed |= BSS_CHANGED_ERP_SLOT; |
John W. Linville | 50c4afb | 2008-04-15 14:09:27 -0400 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | return changed; |
| 1302 | } |
| 1303 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1304 | static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 1305 | struct cfg80211_bss *cbss, |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1306 | u32 bss_info_changed) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1307 | { |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 1308 | struct ieee80211_bss *bss = (void *)cbss->priv; |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1309 | struct ieee80211_local *local = sdata->local; |
Juuso Oikarinen | 6854296 | 2010-06-09 13:43:26 +0300 | [diff] [blame] | 1310 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 1311 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1312 | bss_info_changed |= BSS_CHANGED_ASSOC; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1313 | bss_info_changed |= ieee80211_handle_bss_capability(sdata, |
Luciano Coelho | 50ae34a | 2012-06-20 17:23:24 +0300 | [diff] [blame] | 1314 | bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value); |
Tomas Winkler | 21c0cbe | 2008-03-28 16:33:34 -0700 | [diff] [blame] | 1315 | |
Felix Fietkau | 7ccc8bd | 2010-11-19 22:55:38 +0100 | [diff] [blame] | 1316 | sdata->u.mgd.beacon_timeout = usecs_to_jiffies(ieee80211_tu_to_usec( |
| 1317 | IEEE80211_BEACON_LOSS_COUNT * bss_conf->beacon_int)); |
| 1318 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 1319 | sdata->u.mgd.associated = cbss; |
| 1320 | memcpy(sdata->u.mgd.bssid, cbss->bssid, ETH_ALEN); |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1321 | |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 1322 | sdata->u.mgd.flags |= IEEE80211_STA_RESET_SIGNAL_AVE; |
| 1323 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1324 | /* just to be sure */ |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 1325 | ieee80211_stop_poll(sdata); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1326 | |
Tomas Winkler | f5e5bf2 | 2008-09-08 17:33:39 +0200 | [diff] [blame] | 1327 | ieee80211_led_assoc(local, 1); |
| 1328 | |
Johannes Berg | e5b900d | 2010-07-29 16:08:55 +0200 | [diff] [blame] | 1329 | if (local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) |
| 1330 | bss_conf->dtim_period = bss->dtim_period; |
| 1331 | else |
| 1332 | bss_conf->dtim_period = 0; |
| 1333 | |
Juuso Oikarinen | 6854296 | 2010-06-09 13:43:26 +0300 | [diff] [blame] | 1334 | bss_conf->assoc = 1; |
Johannes Berg | 9cef873 | 2009-05-14 13:10:14 +0200 | [diff] [blame] | 1335 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1336 | /* Tell the driver to monitor connection quality (if supported) */ |
Johannes Berg | ea08635 | 2012-01-19 09:29:58 +0100 | [diff] [blame] | 1337 | if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI && |
Juuso Oikarinen | 6854296 | 2010-06-09 13:43:26 +0300 | [diff] [blame] | 1338 | bss_conf->cqm_rssi_thold) |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1339 | bss_info_changed |= BSS_CHANGED_CQM; |
| 1340 | |
Juuso Oikarinen | 6854296 | 2010-06-09 13:43:26 +0300 | [diff] [blame] | 1341 | /* Enable ARP filtering */ |
| 1342 | if (bss_conf->arp_filter_enabled != sdata->arp_filter_state) { |
| 1343 | bss_conf->arp_filter_enabled = sdata->arp_filter_state; |
| 1344 | bss_info_changed |= BSS_CHANGED_ARP_FILTER; |
| 1345 | } |
| 1346 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1347 | ieee80211_bss_info_change_notify(sdata, bss_info_changed); |
Guy Cohen | 8db9369 | 2008-07-03 19:56:13 +0300 | [diff] [blame] | 1348 | |
Johannes Berg | 056508d | 2009-07-30 21:43:55 +0200 | [diff] [blame] | 1349 | mutex_lock(&local->iflist_mtx); |
| 1350 | ieee80211_recalc_ps(local, -1); |
| 1351 | mutex_unlock(&local->iflist_mtx); |
Kalle Valo | e0cb686 | 2008-12-18 23:35:13 +0200 | [diff] [blame] | 1352 | |
Johannes Berg | 5d8e423 | 2012-09-11 10:17:11 +0200 | [diff] [blame] | 1353 | ieee80211_recalc_smps(local); |
Eliad Peller | ab09587 | 2012-07-27 12:33:22 +0300 | [diff] [blame] | 1354 | ieee80211_recalc_ps_vif(sdata); |
| 1355 | |
John W. Linville | 8a5b33f | 2010-01-06 15:39:39 -0500 | [diff] [blame] | 1356 | netif_tx_start_all_queues(sdata->dev); |
Tomas Winkler | f5e5bf2 | 2008-09-08 17:33:39 +0200 | [diff] [blame] | 1357 | netif_carrier_on(sdata->dev); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
Jouni Malinen | e69e95d | 2010-03-29 23:29:31 -0700 | [diff] [blame] | 1360 | static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1361 | u16 stype, u16 reason, bool tx, |
| 1362 | u8 *frame_buf) |
Tomas Winkler | aa458d1 | 2008-09-09 00:32:12 +0300 | [diff] [blame] | 1363 | { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 1364 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Tomas Winkler | aa458d1 | 2008-09-09 00:32:12 +0300 | [diff] [blame] | 1365 | struct ieee80211_local *local = sdata->local; |
| 1366 | struct sta_info *sta; |
Johannes Berg | 3cc5240 | 2012-03-09 13:12:35 +0100 | [diff] [blame] | 1367 | u32 changed = 0; |
Tomas Winkler | aa458d1 | 2008-09-09 00:32:12 +0300 | [diff] [blame] | 1368 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1369 | ASSERT_MGD_MTX(ifmgd); |
| 1370 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1371 | if (WARN_ON_ONCE(tx && !frame_buf)) |
| 1372 | return; |
| 1373 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1374 | if (WARN_ON(!ifmgd->associated)) |
| 1375 | return; |
| 1376 | |
David Spinadel | 79543d8 | 2012-06-12 09:59:45 +0300 | [diff] [blame] | 1377 | ieee80211_stop_poll(sdata); |
| 1378 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1379 | ifmgd->associated = NULL; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1380 | |
| 1381 | /* |
| 1382 | * we need to commit the associated = NULL change because the |
| 1383 | * scan code uses that to determine whether this iface should |
| 1384 | * go to/wake up from powersave or not -- and could otherwise |
| 1385 | * wake the queues erroneously. |
| 1386 | */ |
| 1387 | smp_mb(); |
| 1388 | |
| 1389 | /* |
| 1390 | * Thus, we can only afterwards stop the queues -- to account |
| 1391 | * for the case where another CPU is finishing a scan at this |
| 1392 | * time -- we don't want the scan code to enable queues. |
| 1393 | */ |
Tomas Winkler | aa458d1 | 2008-09-09 00:32:12 +0300 | [diff] [blame] | 1394 | |
John W. Linville | 8a5b33f | 2010-01-06 15:39:39 -0500 | [diff] [blame] | 1395 | netif_tx_stop_all_queues(sdata->dev); |
Tomas Winkler | aa458d1 | 2008-09-09 00:32:12 +0300 | [diff] [blame] | 1396 | netif_carrier_off(sdata->dev); |
| 1397 | |
Johannes Berg | 2a41905 | 2010-06-10 10:21:29 +0200 | [diff] [blame] | 1398 | mutex_lock(&local->sta_mtx); |
Eliad Peller | 88a9e31 | 2012-06-01 11:14:03 +0300 | [diff] [blame] | 1399 | sta = sta_info_get(sdata, ifmgd->bssid); |
Sujith | 4cad6c7 | 2010-02-10 14:52:21 +0530 | [diff] [blame] | 1400 | if (sta) { |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1401 | set_sta_flag(sta, WLAN_STA_BLOCK_BA); |
Johannes Berg | 7f16114 | 2012-07-18 12:53:34 +0200 | [diff] [blame] | 1402 | ieee80211_sta_tear_down_BA_sessions(sta, false); |
Sujith | 4cad6c7 | 2010-02-10 14:52:21 +0530 | [diff] [blame] | 1403 | } |
Johannes Berg | 2a41905 | 2010-06-10 10:21:29 +0200 | [diff] [blame] | 1404 | mutex_unlock(&local->sta_mtx); |
Tomas Winkler | aa458d1 | 2008-09-09 00:32:12 +0300 | [diff] [blame] | 1405 | |
Eliad Peller | 88bc40e | 2012-07-12 17:35:33 +0300 | [diff] [blame] | 1406 | /* |
| 1407 | * if we want to get out of ps before disassoc (why?) we have |
| 1408 | * to do it before sending disassoc, as otherwise the null-packet |
| 1409 | * won't be valid. |
| 1410 | */ |
| 1411 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { |
| 1412 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; |
| 1413 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 1414 | } |
| 1415 | local->ps_sdata = NULL; |
| 1416 | |
Eliad Peller | ab09587 | 2012-07-27 12:33:22 +0300 | [diff] [blame] | 1417 | /* disable per-vif ps */ |
| 1418 | ieee80211_recalc_ps_vif(sdata); |
| 1419 | |
Eliad Peller | f823981 | 2012-06-27 14:18:22 +0300 | [diff] [blame] | 1420 | /* flush out any pending frame (e.g. DELBA) before deauth/disassoc */ |
| 1421 | if (tx) |
| 1422 | drv_flush(local, false); |
| 1423 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1424 | /* deauthenticate/disassociate now */ |
| 1425 | if (tx || frame_buf) |
Eliad Peller | 88a9e31 | 2012-06-01 11:14:03 +0300 | [diff] [blame] | 1426 | ieee80211_send_deauth_disassoc(sdata, ifmgd->bssid, stype, |
| 1427 | reason, tx, frame_buf); |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1428 | |
| 1429 | /* flush out frame */ |
| 1430 | if (tx) |
| 1431 | drv_flush(local, false); |
| 1432 | |
Eliad Peller | 88a9e31 | 2012-06-01 11:14:03 +0300 | [diff] [blame] | 1433 | /* clear bssid only after building the needed mgmt frames */ |
| 1434 | memset(ifmgd->bssid, 0, ETH_ALEN); |
| 1435 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1436 | /* remove AP and TDLS peers */ |
| 1437 | sta_info_flush(local, sdata); |
| 1438 | |
| 1439 | /* finally reset all BSS / config parameters */ |
Tomas Winkler | f5e5bf2 | 2008-09-08 17:33:39 +0200 | [diff] [blame] | 1440 | changed |= ieee80211_reset_erp_info(sdata); |
| 1441 | |
Tomas Winkler | f5e5bf2 | 2008-09-08 17:33:39 +0200 | [diff] [blame] | 1442 | ieee80211_led_assoc(local, 0); |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1443 | changed |= BSS_CHANGED_ASSOC; |
| 1444 | sdata->vif.bss_conf.assoc = false; |
Tomas Winkler | f5e5bf2 | 2008-09-08 17:33:39 +0200 | [diff] [blame] | 1445 | |
Johannes Berg | 413ad50 | 2009-05-08 21:21:06 +0200 | [diff] [blame] | 1446 | /* on the next assoc, re-program HT parameters */ |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 1447 | memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); |
| 1448 | memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask)); |
Johannes Berg | 413ad50 | 2009-05-08 21:21:06 +0200 | [diff] [blame] | 1449 | |
Johannes Berg | 04b7b2f | 2012-09-05 13:41:37 +0200 | [diff] [blame] | 1450 | local->ap_power_level = 0; |
Vasanthakumar Thiagarajan | a8302de | 2009-01-09 18:14:15 +0530 | [diff] [blame] | 1451 | |
Kalle Valo | 520eb82 | 2008-12-18 23:35:27 +0200 | [diff] [blame] | 1452 | del_timer_sync(&local->dynamic_ps_timer); |
| 1453 | cancel_work_sync(&local->dynamic_ps_enable_work); |
| 1454 | |
Juuso Oikarinen | 6854296 | 2010-06-09 13:43:26 +0300 | [diff] [blame] | 1455 | /* Disable ARP filtering */ |
| 1456 | if (sdata->vif.bss_conf.arp_filter_enabled) { |
| 1457 | sdata->vif.bss_conf.arp_filter_enabled = false; |
| 1458 | changed |= BSS_CHANGED_ARP_FILTER; |
| 1459 | } |
| 1460 | |
Johannes Berg | 3abead5 | 2012-03-02 15:56:59 +0100 | [diff] [blame] | 1461 | sdata->vif.bss_conf.qos = false; |
| 1462 | changed |= BSS_CHANGED_QOS; |
| 1463 | |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1464 | /* The BSSID (not really interesting) and HT changed */ |
| 1465 | changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1466 | ieee80211_bss_info_change_notify(sdata, changed); |
Tomas Winkler | 8e268e4 | 2008-11-25 13:05:44 +0200 | [diff] [blame] | 1467 | |
Johannes Berg | 3cc5240 | 2012-03-09 13:12:35 +0100 | [diff] [blame] | 1468 | /* channel(_type) changes are handled by ieee80211_hw_config */ |
| 1469 | WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT)); |
| 1470 | ieee80211_hw_config(local, 0); |
| 1471 | |
Johannes Berg | 3abead5 | 2012-03-02 15:56:59 +0100 | [diff] [blame] | 1472 | /* disassociated - set to defaults now */ |
| 1473 | ieee80211_set_wmm_default(sdata, false); |
| 1474 | |
Johannes Berg | b9dcf71 | 2010-08-27 12:35:54 +0200 | [diff] [blame] | 1475 | del_timer_sync(&sdata->u.mgd.conn_mon_timer); |
| 1476 | del_timer_sync(&sdata->u.mgd.bcn_mon_timer); |
| 1477 | del_timer_sync(&sdata->u.mgd.timer); |
| 1478 | del_timer_sync(&sdata->u.mgd.chswitch_timer); |
Johannes Berg | 2d9957c | 2012-08-01 20:54:52 +0200 | [diff] [blame] | 1479 | |
| 1480 | sdata->u.mgd.timers_running = 0; |
Tomas Winkler | aa458d1 | 2008-09-09 00:32:12 +0300 | [diff] [blame] | 1481 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1482 | |
Kalle Valo | 3cf335d | 2009-03-22 21:57:06 +0200 | [diff] [blame] | 1483 | void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, |
| 1484 | struct ieee80211_hdr *hdr) |
| 1485 | { |
| 1486 | /* |
| 1487 | * We can postpone the mgd.timer whenever receiving unicast frames |
| 1488 | * from AP because we know that the connection is working both ways |
| 1489 | * at that time. But multicast frames (and hence also beacons) must |
| 1490 | * be ignored here, because we need to trigger the timer during |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1491 | * data idle periods for sending the periodic probe request to the |
| 1492 | * AP we're connected to. |
Kalle Valo | 3cf335d | 2009-03-22 21:57:06 +0200 | [diff] [blame] | 1493 | */ |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1494 | if (is_multicast_ether_addr(hdr->addr1)) |
| 1495 | return; |
| 1496 | |
Luis R. Rodriguez | be099e8 | 2010-09-16 15:12:29 -0400 | [diff] [blame] | 1497 | ieee80211_sta_reset_conn_monitor(sdata); |
Kalle Valo | 3cf335d | 2009-03-22 21:57:06 +0200 | [diff] [blame] | 1498 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1499 | |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1500 | static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata) |
| 1501 | { |
| 1502 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1503 | struct ieee80211_local *local = sdata->local; |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1504 | |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1505 | mutex_lock(&local->mtx); |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1506 | if (!(ifmgd->flags & (IEEE80211_STA_BEACON_POLL | |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1507 | IEEE80211_STA_CONNECTION_POLL))) { |
| 1508 | mutex_unlock(&local->mtx); |
| 1509 | return; |
| 1510 | } |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1511 | |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 1512 | __ieee80211_stop_poll(sdata); |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1513 | |
| 1514 | mutex_lock(&local->iflist_mtx); |
| 1515 | ieee80211_recalc_ps(local, -1); |
| 1516 | mutex_unlock(&local->iflist_mtx); |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1517 | |
| 1518 | if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1519 | goto out; |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1520 | |
| 1521 | /* |
| 1522 | * We've received a probe response, but are not sure whether |
| 1523 | * we have or will be receiving any beacons or data, so let's |
| 1524 | * schedule the timers again, just in case. |
| 1525 | */ |
| 1526 | ieee80211_sta_reset_beacon_monitor(sdata); |
| 1527 | |
| 1528 | mod_timer(&ifmgd->conn_mon_timer, |
| 1529 | round_jiffies_up(jiffies + |
| 1530 | IEEE80211_CONNECTION_IDLE_TIME)); |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1531 | out: |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1532 | mutex_unlock(&local->mtx); |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata, |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 1536 | struct ieee80211_hdr *hdr, bool ack) |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1537 | { |
Felix Fietkau | 75706d0 | 2010-12-02 21:01:07 +0100 | [diff] [blame] | 1538 | if (!ieee80211_is_data(hdr->frame_control)) |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1539 | return; |
| 1540 | |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 1541 | if (ack) |
| 1542 | ieee80211_sta_reset_conn_monitor(sdata); |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1543 | |
| 1544 | if (ieee80211_is_nullfunc(hdr->frame_control) && |
| 1545 | sdata->u.mgd.probe_send_count > 0) { |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 1546 | if (ack) |
| 1547 | sdata->u.mgd.probe_send_count = 0; |
| 1548 | else |
| 1549 | sdata->u.mgd.nullfunc_failed = true; |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1550 | ieee80211_queue_work(&sdata->local->hw, &sdata->work); |
| 1551 | } |
| 1552 | } |
| 1553 | |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 1554 | static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) |
| 1555 | { |
| 1556 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 1557 | const u8 *ssid; |
Luis R. Rodriguez | f01a067 | 2010-09-16 15:12:34 -0400 | [diff] [blame] | 1558 | u8 *dst = ifmgd->associated->bssid; |
Ben Greear | 180205b | 2011-02-04 15:30:24 -0800 | [diff] [blame] | 1559 | u8 unicast_limit = max(1, max_probe_tries - 3); |
Luis R. Rodriguez | f01a067 | 2010-09-16 15:12:34 -0400 | [diff] [blame] | 1560 | |
| 1561 | /* |
| 1562 | * Try sending broadcast probe requests for the last three |
| 1563 | * probe requests after the first ones failed since some |
| 1564 | * buggy APs only support broadcast probe requests. |
| 1565 | */ |
| 1566 | if (ifmgd->probe_send_count >= unicast_limit) |
| 1567 | dst = NULL; |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 1568 | |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1569 | /* |
| 1570 | * When the hardware reports an accurate Tx ACK status, it's |
| 1571 | * better to send a nullfunc frame instead of a probe request, |
| 1572 | * as it will kick us off the AP quickly if we aren't associated |
| 1573 | * anymore. The timeout will be reset if the frame is ACKed by |
| 1574 | * the AP. |
| 1575 | */ |
Soumik Das | 992e68b | 2012-05-20 15:31:13 +0530 | [diff] [blame] | 1576 | ifmgd->probe_send_count++; |
| 1577 | |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 1578 | if (sdata->local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) { |
| 1579 | ifmgd->nullfunc_failed = false; |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1580 | ieee80211_send_nullfunc(sdata->local, sdata, 0); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 1581 | } else { |
Stanislaw Gruszka | 88c868c | 2012-03-29 16:30:41 +0200 | [diff] [blame] | 1582 | int ssid_len; |
| 1583 | |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1584 | ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); |
Stanislaw Gruszka | 88c868c | 2012-03-29 16:30:41 +0200 | [diff] [blame] | 1585 | if (WARN_ON_ONCE(ssid == NULL)) |
| 1586 | ssid_len = 0; |
| 1587 | else |
| 1588 | ssid_len = ssid[1]; |
| 1589 | |
| 1590 | ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL, |
Johannes Berg | fe94fe0 | 2012-07-30 12:26:34 +0200 | [diff] [blame] | 1591 | 0, (u32) -1, true, false, |
| 1592 | ifmgd->associated->channel); |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 1593 | } |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 1594 | |
Ben Greear | 180205b | 2011-02-04 15:30:24 -0800 | [diff] [blame] | 1595 | ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms); |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 1596 | run_again(ifmgd, ifmgd->probe_timeout); |
Rajkumar Manoharan | f69b9c7 | 2012-03-15 06:15:26 +0530 | [diff] [blame] | 1597 | if (sdata->local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) |
| 1598 | drv_flush(sdata->local, false); |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 1599 | } |
| 1600 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1601 | static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata, |
| 1602 | bool beacon) |
Kalle Valo | 04de838 | 2009-03-22 21:57:35 +0200 | [diff] [blame] | 1603 | { |
Kalle Valo | 04de838 | 2009-03-22 21:57:35 +0200 | [diff] [blame] | 1604 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1605 | bool already = false; |
Johannes Berg | 34bfc41 | 2009-05-12 19:58:12 +0200 | [diff] [blame] | 1606 | |
Johannes Berg | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 1607 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | 0e2b628 | 2009-07-13 13:23:39 +0200 | [diff] [blame] | 1608 | return; |
| 1609 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1610 | mutex_lock(&ifmgd->mtx); |
| 1611 | |
| 1612 | if (!ifmgd->associated) |
| 1613 | goto out; |
| 1614 | |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1615 | mutex_lock(&sdata->local->mtx); |
| 1616 | |
| 1617 | if (sdata->local->tmp_channel || sdata->local->scanning) { |
| 1618 | mutex_unlock(&sdata->local->mtx); |
| 1619 | goto out; |
| 1620 | } |
| 1621 | |
Joe Perches | e87cc47 | 2012-05-13 21:56:26 +0000 | [diff] [blame] | 1622 | if (beacon) |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1623 | mlme_dbg_ratelimited(sdata, |
| 1624 | "detected beacon loss from AP - sending probe request\n"); |
| 1625 | |
Holger Schurig | 6efb71b | 2012-05-15 15:38:59 +0200 | [diff] [blame] | 1626 | ieee80211_cqm_rssi_notify(&sdata->vif, |
| 1627 | NL80211_CQM_RSSI_BEACON_LOSS_EVENT, GFP_KERNEL); |
Kalle Valo | 04de838 | 2009-03-22 21:57:35 +0200 | [diff] [blame] | 1628 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1629 | /* |
| 1630 | * The driver/our work has already reported this event or the |
| 1631 | * connection monitoring has kicked in and we have already sent |
| 1632 | * a probe request. Or maybe the AP died and the driver keeps |
| 1633 | * reporting until we disassociate... |
| 1634 | * |
| 1635 | * In either case we have to ignore the current call to this |
| 1636 | * function (except for setting the correct probe reason bit) |
| 1637 | * because otherwise we would reset the timer every time and |
| 1638 | * never check whether we received a probe response! |
| 1639 | */ |
| 1640 | if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | |
| 1641 | IEEE80211_STA_CONNECTION_POLL)) |
| 1642 | already = true; |
| 1643 | |
| 1644 | if (beacon) |
| 1645 | ifmgd->flags |= IEEE80211_STA_BEACON_POLL; |
| 1646 | else |
| 1647 | ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL; |
| 1648 | |
Stanislaw Gruszka | 133d40f | 2012-03-28 16:01:19 +0200 | [diff] [blame] | 1649 | mutex_unlock(&sdata->local->mtx); |
| 1650 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1651 | if (already) |
| 1652 | goto out; |
| 1653 | |
Johannes Berg | 4e75184 | 2009-06-10 15:16:52 +0200 | [diff] [blame] | 1654 | mutex_lock(&sdata->local->iflist_mtx); |
| 1655 | ieee80211_recalc_ps(sdata->local, -1); |
| 1656 | mutex_unlock(&sdata->local->iflist_mtx); |
| 1657 | |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 1658 | ifmgd->probe_send_count = 0; |
| 1659 | ieee80211_mgd_probe_ap_send(sdata); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1660 | out: |
| 1661 | mutex_unlock(&ifmgd->mtx); |
Kalle Valo | 04de838 | 2009-03-22 21:57:35 +0200 | [diff] [blame] | 1662 | } |
| 1663 | |
Juuso Oikarinen | a619a4c | 2010-11-11 08:50:18 +0200 | [diff] [blame] | 1664 | struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, |
| 1665 | struct ieee80211_vif *vif) |
| 1666 | { |
| 1667 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
| 1668 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Eliad Peller | d9b3b28 | 2012-06-28 15:03:13 +0300 | [diff] [blame] | 1669 | struct cfg80211_bss *cbss; |
Juuso Oikarinen | a619a4c | 2010-11-11 08:50:18 +0200 | [diff] [blame] | 1670 | struct sk_buff *skb; |
| 1671 | const u8 *ssid; |
Stanislaw Gruszka | 88c868c | 2012-03-29 16:30:41 +0200 | [diff] [blame] | 1672 | int ssid_len; |
Juuso Oikarinen | a619a4c | 2010-11-11 08:50:18 +0200 | [diff] [blame] | 1673 | |
| 1674 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) |
| 1675 | return NULL; |
| 1676 | |
| 1677 | ASSERT_MGD_MTX(ifmgd); |
| 1678 | |
Eliad Peller | d9b3b28 | 2012-06-28 15:03:13 +0300 | [diff] [blame] | 1679 | if (ifmgd->associated) |
| 1680 | cbss = ifmgd->associated; |
| 1681 | else if (ifmgd->auth_data) |
| 1682 | cbss = ifmgd->auth_data->bss; |
| 1683 | else if (ifmgd->assoc_data) |
| 1684 | cbss = ifmgd->assoc_data->bss; |
| 1685 | else |
Juuso Oikarinen | a619a4c | 2010-11-11 08:50:18 +0200 | [diff] [blame] | 1686 | return NULL; |
| 1687 | |
Eliad Peller | d9b3b28 | 2012-06-28 15:03:13 +0300 | [diff] [blame] | 1688 | ssid = ieee80211_bss_get_ie(cbss, WLAN_EID_SSID); |
Stanislaw Gruszka | 88c868c | 2012-03-29 16:30:41 +0200 | [diff] [blame] | 1689 | if (WARN_ON_ONCE(ssid == NULL)) |
| 1690 | ssid_len = 0; |
| 1691 | else |
| 1692 | ssid_len = ssid[1]; |
| 1693 | |
Eliad Peller | d9b3b28 | 2012-06-28 15:03:13 +0300 | [diff] [blame] | 1694 | skb = ieee80211_build_probe_req(sdata, cbss->bssid, |
Johannes Berg | 6b77863 | 2012-07-23 14:53:27 +0200 | [diff] [blame] | 1695 | (u32) -1, |
| 1696 | sdata->local->oper_channel, |
| 1697 | ssid + 2, ssid_len, |
Johannes Berg | 85a237f | 2011-07-18 18:08:36 +0200 | [diff] [blame] | 1698 | NULL, 0, true); |
Juuso Oikarinen | a619a4c | 2010-11-11 08:50:18 +0200 | [diff] [blame] | 1699 | |
| 1700 | return skb; |
| 1701 | } |
| 1702 | EXPORT_SYMBOL(ieee80211_ap_probereq_get); |
| 1703 | |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 1704 | static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata, |
| 1705 | bool transmit_frame) |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1706 | { |
| 1707 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 1708 | struct ieee80211_local *local = sdata->local; |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 1709 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1710 | |
| 1711 | mutex_lock(&ifmgd->mtx); |
| 1712 | if (!ifmgd->associated) { |
| 1713 | mutex_unlock(&ifmgd->mtx); |
| 1714 | return; |
| 1715 | } |
| 1716 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1717 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, |
| 1718 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 1719 | transmit_frame, frame_buf); |
| 1720 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1721 | mutex_unlock(&ifmgd->mtx); |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 1722 | |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1723 | /* |
| 1724 | * must be outside lock due to cfg80211, |
| 1725 | * but that's not a problem. |
| 1726 | */ |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 1727 | cfg80211_send_deauth(sdata->dev, frame_buf, IEEE80211_DEAUTH_FRAME_LEN); |
Felix Fietkau | fcac4fb | 2011-11-16 13:34:55 +0100 | [diff] [blame] | 1728 | |
| 1729 | mutex_lock(&local->mtx); |
| 1730 | ieee80211_recalc_idle(local); |
| 1731 | mutex_unlock(&local->mtx); |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1732 | } |
| 1733 | |
Johannes Berg | cc74c0c | 2012-08-01 16:49:34 +0200 | [diff] [blame] | 1734 | static void ieee80211_beacon_connection_loss_work(struct work_struct *work) |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1735 | { |
| 1736 | struct ieee80211_sub_if_data *sdata = |
| 1737 | container_of(work, struct ieee80211_sub_if_data, |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1738 | u.mgd.beacon_connection_loss_work); |
Paul Stewart | a85e1d5 | 2011-12-09 11:01:49 -0800 | [diff] [blame] | 1739 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 1740 | struct sta_info *sta; |
| 1741 | |
| 1742 | if (ifmgd->associated) { |
Mohammed Shafi Shajakhan | 30fa904 | 2011-12-27 18:54:07 +0530 | [diff] [blame] | 1743 | rcu_read_lock(); |
Paul Stewart | a85e1d5 | 2011-12-09 11:01:49 -0800 | [diff] [blame] | 1744 | sta = sta_info_get(sdata, ifmgd->bssid); |
| 1745 | if (sta) |
| 1746 | sta->beacon_loss_count++; |
Mohammed Shafi Shajakhan | 30fa904 | 2011-12-27 18:54:07 +0530 | [diff] [blame] | 1747 | rcu_read_unlock(); |
Paul Stewart | a85e1d5 | 2011-12-09 11:01:49 -0800 | [diff] [blame] | 1748 | } |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1749 | |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 1750 | if (sdata->local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) { |
| 1751 | sdata_info(sdata, "Connection to AP %pM lost\n", |
| 1752 | ifmgd->bssid); |
| 1753 | __ieee80211_disconnect(sdata, false); |
| 1754 | } else { |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1755 | ieee80211_mgd_probe_ap(sdata, true); |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 1756 | } |
| 1757 | } |
| 1758 | |
| 1759 | static void ieee80211_csa_connection_drop_work(struct work_struct *work) |
| 1760 | { |
| 1761 | struct ieee80211_sub_if_data *sdata = |
| 1762 | container_of(work, struct ieee80211_sub_if_data, |
| 1763 | u.mgd.csa_connection_drop_work); |
| 1764 | |
| 1765 | ieee80211_wake_queues_by_reason(&sdata->local->hw, |
| 1766 | IEEE80211_QUEUE_STOP_REASON_CSA); |
| 1767 | __ieee80211_disconnect(sdata, true); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 1768 | } |
| 1769 | |
Kalle Valo | 04de838 | 2009-03-22 21:57:35 +0200 | [diff] [blame] | 1770 | void ieee80211_beacon_loss(struct ieee80211_vif *vif) |
| 1771 | { |
| 1772 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1773 | struct ieee80211_hw *hw = &sdata->local->hw; |
Kalle Valo | 04de838 | 2009-03-22 21:57:35 +0200 | [diff] [blame] | 1774 | |
Johannes Berg | b5878a2 | 2010-04-07 16:48:40 +0200 | [diff] [blame] | 1775 | trace_api_beacon_loss(sdata); |
| 1776 | |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1777 | WARN_ON(hw->flags & IEEE80211_HW_CONNECTION_MONITOR); |
| 1778 | ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); |
Kalle Valo | 04de838 | 2009-03-22 21:57:35 +0200 | [diff] [blame] | 1779 | } |
| 1780 | EXPORT_SYMBOL(ieee80211_beacon_loss); |
| 1781 | |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1782 | void ieee80211_connection_loss(struct ieee80211_vif *vif) |
| 1783 | { |
| 1784 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
| 1785 | struct ieee80211_hw *hw = &sdata->local->hw; |
| 1786 | |
Johannes Berg | b5878a2 | 2010-04-07 16:48:40 +0200 | [diff] [blame] | 1787 | trace_api_connection_loss(sdata); |
| 1788 | |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 1789 | WARN_ON(!(hw->flags & IEEE80211_HW_CONNECTION_MONITOR)); |
| 1790 | ieee80211_queue_work(hw, &sdata->u.mgd.beacon_connection_loss_work); |
| 1791 | } |
| 1792 | EXPORT_SYMBOL(ieee80211_connection_loss); |
| 1793 | |
| 1794 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1795 | static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata, |
| 1796 | bool assoc) |
| 1797 | { |
| 1798 | struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; |
| 1799 | |
| 1800 | lockdep_assert_held(&sdata->u.mgd.mtx); |
| 1801 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1802 | if (!assoc) { |
| 1803 | sta_info_destroy_addr(sdata, auth_data->bss->bssid); |
| 1804 | |
| 1805 | memset(sdata->u.mgd.bssid, 0, ETH_ALEN); |
| 1806 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); |
| 1807 | } |
| 1808 | |
| 1809 | cfg80211_put_bss(auth_data->bss); |
| 1810 | kfree(auth_data); |
| 1811 | sdata->u.mgd.auth_data = NULL; |
| 1812 | } |
| 1813 | |
| 1814 | static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, |
| 1815 | struct ieee80211_mgmt *mgmt, size_t len) |
| 1816 | { |
| 1817 | struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; |
| 1818 | u8 *pos; |
| 1819 | struct ieee802_11_elems elems; |
| 1820 | |
| 1821 | pos = mgmt->u.auth.variable; |
| 1822 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); |
| 1823 | if (!elems.challenge) |
| 1824 | return; |
| 1825 | auth_data->expected_transaction = 4; |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 1826 | drv_mgd_prepare_tx(sdata->local, sdata); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1827 | ieee80211_send_auth(sdata, 3, auth_data->algorithm, |
| 1828 | elems.challenge - 2, elems.challenge_len + 2, |
| 1829 | auth_data->bss->bssid, auth_data->bss->bssid, |
| 1830 | auth_data->key, auth_data->key_len, |
| 1831 | auth_data->key_idx); |
| 1832 | } |
| 1833 | |
| 1834 | static enum rx_mgmt_action __must_check |
| 1835 | ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, |
| 1836 | struct ieee80211_mgmt *mgmt, size_t len) |
| 1837 | { |
| 1838 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 1839 | u8 bssid[ETH_ALEN]; |
| 1840 | u16 auth_alg, auth_transaction, status_code; |
| 1841 | struct sta_info *sta; |
| 1842 | |
| 1843 | lockdep_assert_held(&ifmgd->mtx); |
| 1844 | |
| 1845 | if (len < 24 + 6) |
| 1846 | return RX_MGMT_NONE; |
| 1847 | |
| 1848 | if (!ifmgd->auth_data || ifmgd->auth_data->done) |
| 1849 | return RX_MGMT_NONE; |
| 1850 | |
| 1851 | memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); |
| 1852 | |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 1853 | if (!ether_addr_equal(bssid, mgmt->bssid)) |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1854 | return RX_MGMT_NONE; |
| 1855 | |
| 1856 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); |
| 1857 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); |
| 1858 | status_code = le16_to_cpu(mgmt->u.auth.status_code); |
| 1859 | |
| 1860 | if (auth_alg != ifmgd->auth_data->algorithm || |
| 1861 | auth_transaction != ifmgd->auth_data->expected_transaction) |
| 1862 | return RX_MGMT_NONE; |
| 1863 | |
| 1864 | if (status_code != WLAN_STATUS_SUCCESS) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1865 | sdata_info(sdata, "%pM denied authentication (status %d)\n", |
| 1866 | mgmt->sa, status_code); |
Eliad Peller | dac211e | 2012-05-13 18:07:04 +0300 | [diff] [blame] | 1867 | ieee80211_destroy_auth_data(sdata, false); |
| 1868 | return RX_MGMT_CFG80211_RX_AUTH; |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1869 | } |
| 1870 | |
| 1871 | switch (ifmgd->auth_data->algorithm) { |
| 1872 | case WLAN_AUTH_OPEN: |
| 1873 | case WLAN_AUTH_LEAP: |
| 1874 | case WLAN_AUTH_FT: |
| 1875 | break; |
| 1876 | case WLAN_AUTH_SHARED_KEY: |
| 1877 | if (ifmgd->auth_data->expected_transaction != 4) { |
| 1878 | ieee80211_auth_challenge(sdata, mgmt, len); |
| 1879 | /* need another frame */ |
| 1880 | return RX_MGMT_NONE; |
| 1881 | } |
| 1882 | break; |
| 1883 | default: |
| 1884 | WARN_ONCE(1, "invalid auth alg %d", |
| 1885 | ifmgd->auth_data->algorithm); |
| 1886 | return RX_MGMT_NONE; |
| 1887 | } |
| 1888 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1889 | sdata_info(sdata, "authenticated\n"); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1890 | ifmgd->auth_data->done = true; |
| 1891 | ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; |
| 1892 | run_again(ifmgd, ifmgd->auth_data->timeout); |
| 1893 | |
| 1894 | /* move station state to auth */ |
| 1895 | mutex_lock(&sdata->local->sta_mtx); |
| 1896 | sta = sta_info_get(sdata, bssid); |
| 1897 | if (!sta) { |
| 1898 | WARN_ONCE(1, "%s: STA %pM not found", sdata->name, bssid); |
| 1899 | goto out_err; |
| 1900 | } |
| 1901 | if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1902 | sdata_info(sdata, "failed moving %pM to auth\n", bssid); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1903 | goto out_err; |
| 1904 | } |
| 1905 | mutex_unlock(&sdata->local->sta_mtx); |
| 1906 | |
| 1907 | return RX_MGMT_CFG80211_RX_AUTH; |
| 1908 | out_err: |
| 1909 | mutex_unlock(&sdata->local->sta_mtx); |
| 1910 | /* ignore frame -- wait for timeout */ |
| 1911 | return RX_MGMT_NONE; |
| 1912 | } |
| 1913 | |
| 1914 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1915 | static enum rx_mgmt_action __must_check |
| 1916 | ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1917 | struct ieee80211_mgmt *mgmt, size_t len) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1918 | { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 1919 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1920 | const u8 *bssid = NULL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1921 | u16 reason_code; |
| 1922 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1923 | lockdep_assert_held(&ifmgd->mtx); |
| 1924 | |
Johannes Berg | f4ea83d | 2008-06-30 15:10:46 +0200 | [diff] [blame] | 1925 | if (len < 24 + 2) |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1926 | return RX_MGMT_NONE; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1927 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1928 | if (!ifmgd->associated || |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 1929 | !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1930 | return RX_MGMT_NONE; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1931 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 1932 | bssid = ifmgd->associated->bssid; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1933 | |
| 1934 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); |
| 1935 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1936 | sdata_info(sdata, "deauthenticated from %pM (Reason: %u)\n", |
| 1937 | bssid, reason_code); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1938 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1939 | ieee80211_set_disassoc(sdata, 0, 0, false, NULL); |
| 1940 | |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 1941 | mutex_lock(&sdata->local->mtx); |
Johannes Berg | 63f170e | 2009-12-23 13:15:33 +0100 | [diff] [blame] | 1942 | ieee80211_recalc_idle(sdata->local); |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 1943 | mutex_unlock(&sdata->local->mtx); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1944 | |
| 1945 | return RX_MGMT_CFG80211_DEAUTH; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1946 | } |
| 1947 | |
| 1948 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1949 | static enum rx_mgmt_action __must_check |
| 1950 | ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, |
| 1951 | struct ieee80211_mgmt *mgmt, size_t len) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1952 | { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 1953 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1954 | u16 reason_code; |
| 1955 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1956 | lockdep_assert_held(&ifmgd->mtx); |
| 1957 | |
Johannes Berg | f4ea83d | 2008-06-30 15:10:46 +0200 | [diff] [blame] | 1958 | if (len < 24 + 2) |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1959 | return RX_MGMT_NONE; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1960 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 1961 | if (!ifmgd->associated || |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 1962 | !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1963 | return RX_MGMT_NONE; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1964 | |
| 1965 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); |
| 1966 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1967 | sdata_info(sdata, "disassociated from %pM (Reason: %u)\n", |
| 1968 | mgmt->sa, reason_code); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1969 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1970 | ieee80211_set_disassoc(sdata, 0, 0, false, NULL); |
| 1971 | |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 1972 | mutex_lock(&sdata->local->mtx); |
Johannes Berg | bc83b68 | 2009-11-29 12:19:06 +0100 | [diff] [blame] | 1973 | ieee80211_recalc_idle(sdata->local); |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 1974 | mutex_unlock(&sdata->local->mtx); |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 1975 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1976 | return RX_MGMT_CFG80211_DISASSOC; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1977 | } |
| 1978 | |
Christian Lamparter | c74d084 | 2011-10-15 00:14:49 +0200 | [diff] [blame] | 1979 | static void ieee80211_get_rates(struct ieee80211_supported_band *sband, |
| 1980 | u8 *supp_rates, unsigned int supp_rates_len, |
| 1981 | u32 *rates, u32 *basic_rates, |
| 1982 | bool *have_higher_than_11mbit, |
| 1983 | int *min_rate, int *min_rate_index) |
| 1984 | { |
| 1985 | int i, j; |
| 1986 | |
| 1987 | for (i = 0; i < supp_rates_len; i++) { |
| 1988 | int rate = (supp_rates[i] & 0x7f) * 5; |
| 1989 | bool is_basic = !!(supp_rates[i] & 0x80); |
| 1990 | |
| 1991 | if (rate > 110) |
| 1992 | *have_higher_than_11mbit = true; |
| 1993 | |
| 1994 | /* |
| 1995 | * BSS_MEMBERSHIP_SELECTOR_HT_PHY is defined in 802.11n-2009 |
| 1996 | * 7.3.2.2 as a magic value instead of a rate. Hence, skip it. |
| 1997 | * |
| 1998 | * Note: Even through the membership selector and the basic |
| 1999 | * rate flag share the same bit, they are not exactly |
| 2000 | * the same. |
| 2001 | */ |
| 2002 | if (!!(supp_rates[i] & 0x80) && |
| 2003 | (supp_rates[i] & 0x7f) == BSS_MEMBERSHIP_SELECTOR_HT_PHY) |
| 2004 | continue; |
| 2005 | |
| 2006 | for (j = 0; j < sband->n_bitrates; j++) { |
| 2007 | if (sband->bitrates[j].bitrate == rate) { |
| 2008 | *rates |= BIT(j); |
| 2009 | if (is_basic) |
| 2010 | *basic_rates |= BIT(j); |
| 2011 | if (rate < *min_rate) { |
| 2012 | *min_rate = rate; |
| 2013 | *min_rate_index = j; |
| 2014 | } |
| 2015 | break; |
| 2016 | } |
| 2017 | } |
| 2018 | } |
| 2019 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2020 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2021 | static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata, |
| 2022 | bool assoc) |
| 2023 | { |
| 2024 | struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; |
| 2025 | |
| 2026 | lockdep_assert_held(&sdata->u.mgd.mtx); |
| 2027 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2028 | if (!assoc) { |
| 2029 | sta_info_destroy_addr(sdata, assoc_data->bss->bssid); |
| 2030 | |
| 2031 | memset(sdata->u.mgd.bssid, 0, ETH_ALEN); |
| 2032 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); |
| 2033 | } |
| 2034 | |
| 2035 | kfree(assoc_data); |
| 2036 | sdata->u.mgd.assoc_data = NULL; |
| 2037 | } |
| 2038 | |
| 2039 | static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, |
| 2040 | struct cfg80211_bss *cbss, |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2041 | struct ieee80211_mgmt *mgmt, size_t len) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2042 | { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 2043 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 2044 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 2045 | struct ieee80211_supported_band *sband; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2046 | struct sta_info *sta; |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2047 | u8 *pos; |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2048 | u16 capab_info, aid; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2049 | struct ieee802_11_elems elems; |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 2050 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 2051 | u32 changed = 0; |
Christian Lamparter | c74d084 | 2011-10-15 00:14:49 +0200 | [diff] [blame] | 2052 | int err; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2053 | |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2054 | /* AssocResp and ReassocResp have identical structure */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2055 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2056 | aid = le16_to_cpu(mgmt->u.assoc_resp.aid); |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2057 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2058 | |
Johannes Berg | 1dd84aa | 2007-10-10 12:03:41 +0200 | [diff] [blame] | 2059 | if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2060 | sdata_info(sdata, "invalid AID value 0x%x; bits 15:14 not set\n", |
| 2061 | aid); |
Johannes Berg | 1dd84aa | 2007-10-10 12:03:41 +0200 | [diff] [blame] | 2062 | aid &= ~(BIT(15) | BIT(14)); |
| 2063 | |
Johannes Berg | 05cb910 | 2011-10-28 11:59:47 +0200 | [diff] [blame] | 2064 | ifmgd->broken_ap = false; |
| 2065 | |
| 2066 | if (aid == 0 || aid > IEEE80211_MAX_AID) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2067 | sdata_info(sdata, "invalid AID value %d (out of range), turn off PS\n", |
| 2068 | aid); |
Johannes Berg | 05cb910 | 2011-10-28 11:59:47 +0200 | [diff] [blame] | 2069 | aid = 0; |
| 2070 | ifmgd->broken_ap = true; |
| 2071 | } |
| 2072 | |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2073 | pos = mgmt->u.assoc_resp.variable; |
| 2074 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); |
| 2075 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2076 | if (!elems.supp_rates) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2077 | sdata_info(sdata, "no SuppRates element in AssocResp\n"); |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2078 | return false; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2079 | } |
| 2080 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 2081 | ifmgd->aid = aid; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2082 | |
Guy Eilam | 2a33bee | 2011-08-17 15:18:15 +0300 | [diff] [blame] | 2083 | mutex_lock(&sdata->local->sta_mtx); |
| 2084 | /* |
| 2085 | * station info was already allocated and inserted before |
| 2086 | * the association and should be available to us |
| 2087 | */ |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 2088 | sta = sta_info_get(sdata, cbss->bssid); |
Guy Eilam | 2a33bee | 2011-08-17 15:18:15 +0300 | [diff] [blame] | 2089 | if (WARN_ON(!sta)) { |
| 2090 | mutex_unlock(&sdata->local->sta_mtx); |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2091 | return false; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2092 | } |
| 2093 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2094 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 2095 | |
Johannes Berg | ab1faea | 2009-07-01 21:41:17 +0200 | [diff] [blame] | 2096 | if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 2097 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 2098 | elems.ht_cap_elem, &sta->sta.ht_cap); |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 2099 | |
Johannes Berg | 64f68e5 | 2012-03-28 10:58:37 +0200 | [diff] [blame] | 2100 | sta->supports_40mhz = |
| 2101 | sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 2102 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 2103 | rate_control_rate_init(sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2104 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 2105 | if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 2106 | set_sta_flag(sta, WLAN_STA_MFP); |
Jouni Malinen | 5394af4 | 2009-01-08 13:31:59 +0200 | [diff] [blame] | 2107 | |
Johannes Berg | ddf4ac5 | 2008-10-22 11:41:38 +0200 | [diff] [blame] | 2108 | if (elems.wmm_param) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 2109 | set_sta_flag(sta, WLAN_STA_WME); |
Johannes Berg | ddf4ac5 | 2008-10-22 11:41:38 +0200 | [diff] [blame] | 2110 | |
Johannes Berg | c898787 | 2012-01-20 13:55:17 +0100 | [diff] [blame] | 2111 | err = sta_info_move_state(sta, IEEE80211_STA_AUTH); |
| 2112 | if (!err) |
| 2113 | err = sta_info_move_state(sta, IEEE80211_STA_ASSOC); |
| 2114 | if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) |
| 2115 | err = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); |
| 2116 | if (err) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2117 | sdata_info(sdata, |
| 2118 | "failed to move station %pM to desired state\n", |
| 2119 | sta->sta.addr); |
Johannes Berg | c898787 | 2012-01-20 13:55:17 +0100 | [diff] [blame] | 2120 | WARN_ON(__sta_info_destroy(sta)); |
| 2121 | mutex_unlock(&sdata->local->sta_mtx); |
| 2122 | return false; |
| 2123 | } |
| 2124 | |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 2125 | mutex_unlock(&sdata->local->sta_mtx); |
Johannes Berg | ddf4ac5 | 2008-10-22 11:41:38 +0200 | [diff] [blame] | 2126 | |
Juuso Oikarinen | f2176d7 | 2010-09-28 14:39:32 +0300 | [diff] [blame] | 2127 | /* |
| 2128 | * Always handle WMM once after association regardless |
| 2129 | * of the first value the AP uses. Setting -1 here has |
| 2130 | * that effect because the AP values is an unsigned |
| 2131 | * 4-bit value. |
| 2132 | */ |
| 2133 | ifmgd->wmm_last_param_set = -1; |
| 2134 | |
Johannes Berg | ddf4ac5 | 2008-10-22 11:41:38 +0200 | [diff] [blame] | 2135 | if (elems.wmm_param) |
Johannes Berg | 4ced3f7 | 2010-07-19 16:39:04 +0200 | [diff] [blame] | 2136 | ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2137 | elems.wmm_param_len); |
Johannes Berg | aa837e1 | 2009-05-07 16:16:24 +0200 | [diff] [blame] | 2138 | else |
Johannes Berg | 3abead5 | 2012-03-02 15:56:59 +0100 | [diff] [blame] | 2139 | ieee80211_set_wmm_default(sdata, false); |
| 2140 | changed |= BSS_CHANGED_QOS; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2141 | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 2142 | if (elems.ht_operation && elems.wmm_param && |
Johannes Berg | ab1faea | 2009-07-01 21:41:17 +0200 | [diff] [blame] | 2143 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 2144 | changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation, |
| 2145 | cbss->bssid, false); |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 2146 | |
Tomas Winkler | 21c0cbe | 2008-03-28 16:33:34 -0700 | [diff] [blame] | 2147 | /* set AID and assoc capability, |
| 2148 | * ieee80211_set_associated() will tell the driver */ |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 2149 | bss_conf->aid = aid; |
Tomas Winkler | 21c0cbe | 2008-03-28 16:33:34 -0700 | [diff] [blame] | 2150 | bss_conf->assoc_capability = capab_info; |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 2151 | ieee80211_set_associated(sdata, cbss, changed); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2152 | |
Kalle Valo | 15b7b06 | 2009-03-22 21:57:14 +0200 | [diff] [blame] | 2153 | /* |
Felix Fietkau | d524215 | 2010-01-08 18:06:26 +0100 | [diff] [blame] | 2154 | * If we're using 4-addr mode, let the AP know that we're |
| 2155 | * doing so, so that it can create the STA VLAN on its side |
| 2156 | */ |
| 2157 | if (ifmgd->use_4addr) |
| 2158 | ieee80211_send_4addr_nullfunc(local, sdata); |
| 2159 | |
| 2160 | /* |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2161 | * Start timer to probe the connection to the AP now. |
| 2162 | * Also start the timer that will detect beacon loss. |
Kalle Valo | 15b7b06 | 2009-03-22 21:57:14 +0200 | [diff] [blame] | 2163 | */ |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2164 | ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt); |
Luis R. Rodriguez | d3a910a | 2010-09-16 15:12:32 -0400 | [diff] [blame] | 2165 | ieee80211_sta_reset_beacon_monitor(sdata); |
Kalle Valo | 15b7b06 | 2009-03-22 21:57:14 +0200 | [diff] [blame] | 2166 | |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2167 | return true; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2168 | } |
| 2169 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2170 | static enum rx_mgmt_action __must_check |
| 2171 | ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, |
| 2172 | struct ieee80211_mgmt *mgmt, size_t len, |
| 2173 | struct cfg80211_bss **bss) |
| 2174 | { |
| 2175 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 2176 | struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; |
| 2177 | u16 capab_info, status_code, aid; |
| 2178 | struct ieee802_11_elems elems; |
| 2179 | u8 *pos; |
| 2180 | bool reassoc; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2181 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2182 | lockdep_assert_held(&ifmgd->mtx); |
| 2183 | |
| 2184 | if (!assoc_data) |
| 2185 | return RX_MGMT_NONE; |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 2186 | if (!ether_addr_equal(assoc_data->bss->bssid, mgmt->bssid)) |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2187 | return RX_MGMT_NONE; |
| 2188 | |
| 2189 | /* |
| 2190 | * AssocResp and ReassocResp have identical structure, so process both |
| 2191 | * of them in this function. |
| 2192 | */ |
| 2193 | |
| 2194 | if (len < 24 + 6) |
| 2195 | return RX_MGMT_NONE; |
| 2196 | |
| 2197 | reassoc = ieee80211_is_reassoc_req(mgmt->frame_control); |
| 2198 | capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); |
| 2199 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); |
| 2200 | aid = le16_to_cpu(mgmt->u.assoc_resp.aid); |
| 2201 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2202 | sdata_info(sdata, |
| 2203 | "RX %sssocResp from %pM (capab=0x%x status=%d aid=%d)\n", |
| 2204 | reassoc ? "Rea" : "A", mgmt->sa, |
| 2205 | capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2206 | |
| 2207 | pos = mgmt->u.assoc_resp.variable; |
| 2208 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); |
| 2209 | |
| 2210 | if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && |
| 2211 | elems.timeout_int && elems.timeout_int_len == 5 && |
| 2212 | elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { |
| 2213 | u32 tu, ms; |
| 2214 | tu = get_unaligned_le32(elems.timeout_int + 1); |
| 2215 | ms = tu * 1024 / 1000; |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2216 | sdata_info(sdata, |
| 2217 | "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n", |
| 2218 | mgmt->sa, tu, ms); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2219 | assoc_data->timeout = jiffies + msecs_to_jiffies(ms); |
| 2220 | if (ms > IEEE80211_ASSOC_TIMEOUT) |
| 2221 | run_again(ifmgd, assoc_data->timeout); |
| 2222 | return RX_MGMT_NONE; |
| 2223 | } |
| 2224 | |
| 2225 | *bss = assoc_data->bss; |
| 2226 | |
| 2227 | if (status_code != WLAN_STATUS_SUCCESS) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2228 | sdata_info(sdata, "%pM denied association (code=%d)\n", |
| 2229 | mgmt->sa, status_code); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2230 | ieee80211_destroy_assoc_data(sdata, false); |
| 2231 | } else { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2232 | if (!ieee80211_assoc_success(sdata, *bss, mgmt, len)) { |
| 2233 | /* oops -- internal error -- send timeout for now */ |
Eliad Peller | 10a9109 | 2012-07-02 14:42:03 +0300 | [diff] [blame] | 2234 | ieee80211_destroy_assoc_data(sdata, false); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2235 | cfg80211_put_bss(*bss); |
| 2236 | return RX_MGMT_CFG80211_ASSOC_TIMEOUT; |
| 2237 | } |
John W. Linville | 635d999 | 2012-07-09 16:34:34 -0400 | [diff] [blame] | 2238 | sdata_info(sdata, "associated\n"); |
Johannes Berg | 79ebfb8 | 2012-02-20 14:19:58 +0100 | [diff] [blame] | 2239 | |
| 2240 | /* |
| 2241 | * destroy assoc_data afterwards, as otherwise an idle |
| 2242 | * recalc after assoc_data is NULL but before associated |
| 2243 | * is set can cause the interface to go idle |
| 2244 | */ |
| 2245 | ieee80211_destroy_assoc_data(sdata, true); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2246 | } |
| 2247 | |
| 2248 | return RX_MGMT_CFG80211_RX_ASSOC; |
| 2249 | } |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 2250 | static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2251 | struct ieee80211_mgmt *mgmt, |
| 2252 | size_t len, |
| 2253 | struct ieee80211_rx_status *rx_status, |
Johannes Berg | 98c8fcc | 2008-09-08 17:44:26 +0200 | [diff] [blame] | 2254 | struct ieee802_11_elems *elems, |
| 2255 | bool beacon) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2256 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 2257 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 98c8fcc | 2008-09-08 17:44:26 +0200 | [diff] [blame] | 2258 | int freq; |
Johannes Berg | c2b1345 | 2008-09-11 00:01:55 +0200 | [diff] [blame] | 2259 | struct ieee80211_bss *bss; |
Johannes Berg | fab7d4a | 2008-03-16 18:42:44 +0100 | [diff] [blame] | 2260 | struct ieee80211_channel *channel; |
Johannes Berg | 56007a0 | 2010-01-26 14:19:52 +0100 | [diff] [blame] | 2261 | bool need_ps = false; |
| 2262 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2263 | if (sdata->u.mgd.associated && |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 2264 | ether_addr_equal(mgmt->bssid, sdata->u.mgd.associated->bssid)) { |
Johannes Berg | 56007a0 | 2010-01-26 14:19:52 +0100 | [diff] [blame] | 2265 | bss = (void *)sdata->u.mgd.associated->priv; |
| 2266 | /* not previously set so we may need to recalc */ |
| 2267 | need_ps = !bss->dtim_period; |
| 2268 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2269 | |
Johannes Berg | 5bda617 | 2008-09-08 11:05:10 +0200 | [diff] [blame] | 2270 | if (elems->ds_params && elems->ds_params_len == 1) |
Bruno Randolf | 59eb21a | 2011-01-17 13:37:28 +0900 | [diff] [blame] | 2271 | freq = ieee80211_channel_to_frequency(elems->ds_params[0], |
| 2272 | rx_status->band); |
Johannes Berg | 5bda617 | 2008-09-08 11:05:10 +0200 | [diff] [blame] | 2273 | else |
| 2274 | freq = rx_status->freq; |
| 2275 | |
| 2276 | channel = ieee80211_get_channel(local->hw.wiphy, freq); |
| 2277 | |
| 2278 | if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) |
| 2279 | return; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2280 | |
Johannes Berg | 98c8fcc | 2008-09-08 17:44:26 +0200 | [diff] [blame] | 2281 | bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 2282 | channel, beacon); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2283 | if (bss) |
| 2284 | ieee80211_rx_bss_put(local, bss); |
| 2285 | |
| 2286 | if (!sdata->u.mgd.associated) |
Johannes Berg | 98c8fcc | 2008-09-08 17:44:26 +0200 | [diff] [blame] | 2287 | return; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2288 | |
Johannes Berg | 56007a0 | 2010-01-26 14:19:52 +0100 | [diff] [blame] | 2289 | if (need_ps) { |
| 2290 | mutex_lock(&local->iflist_mtx); |
| 2291 | ieee80211_recalc_ps(local, -1); |
| 2292 | mutex_unlock(&local->iflist_mtx); |
| 2293 | } |
| 2294 | |
Johannes Berg | 5bc1420 | 2012-08-01 16:13:02 +0200 | [diff] [blame] | 2295 | if (elems->ch_switch_ie && |
| 2296 | memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, ETH_ALEN) == 0) |
| 2297 | ieee80211_sta_process_chanswitch(sdata, elems->ch_switch_ie, |
Johannes Berg | 5ce6e43 | 2010-05-11 16:20:57 +0200 | [diff] [blame] | 2298 | bss, rx_status->mactime); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2299 | } |
| 2300 | |
| 2301 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 2302 | static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2303 | struct sk_buff *skb) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2304 | { |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2305 | struct ieee80211_mgmt *mgmt = (void *)skb->data; |
Kalle Valo | 15b7b06 | 2009-03-22 21:57:14 +0200 | [diff] [blame] | 2306 | struct ieee80211_if_managed *ifmgd; |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 2307 | struct ieee80211_rx_status *rx_status = (void *) skb->cb; |
| 2308 | size_t baselen, len = skb->len; |
Ester Kummer | ae6a44e | 2008-06-27 18:54:48 +0300 | [diff] [blame] | 2309 | struct ieee802_11_elems elems; |
| 2310 | |
Kalle Valo | 15b7b06 | 2009-03-22 21:57:14 +0200 | [diff] [blame] | 2311 | ifmgd = &sdata->u.mgd; |
| 2312 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2313 | ASSERT_MGD_MTX(ifmgd); |
| 2314 | |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 2315 | if (!ether_addr_equal(mgmt->da, sdata->vif.addr)) |
Tomas Winkler | 8e7cdbb | 2008-08-03 14:32:01 +0300 | [diff] [blame] | 2316 | return; /* ignore ProbeResp to foreign address */ |
| 2317 | |
Ester Kummer | ae6a44e | 2008-06-27 18:54:48 +0300 | [diff] [blame] | 2318 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; |
| 2319 | if (baselen > len) |
| 2320 | return; |
| 2321 | |
| 2322 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, |
| 2323 | &elems); |
| 2324 | |
Johannes Berg | 98c8fcc | 2008-09-08 17:44:26 +0200 | [diff] [blame] | 2325 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); |
Ron Rindjunsky | 9859b81 | 2008-08-09 03:02:19 +0300 | [diff] [blame] | 2326 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2327 | if (ifmgd->associated && |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 2328 | ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 2329 | ieee80211_reset_ap_probe(sdata); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2330 | |
| 2331 | if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies && |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 2332 | ether_addr_equal(mgmt->bssid, ifmgd->auth_data->bss->bssid)) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2333 | /* got probe response, continue with auth */ |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2334 | sdata_info(sdata, "direct probe responded\n"); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2335 | ifmgd->auth_data->tries = 0; |
| 2336 | ifmgd->auth_data->timeout = jiffies; |
| 2337 | run_again(ifmgd, ifmgd->auth_data->timeout); |
| 2338 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2339 | } |
| 2340 | |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 2341 | /* |
| 2342 | * This is the canonical list of information elements we care about, |
| 2343 | * the filter code also gives us all changes to the Microsoft OUI |
| 2344 | * (00:50:F2) vendor IE which is used for WMM which we need to track. |
| 2345 | * |
| 2346 | * We implement beacon filtering in software since that means we can |
| 2347 | * avoid processing the frame here and in cfg80211, and userspace |
| 2348 | * will not be able to tell whether the hardware supports it or not. |
| 2349 | * |
| 2350 | * XXX: This list needs to be dynamic -- userspace needs to be able to |
| 2351 | * add items it requires. It also needs to be able to tell us to |
| 2352 | * look out for other vendor IEs. |
| 2353 | */ |
| 2354 | static const u64 care_about_ies = |
Johannes Berg | 1d4df3a | 2009-04-22 11:25:43 +0200 | [diff] [blame] | 2355 | (1ULL << WLAN_EID_COUNTRY) | |
| 2356 | (1ULL << WLAN_EID_ERP_INFO) | |
| 2357 | (1ULL << WLAN_EID_CHANNEL_SWITCH) | |
| 2358 | (1ULL << WLAN_EID_PWR_CONSTRAINT) | |
| 2359 | (1ULL << WLAN_EID_HT_CAPABILITY) | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 2360 | (1ULL << WLAN_EID_HT_OPERATION); |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 2361 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 2362 | static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2363 | struct ieee80211_mgmt *mgmt, |
| 2364 | size_t len, |
| 2365 | struct ieee80211_rx_status *rx_status) |
| 2366 | { |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 2367 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 2368 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2369 | size_t baselen; |
| 2370 | struct ieee802_11_elems elems; |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 2371 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 2372 | u32 changed = 0; |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 2373 | bool erp_valid, directed_tim = false; |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 2374 | u8 erp_value = 0; |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 2375 | u32 ncrc; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2376 | u8 *bssid; |
| 2377 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2378 | lockdep_assert_held(&ifmgd->mtx); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2379 | |
Ester Kummer | ae6a44e | 2008-06-27 18:54:48 +0300 | [diff] [blame] | 2380 | /* Process beacon from the current BSS */ |
| 2381 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; |
| 2382 | if (baselen > len) |
| 2383 | return; |
| 2384 | |
Johannes Berg | 568d6e2 | 2012-07-23 14:29:21 +0200 | [diff] [blame] | 2385 | if (rx_status->freq != local->oper_channel->center_freq) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2386 | return; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2387 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2388 | if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 2389 | ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2390 | ieee802_11_parse_elems(mgmt->u.beacon.variable, |
| 2391 | len - baselen, &elems); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2392 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2393 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, |
| 2394 | false); |
| 2395 | ifmgd->assoc_data->have_beacon = true; |
| 2396 | ifmgd->assoc_data->sent_assoc = false; |
| 2397 | /* continue assoc process */ |
| 2398 | ifmgd->assoc_data->timeout = jiffies; |
| 2399 | run_again(ifmgd, ifmgd->assoc_data->timeout); |
| 2400 | return; |
| 2401 | } |
| 2402 | |
| 2403 | if (!ifmgd->associated || |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 2404 | !ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2405 | return; |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 2406 | bssid = ifmgd->associated->bssid; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2407 | |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 2408 | /* Track average RSSI from the Beacon frames of the current AP */ |
| 2409 | ifmgd->last_beacon_signal = rx_status->signal; |
| 2410 | if (ifmgd->flags & IEEE80211_STA_RESET_SIGNAL_AVE) { |
| 2411 | ifmgd->flags &= ~IEEE80211_STA_RESET_SIGNAL_AVE; |
Jouni Malinen | 3ba06c6 | 2010-08-27 22:21:13 +0300 | [diff] [blame] | 2412 | ifmgd->ave_beacon_signal = rx_status->signal * 16; |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 2413 | ifmgd->last_cqm_event_signal = 0; |
Jouni Malinen | 391a200 | 2010-08-27 22:22:00 +0300 | [diff] [blame] | 2414 | ifmgd->count_beacon_signal = 1; |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 2415 | ifmgd->last_ave_beacon_signal = 0; |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 2416 | } else { |
| 2417 | ifmgd->ave_beacon_signal = |
| 2418 | (IEEE80211_SIGNAL_AVE_WEIGHT * rx_status->signal * 16 + |
| 2419 | (16 - IEEE80211_SIGNAL_AVE_WEIGHT) * |
| 2420 | ifmgd->ave_beacon_signal) / 16; |
Jouni Malinen | 391a200 | 2010-08-27 22:22:00 +0300 | [diff] [blame] | 2421 | ifmgd->count_beacon_signal++; |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 2422 | } |
Meenakshi Venkataraman | 615f7b9 | 2011-07-08 08:46:22 -0700 | [diff] [blame] | 2423 | |
| 2424 | if (ifmgd->rssi_min_thold != ifmgd->rssi_max_thold && |
| 2425 | ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT) { |
| 2426 | int sig = ifmgd->ave_beacon_signal; |
| 2427 | int last_sig = ifmgd->last_ave_beacon_signal; |
| 2428 | |
| 2429 | /* |
| 2430 | * if signal crosses either of the boundaries, invoke callback |
| 2431 | * with appropriate parameters |
| 2432 | */ |
| 2433 | if (sig > ifmgd->rssi_max_thold && |
| 2434 | (last_sig <= ifmgd->rssi_min_thold || last_sig == 0)) { |
| 2435 | ifmgd->last_ave_beacon_signal = sig; |
| 2436 | drv_rssi_callback(local, RSSI_EVENT_HIGH); |
| 2437 | } else if (sig < ifmgd->rssi_min_thold && |
| 2438 | (last_sig >= ifmgd->rssi_max_thold || |
| 2439 | last_sig == 0)) { |
| 2440 | ifmgd->last_ave_beacon_signal = sig; |
| 2441 | drv_rssi_callback(local, RSSI_EVENT_LOW); |
| 2442 | } |
| 2443 | } |
| 2444 | |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 2445 | if (bss_conf->cqm_rssi_thold && |
Jouni Malinen | 391a200 | 2010-08-27 22:22:00 +0300 | [diff] [blame] | 2446 | ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT && |
Johannes Berg | ea08635 | 2012-01-19 09:29:58 +0100 | [diff] [blame] | 2447 | !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) { |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 2448 | int sig = ifmgd->ave_beacon_signal / 16; |
| 2449 | int last_event = ifmgd->last_cqm_event_signal; |
| 2450 | int thold = bss_conf->cqm_rssi_thold; |
| 2451 | int hyst = bss_conf->cqm_rssi_hyst; |
| 2452 | if (sig < thold && |
| 2453 | (last_event == 0 || sig < last_event - hyst)) { |
| 2454 | ifmgd->last_cqm_event_signal = sig; |
| 2455 | ieee80211_cqm_rssi_notify( |
| 2456 | &sdata->vif, |
| 2457 | NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW, |
| 2458 | GFP_KERNEL); |
| 2459 | } else if (sig > thold && |
| 2460 | (last_event == 0 || sig > last_event + hyst)) { |
| 2461 | ifmgd->last_cqm_event_signal = sig; |
| 2462 | ieee80211_cqm_rssi_notify( |
| 2463 | &sdata->vif, |
| 2464 | NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH, |
| 2465 | GFP_KERNEL); |
| 2466 | } |
| 2467 | } |
| 2468 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2469 | if (ifmgd->flags & IEEE80211_STA_BEACON_POLL) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2470 | mlme_dbg_ratelimited(sdata, |
| 2471 | "cancelling probereq poll due to a received beacon\n"); |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 2472 | mutex_lock(&local->mtx); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2473 | ifmgd->flags &= ~IEEE80211_STA_BEACON_POLL; |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 2474 | ieee80211_run_deferred_scan(local); |
| 2475 | mutex_unlock(&local->mtx); |
| 2476 | |
Johannes Berg | 4e75184 | 2009-06-10 15:16:52 +0200 | [diff] [blame] | 2477 | mutex_lock(&local->iflist_mtx); |
| 2478 | ieee80211_recalc_ps(local, -1); |
| 2479 | mutex_unlock(&local->iflist_mtx); |
Jouni Malinen | 9277818 | 2009-05-14 21:15:36 +0300 | [diff] [blame] | 2480 | } |
| 2481 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2482 | /* |
| 2483 | * Push the beacon loss detection into the future since |
| 2484 | * we are processing a beacon from the AP just now. |
| 2485 | */ |
Luis R. Rodriguez | d3a910a | 2010-09-16 15:12:32 -0400 | [diff] [blame] | 2486 | ieee80211_sta_reset_beacon_monitor(sdata); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2487 | |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 2488 | ncrc = crc32_be(0, (void *)&mgmt->u.beacon.beacon_int, 4); |
| 2489 | ncrc = ieee802_11_parse_elems_crc(mgmt->u.beacon.variable, |
| 2490 | len - baselen, &elems, |
| 2491 | care_about_ies, ncrc); |
| 2492 | |
| 2493 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) |
Johannes Berg | e7ec86f | 2009-04-18 17:33:24 +0200 | [diff] [blame] | 2494 | directed_tim = ieee80211_check_tim(elems.tim, elems.tim_len, |
| 2495 | ifmgd->aid); |
Johannes Berg | d91f36d | 2009-04-16 13:17:26 +0200 | [diff] [blame] | 2496 | |
Vivek Natarajan | 25c9c87 | 2009-03-02 20:20:30 +0530 | [diff] [blame] | 2497 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) { |
Kalle Valo | 1fb3606 | 2009-02-10 17:09:24 +0200 | [diff] [blame] | 2498 | if (directed_tim) { |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 2499 | if (local->hw.conf.dynamic_ps_timeout > 0) { |
Ronald Wahl | 70b12f2 | 2012-03-19 14:37:20 +0100 | [diff] [blame] | 2500 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { |
| 2501 | local->hw.conf.flags &= ~IEEE80211_CONF_PS; |
| 2502 | ieee80211_hw_config(local, |
| 2503 | IEEE80211_CONF_CHANGE_PS); |
| 2504 | } |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 2505 | ieee80211_send_nullfunc(local, sdata, 0); |
Rajkumar Manoharan | 6f0756a | 2012-03-15 05:50:36 +0530 | [diff] [blame] | 2506 | } else if (!local->pspolling && sdata->u.mgd.powersave) { |
Kalle Valo | 572e001 | 2009-02-10 17:09:31 +0200 | [diff] [blame] | 2507 | local->pspolling = true; |
| 2508 | |
| 2509 | /* |
| 2510 | * Here is assumed that the driver will be |
| 2511 | * able to send ps-poll frame and receive a |
| 2512 | * response even though power save mode is |
| 2513 | * enabled, but some drivers might require |
| 2514 | * to disable power save here. This needs |
| 2515 | * to be investigated. |
| 2516 | */ |
| 2517 | ieee80211_send_pspoll(local, sdata); |
| 2518 | } |
Vivek Natarajan | a97b77b | 2008-12-23 18:39:02 -0800 | [diff] [blame] | 2519 | } |
| 2520 | } |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 2521 | |
Juuso Oikarinen | d8ec443 | 2010-10-01 16:02:31 +0300 | [diff] [blame] | 2522 | if (ncrc == ifmgd->beacon_crc && ifmgd->beacon_crc_valid) |
Jouni Malinen | 3019667 | 2009-05-19 17:01:43 +0300 | [diff] [blame] | 2523 | return; |
| 2524 | ifmgd->beacon_crc = ncrc; |
Juuso Oikarinen | d8ec443 | 2010-10-01 16:02:31 +0300 | [diff] [blame] | 2525 | ifmgd->beacon_crc_valid = true; |
Jouni Malinen | 3019667 | 2009-05-19 17:01:43 +0300 | [diff] [blame] | 2526 | |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 2527 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, |
| 2528 | true); |
| 2529 | |
| 2530 | if (ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, |
| 2531 | elems.wmm_param_len)) |
| 2532 | changed |= BSS_CHANGED_QOS; |
| 2533 | |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 2534 | if (elems.erp_info && elems.erp_info_len >= 1) { |
| 2535 | erp_valid = true; |
| 2536 | erp_value = elems.erp_info[0]; |
| 2537 | } else { |
| 2538 | erp_valid = false; |
John W. Linville | 50c4afb | 2008-04-15 14:09:27 -0400 | [diff] [blame] | 2539 | } |
Johannes Berg | 7a5158e | 2008-10-08 10:59:33 +0200 | [diff] [blame] | 2540 | changed |= ieee80211_handle_bss_capability(sdata, |
| 2541 | le16_to_cpu(mgmt->u.beacon.capab_info), |
| 2542 | erp_valid, erp_value); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2543 | |
Ron Rindjunsky | d3c990f | 2007-11-26 16:14:34 +0200 | [diff] [blame] | 2544 | |
Johannes Berg | 074d46d | 2012-03-15 19:45:16 +0100 | [diff] [blame] | 2545 | if (elems.ht_cap_elem && elems.ht_operation && elems.wmm_param && |
Johannes Berg | ab1faea | 2009-07-01 21:41:17 +0200 | [diff] [blame] | 2546 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) { |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 2547 | struct ieee80211_supported_band *sband; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 2548 | |
Johannes Berg | 568d6e2 | 2012-07-23 14:29:21 +0200 | [diff] [blame] | 2549 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 2550 | |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 2551 | changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation, |
| 2552 | bssid, true); |
Ron Rindjunsky | d3c990f | 2007-11-26 16:14:34 +0200 | [diff] [blame] | 2553 | } |
| 2554 | |
Johannes Berg | 04b7b2f | 2012-09-05 13:41:37 +0200 | [diff] [blame] | 2555 | if (elems.country_elem && elems.pwr_constr_elem && |
| 2556 | mgmt->u.probe_resp.capab_info & |
| 2557 | cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT)) |
| 2558 | ieee80211_handle_pwr_constr(sdata, local->oper_channel, |
| 2559 | elems.country_elem, |
| 2560 | elems.country_elem_len, |
| 2561 | elems.pwr_constr_elem); |
Luis R. Rodriguez | 3f2355c | 2008-11-12 14:22:02 -0800 | [diff] [blame] | 2562 | |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 2563 | ieee80211_bss_info_change_notify(sdata, changed); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2564 | } |
| 2565 | |
Johannes Berg | 1fa57d0 | 2010-06-10 10:21:32 +0200 | [diff] [blame] | 2566 | void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, |
| 2567 | struct sk_buff *skb) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2568 | { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2569 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2570 | struct ieee80211_rx_status *rx_status; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2571 | struct ieee80211_mgmt *mgmt; |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2572 | struct cfg80211_bss *bss = NULL; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2573 | enum rx_mgmt_action rma = RX_MGMT_NONE; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2574 | u16 fc; |
| 2575 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2576 | rx_status = (struct ieee80211_rx_status *) skb->cb; |
| 2577 | mgmt = (struct ieee80211_mgmt *) skb->data; |
| 2578 | fc = le16_to_cpu(mgmt->frame_control); |
| 2579 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2580 | mutex_lock(&ifmgd->mtx); |
| 2581 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2582 | switch (fc & IEEE80211_FCTL_STYPE) { |
| 2583 | case IEEE80211_STYPE_BEACON: |
| 2584 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, rx_status); |
| 2585 | break; |
| 2586 | case IEEE80211_STYPE_PROBE_RESP: |
| 2587 | ieee80211_rx_mgmt_probe_resp(sdata, skb); |
| 2588 | break; |
| 2589 | case IEEE80211_STYPE_AUTH: |
| 2590 | rma = ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len); |
| 2591 | break; |
| 2592 | case IEEE80211_STYPE_DEAUTH: |
| 2593 | rma = ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); |
| 2594 | break; |
| 2595 | case IEEE80211_STYPE_DISASSOC: |
| 2596 | rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); |
| 2597 | break; |
| 2598 | case IEEE80211_STYPE_ASSOC_RESP: |
| 2599 | case IEEE80211_STYPE_REASSOC_RESP: |
| 2600 | rma = ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, &bss); |
| 2601 | break; |
| 2602 | case IEEE80211_STYPE_ACTION: |
| 2603 | switch (mgmt->u.action.category) { |
| 2604 | case WLAN_CATEGORY_SPECTRUM_MGMT: |
| 2605 | ieee80211_sta_process_chanswitch(sdata, |
| 2606 | &mgmt->u.action.u.chan_switch.sw_elem, |
| 2607 | (void *)ifmgd->associated->priv, |
| 2608 | rx_status->mactime); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2609 | break; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2610 | } |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2611 | } |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2612 | mutex_unlock(&ifmgd->mtx); |
| 2613 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2614 | switch (rma) { |
| 2615 | case RX_MGMT_NONE: |
| 2616 | /* no action */ |
| 2617 | break; |
| 2618 | case RX_MGMT_CFG80211_DEAUTH: |
Holger Schurig | ce47061 | 2009-10-13 13:28:13 +0200 | [diff] [blame] | 2619 | cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2620 | break; |
| 2621 | case RX_MGMT_CFG80211_DISASSOC: |
| 2622 | cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len); |
| 2623 | break; |
| 2624 | case RX_MGMT_CFG80211_RX_AUTH: |
| 2625 | cfg80211_send_rx_auth(sdata->dev, (u8 *)mgmt, skb->len); |
| 2626 | break; |
| 2627 | case RX_MGMT_CFG80211_RX_ASSOC: |
| 2628 | cfg80211_send_rx_assoc(sdata->dev, bss, (u8 *)mgmt, skb->len); |
| 2629 | break; |
| 2630 | case RX_MGMT_CFG80211_ASSOC_TIMEOUT: |
| 2631 | cfg80211_send_assoc_timeout(sdata->dev, mgmt->bssid); |
| 2632 | break; |
| 2633 | default: |
| 2634 | WARN(1, "unexpected: %d", rma); |
Johannes Berg | b054b74 | 2010-06-07 21:50:07 +0200 | [diff] [blame] | 2635 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2636 | } |
| 2637 | |
Johannes Berg | 9c6bd79 | 2008-09-11 00:01:52 +0200 | [diff] [blame] | 2638 | static void ieee80211_sta_timer(unsigned long data) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2639 | { |
| 2640 | struct ieee80211_sub_if_data *sdata = |
| 2641 | (struct ieee80211_sub_if_data *) data; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 2642 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 2643 | struct ieee80211_local *local = sdata->local; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2644 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 2645 | if (local->quiescing) { |
| 2646 | set_bit(TMR_RUNNING_TIMER, &ifmgd->timers_running); |
| 2647 | return; |
| 2648 | } |
| 2649 | |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 2650 | ieee80211_queue_work(&local->hw, &sdata->work); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2651 | } |
| 2652 | |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2653 | static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 95acac6 | 2011-07-12 12:30:59 +0200 | [diff] [blame] | 2654 | u8 *bssid, u8 reason) |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2655 | { |
| 2656 | struct ieee80211_local *local = sdata->local; |
| 2657 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 2658 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2659 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 2660 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, reason, |
| 2661 | false, frame_buf); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2662 | mutex_unlock(&ifmgd->mtx); |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 2663 | |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2664 | /* |
| 2665 | * must be outside lock due to cfg80211, |
| 2666 | * but that's not a problem. |
| 2667 | */ |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 2668 | cfg80211_send_deauth(sdata->dev, frame_buf, IEEE80211_DEAUTH_FRAME_LEN); |
Felix Fietkau | fcac4fb | 2011-11-16 13:34:55 +0100 | [diff] [blame] | 2669 | |
| 2670 | mutex_lock(&local->mtx); |
| 2671 | ieee80211_recalc_idle(local); |
| 2672 | mutex_unlock(&local->mtx); |
| 2673 | |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2674 | mutex_lock(&ifmgd->mtx); |
| 2675 | } |
| 2676 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2677 | static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata) |
| 2678 | { |
| 2679 | struct ieee80211_local *local = sdata->local; |
| 2680 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 2681 | struct ieee80211_mgd_auth_data *auth_data = ifmgd->auth_data; |
| 2682 | |
| 2683 | lockdep_assert_held(&ifmgd->mtx); |
| 2684 | |
| 2685 | if (WARN_ON_ONCE(!auth_data)) |
| 2686 | return -EINVAL; |
| 2687 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2688 | auth_data->tries++; |
| 2689 | |
| 2690 | if (auth_data->tries > IEEE80211_AUTH_MAX_TRIES) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2691 | sdata_info(sdata, "authentication with %pM timed out\n", |
| 2692 | auth_data->bss->bssid); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2693 | |
| 2694 | /* |
| 2695 | * Most likely AP is not in the range so remove the |
| 2696 | * bss struct for that AP. |
| 2697 | */ |
| 2698 | cfg80211_unlink_bss(local->hw.wiphy, auth_data->bss); |
| 2699 | |
| 2700 | return -ETIMEDOUT; |
| 2701 | } |
| 2702 | |
Johannes Berg | a1845fc | 2012-06-27 13:18:36 +0200 | [diff] [blame] | 2703 | drv_mgd_prepare_tx(local, sdata); |
| 2704 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2705 | if (auth_data->bss->proberesp_ies) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2706 | sdata_info(sdata, "send auth to %pM (try %d/%d)\n", |
| 2707 | auth_data->bss->bssid, auth_data->tries, |
| 2708 | IEEE80211_AUTH_MAX_TRIES); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2709 | |
| 2710 | auth_data->expected_transaction = 2; |
| 2711 | ieee80211_send_auth(sdata, 1, auth_data->algorithm, |
| 2712 | auth_data->ie, auth_data->ie_len, |
| 2713 | auth_data->bss->bssid, |
| 2714 | auth_data->bss->bssid, NULL, 0, 0); |
| 2715 | } else { |
| 2716 | const u8 *ssidie; |
| 2717 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2718 | sdata_info(sdata, "direct probe to %pM (try %d/%i)\n", |
| 2719 | auth_data->bss->bssid, auth_data->tries, |
| 2720 | IEEE80211_AUTH_MAX_TRIES); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2721 | |
| 2722 | ssidie = ieee80211_bss_get_ie(auth_data->bss, WLAN_EID_SSID); |
| 2723 | if (!ssidie) |
| 2724 | return -EINVAL; |
| 2725 | /* |
| 2726 | * Direct probe is sent to broadcast address as some APs |
| 2727 | * will not answer to direct packet in unassociated state. |
| 2728 | */ |
| 2729 | ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1], |
Johannes Berg | fe94fe0 | 2012-07-30 12:26:34 +0200 | [diff] [blame] | 2730 | NULL, 0, (u32) -1, true, false, |
| 2731 | auth_data->bss->channel); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; |
| 2735 | run_again(ifmgd, auth_data->timeout); |
| 2736 | |
| 2737 | return 0; |
| 2738 | } |
| 2739 | |
| 2740 | static int ieee80211_do_assoc(struct ieee80211_sub_if_data *sdata) |
| 2741 | { |
| 2742 | struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; |
| 2743 | struct ieee80211_local *local = sdata->local; |
| 2744 | |
| 2745 | lockdep_assert_held(&sdata->u.mgd.mtx); |
| 2746 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2747 | assoc_data->tries++; |
| 2748 | if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2749 | sdata_info(sdata, "association with %pM timed out\n", |
| 2750 | assoc_data->bss->bssid); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2751 | |
| 2752 | /* |
| 2753 | * Most likely AP is not in the range so remove the |
| 2754 | * bss struct for that AP. |
| 2755 | */ |
| 2756 | cfg80211_unlink_bss(local->hw.wiphy, assoc_data->bss); |
| 2757 | |
| 2758 | return -ETIMEDOUT; |
| 2759 | } |
| 2760 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2761 | sdata_info(sdata, "associate with %pM (try %d/%d)\n", |
| 2762 | assoc_data->bss->bssid, assoc_data->tries, |
| 2763 | IEEE80211_ASSOC_MAX_TRIES); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2764 | ieee80211_send_assoc(sdata); |
| 2765 | |
| 2766 | assoc_data->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; |
| 2767 | run_again(&sdata->u.mgd, assoc_data->timeout); |
| 2768 | |
| 2769 | return 0; |
| 2770 | } |
| 2771 | |
Johannes Berg | 1fa57d0 | 2010-06-10 10:21:32 +0200 | [diff] [blame] | 2772 | void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 2773 | { |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 2774 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 1fa57d0 | 2010-06-10 10:21:32 +0200 | [diff] [blame] | 2775 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 2776 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2777 | mutex_lock(&ifmgd->mtx); |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 2778 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2779 | if (ifmgd->auth_data && |
| 2780 | time_after(jiffies, ifmgd->auth_data->timeout)) { |
| 2781 | if (ifmgd->auth_data->done) { |
| 2782 | /* |
| 2783 | * ok ... we waited for assoc but userspace didn't, |
| 2784 | * so let's just kill the auth data |
| 2785 | */ |
| 2786 | ieee80211_destroy_auth_data(sdata, false); |
| 2787 | } else if (ieee80211_probe_auth(sdata)) { |
| 2788 | u8 bssid[ETH_ALEN]; |
| 2789 | |
| 2790 | memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); |
| 2791 | |
| 2792 | ieee80211_destroy_auth_data(sdata, false); |
| 2793 | |
| 2794 | mutex_unlock(&ifmgd->mtx); |
| 2795 | cfg80211_send_auth_timeout(sdata->dev, bssid); |
| 2796 | mutex_lock(&ifmgd->mtx); |
| 2797 | } |
| 2798 | } else if (ifmgd->auth_data) |
| 2799 | run_again(ifmgd, ifmgd->auth_data->timeout); |
| 2800 | |
| 2801 | if (ifmgd->assoc_data && |
| 2802 | time_after(jiffies, ifmgd->assoc_data->timeout)) { |
| 2803 | if (!ifmgd->assoc_data->have_beacon || |
| 2804 | ieee80211_do_assoc(sdata)) { |
| 2805 | u8 bssid[ETH_ALEN]; |
| 2806 | |
| 2807 | memcpy(bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN); |
| 2808 | |
| 2809 | ieee80211_destroy_assoc_data(sdata, false); |
| 2810 | |
| 2811 | mutex_unlock(&ifmgd->mtx); |
| 2812 | cfg80211_send_assoc_timeout(sdata->dev, bssid); |
| 2813 | mutex_lock(&ifmgd->mtx); |
| 2814 | } |
| 2815 | } else if (ifmgd->assoc_data) |
| 2816 | run_again(ifmgd, ifmgd->assoc_data->timeout); |
| 2817 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2818 | if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | |
| 2819 | IEEE80211_STA_CONNECTION_POLL) && |
| 2820 | ifmgd->associated) { |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 2821 | u8 bssid[ETH_ALEN]; |
Felix Fietkau | 72a8a3e | 2010-11-23 03:10:32 +0100 | [diff] [blame] | 2822 | int max_tries; |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 2823 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 2824 | memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN); |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 2825 | |
Felix Fietkau | 72a8a3e | 2010-11-23 03:10:32 +0100 | [diff] [blame] | 2826 | if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) |
Ben Greear | 180205b | 2011-02-04 15:30:24 -0800 | [diff] [blame] | 2827 | max_tries = max_nullfunc_tries; |
Felix Fietkau | 72a8a3e | 2010-11-23 03:10:32 +0100 | [diff] [blame] | 2828 | else |
Ben Greear | 180205b | 2011-02-04 15:30:24 -0800 | [diff] [blame] | 2829 | max_tries = max_probe_tries; |
Felix Fietkau | 72a8a3e | 2010-11-23 03:10:32 +0100 | [diff] [blame] | 2830 | |
Felix Fietkau | 4e5ff37 | 2010-11-23 03:10:31 +0100 | [diff] [blame] | 2831 | /* ACK received for nullfunc probing frame */ |
| 2832 | if (!ifmgd->probe_send_count) |
| 2833 | ieee80211_reset_ap_probe(sdata); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2834 | else if (ifmgd->nullfunc_failed) { |
| 2835 | if (ifmgd->probe_send_count < max_tries) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2836 | mlme_dbg(sdata, |
| 2837 | "No ack for nullfunc frame to AP %pM, try %d/%i\n", |
| 2838 | bssid, ifmgd->probe_send_count, |
| 2839 | max_tries); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2840 | ieee80211_mgd_probe_ap_send(sdata); |
| 2841 | } else { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2842 | mlme_dbg(sdata, |
| 2843 | "No ack for nullfunc frame to AP %pM, disconnecting.\n", |
| 2844 | bssid); |
Johannes Berg | 95acac6 | 2011-07-12 12:30:59 +0200 | [diff] [blame] | 2845 | ieee80211_sta_connection_lost(sdata, bssid, |
| 2846 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2847 | } |
| 2848 | } else if (time_is_after_jiffies(ifmgd->probe_timeout)) |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2849 | run_again(ifmgd, ifmgd->probe_timeout); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2850 | else if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2851 | mlme_dbg(sdata, |
| 2852 | "Failed to send nullfunc to AP %pM after %dms, disconnecting\n", |
| 2853 | bssid, probe_wait_ms); |
Johannes Berg | 95acac6 | 2011-07-12 12:30:59 +0200 | [diff] [blame] | 2854 | ieee80211_sta_connection_lost(sdata, bssid, |
| 2855 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2856 | } else if (ifmgd->probe_send_count < max_tries) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2857 | mlme_dbg(sdata, |
| 2858 | "No probe response from AP %pM after %dms, try %d/%i\n", |
| 2859 | bssid, probe_wait_ms, |
| 2860 | ifmgd->probe_send_count, max_tries); |
Maxim Levitsky | a43abf2 | 2009-07-31 18:54:12 +0300 | [diff] [blame] | 2861 | ieee80211_mgd_probe_ap_send(sdata); |
| 2862 | } else { |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2863 | /* |
| 2864 | * We actually lost the connection ... or did we? |
| 2865 | * Let's make sure! |
| 2866 | */ |
Ben Greear | b38afa8 | 2010-10-07 16:12:06 -0700 | [diff] [blame] | 2867 | wiphy_debug(local->hw.wiphy, |
| 2868 | "%s: No probe response from AP %pM" |
| 2869 | " after %dms, disconnecting.\n", |
| 2870 | sdata->name, |
Ben Greear | 180205b | 2011-02-04 15:30:24 -0800 | [diff] [blame] | 2871 | bssid, probe_wait_ms); |
Felix Fietkau | 04ac3c0 | 2010-12-02 21:01:08 +0100 | [diff] [blame] | 2872 | |
Johannes Berg | 95acac6 | 2011-07-12 12:30:59 +0200 | [diff] [blame] | 2873 | ieee80211_sta_connection_lost(sdata, bssid, |
| 2874 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2875 | } |
| 2876 | } |
| 2877 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2878 | mutex_unlock(&ifmgd->mtx); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 2879 | |
| 2880 | mutex_lock(&local->mtx); |
| 2881 | ieee80211_recalc_idle(local); |
| 2882 | mutex_unlock(&local->mtx); |
Johannes Berg | 60f8b39 | 2008-09-08 17:44:22 +0200 | [diff] [blame] | 2883 | } |
Johannes Berg | 0a51b27 | 2008-09-08 17:44:25 +0200 | [diff] [blame] | 2884 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2885 | static void ieee80211_sta_bcn_mon_timer(unsigned long data) |
| 2886 | { |
| 2887 | struct ieee80211_sub_if_data *sdata = |
| 2888 | (struct ieee80211_sub_if_data *) data; |
| 2889 | struct ieee80211_local *local = sdata->local; |
| 2890 | |
| 2891 | if (local->quiescing) |
| 2892 | return; |
| 2893 | |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 2894 | ieee80211_queue_work(&sdata->local->hw, |
| 2895 | &sdata->u.mgd.beacon_connection_loss_work); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2896 | } |
| 2897 | |
| 2898 | static void ieee80211_sta_conn_mon_timer(unsigned long data) |
| 2899 | { |
| 2900 | struct ieee80211_sub_if_data *sdata = |
| 2901 | (struct ieee80211_sub_if_data *) data; |
| 2902 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 2903 | struct ieee80211_local *local = sdata->local; |
| 2904 | |
| 2905 | if (local->quiescing) |
| 2906 | return; |
| 2907 | |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 2908 | ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2909 | } |
| 2910 | |
| 2911 | static void ieee80211_sta_monitor_work(struct work_struct *work) |
| 2912 | { |
| 2913 | struct ieee80211_sub_if_data *sdata = |
| 2914 | container_of(work, struct ieee80211_sub_if_data, |
| 2915 | u.mgd.monitor_work); |
| 2916 | |
| 2917 | ieee80211_mgd_probe_ap(sdata, false); |
| 2918 | } |
| 2919 | |
Johannes Berg | a1678f8 | 2008-09-11 00:01:47 +0200 | [diff] [blame] | 2920 | static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata) |
| 2921 | { |
Eliad Peller | 494f1fe | 2012-02-19 15:26:09 +0200 | [diff] [blame] | 2922 | u32 flags; |
| 2923 | |
Kalle Valo | ad93568 | 2009-04-19 08:47:19 +0300 | [diff] [blame] | 2924 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 2925 | __ieee80211_stop_poll(sdata); |
Kalle Valo | ad93568 | 2009-04-19 08:47:19 +0300 | [diff] [blame] | 2926 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2927 | /* let's probe the connection once */ |
Eliad Peller | 494f1fe | 2012-02-19 15:26:09 +0200 | [diff] [blame] | 2928 | flags = sdata->local->hw.flags; |
| 2929 | if (!(flags & IEEE80211_HW_CONNECTION_MONITOR)) |
| 2930 | ieee80211_queue_work(&sdata->local->hw, |
| 2931 | &sdata->u.mgd.monitor_work); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2932 | /* and do all the other regular work too */ |
Johannes Berg | 64592c8 | 2010-06-10 10:21:31 +0200 | [diff] [blame] | 2933 | ieee80211_queue_work(&sdata->local->hw, &sdata->work); |
Kalle Valo | ad93568 | 2009-04-19 08:47:19 +0300 | [diff] [blame] | 2934 | } |
Johannes Berg | a1678f8 | 2008-09-11 00:01:47 +0200 | [diff] [blame] | 2935 | } |
| 2936 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 2937 | #ifdef CONFIG_PM |
| 2938 | void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata) |
| 2939 | { |
| 2940 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 2941 | |
| 2942 | /* |
| 2943 | * we need to use atomic bitops for the running bits |
| 2944 | * only because both timers might fire at the same |
| 2945 | * time -- the code here is properly synchronised. |
| 2946 | */ |
| 2947 | |
Johannes Berg | d1f5b7a | 2010-08-05 17:05:55 +0200 | [diff] [blame] | 2948 | cancel_work_sync(&ifmgd->request_smps_work); |
| 2949 | |
Johannes Berg | 0ecfe806 | 2011-11-09 12:14:16 +0100 | [diff] [blame] | 2950 | cancel_work_sync(&ifmgd->monitor_work); |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 2951 | cancel_work_sync(&ifmgd->beacon_connection_loss_work); |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 2952 | cancel_work_sync(&ifmgd->csa_connection_drop_work); |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 2953 | if (del_timer_sync(&ifmgd->timer)) |
| 2954 | set_bit(TMR_RUNNING_TIMER, &ifmgd->timers_running); |
| 2955 | |
| 2956 | cancel_work_sync(&ifmgd->chswitch_work); |
| 2957 | if (del_timer_sync(&ifmgd->chswitch_timer)) |
| 2958 | set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2959 | |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 2960 | /* these will just be re-established on connection */ |
| 2961 | del_timer_sync(&ifmgd->conn_mon_timer); |
| 2962 | del_timer_sync(&ifmgd->bcn_mon_timer); |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 2963 | } |
| 2964 | |
| 2965 | void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) |
| 2966 | { |
| 2967 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 2968 | |
Rajkumar Manoharan | 676b58c | 2011-07-07 23:33:39 +0530 | [diff] [blame] | 2969 | if (!ifmgd->associated) |
| 2970 | return; |
| 2971 | |
Johannes Berg | 95acac6 | 2011-07-12 12:30:59 +0200 | [diff] [blame] | 2972 | if (sdata->flags & IEEE80211_SDATA_DISCONNECT_RESUME) { |
| 2973 | sdata->flags &= ~IEEE80211_SDATA_DISCONNECT_RESUME; |
| 2974 | mutex_lock(&ifmgd->mtx); |
| 2975 | if (ifmgd->associated) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2976 | mlme_dbg(sdata, |
| 2977 | "driver requested disconnect after resume\n"); |
Johannes Berg | 95acac6 | 2011-07-12 12:30:59 +0200 | [diff] [blame] | 2978 | ieee80211_sta_connection_lost(sdata, |
| 2979 | ifmgd->associated->bssid, |
| 2980 | WLAN_REASON_UNSPECIFIED); |
| 2981 | mutex_unlock(&ifmgd->mtx); |
| 2982 | return; |
| 2983 | } |
| 2984 | mutex_unlock(&ifmgd->mtx); |
| 2985 | } |
| 2986 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 2987 | if (test_and_clear_bit(TMR_RUNNING_TIMER, &ifmgd->timers_running)) |
| 2988 | add_timer(&ifmgd->timer); |
| 2989 | if (test_and_clear_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running)) |
| 2990 | add_timer(&ifmgd->chswitch_timer); |
Felix Fietkau | c8a7972 | 2010-11-19 22:55:37 +0100 | [diff] [blame] | 2991 | ieee80211_sta_reset_beacon_monitor(sdata); |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 2992 | |
| 2993 | mutex_lock(&sdata->local->mtx); |
Felix Fietkau | 4609097 | 2010-11-23 20:28:03 +0100 | [diff] [blame] | 2994 | ieee80211_restart_sta_timer(sdata); |
Stanislaw Gruszka | 925e64c | 2012-05-16 15:27:20 +0200 | [diff] [blame] | 2995 | mutex_unlock(&sdata->local->mtx); |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 2996 | } |
| 2997 | #endif |
| 2998 | |
Johannes Berg | 9c6bd79 | 2008-09-11 00:01:52 +0200 | [diff] [blame] | 2999 | /* interface setup */ |
| 3000 | void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) |
| 3001 | { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 3002 | struct ieee80211_if_managed *ifmgd; |
Johannes Berg | 9c6bd79 | 2008-09-11 00:01:52 +0200 | [diff] [blame] | 3003 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 3004 | ifmgd = &sdata->u.mgd; |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 3005 | INIT_WORK(&ifmgd->monitor_work, ieee80211_sta_monitor_work); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 3006 | INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work); |
Juuso Oikarinen | 1e4dcd0 | 2010-03-19 07:14:53 +0200 | [diff] [blame] | 3007 | INIT_WORK(&ifmgd->beacon_connection_loss_work, |
| 3008 | ieee80211_beacon_connection_loss_work); |
Johannes Berg | 882a7c6 | 2012-08-01 22:32:45 +0200 | [diff] [blame] | 3009 | INIT_WORK(&ifmgd->csa_connection_drop_work, |
| 3010 | ieee80211_csa_connection_drop_work); |
Johannes Berg | d1f5b7a | 2010-08-05 17:05:55 +0200 | [diff] [blame] | 3011 | INIT_WORK(&ifmgd->request_smps_work, ieee80211_request_smps_work); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 3012 | setup_timer(&ifmgd->timer, ieee80211_sta_timer, |
Johannes Berg | 9c6bd79 | 2008-09-11 00:01:52 +0200 | [diff] [blame] | 3013 | (unsigned long) sdata); |
Johannes Berg | b291ba1 | 2009-07-10 15:29:03 +0200 | [diff] [blame] | 3014 | setup_timer(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, |
| 3015 | (unsigned long) sdata); |
| 3016 | setup_timer(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, |
| 3017 | (unsigned long) sdata); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 3018 | setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, |
Sujith | c481ec9 | 2009-01-06 09:28:37 +0530 | [diff] [blame] | 3019 | (unsigned long) sdata); |
Johannes Berg | 9c6bd79 | 2008-09-11 00:01:52 +0200 | [diff] [blame] | 3020 | |
Johannes Berg | ab1faea | 2009-07-01 21:41:17 +0200 | [diff] [blame] | 3021 | ifmgd->flags = 0; |
Mohammed Shafi Shajakhan | 1478acb | 2011-12-14 19:46:08 +0530 | [diff] [blame] | 3022 | ifmgd->powersave = sdata->wdev.ps; |
Eliad Peller | dc41e4d | 2012-03-14 16:15:03 +0200 | [diff] [blame] | 3023 | ifmgd->uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; |
| 3024 | ifmgd->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; |
Johannes Berg | bbbdff9 | 2009-04-16 13:27:42 +0200 | [diff] [blame] | 3025 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3026 | mutex_init(&ifmgd->mtx); |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 3027 | |
| 3028 | if (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) |
| 3029 | ifmgd->req_smps = IEEE80211_SMPS_AUTOMATIC; |
| 3030 | else |
| 3031 | ifmgd->req_smps = IEEE80211_SMPS_OFF; |
Johannes Berg | 9c6bd79 | 2008-09-11 00:01:52 +0200 | [diff] [blame] | 3032 | } |
| 3033 | |
| 3034 | /* scan finished notification */ |
Johannes Berg | 0a51b27 | 2008-09-08 17:44:25 +0200 | [diff] [blame] | 3035 | void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) |
| 3036 | { |
Johannes Berg | 31ee67a | 2012-07-06 21:18:24 +0200 | [diff] [blame] | 3037 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | a1678f8 | 2008-09-11 00:01:47 +0200 | [diff] [blame] | 3038 | |
| 3039 | /* Restart STA timers */ |
| 3040 | rcu_read_lock(); |
| 3041 | list_for_each_entry_rcu(sdata, &local->interfaces, list) |
| 3042 | ieee80211_restart_sta_timer(sdata); |
| 3043 | rcu_read_unlock(); |
Johannes Berg | 0a51b27 | 2008-09-08 17:44:25 +0200 | [diff] [blame] | 3044 | } |
Johannes Berg | 10f644a | 2009-04-16 13:17:25 +0200 | [diff] [blame] | 3045 | |
| 3046 | int ieee80211_max_network_latency(struct notifier_block *nb, |
| 3047 | unsigned long data, void *dummy) |
| 3048 | { |
| 3049 | s32 latency_usec = (s32) data; |
| 3050 | struct ieee80211_local *local = |
| 3051 | container_of(nb, struct ieee80211_local, |
| 3052 | network_latency_notifier); |
| 3053 | |
| 3054 | mutex_lock(&local->iflist_mtx); |
| 3055 | ieee80211_recalc_ps(local, latency_usec); |
| 3056 | mutex_unlock(&local->iflist_mtx); |
| 3057 | |
| 3058 | return 0; |
| 3059 | } |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3060 | |
Johannes Berg | b17166a | 2012-07-27 11:41:27 +0200 | [diff] [blame] | 3061 | static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata, |
| 3062 | struct cfg80211_bss *cbss) |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3063 | { |
| 3064 | struct ieee80211_local *local = sdata->local; |
| 3065 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 3066 | int ht_cfreq; |
| 3067 | enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; |
| 3068 | const u8 *ht_oper_ie; |
| 3069 | const struct ieee80211_ht_operation *ht_oper = NULL; |
| 3070 | struct ieee80211_supported_band *sband; |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3071 | |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 3072 | sband = local->hw.wiphy->bands[cbss->channel->band]; |
| 3073 | |
| 3074 | ifmgd->flags &= ~IEEE80211_STA_DISABLE_40MHZ; |
| 3075 | |
| 3076 | if (sband->ht_cap.ht_supported) { |
| 3077 | ht_oper_ie = cfg80211_find_ie(WLAN_EID_HT_OPERATION, |
| 3078 | cbss->information_elements, |
| 3079 | cbss->len_information_elements); |
| 3080 | if (ht_oper_ie && ht_oper_ie[1] >= sizeof(*ht_oper)) |
| 3081 | ht_oper = (void *)(ht_oper_ie + 2); |
| 3082 | } |
| 3083 | |
| 3084 | if (ht_oper) { |
| 3085 | ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan, |
| 3086 | cbss->channel->band); |
| 3087 | /* check that channel matches the right operating channel */ |
| 3088 | if (cbss->channel->center_freq != ht_cfreq) { |
| 3089 | /* |
| 3090 | * It's possible that some APs are confused here; |
| 3091 | * Netgear WNDR3700 sometimes reports 4 higher than |
| 3092 | * the actual channel in association responses, but |
| 3093 | * since we look at probe response/beacon data here |
| 3094 | * it should be OK. |
| 3095 | */ |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3096 | sdata_info(sdata, |
| 3097 | "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n", |
| 3098 | cbss->channel->center_freq, |
| 3099 | ht_cfreq, ht_oper->primary_chan, |
| 3100 | cbss->channel->band); |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 3101 | ht_oper = NULL; |
| 3102 | } |
| 3103 | } |
| 3104 | |
| 3105 | if (ht_oper) { |
| 3106 | channel_type = NL80211_CHAN_HT20; |
| 3107 | |
| 3108 | if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { |
| 3109 | switch (ht_oper->ht_param & |
| 3110 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { |
| 3111 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
| 3112 | channel_type = NL80211_CHAN_HT40PLUS; |
| 3113 | break; |
| 3114 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
| 3115 | channel_type = NL80211_CHAN_HT40MINUS; |
| 3116 | break; |
| 3117 | } |
| 3118 | } |
| 3119 | } |
| 3120 | |
| 3121 | if (!ieee80211_set_channel_type(local, sdata, channel_type)) { |
| 3122 | /* can only fail due to HT40+/- mismatch */ |
| 3123 | channel_type = NL80211_CHAN_HT20; |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3124 | sdata_info(sdata, |
| 3125 | "disabling 40 MHz due to multi-vif mismatch\n"); |
Johannes Berg | 24398e3 | 2012-03-28 10:58:36 +0200 | [diff] [blame] | 3126 | ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ; |
| 3127 | WARN_ON(!ieee80211_set_channel_type(local, sdata, |
| 3128 | channel_type)); |
| 3129 | } |
| 3130 | |
Johannes Berg | 5d6a1b0 | 2012-03-08 15:02:08 +0100 | [diff] [blame] | 3131 | local->oper_channel = cbss->channel; |
Stanislaw Gruszka | 6aee4ca | 2012-06-07 14:47:21 +0200 | [diff] [blame] | 3132 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3133 | |
Johannes Berg | b17166a | 2012-07-27 11:41:27 +0200 | [diff] [blame] | 3134 | return 0; |
| 3135 | } |
| 3136 | |
| 3137 | static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, |
| 3138 | struct cfg80211_bss *cbss, bool assoc) |
| 3139 | { |
| 3140 | struct ieee80211_local *local = sdata->local; |
| 3141 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 3142 | struct ieee80211_bss *bss = (void *)cbss->priv; |
| 3143 | struct sta_info *new_sta = NULL; |
| 3144 | bool have_sta = false; |
| 3145 | int err; |
| 3146 | |
| 3147 | if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data)) |
| 3148 | return -EINVAL; |
| 3149 | |
| 3150 | if (assoc) { |
| 3151 | rcu_read_lock(); |
| 3152 | have_sta = sta_info_get(sdata, cbss->bssid); |
| 3153 | rcu_read_unlock(); |
| 3154 | } |
| 3155 | |
| 3156 | if (!have_sta) { |
| 3157 | new_sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL); |
| 3158 | if (!new_sta) |
| 3159 | return -ENOMEM; |
| 3160 | } |
| 3161 | |
| 3162 | mutex_lock(&local->mtx); |
| 3163 | ieee80211_recalc_idle(sdata->local); |
| 3164 | mutex_unlock(&local->mtx); |
| 3165 | |
Johannes Berg | 13e0c8e | 2012-07-27 10:43:16 +0200 | [diff] [blame] | 3166 | if (new_sta) { |
Johannes Berg | 5d6a1b0 | 2012-03-08 15:02:08 +0100 | [diff] [blame] | 3167 | u32 rates = 0, basic_rates = 0; |
| 3168 | bool have_higher_than_11mbit; |
| 3169 | int min_rate = INT_MAX, min_rate_index = -1; |
Johannes Berg | b17166a | 2012-07-27 11:41:27 +0200 | [diff] [blame] | 3170 | struct ieee80211_supported_band *sband; |
| 3171 | |
| 3172 | sband = local->hw.wiphy->bands[cbss->channel->band]; |
| 3173 | |
| 3174 | err = ieee80211_prep_channel(sdata, cbss); |
| 3175 | if (err) { |
| 3176 | sta_info_free(local, new_sta); |
| 3177 | return err; |
| 3178 | } |
Johannes Berg | 5d6a1b0 | 2012-03-08 15:02:08 +0100 | [diff] [blame] | 3179 | |
Johannes Berg | 5d6a1b0 | 2012-03-08 15:02:08 +0100 | [diff] [blame] | 3180 | ieee80211_get_rates(sband, bss->supp_rates, |
| 3181 | bss->supp_rates_len, |
| 3182 | &rates, &basic_rates, |
| 3183 | &have_higher_than_11mbit, |
| 3184 | &min_rate, &min_rate_index); |
| 3185 | |
| 3186 | /* |
| 3187 | * This used to be a workaround for basic rates missing |
| 3188 | * in the association response frame. Now that we no |
| 3189 | * longer use the basic rates from there, it probably |
| 3190 | * doesn't happen any more, but keep the workaround so |
| 3191 | * in case some *other* APs are buggy in different ways |
| 3192 | * we can connect -- with a warning. |
| 3193 | */ |
| 3194 | if (!basic_rates && min_rate_index >= 0) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3195 | sdata_info(sdata, |
| 3196 | "No basic rates, using min rate instead\n"); |
Johannes Berg | 5d6a1b0 | 2012-03-08 15:02:08 +0100 | [diff] [blame] | 3197 | basic_rates = BIT(min_rate_index); |
| 3198 | } |
| 3199 | |
Johannes Berg | 13e0c8e | 2012-07-27 10:43:16 +0200 | [diff] [blame] | 3200 | new_sta->sta.supp_rates[cbss->channel->band] = rates; |
Johannes Berg | 5d6a1b0 | 2012-03-08 15:02:08 +0100 | [diff] [blame] | 3201 | sdata->vif.bss_conf.basic_rates = basic_rates; |
| 3202 | |
| 3203 | /* cf. IEEE 802.11 9.2.12 */ |
| 3204 | if (local->oper_channel->band == IEEE80211_BAND_2GHZ && |
| 3205 | have_higher_than_11mbit) |
| 3206 | sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; |
| 3207 | else |
| 3208 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; |
| 3209 | |
| 3210 | memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN); |
| 3211 | |
Johannes Berg | 8c358bc | 2012-05-22 22:13:05 +0200 | [diff] [blame] | 3212 | /* set timing information */ |
| 3213 | sdata->vif.bss_conf.beacon_int = cbss->beacon_interval; |
| 3214 | sdata->vif.bss_conf.sync_tsf = cbss->tsf; |
| 3215 | sdata->vif.bss_conf.sync_device_ts = bss->device_ts; |
| 3216 | |
| 3217 | /* tell driver about BSSID, basic rates and timing */ |
Johannes Berg | 5d6a1b0 | 2012-03-08 15:02:08 +0100 | [diff] [blame] | 3218 | ieee80211_bss_info_change_notify(sdata, |
Johannes Berg | 8c358bc | 2012-05-22 22:13:05 +0200 | [diff] [blame] | 3219 | BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES | |
| 3220 | BSS_CHANGED_BEACON_INT); |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3221 | |
| 3222 | if (assoc) |
Johannes Berg | 13e0c8e | 2012-07-27 10:43:16 +0200 | [diff] [blame] | 3223 | sta_info_pre_move_state(new_sta, IEEE80211_STA_AUTH); |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3224 | |
Johannes Berg | 13e0c8e | 2012-07-27 10:43:16 +0200 | [diff] [blame] | 3225 | err = sta_info_insert(new_sta); |
| 3226 | new_sta = NULL; |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3227 | if (err) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3228 | sdata_info(sdata, |
| 3229 | "failed to insert STA entry for the AP (error %d)\n", |
| 3230 | err); |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3231 | return err; |
| 3232 | } |
| 3233 | } else |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 3234 | WARN_ON_ONCE(!ether_addr_equal(ifmgd->bssid, cbss->bssid)); |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3235 | |
| 3236 | return 0; |
| 3237 | } |
| 3238 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3239 | /* config hooks */ |
| 3240 | int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, |
| 3241 | struct cfg80211_auth_request *req) |
| 3242 | { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3243 | struct ieee80211_local *local = sdata->local; |
| 3244 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 3245 | struct ieee80211_mgd_auth_data *auth_data; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3246 | u16 auth_alg; |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3247 | int err; |
| 3248 | |
| 3249 | /* prepare auth data structure */ |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3250 | |
| 3251 | switch (req->auth_type) { |
| 3252 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
| 3253 | auth_alg = WLAN_AUTH_OPEN; |
| 3254 | break; |
| 3255 | case NL80211_AUTHTYPE_SHARED_KEY: |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3256 | if (IS_ERR(local->wep_tx_tfm)) |
Johannes Berg | 9dca9c4 | 2010-07-21 10:09:25 +0200 | [diff] [blame] | 3257 | return -EOPNOTSUPP; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3258 | auth_alg = WLAN_AUTH_SHARED_KEY; |
| 3259 | break; |
| 3260 | case NL80211_AUTHTYPE_FT: |
| 3261 | auth_alg = WLAN_AUTH_FT; |
| 3262 | break; |
| 3263 | case NL80211_AUTHTYPE_NETWORK_EAP: |
| 3264 | auth_alg = WLAN_AUTH_LEAP; |
| 3265 | break; |
| 3266 | default: |
| 3267 | return -EOPNOTSUPP; |
| 3268 | } |
| 3269 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3270 | auth_data = kzalloc(sizeof(*auth_data) + req->ie_len, GFP_KERNEL); |
| 3271 | if (!auth_data) |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3272 | return -ENOMEM; |
| 3273 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3274 | auth_data->bss = req->bss; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3275 | |
| 3276 | if (req->ie && req->ie_len) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3277 | memcpy(auth_data->ie, req->ie, req->ie_len); |
| 3278 | auth_data->ie_len = req->ie_len; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3279 | } |
| 3280 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 3281 | if (req->key && req->key_len) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3282 | auth_data->key_len = req->key_len; |
| 3283 | auth_data->key_idx = req->key_idx; |
| 3284 | memcpy(auth_data->key, req->key, req->key_len); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 3285 | } |
| 3286 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3287 | auth_data->algorithm = auth_alg; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3288 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3289 | /* try to authenticate/probe */ |
Johannes Berg | f679f65 | 2009-12-23 13:15:34 +0100 | [diff] [blame] | 3290 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3291 | mutex_lock(&ifmgd->mtx); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3292 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3293 | if ((ifmgd->auth_data && !ifmgd->auth_data->done) || |
| 3294 | ifmgd->assoc_data) { |
| 3295 | err = -EBUSY; |
| 3296 | goto err_free; |
| 3297 | } |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3298 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3299 | if (ifmgd->auth_data) |
| 3300 | ieee80211_destroy_auth_data(sdata, false); |
Guy Eilam | 2a33bee | 2011-08-17 15:18:15 +0300 | [diff] [blame] | 3301 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3302 | /* prep auth_data so we don't go into idle on disassoc */ |
| 3303 | ifmgd->auth_data = auth_data; |
| 3304 | |
| 3305 | if (ifmgd->associated) |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3306 | ieee80211_set_disassoc(sdata, 0, 0, false, NULL); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3307 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3308 | sdata_info(sdata, "authenticate with %pM\n", req->bss->bssid); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3309 | |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3310 | err = ieee80211_prep_connection(sdata, req->bss, false); |
| 3311 | if (err) |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3312 | goto err_clear; |
Guy Eilam | 2a33bee | 2011-08-17 15:18:15 +0300 | [diff] [blame] | 3313 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3314 | err = ieee80211_probe_auth(sdata); |
| 3315 | if (err) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3316 | sta_info_destroy_addr(sdata, req->bss->bssid); |
| 3317 | goto err_clear; |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 3318 | } |
| 3319 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3320 | /* hold our own reference */ |
| 3321 | cfg80211_ref_bss(auth_data->bss); |
| 3322 | err = 0; |
| 3323 | goto out_unlock; |
Johannes Berg | e5b900d | 2010-07-29 16:08:55 +0200 | [diff] [blame] | 3324 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3325 | err_clear: |
Eliad Peller | 3d2abdf | 2012-09-04 17:44:45 +0300 | [diff] [blame] | 3326 | memset(ifmgd->bssid, 0, ETH_ALEN); |
| 3327 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3328 | ifmgd->auth_data = NULL; |
| 3329 | err_free: |
| 3330 | kfree(auth_data); |
| 3331 | out_unlock: |
| 3332 | mutex_unlock(&ifmgd->mtx); |
Johannes Berg | e5b900d | 2010-07-29 16:08:55 +0200 | [diff] [blame] | 3333 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3334 | return err; |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 3335 | } |
| 3336 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3337 | int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, |
| 3338 | struct cfg80211_assoc_request *req) |
| 3339 | { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3340 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3341 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 3342 | struct ieee80211_bss *bss = (void *)req->bss->priv; |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3343 | struct ieee80211_mgd_assoc_data *assoc_data; |
Johannes Berg | 4e74bfd | 2012-03-08 15:02:04 +0100 | [diff] [blame] | 3344 | struct ieee80211_supported_band *sband; |
Johannes Berg | 9dde642 | 2012-05-16 23:43:19 +0200 | [diff] [blame] | 3345 | const u8 *ssidie, *ht_ie; |
Guy Eilam | 2a33bee | 2011-08-17 15:18:15 +0300 | [diff] [blame] | 3346 | int i, err; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3347 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3348 | ssidie = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); |
| 3349 | if (!ssidie) |
| 3350 | return -EINVAL; |
Jouni Malinen | 9c87ba6 | 2010-02-28 12:13:46 +0200 | [diff] [blame] | 3351 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3352 | assoc_data = kzalloc(sizeof(*assoc_data) + req->ie_len, GFP_KERNEL); |
| 3353 | if (!assoc_data) |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 3354 | return -ENOMEM; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3355 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3356 | mutex_lock(&ifmgd->mtx); |
| 3357 | |
| 3358 | if (ifmgd->associated) |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3359 | ieee80211_set_disassoc(sdata, 0, 0, false, NULL); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3360 | |
| 3361 | if (ifmgd->auth_data && !ifmgd->auth_data->done) { |
| 3362 | err = -EBUSY; |
| 3363 | goto err_free; |
Guy Eilam | 2a33bee | 2011-08-17 15:18:15 +0300 | [diff] [blame] | 3364 | } |
| 3365 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3366 | if (ifmgd->assoc_data) { |
| 3367 | err = -EBUSY; |
| 3368 | goto err_free; |
| 3369 | } |
| 3370 | |
| 3371 | if (ifmgd->auth_data) { |
| 3372 | bool match; |
| 3373 | |
| 3374 | /* keep sta info, bssid if matching */ |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 3375 | match = ether_addr_equal(ifmgd->bssid, req->bss->bssid); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3376 | ieee80211_destroy_auth_data(sdata, match); |
| 3377 | } |
| 3378 | |
| 3379 | /* prepare assoc data */ |
Johannes Berg | 19c3b83 | 2012-08-01 20:13:36 +0200 | [diff] [blame] | 3380 | |
| 3381 | /* |
| 3382 | * keep only the 40 MHz disable bit set as it might have |
| 3383 | * been set during authentication already, all other bits |
| 3384 | * should be reset for a new connection |
| 3385 | */ |
| 3386 | ifmgd->flags &= IEEE80211_STA_DISABLE_40MHZ; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3387 | |
Juuso Oikarinen | d8ec443 | 2010-10-01 16:02:31 +0300 | [diff] [blame] | 3388 | ifmgd->beacon_crc_valid = false; |
| 3389 | |
Johannes Berg | de5036a | 2012-03-08 15:02:03 +0100 | [diff] [blame] | 3390 | /* |
| 3391 | * IEEE802.11n does not allow TKIP/WEP as pairwise ciphers in HT mode. |
| 3392 | * We still associate in non-HT mode (11a/b/g) if any one of these |
| 3393 | * ciphers is configured as pairwise. |
| 3394 | * We can set this to true for non-11n hardware, that'll be checked |
| 3395 | * separately along with the peer capabilities. |
| 3396 | */ |
Johannes Berg | 1c4cb92 | 2012-05-30 15:57:00 +0200 | [diff] [blame] | 3397 | for (i = 0; i < req->crypto.n_ciphers_pairwise; i++) { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3398 | if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 || |
| 3399 | req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP || |
Johannes Berg | 1c4cb92 | 2012-05-30 15:57:00 +0200 | [diff] [blame] | 3400 | req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3401 | ifmgd->flags |= IEEE80211_STA_DISABLE_11N; |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 3402 | ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; |
Johannes Berg | 1c4cb92 | 2012-05-30 15:57:00 +0200 | [diff] [blame] | 3403 | netdev_info(sdata->dev, |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 3404 | "disabling HT/VHT due to WEP/TKIP use\n"); |
Johannes Berg | 1c4cb92 | 2012-05-30 15:57:00 +0200 | [diff] [blame] | 3405 | } |
| 3406 | } |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3407 | |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 3408 | if (req->flags & ASSOC_REQ_DISABLE_HT) { |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 3409 | ifmgd->flags |= IEEE80211_STA_DISABLE_11N; |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 3410 | ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; |
| 3411 | } |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 3412 | |
Johannes Berg | 4e74bfd | 2012-03-08 15:02:04 +0100 | [diff] [blame] | 3413 | /* Also disable HT if we don't support it or the AP doesn't use WMM */ |
| 3414 | sband = local->hw.wiphy->bands[req->bss->channel->band]; |
| 3415 | if (!sband->ht_cap.ht_supported || |
Johannes Berg | 1c4cb92 | 2012-05-30 15:57:00 +0200 | [diff] [blame] | 3416 | local->hw.queues < IEEE80211_NUM_ACS || !bss->wmm_used) { |
Johannes Berg | 4e74bfd | 2012-03-08 15:02:04 +0100 | [diff] [blame] | 3417 | ifmgd->flags |= IEEE80211_STA_DISABLE_11N; |
Johannes Berg | 1b49de2 | 2012-07-27 10:29:14 +0200 | [diff] [blame] | 3418 | if (!bss->wmm_used) |
| 3419 | netdev_info(sdata->dev, |
| 3420 | "disabling HT as WMM/QoS is not supported by the AP\n"); |
Johannes Berg | 1c4cb92 | 2012-05-30 15:57:00 +0200 | [diff] [blame] | 3421 | } |
Johannes Berg | 4e74bfd | 2012-03-08 15:02:04 +0100 | [diff] [blame] | 3422 | |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 3423 | /* disable VHT if we don't support it or the AP doesn't use WMM */ |
| 3424 | if (!sband->vht_cap.vht_supported || |
| 3425 | local->hw.queues < IEEE80211_NUM_ACS || !bss->wmm_used) { |
| 3426 | ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; |
Johannes Berg | 1b49de2 | 2012-07-27 10:29:14 +0200 | [diff] [blame] | 3427 | if (!bss->wmm_used) |
| 3428 | netdev_info(sdata->dev, |
| 3429 | "disabling VHT as WMM/QoS is not supported by the AP\n"); |
Mahesh Palivela | d545dab | 2012-07-24 03:33:10 +0000 | [diff] [blame] | 3430 | } |
| 3431 | |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 3432 | memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa)); |
| 3433 | memcpy(&ifmgd->ht_capa_mask, &req->ht_capa_mask, |
| 3434 | sizeof(ifmgd->ht_capa_mask)); |
| 3435 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3436 | if (req->ie && req->ie_len) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3437 | memcpy(assoc_data->ie, req->ie, req->ie_len); |
| 3438 | assoc_data->ie_len = req->ie_len; |
| 3439 | } |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3440 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3441 | assoc_data->bss = req->bss; |
Johannes Berg | f679f65 | 2009-12-23 13:15:34 +0100 | [diff] [blame] | 3442 | |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 3443 | if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) { |
| 3444 | if (ifmgd->powersave) |
| 3445 | ifmgd->ap_smps = IEEE80211_SMPS_DYNAMIC; |
| 3446 | else |
| 3447 | ifmgd->ap_smps = IEEE80211_SMPS_OFF; |
| 3448 | } else |
| 3449 | ifmgd->ap_smps = ifmgd->req_smps; |
| 3450 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3451 | assoc_data->capability = req->bss->capability; |
Johannes Berg | 32c5057 | 2012-03-28 11:04:29 +0200 | [diff] [blame] | 3452 | assoc_data->wmm = bss->wmm_used && |
| 3453 | (local->hw.queues >= IEEE80211_NUM_ACS); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3454 | assoc_data->supp_rates = bss->supp_rates; |
| 3455 | assoc_data->supp_rates_len = bss->supp_rates_len; |
Johannes Berg | 9dde642 | 2012-05-16 23:43:19 +0200 | [diff] [blame] | 3456 | |
| 3457 | ht_ie = ieee80211_bss_get_ie(req->bss, WLAN_EID_HT_OPERATION); |
| 3458 | if (ht_ie && ht_ie[1] >= sizeof(struct ieee80211_ht_operation)) |
| 3459 | assoc_data->ap_ht_param = |
| 3460 | ((struct ieee80211_ht_operation *)(ht_ie + 2))->ht_param; |
| 3461 | else |
| 3462 | ifmgd->flags |= IEEE80211_STA_DISABLE_11N; |
Johannes Berg | 63f170e | 2009-12-23 13:15:33 +0100 | [diff] [blame] | 3463 | |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 3464 | if (bss->wmm_used && bss->uapsd_supported && |
| 3465 | (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)) { |
Johannes Berg | 76f0303 | 2012-03-08 15:02:05 +0100 | [diff] [blame] | 3466 | assoc_data->uapsd = true; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 3467 | ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; |
| 3468 | } else { |
Johannes Berg | 76f0303 | 2012-03-08 15:02:05 +0100 | [diff] [blame] | 3469 | assoc_data->uapsd = false; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 3470 | ifmgd->flags &= ~IEEE80211_STA_UAPSD_ENABLED; |
| 3471 | } |
| 3472 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3473 | memcpy(assoc_data->ssid, ssidie + 2, ssidie[1]); |
| 3474 | assoc_data->ssid_len = ssidie[1]; |
Johannes Berg | 63f170e | 2009-12-23 13:15:33 +0100 | [diff] [blame] | 3475 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3476 | if (req->prev_bssid) |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3477 | memcpy(assoc_data->prev_bssid, req->prev_bssid, ETH_ALEN); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3478 | |
| 3479 | if (req->use_mfp) { |
| 3480 | ifmgd->mfp = IEEE80211_MFP_REQUIRED; |
| 3481 | ifmgd->flags |= IEEE80211_STA_MFP_ENABLED; |
| 3482 | } else { |
| 3483 | ifmgd->mfp = IEEE80211_MFP_DISABLED; |
| 3484 | ifmgd->flags &= ~IEEE80211_STA_MFP_ENABLED; |
| 3485 | } |
| 3486 | |
| 3487 | if (req->crypto.control_port) |
| 3488 | ifmgd->flags |= IEEE80211_STA_CONTROL_PORT; |
| 3489 | else |
| 3490 | ifmgd->flags &= ~IEEE80211_STA_CONTROL_PORT; |
| 3491 | |
Johannes Berg | a621fa4 | 2010-08-27 14:26:54 +0300 | [diff] [blame] | 3492 | sdata->control_port_protocol = req->crypto.control_port_ethertype; |
| 3493 | sdata->control_port_no_encrypt = req->crypto.control_port_no_encrypt; |
| 3494 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3495 | /* kick off associate process */ |
| 3496 | |
| 3497 | ifmgd->assoc_data = assoc_data; |
| 3498 | |
Johannes Berg | a1cf775 | 2012-03-08 15:02:07 +0100 | [diff] [blame] | 3499 | err = ieee80211_prep_connection(sdata, req->bss, true); |
| 3500 | if (err) |
| 3501 | goto err_clear; |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3502 | |
| 3503 | if (!bss->dtim_period && |
| 3504 | sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) { |
| 3505 | /* |
| 3506 | * Wait up to one beacon interval ... |
| 3507 | * should this be more if we miss one? |
| 3508 | */ |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3509 | sdata_info(sdata, "waiting for beacon from %pM\n", |
| 3510 | ifmgd->bssid); |
Johannes Berg | 3f9768a | 2012-03-28 21:02:46 +0200 | [diff] [blame] | 3511 | assoc_data->timeout = TU_TO_EXP_TIME(req->bss->beacon_interval); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3512 | } else { |
| 3513 | assoc_data->have_beacon = true; |
| 3514 | assoc_data->sent_assoc = false; |
| 3515 | assoc_data->timeout = jiffies; |
| 3516 | } |
| 3517 | run_again(ifmgd, assoc_data->timeout); |
| 3518 | |
Paul Stewart | fcff4f1 | 2012-02-23 17:59:53 -0800 | [diff] [blame] | 3519 | if (bss->corrupt_data) { |
| 3520 | char *corrupt_type = "data"; |
| 3521 | if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_BEACON) { |
| 3522 | if (bss->corrupt_data & |
| 3523 | IEEE80211_BSS_CORRUPT_PROBE_RESP) |
| 3524 | corrupt_type = "beacon and probe response"; |
| 3525 | else |
| 3526 | corrupt_type = "beacon"; |
| 3527 | } else if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_PROBE_RESP) |
| 3528 | corrupt_type = "probe response"; |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3529 | sdata_info(sdata, "associating with AP with corrupt %s\n", |
| 3530 | corrupt_type); |
Paul Stewart | fcff4f1 | 2012-02-23 17:59:53 -0800 | [diff] [blame] | 3531 | } |
| 3532 | |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3533 | err = 0; |
| 3534 | goto out; |
| 3535 | err_clear: |
Eliad Peller | 3d2abdf | 2012-09-04 17:44:45 +0300 | [diff] [blame] | 3536 | memset(ifmgd->bssid, 0, ETH_ALEN); |
| 3537 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3538 | ifmgd->assoc_data = NULL; |
| 3539 | err_free: |
| 3540 | kfree(assoc_data); |
| 3541 | out: |
| 3542 | mutex_unlock(&ifmgd->mtx); |
| 3543 | |
| 3544 | return err; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3545 | } |
| 3546 | |
| 3547 | int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 3548 | struct cfg80211_deauth_request *req) |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3549 | { |
| 3550 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 3551 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3552 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3553 | mutex_lock(&ifmgd->mtx); |
| 3554 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3555 | if (ifmgd->auth_data) { |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3556 | ieee80211_destroy_auth_data(sdata, false); |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 3557 | mutex_unlock(&ifmgd->mtx); |
Johannes Berg | 66e67e4 | 2012-01-20 13:55:27 +0100 | [diff] [blame] | 3558 | return 0; |
Johannes Berg | af6b637 | 2009-12-23 13:15:35 +0100 | [diff] [blame] | 3559 | } |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3560 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3561 | sdata_info(sdata, |
| 3562 | "deauthenticating from %pM by local choice (reason=%d)\n", |
| 3563 | req->bssid, req->reason_code); |
Johannes Berg | 0ff7161 | 2009-09-26 14:45:41 +0200 | [diff] [blame] | 3564 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3565 | if (ifmgd->associated && |
Emmanuel Grumbach | 8c7d857 | 2012-07-25 01:42:36 +0300 | [diff] [blame] | 3566 | ether_addr_equal(ifmgd->associated->bssid, req->bssid)) { |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3567 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, |
Johannes Berg | 5fef7db | 2012-02-24 13:50:52 +0100 | [diff] [blame] | 3568 | req->reason_code, true, frame_buf); |
Emmanuel Grumbach | 8c7d857 | 2012-07-25 01:42:36 +0300 | [diff] [blame] | 3569 | } else { |
| 3570 | drv_mgd_prepare_tx(sdata->local, sdata); |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3571 | ieee80211_send_deauth_disassoc(sdata, req->bssid, |
| 3572 | IEEE80211_STYPE_DEAUTH, |
| 3573 | req->reason_code, true, |
| 3574 | frame_buf); |
Emmanuel Grumbach | 8c7d857 | 2012-07-25 01:42:36 +0300 | [diff] [blame] | 3575 | } |
| 3576 | |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3577 | mutex_unlock(&ifmgd->mtx); |
| 3578 | |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 3579 | __cfg80211_send_deauth(sdata->dev, frame_buf, |
| 3580 | IEEE80211_DEAUTH_FRAME_LEN); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3581 | |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 3582 | mutex_lock(&sdata->local->mtx); |
Johannes Berg | bc83b68 | 2009-11-29 12:19:06 +0100 | [diff] [blame] | 3583 | ieee80211_recalc_idle(sdata->local); |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 3584 | mutex_unlock(&sdata->local->mtx); |
Johannes Berg | bc83b68 | 2009-11-29 12:19:06 +0100 | [diff] [blame] | 3585 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3586 | return 0; |
| 3587 | } |
| 3588 | |
| 3589 | int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 3590 | struct cfg80211_disassoc_request *req) |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3591 | { |
| 3592 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
Jouni Malinen | e69e95d | 2010-03-29 23:29:31 -0700 | [diff] [blame] | 3593 | u8 bssid[ETH_ALEN]; |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 3594 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3595 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3596 | mutex_lock(&ifmgd->mtx); |
| 3597 | |
Johannes Berg | 8d8b261 | 2009-07-25 11:58:36 +0200 | [diff] [blame] | 3598 | /* |
| 3599 | * cfg80211 should catch this ... but it's racy since |
| 3600 | * we can receive a disassoc frame, process it, hand it |
| 3601 | * to cfg80211 while that's in a locked section already |
| 3602 | * trying to tell us that the user wants to disconnect. |
| 3603 | */ |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 3604 | if (ifmgd->associated != req->bss) { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3605 | mutex_unlock(&ifmgd->mtx); |
| 3606 | return -ENOLINK; |
| 3607 | } |
| 3608 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3609 | sdata_info(sdata, |
| 3610 | "disassociating from %pM by local choice (reason=%d)\n", |
| 3611 | req->bss->bssid, req->reason_code); |
Johannes Berg | 0ff7161 | 2009-09-26 14:45:41 +0200 | [diff] [blame] | 3612 | |
Jouni Malinen | e69e95d | 2010-03-29 23:29:31 -0700 | [diff] [blame] | 3613 | memcpy(bssid, req->bss->bssid, ETH_ALEN); |
Johannes Berg | 37ad388 | 2012-02-24 13:50:54 +0100 | [diff] [blame] | 3614 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DISASSOC, |
| 3615 | req->reason_code, !req->local_state_change, |
| 3616 | frame_buf); |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3617 | mutex_unlock(&ifmgd->mtx); |
| 3618 | |
Antonio Quartulli | 6ae1677 | 2012-09-07 13:28:52 +0200 | [diff] [blame] | 3619 | __cfg80211_send_disassoc(sdata->dev, frame_buf, |
| 3620 | IEEE80211_DEAUTH_FRAME_LEN); |
Johannes Berg | bc83b68 | 2009-11-29 12:19:06 +0100 | [diff] [blame] | 3621 | |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 3622 | mutex_lock(&sdata->local->mtx); |
Johannes Berg | bc83b68 | 2009-11-29 12:19:06 +0100 | [diff] [blame] | 3623 | ieee80211_recalc_idle(sdata->local); |
Johannes Berg | 7da7cc1 | 2010-08-05 17:02:38 +0200 | [diff] [blame] | 3624 | mutex_unlock(&sdata->local->mtx); |
Johannes Berg | bc83b68 | 2009-11-29 12:19:06 +0100 | [diff] [blame] | 3625 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 3626 | return 0; |
| 3627 | } |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 3628 | |
Eliad Peller | afa762f | 2012-04-23 14:45:15 +0300 | [diff] [blame] | 3629 | void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 54e4ffb | 2012-02-25 21:48:08 +0100 | [diff] [blame] | 3630 | { |
| 3631 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 3632 | |
| 3633 | mutex_lock(&ifmgd->mtx); |
| 3634 | if (ifmgd->assoc_data) |
| 3635 | ieee80211_destroy_assoc_data(sdata, false); |
| 3636 | if (ifmgd->auth_data) |
| 3637 | ieee80211_destroy_auth_data(sdata, false); |
| 3638 | del_timer_sync(&ifmgd->timer); |
| 3639 | mutex_unlock(&ifmgd->mtx); |
| 3640 | } |
| 3641 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 3642 | void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, |
| 3643 | enum nl80211_cqm_rssi_threshold_event rssi_event, |
| 3644 | gfp_t gfp) |
| 3645 | { |
| 3646 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
| 3647 | |
Johannes Berg | b5878a2 | 2010-04-07 16:48:40 +0200 | [diff] [blame] | 3648 | trace_api_cqm_rssi_notify(sdata, rssi_event); |
| 3649 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 3650 | cfg80211_cqm_rssi_notify(sdata->dev, rssi_event, gfp); |
| 3651 | } |
| 3652 | EXPORT_SYMBOL(ieee80211_cqm_rssi_notify); |