Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * mac80211 configuration hooks for cfg80211 |
| 3 | * |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 4 | * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 5 | * |
| 6 | * This file is GPLv2 as found in COPYING. |
| 7 | */ |
| 8 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 9 | #include <linux/ieee80211.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 10 | #include <linux/nl80211.h> |
| 11 | #include <linux/rtnetlink.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 13 | #include <net/net_namespace.h> |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 14 | #include <linux/rcupdate.h> |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 15 | #include <linux/if_ether.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 16 | #include <net/cfg80211.h> |
| 17 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 18 | #include "driver-ops.h" |
Michael Wu | e0eb685 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 19 | #include "cfg.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 20 | #include "rate.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 21 | #include "mesh.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 22 | |
Johannes Berg | 552bff0 | 2012-09-19 09:26:06 +0200 | [diff] [blame] | 23 | static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, |
| 24 | const char *name, |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 25 | enum nl80211_iftype type, |
| 26 | u32 *flags, |
| 27 | struct vif_params *params) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 28 | { |
| 29 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 30 | struct wireless_dev *wdev; |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 31 | struct ieee80211_sub_if_data *sdata; |
| 32 | int err; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 33 | |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 34 | err = ieee80211_if_add(local, name, &wdev, type, params); |
Johannes Berg | f9e10ce | 2010-12-03 09:20:42 +0100 | [diff] [blame] | 35 | if (err) |
| 36 | return ERR_PTR(err); |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 37 | |
Johannes Berg | f9e10ce | 2010-12-03 09:20:42 +0100 | [diff] [blame] | 38 | if (type == NL80211_IFTYPE_MONITOR && flags) { |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 39 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | f9e10ce | 2010-12-03 09:20:42 +0100 | [diff] [blame] | 40 | sdata->u.mntr_flags = *flags; |
| 41 | } |
| 42 | |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 43 | return wdev; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 46 | static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 47 | { |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 48 | ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 49 | |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 50 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Johannes Berg | e36d56b | 2009-06-09 21:04:43 +0200 | [diff] [blame] | 53 | static int ieee80211_change_iface(struct wiphy *wiphy, |
| 54 | struct net_device *dev, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 55 | enum nl80211_iftype type, u32 *flags, |
| 56 | struct vif_params *params) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 57 | { |
Johannes Berg | 9607e6b66 | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 58 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 59 | int ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 60 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 61 | ret = ieee80211_if_change_type(sdata, type); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 62 | if (ret) |
| 63 | return ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 64 | |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 65 | if (type == NL80211_IFTYPE_AP_VLAN && |
| 66 | params && params->use_4addr == 0) |
Stephen Hemminger | a9b3cd7 | 2011-08-01 16:19:00 +0000 | [diff] [blame] | 67 | RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 68 | else if (type == NL80211_IFTYPE_STATION && |
| 69 | params && params->use_4addr >= 0) |
| 70 | sdata->u.mgd.use_4addr = params->use_4addr; |
| 71 | |
Christian Lamparter | 85416a4 | 2010-10-02 13:17:07 +0200 | [diff] [blame] | 72 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) { |
| 73 | struct ieee80211_local *local = sdata->local; |
| 74 | |
| 75 | if (ieee80211_sdata_running(sdata)) { |
Felix Fietkau | 31eba5b | 2013-05-28 13:01:53 +0200 | [diff] [blame] | 76 | u32 mask = MONITOR_FLAG_COOK_FRAMES | |
| 77 | MONITOR_FLAG_ACTIVE; |
| 78 | |
Christian Lamparter | 85416a4 | 2010-10-02 13:17:07 +0200 | [diff] [blame] | 79 | /* |
Felix Fietkau | 31eba5b | 2013-05-28 13:01:53 +0200 | [diff] [blame] | 80 | * Prohibit MONITOR_FLAG_COOK_FRAMES and |
| 81 | * MONITOR_FLAG_ACTIVE to be changed while the |
| 82 | * interface is up. |
Christian Lamparter | 85416a4 | 2010-10-02 13:17:07 +0200 | [diff] [blame] | 83 | * Else we would need to add a lot of cruft |
| 84 | * to update everything: |
| 85 | * cooked_mntrs, monitor and all fif_* counters |
| 86 | * reconfigure hardware |
| 87 | */ |
Felix Fietkau | 31eba5b | 2013-05-28 13:01:53 +0200 | [diff] [blame] | 88 | if ((*flags & mask) != (sdata->u.mntr_flags & mask)) |
Christian Lamparter | 85416a4 | 2010-10-02 13:17:07 +0200 | [diff] [blame] | 89 | return -EBUSY; |
| 90 | |
| 91 | ieee80211_adjust_monitor_flags(sdata, -1); |
| 92 | sdata->u.mntr_flags = *flags; |
| 93 | ieee80211_adjust_monitor_flags(sdata, 1); |
| 94 | |
| 95 | ieee80211_configure_filter(local); |
| 96 | } else { |
| 97 | /* |
| 98 | * Because the interface is down, ieee80211_do_stop |
| 99 | * and ieee80211_do_open take care of "everything" |
| 100 | * mentioned in the comment above. |
| 101 | */ |
| 102 | sdata->u.mntr_flags = *flags; |
| 103 | } |
| 104 | } |
Felix Fietkau | f7917af | 2010-04-27 00:26:34 +0200 | [diff] [blame] | 105 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 106 | return 0; |
| 107 | } |
| 108 | |
Johannes Berg | f142c6b | 2012-06-18 20:07:15 +0200 | [diff] [blame] | 109 | static int ieee80211_start_p2p_device(struct wiphy *wiphy, |
| 110 | struct wireless_dev *wdev) |
| 111 | { |
Luciano Coelho | b6a5501 | 2014-02-27 11:07:21 +0200 | [diff] [blame^] | 112 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
| 113 | int ret; |
| 114 | |
| 115 | mutex_lock(&sdata->local->chanctx_mtx); |
| 116 | ret = ieee80211_check_combinations(sdata, NULL, 0, 0); |
| 117 | mutex_unlock(&sdata->local->chanctx_mtx); |
| 118 | if (ret < 0) |
| 119 | return ret; |
| 120 | |
Johannes Berg | f142c6b | 2012-06-18 20:07:15 +0200 | [diff] [blame] | 121 | return ieee80211_do_open(wdev, true); |
| 122 | } |
| 123 | |
| 124 | static void ieee80211_stop_p2p_device(struct wiphy *wiphy, |
| 125 | struct wireless_dev *wdev) |
| 126 | { |
| 127 | ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev)); |
| 128 | } |
| 129 | |
Simon Wunderlich | b53be79 | 2011-11-18 14:20:44 +0100 | [diff] [blame] | 130 | static int ieee80211_set_noack_map(struct wiphy *wiphy, |
| 131 | struct net_device *dev, |
| 132 | u16 noack_map) |
| 133 | { |
| 134 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 135 | |
| 136 | sdata->noack_map = noack_map; |
| 137 | return 0; |
| 138 | } |
| 139 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 140 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 141 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 142 | struct key_params *params) |
| 143 | { |
Johannes Berg | 26a5845 | 2010-08-27 12:35:55 +0200 | [diff] [blame] | 144 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 145 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 146 | struct sta_info *sta = NULL; |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 147 | const struct ieee80211_cipher_scheme *cs = NULL; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 148 | struct ieee80211_key *key; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 149 | int err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 150 | |
Johannes Berg | 26a5845 | 2010-08-27 12:35:55 +0200 | [diff] [blame] | 151 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 152 | return -ENETDOWN; |
| 153 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 154 | /* reject WEP and TKIP keys if WEP failed to initialize */ |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 155 | switch (params->cipher) { |
| 156 | case WLAN_CIPHER_SUITE_WEP40: |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 157 | case WLAN_CIPHER_SUITE_TKIP: |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 158 | case WLAN_CIPHER_SUITE_WEP104: |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 159 | if (IS_ERR(local->wep_tx_tfm)) |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 160 | return -EINVAL; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 161 | break; |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 162 | case WLAN_CIPHER_SUITE_CCMP: |
| 163 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 164 | case WLAN_CIPHER_SUITE_GCMP: |
| 165 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 166 | default: |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 167 | cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type); |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 168 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 169 | } |
| 170 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 171 | key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 172 | params->key, params->seq_len, params->seq, |
| 173 | cs); |
Ben Hutchings | 1ac62ba | 2010-08-01 17:37:03 +0100 | [diff] [blame] | 174 | if (IS_ERR(key)) |
| 175 | return PTR_ERR(key); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 176 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 177 | if (pairwise) |
| 178 | key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE; |
| 179 | |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 180 | mutex_lock(&local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 181 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 182 | if (mac_addr) { |
Thomas Pedersen | ff973af | 2011-05-03 16:57:12 -0700 | [diff] [blame] | 183 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
| 184 | sta = sta_info_get(sdata, mac_addr); |
| 185 | else |
| 186 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | 1626e0f | 2013-01-11 14:34:25 +0100 | [diff] [blame] | 187 | /* |
| 188 | * The ASSOC test makes sure the driver is ready to |
| 189 | * receive the key. When wpa_supplicant has roamed |
| 190 | * using FT, it attempts to set the key before |
| 191 | * association has completed, this rejects that attempt |
| 192 | * so it will set the key again after assocation. |
| 193 | * |
| 194 | * TODO: accept the key if we have a station entry and |
| 195 | * add it to the device after the station. |
| 196 | */ |
| 197 | if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) { |
Johannes Berg | 79cf2df | 2013-03-06 22:53:52 +0100 | [diff] [blame] | 198 | ieee80211_key_free_unused(key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 199 | err = -ENOENT; |
| 200 | goto out_unlock; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 201 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 202 | } |
| 203 | |
Johannes Berg | e548c49 | 2012-09-04 17:08:23 +0200 | [diff] [blame] | 204 | switch (sdata->vif.type) { |
| 205 | case NL80211_IFTYPE_STATION: |
| 206 | if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) |
| 207 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; |
| 208 | break; |
| 209 | case NL80211_IFTYPE_AP: |
| 210 | case NL80211_IFTYPE_AP_VLAN: |
| 211 | /* Keys without a station are used for TX only */ |
| 212 | if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP)) |
| 213 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; |
| 214 | break; |
| 215 | case NL80211_IFTYPE_ADHOC: |
| 216 | /* no MFP (yet) */ |
| 217 | break; |
| 218 | case NL80211_IFTYPE_MESH_POINT: |
| 219 | #ifdef CONFIG_MAC80211_MESH |
| 220 | if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE) |
| 221 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; |
| 222 | break; |
| 223 | #endif |
| 224 | case NL80211_IFTYPE_WDS: |
| 225 | case NL80211_IFTYPE_MONITOR: |
| 226 | case NL80211_IFTYPE_P2P_DEVICE: |
| 227 | case NL80211_IFTYPE_UNSPECIFIED: |
| 228 | case NUM_NL80211_IFTYPES: |
| 229 | case NL80211_IFTYPE_P2P_CLIENT: |
| 230 | case NL80211_IFTYPE_P2P_GO: |
| 231 | /* shouldn't happen */ |
| 232 | WARN_ON_ONCE(1); |
| 233 | break; |
| 234 | } |
| 235 | |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 236 | if (sta) |
| 237 | sta->cipher_scheme = cs; |
| 238 | |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 239 | err = ieee80211_key_link(key, sdata, sta); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 240 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 241 | out_unlock: |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 242 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 243 | |
| 244 | return err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 248 | u8 key_idx, bool pairwise, const u8 *mac_addr) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 249 | { |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 250 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 251 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 252 | struct sta_info *sta; |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 253 | struct ieee80211_key *key = NULL; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 254 | int ret; |
| 255 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 256 | mutex_lock(&local->sta_mtx); |
| 257 | mutex_lock(&local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 258 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 259 | if (mac_addr) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 260 | ret = -ENOENT; |
| 261 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 262 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 263 | if (!sta) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 264 | goto out_unlock; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 265 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 266 | if (pairwise) |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 267 | key = key_mtx_dereference(local, sta->ptk[key_idx]); |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 268 | else |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 269 | key = key_mtx_dereference(local, sta->gtk[key_idx]); |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 270 | } else |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 271 | key = key_mtx_dereference(local, sdata->keys[key_idx]); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 272 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 273 | if (!key) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 274 | ret = -ENOENT; |
| 275 | goto out_unlock; |
| 276 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 277 | |
Johannes Berg | 3b8d9c2 | 2013-03-06 22:58:23 +0100 | [diff] [blame] | 278 | ieee80211_key_free(key, true); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 279 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 280 | ret = 0; |
| 281 | out_unlock: |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 282 | mutex_unlock(&local->key_mtx); |
| 283 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 284 | |
| 285 | return ret; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 288 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 289 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
| 290 | void *cookie, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 291 | void (*callback)(void *cookie, |
| 292 | struct key_params *params)) |
| 293 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 294 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 295 | struct sta_info *sta = NULL; |
| 296 | u8 seq[6] = {0}; |
| 297 | struct key_params params; |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 298 | struct ieee80211_key *key = NULL; |
Johannes Berg | aba83a0b | 2011-07-06 21:59:39 +0200 | [diff] [blame] | 299 | u64 pn64; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 300 | u32 iv32; |
| 301 | u16 iv16; |
| 302 | int err = -ENOENT; |
| 303 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 304 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 305 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 306 | rcu_read_lock(); |
| 307 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 308 | if (mac_addr) { |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 309 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 310 | if (!sta) |
| 311 | goto out; |
| 312 | |
Max Stepanov | 354e159 | 2013-12-08 13:30:52 +0200 | [diff] [blame] | 313 | if (pairwise && key_idx < NUM_DEFAULT_KEYS) |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 314 | key = rcu_dereference(sta->ptk[key_idx]); |
Max Stepanov | 31f1f4e | 2013-12-08 13:31:29 +0200 | [diff] [blame] | 315 | else if (!pairwise && |
| 316 | key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS) |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 317 | key = rcu_dereference(sta->gtk[key_idx]); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 318 | } else |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 319 | key = rcu_dereference(sdata->keys[key_idx]); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 320 | |
| 321 | if (!key) |
| 322 | goto out; |
| 323 | |
| 324 | memset(¶ms, 0, sizeof(params)); |
| 325 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 326 | params.cipher = key->conf.cipher; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 327 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 328 | switch (key->conf.cipher) { |
| 329 | case WLAN_CIPHER_SUITE_TKIP: |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 330 | iv32 = key->u.tkip.tx.iv32; |
| 331 | iv16 = key->u.tkip.tx.iv16; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 332 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 333 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) |
| 334 | drv_get_tkip_seq(sdata->local, |
| 335 | key->conf.hw_key_idx, |
| 336 | &iv32, &iv16); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 337 | |
| 338 | seq[0] = iv16 & 0xff; |
| 339 | seq[1] = (iv16 >> 8) & 0xff; |
| 340 | seq[2] = iv32 & 0xff; |
| 341 | seq[3] = (iv32 >> 8) & 0xff; |
| 342 | seq[4] = (iv32 >> 16) & 0xff; |
| 343 | seq[5] = (iv32 >> 24) & 0xff; |
| 344 | params.seq = seq; |
| 345 | params.seq_len = 6; |
| 346 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 347 | case WLAN_CIPHER_SUITE_CCMP: |
Johannes Berg | aba83a0b | 2011-07-06 21:59:39 +0200 | [diff] [blame] | 348 | pn64 = atomic64_read(&key->u.ccmp.tx_pn); |
| 349 | seq[0] = pn64; |
| 350 | seq[1] = pn64 >> 8; |
| 351 | seq[2] = pn64 >> 16; |
| 352 | seq[3] = pn64 >> 24; |
| 353 | seq[4] = pn64 >> 32; |
| 354 | seq[5] = pn64 >> 40; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 355 | params.seq = seq; |
| 356 | params.seq_len = 6; |
| 357 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 358 | case WLAN_CIPHER_SUITE_AES_CMAC: |
Johannes Berg | 75396ae | 2011-07-06 22:00:35 +0200 | [diff] [blame] | 359 | pn64 = atomic64_read(&key->u.aes_cmac.tx_pn); |
| 360 | seq[0] = pn64; |
| 361 | seq[1] = pn64 >> 8; |
| 362 | seq[2] = pn64 >> 16; |
| 363 | seq[3] = pn64 >> 24; |
| 364 | seq[4] = pn64 >> 32; |
| 365 | seq[5] = pn64 >> 40; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 366 | params.seq = seq; |
| 367 | params.seq_len = 6; |
| 368 | break; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | params.key = key->conf.key; |
| 372 | params.key_len = key->conf.keylen; |
| 373 | |
| 374 | callback(cookie, ¶ms); |
| 375 | err = 0; |
| 376 | |
| 377 | out: |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 378 | rcu_read_unlock(); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 379 | return err; |
| 380 | } |
| 381 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 382 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
| 383 | struct net_device *dev, |
Johannes Berg | dbd2fd6 | 2010-12-09 19:58:59 +0100 | [diff] [blame] | 384 | u8 key_idx, bool uni, |
| 385 | bool multi) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 386 | { |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 387 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 388 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 389 | ieee80211_set_default_key(sdata, key_idx, uni, multi); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 390 | |
| 391 | return 0; |
| 392 | } |
| 393 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 394 | static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, |
| 395 | struct net_device *dev, |
| 396 | u8 key_idx) |
| 397 | { |
Johannes Berg | 66c5242 | 2010-07-22 13:58:51 +0200 | [diff] [blame] | 398 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 399 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 400 | ieee80211_set_default_mgmt_key(sdata, key_idx); |
| 401 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 402 | return 0; |
| 403 | } |
| 404 | |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 405 | void sta_set_rate_info_tx(struct sta_info *sta, |
| 406 | const struct ieee80211_tx_rate *rate, |
| 407 | struct rate_info *rinfo) |
| 408 | { |
| 409 | rinfo->flags = 0; |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 410 | if (rate->flags & IEEE80211_TX_RC_MCS) { |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 411 | rinfo->flags |= RATE_INFO_FLAGS_MCS; |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 412 | rinfo->mcs = rate->idx; |
| 413 | } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { |
| 414 | rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 415 | rinfo->mcs = ieee80211_rate_get_vht_mcs(rate); |
| 416 | rinfo->nss = ieee80211_rate_get_vht_nss(rate); |
| 417 | } else { |
| 418 | struct ieee80211_supported_band *sband; |
Simon Wunderlich | 2103dec | 2013-07-08 16:55:53 +0200 | [diff] [blame] | 419 | int shift = ieee80211_vif_get_shift(&sta->sdata->vif); |
| 420 | u16 brate; |
| 421 | |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 422 | sband = sta->local->hw.wiphy->bands[ |
| 423 | ieee80211_get_sdata_band(sta->sdata)]; |
Simon Wunderlich | 2103dec | 2013-07-08 16:55:53 +0200 | [diff] [blame] | 424 | brate = sband->bitrates[rate->idx].bitrate; |
| 425 | rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 426 | } |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 427 | if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
| 428 | rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 429 | if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) |
| 430 | rinfo->flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 431 | if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) |
| 432 | rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 433 | if (rate->flags & IEEE80211_TX_RC_SHORT_GI) |
| 434 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 435 | } |
| 436 | |
Saravana | 003e676 | 2012-11-28 18:29:38 +0530 | [diff] [blame] | 437 | void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo) |
| 438 | { |
| 439 | rinfo->flags = 0; |
| 440 | |
| 441 | if (sta->last_rx_rate_flag & RX_FLAG_HT) { |
| 442 | rinfo->flags |= RATE_INFO_FLAGS_MCS; |
| 443 | rinfo->mcs = sta->last_rx_rate_idx; |
| 444 | } else if (sta->last_rx_rate_flag & RX_FLAG_VHT) { |
| 445 | rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 446 | rinfo->nss = sta->last_rx_rate_vht_nss; |
| 447 | rinfo->mcs = sta->last_rx_rate_idx; |
| 448 | } else { |
| 449 | struct ieee80211_supported_band *sband; |
Simon Wunderlich | 2103dec | 2013-07-08 16:55:53 +0200 | [diff] [blame] | 450 | int shift = ieee80211_vif_get_shift(&sta->sdata->vif); |
| 451 | u16 brate; |
Saravana | 003e676 | 2012-11-28 18:29:38 +0530 | [diff] [blame] | 452 | |
| 453 | sband = sta->local->hw.wiphy->bands[ |
| 454 | ieee80211_get_sdata_band(sta->sdata)]; |
Simon Wunderlich | 2103dec | 2013-07-08 16:55:53 +0200 | [diff] [blame] | 455 | brate = sband->bitrates[sta->last_rx_rate_idx].bitrate; |
| 456 | rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); |
Saravana | 003e676 | 2012-11-28 18:29:38 +0530 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) |
| 460 | rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 461 | if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) |
| 462 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; |
Emmanuel Grumbach | 1b8d242 | 2014-02-05 16:37:11 +0200 | [diff] [blame] | 463 | if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_80MHZ) |
Saravana | 003e676 | 2012-11-28 18:29:38 +0530 | [diff] [blame] | 464 | rinfo->flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Emmanuel Grumbach | 1b8d242 | 2014-02-05 16:37:11 +0200 | [diff] [blame] | 465 | if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_80P80MHZ) |
Saravana | 003e676 | 2012-11-28 18:29:38 +0530 | [diff] [blame] | 466 | rinfo->flags |= RATE_INFO_FLAGS_80P80_MHZ_WIDTH; |
Emmanuel Grumbach | 1b8d242 | 2014-02-05 16:37:11 +0200 | [diff] [blame] | 467 | if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_160MHZ) |
Saravana | 003e676 | 2012-11-28 18:29:38 +0530 | [diff] [blame] | 468 | rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; |
| 469 | } |
| 470 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 471 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
| 472 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 473 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 474 | struct ieee80211_local *local = sdata->local; |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 475 | struct timespec uptime; |
Johannes Berg | 560d268 | 2013-02-05 10:55:21 +0100 | [diff] [blame] | 476 | u64 packets = 0; |
Felix Fietkau | ef0621e | 2013-04-22 16:29:31 +0200 | [diff] [blame] | 477 | int i, ac; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 478 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 479 | sinfo->generation = sdata->local->sta_generation; |
| 480 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 481 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
Johannes Berg | 560d268 | 2013-02-05 10:55:21 +0100 | [diff] [blame] | 482 | STATION_INFO_RX_BYTES64 | |
| 483 | STATION_INFO_TX_BYTES64 | |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 484 | STATION_INFO_RX_PACKETS | |
| 485 | STATION_INFO_TX_PACKETS | |
Bruno Randolf | b206b4ef | 2010-10-06 18:34:12 +0900 | [diff] [blame] | 486 | STATION_INFO_TX_RETRIES | |
| 487 | STATION_INFO_TX_FAILED | |
Ben Greear | 5a5c731 | 2010-10-07 16:39:20 -0700 | [diff] [blame] | 488 | STATION_INFO_TX_BITRATE | |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 489 | STATION_INFO_RX_BITRATE | |
Paul Stewart | f4263c9 | 2011-03-31 09:25:41 -0700 | [diff] [blame] | 490 | STATION_INFO_RX_DROP_MISC | |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 491 | STATION_INFO_BSS_PARAM | |
Helmut Schaa | 7a72476 | 2011-10-13 16:30:40 +0200 | [diff] [blame] | 492 | STATION_INFO_CONNECTED_TIME | |
Paul Stewart | a85e1d5 | 2011-12-09 11:01:49 -0800 | [diff] [blame] | 493 | STATION_INFO_STA_FLAGS | |
| 494 | STATION_INFO_BEACON_LOSS_COUNT; |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 495 | |
| 496 | do_posix_clock_monotonic_gettime(&uptime); |
| 497 | sinfo->connected_time = uptime.tv_sec - sta->last_connected; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 498 | |
| 499 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
Johannes Berg | 560d268 | 2013-02-05 10:55:21 +0100 | [diff] [blame] | 500 | sinfo->tx_bytes = 0; |
| 501 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
| 502 | sinfo->tx_bytes += sta->tx_bytes[ac]; |
| 503 | packets += sta->tx_packets[ac]; |
| 504 | } |
| 505 | sinfo->tx_packets = packets; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 506 | sinfo->rx_bytes = sta->rx_bytes; |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 507 | sinfo->rx_packets = sta->rx_packets; |
Bruno Randolf | b206b4ef | 2010-10-06 18:34:12 +0900 | [diff] [blame] | 508 | sinfo->tx_retries = sta->tx_retry_count; |
| 509 | sinfo->tx_failed = sta->tx_retry_failed; |
Ben Greear | 5a5c731 | 2010-10-07 16:39:20 -0700 | [diff] [blame] | 510 | sinfo->rx_dropped_misc = sta->rx_dropped; |
Paul Stewart | a85e1d5 | 2011-12-09 11:01:49 -0800 | [diff] [blame] | 511 | sinfo->beacon_loss_count = sta->beacon_loss_count; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 512 | |
John W. Linville | 19deffb | 2009-12-08 17:10:13 -0500 | [diff] [blame] | 513 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
| 514 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 515 | sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG; |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 516 | if (!local->ops->get_rssi || |
| 517 | drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal)) |
| 518 | sinfo->signal = (s8)sta->last_signal; |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 519 | sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 520 | } |
Felix Fietkau | ef0621e | 2013-04-22 16:29:31 +0200 | [diff] [blame] | 521 | if (sta->chains) { |
| 522 | sinfo->filled |= STATION_INFO_CHAIN_SIGNAL | |
| 523 | STATION_INFO_CHAIN_SIGNAL_AVG; |
| 524 | |
| 525 | sinfo->chains = sta->chains; |
| 526 | for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { |
| 527 | sinfo->chain_signal[i] = sta->chain_signal_last[i]; |
| 528 | sinfo->chain_signal_avg[i] = |
| 529 | (s8) -ewma_read(&sta->chain_signal_avg[i]); |
| 530 | } |
| 531 | } |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 532 | |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 533 | sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); |
Saravana | 003e676 | 2012-11-28 18:29:38 +0530 | [diff] [blame] | 534 | sta_set_rate_info_rx(sta, &sinfo->rxrate); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 535 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 536 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 537 | #ifdef CONFIG_MAC80211_MESH |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 538 | sinfo->filled |= STATION_INFO_LLID | |
| 539 | STATION_INFO_PLID | |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 540 | STATION_INFO_PLINK_STATE | |
| 541 | STATION_INFO_LOCAL_PM | |
| 542 | STATION_INFO_PEER_PM | |
| 543 | STATION_INFO_NONPEER_PM; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 544 | |
Chun-Yeow Yeoh | 6f101ef | 2013-11-13 15:43:03 +0800 | [diff] [blame] | 545 | sinfo->llid = sta->llid; |
| 546 | sinfo->plid = sta->plid; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 547 | sinfo->plink_state = sta->plink_state; |
Javier Cardona | d299a1f | 2012-03-31 11:31:33 -0700 | [diff] [blame] | 548 | if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { |
| 549 | sinfo->filled |= STATION_INFO_T_OFFSET; |
| 550 | sinfo->t_offset = sta->t_offset; |
| 551 | } |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 552 | sinfo->local_pm = sta->local_pm; |
| 553 | sinfo->peer_pm = sta->peer_pm; |
| 554 | sinfo->nonpeer_pm = sta->nonpeer_pm; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 555 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 556 | } |
Paul Stewart | f4263c9 | 2011-03-31 09:25:41 -0700 | [diff] [blame] | 557 | |
| 558 | sinfo->bss_param.flags = 0; |
| 559 | if (sdata->vif.bss_conf.use_cts_prot) |
| 560 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; |
| 561 | if (sdata->vif.bss_conf.use_short_preamble) |
| 562 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; |
| 563 | if (sdata->vif.bss_conf.use_short_slot) |
| 564 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; |
| 565 | sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period; |
| 566 | sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; |
Helmut Schaa | 7a72476 | 2011-10-13 16:30:40 +0200 | [diff] [blame] | 567 | |
| 568 | sinfo->sta_flags.set = 0; |
| 569 | sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | |
| 570 | BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | |
| 571 | BIT(NL80211_STA_FLAG_WME) | |
| 572 | BIT(NL80211_STA_FLAG_MFP) | |
Helmut Schaa | e412156 | 2011-11-05 14:15:24 +0100 | [diff] [blame] | 573 | BIT(NL80211_STA_FLAG_AUTHENTICATED) | |
Johannes Berg | d582cff | 2012-10-26 17:53:44 +0200 | [diff] [blame] | 574 | BIT(NL80211_STA_FLAG_ASSOCIATED) | |
Helmut Schaa | e412156 | 2011-11-05 14:15:24 +0100 | [diff] [blame] | 575 | BIT(NL80211_STA_FLAG_TDLS_PEER); |
Helmut Schaa | 7a72476 | 2011-10-13 16:30:40 +0200 | [diff] [blame] | 576 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
| 577 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); |
| 578 | if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) |
| 579 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); |
| 580 | if (test_sta_flag(sta, WLAN_STA_WME)) |
| 581 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); |
| 582 | if (test_sta_flag(sta, WLAN_STA_MFP)) |
| 583 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); |
| 584 | if (test_sta_flag(sta, WLAN_STA_AUTH)) |
| 585 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); |
Johannes Berg | d582cff | 2012-10-26 17:53:44 +0200 | [diff] [blame] | 586 | if (test_sta_flag(sta, WLAN_STA_ASSOC)) |
| 587 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); |
Helmut Schaa | e412156 | 2011-11-05 14:15:24 +0100 | [diff] [blame] | 588 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) |
| 589 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 590 | } |
| 591 | |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 592 | static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = { |
| 593 | "rx_packets", "rx_bytes", "wep_weak_iv_count", |
| 594 | "rx_duplicates", "rx_fragments", "rx_dropped", |
| 595 | "tx_packets", "tx_bytes", "tx_fragments", |
| 596 | "tx_filtered", "tx_retry_failed", "tx_retries", |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 597 | "beacon_loss", "sta_state", "txrate", "rxrate", "signal", |
| 598 | "channel", "noise", "ch_time", "ch_time_busy", |
| 599 | "ch_time_ext_busy", "ch_time_rx", "ch_time_tx" |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 600 | }; |
| 601 | #define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats) |
| 602 | |
| 603 | static int ieee80211_get_et_sset_count(struct wiphy *wiphy, |
| 604 | struct net_device *dev, |
| 605 | int sset) |
| 606 | { |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 607 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 608 | int rv = 0; |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 609 | |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 610 | if (sset == ETH_SS_STATS) |
| 611 | rv += STA_STATS_LEN; |
| 612 | |
| 613 | rv += drv_get_et_sset_count(sdata, sset); |
| 614 | |
| 615 | if (rv == 0) |
| 616 | return -EOPNOTSUPP; |
| 617 | return rv; |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | static void ieee80211_get_et_stats(struct wiphy *wiphy, |
| 621 | struct net_device *dev, |
| 622 | struct ethtool_stats *stats, |
| 623 | u64 *data) |
| 624 | { |
| 625 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 626 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 627 | struct ieee80211_channel *channel; |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 628 | struct sta_info *sta; |
| 629 | struct ieee80211_local *local = sdata->local; |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 630 | struct station_info sinfo; |
| 631 | struct survey_info survey; |
| 632 | int i, q; |
| 633 | #define STA_STATS_SURVEY_LEN 7 |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 634 | |
| 635 | memset(data, 0, sizeof(u64) * STA_STATS_LEN); |
| 636 | |
| 637 | #define ADD_STA_STATS(sta) \ |
| 638 | do { \ |
| 639 | data[i++] += sta->rx_packets; \ |
| 640 | data[i++] += sta->rx_bytes; \ |
| 641 | data[i++] += sta->wep_weak_iv_count; \ |
| 642 | data[i++] += sta->num_duplicates; \ |
| 643 | data[i++] += sta->rx_fragments; \ |
| 644 | data[i++] += sta->rx_dropped; \ |
| 645 | \ |
Johannes Berg | 560d268 | 2013-02-05 10:55:21 +0100 | [diff] [blame] | 646 | data[i++] += sinfo.tx_packets; \ |
| 647 | data[i++] += sinfo.tx_bytes; \ |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 648 | data[i++] += sta->tx_fragments; \ |
| 649 | data[i++] += sta->tx_filtered_count; \ |
| 650 | data[i++] += sta->tx_retry_failed; \ |
| 651 | data[i++] += sta->tx_retry_count; \ |
| 652 | data[i++] += sta->beacon_loss_count; \ |
| 653 | } while (0) |
| 654 | |
| 655 | /* For Managed stations, find the single station based on BSSID |
| 656 | * and use that. For interface types, iterate through all available |
| 657 | * stations and add stats for any station that is assigned to this |
| 658 | * network device. |
| 659 | */ |
| 660 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 661 | mutex_lock(&local->sta_mtx); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 662 | |
| 663 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
| 664 | sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid); |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 665 | |
| 666 | if (!(sta && !WARN_ON(sta->sdata->dev != dev))) |
| 667 | goto do_survey; |
| 668 | |
Johannes Berg | 560d268 | 2013-02-05 10:55:21 +0100 | [diff] [blame] | 669 | sinfo.filled = 0; |
| 670 | sta_set_sinfo(sta, &sinfo); |
| 671 | |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 672 | i = 0; |
| 673 | ADD_STA_STATS(sta); |
| 674 | |
| 675 | data[i++] = sta->sta_state; |
| 676 | |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 677 | |
Joe Perches | 5204267 | 2012-05-30 13:25:54 -0700 | [diff] [blame] | 678 | if (sinfo.filled & STATION_INFO_TX_BITRATE) |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 679 | data[i] = 100000 * |
| 680 | cfg80211_calculate_bitrate(&sinfo.txrate); |
| 681 | i++; |
Joe Perches | 5204267 | 2012-05-30 13:25:54 -0700 | [diff] [blame] | 682 | if (sinfo.filled & STATION_INFO_RX_BITRATE) |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 683 | data[i] = 100000 * |
| 684 | cfg80211_calculate_bitrate(&sinfo.rxrate); |
| 685 | i++; |
| 686 | |
Joe Perches | 5204267 | 2012-05-30 13:25:54 -0700 | [diff] [blame] | 687 | if (sinfo.filled & STATION_INFO_SIGNAL_AVG) |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 688 | data[i] = (u8)sinfo.signal_avg; |
| 689 | i++; |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 690 | } else { |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 691 | list_for_each_entry(sta, &local->sta_list, list) { |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 692 | /* Make sure this station belongs to the proper dev */ |
| 693 | if (sta->sdata->dev != dev) |
| 694 | continue; |
| 695 | |
Johannes Berg | e13bae4 | 2013-07-08 10:43:31 +0200 | [diff] [blame] | 696 | sinfo.filled = 0; |
| 697 | sta_set_sinfo(sta, &sinfo); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 698 | i = 0; |
| 699 | ADD_STA_STATS(sta); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 703 | do_survey: |
| 704 | i = STA_STATS_LEN - STA_STATS_SURVEY_LEN; |
| 705 | /* Get survey stats for current channel */ |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 706 | survey.filled = 0; |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 707 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 708 | rcu_read_lock(); |
| 709 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 710 | if (chanctx_conf) |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 711 | channel = chanctx_conf->def.chan; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 712 | else |
| 713 | channel = NULL; |
| 714 | rcu_read_unlock(); |
| 715 | |
| 716 | if (channel) { |
| 717 | q = 0; |
| 718 | do { |
| 719 | survey.filled = 0; |
| 720 | if (drv_get_survey(local, q, &survey) != 0) { |
| 721 | survey.filled = 0; |
| 722 | break; |
| 723 | } |
| 724 | q++; |
| 725 | } while (channel != survey.channel); |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | if (survey.filled) |
| 729 | data[i++] = survey.channel->center_freq; |
| 730 | else |
| 731 | data[i++] = 0; |
| 732 | if (survey.filled & SURVEY_INFO_NOISE_DBM) |
| 733 | data[i++] = (u8)survey.noise; |
| 734 | else |
| 735 | data[i++] = -1LL; |
| 736 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME) |
| 737 | data[i++] = survey.channel_time; |
| 738 | else |
| 739 | data[i++] = -1LL; |
| 740 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY) |
| 741 | data[i++] = survey.channel_time_busy; |
| 742 | else |
| 743 | data[i++] = -1LL; |
| 744 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY) |
| 745 | data[i++] = survey.channel_time_ext_busy; |
| 746 | else |
| 747 | data[i++] = -1LL; |
| 748 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX) |
| 749 | data[i++] = survey.channel_time_rx; |
| 750 | else |
| 751 | data[i++] = -1LL; |
| 752 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX) |
| 753 | data[i++] = survey.channel_time_tx; |
| 754 | else |
| 755 | data[i++] = -1LL; |
| 756 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 757 | mutex_unlock(&local->sta_mtx); |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 758 | |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 759 | if (WARN_ON(i != STA_STATS_LEN)) |
| 760 | return; |
| 761 | |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 762 | drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN])); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 763 | } |
| 764 | |
| 765 | static void ieee80211_get_et_strings(struct wiphy *wiphy, |
| 766 | struct net_device *dev, |
| 767 | u32 sset, u8 *data) |
| 768 | { |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 769 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 770 | int sz_sta_stats = 0; |
| 771 | |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 772 | if (sset == ETH_SS_STATS) { |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 773 | sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats); |
Johannes Berg | bd500af | 2013-05-06 21:09:46 +0200 | [diff] [blame] | 774 | memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 775 | } |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 776 | drv_get_et_strings(sdata, sset, &(data[sz_sta_stats])); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 777 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 778 | |
| 779 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 780 | int idx, u8 *mac, struct station_info *sinfo) |
| 781 | { |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 782 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 783 | struct ieee80211_local *local = sdata->local; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 784 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 785 | int ret = -ENOENT; |
| 786 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 787 | mutex_lock(&local->sta_mtx); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 788 | |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 789 | sta = sta_info_get_by_idx(sdata, idx); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 790 | if (sta) { |
| 791 | ret = 0; |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 792 | memcpy(mac, sta->sta.addr, ETH_ALEN); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 793 | sta_set_sinfo(sta, sinfo); |
| 794 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 795 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 796 | mutex_unlock(&local->sta_mtx); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 797 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 798 | return ret; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 799 | } |
| 800 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 801 | static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, |
| 802 | int idx, struct survey_info *survey) |
| 803 | { |
| 804 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 805 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 806 | return drv_get_survey(local, idx, survey); |
| 807 | } |
| 808 | |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 809 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 810 | u8 *mac, struct station_info *sinfo) |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 811 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 812 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 813 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 814 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 815 | int ret = -ENOENT; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 816 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 817 | mutex_lock(&local->sta_mtx); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 818 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 819 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 820 | if (sta) { |
| 821 | ret = 0; |
| 822 | sta_set_sinfo(sta, sinfo); |
| 823 | } |
| 824 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 825 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 826 | |
| 827 | return ret; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 828 | } |
| 829 | |
Johannes Berg | e8c9bd5 | 2012-06-06 08:18:22 +0200 | [diff] [blame] | 830 | static int ieee80211_set_monitor_channel(struct wiphy *wiphy, |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 831 | struct cfg80211_chan_def *chandef) |
Johannes Berg | e8c9bd5 | 2012-06-06 08:18:22 +0200 | [diff] [blame] | 832 | { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 833 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 834 | struct ieee80211_sub_if_data *sdata; |
| 835 | int ret = 0; |
| 836 | |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 837 | if (cfg80211_chandef_identical(&local->monitor_chandef, chandef)) |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 838 | return 0; |
| 839 | |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 840 | mutex_lock(&local->mtx); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 841 | mutex_lock(&local->iflist_mtx); |
| 842 | if (local->use_chanctx) { |
| 843 | sdata = rcu_dereference_protected( |
| 844 | local->monitor_sdata, |
| 845 | lockdep_is_held(&local->iflist_mtx)); |
| 846 | if (sdata) { |
| 847 | ieee80211_vif_release_channel(sdata); |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 848 | ret = ieee80211_vif_use_channel(sdata, chandef, |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 849 | IEEE80211_CHANCTX_EXCLUSIVE); |
| 850 | } |
| 851 | } else if (local->open_count == local->monitors) { |
Karl Beldan | 675a0b0 | 2013-03-25 16:26:57 +0100 | [diff] [blame] | 852 | local->_oper_chandef = *chandef; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 853 | ieee80211_hw_config(local, 0); |
| 854 | } |
| 855 | |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 856 | if (ret == 0) |
| 857 | local->monitor_chandef = *chandef; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 858 | mutex_unlock(&local->iflist_mtx); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 859 | mutex_unlock(&local->mtx); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 860 | |
| 861 | return ret; |
Johannes Berg | e8c9bd5 | 2012-06-06 08:18:22 +0200 | [diff] [blame] | 862 | } |
| 863 | |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 864 | static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 865 | const u8 *resp, size_t resp_len) |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 866 | { |
Eyal Shapira | aa7a008 | 2012-08-06 14:26:16 +0300 | [diff] [blame] | 867 | struct probe_resp *new, *old; |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 868 | |
| 869 | if (!resp || !resp_len) |
Sujith Manoharan | aba4e6f | 2012-08-22 14:21:07 +0530 | [diff] [blame] | 870 | return 1; |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 871 | |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 872 | old = sdata_dereference(sdata->u.ap.probe_resp, sdata); |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 873 | |
Eyal Shapira | aa7a008 | 2012-08-06 14:26:16 +0300 | [diff] [blame] | 874 | new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL); |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 875 | if (!new) |
| 876 | return -ENOMEM; |
| 877 | |
Eyal Shapira | aa7a008 | 2012-08-06 14:26:16 +0300 | [diff] [blame] | 878 | new->len = resp_len; |
| 879 | memcpy(new->data, resp, resp_len); |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 880 | |
| 881 | rcu_assign_pointer(sdata->u.ap.probe_resp, new); |
Eyal Shapira | aa7a008 | 2012-08-06 14:26:16 +0300 | [diff] [blame] | 882 | if (old) |
| 883 | kfree_rcu(old, rcu_head); |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 884 | |
| 885 | return 0; |
| 886 | } |
| 887 | |
Luciano Coelho | 0ae0796 | 2013-12-08 09:42:25 +0200 | [diff] [blame] | 888 | static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, |
| 889 | struct cfg80211_beacon_data *params) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 890 | { |
| 891 | struct beacon_data *new, *old; |
| 892 | int new_head_len, new_tail_len; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 893 | int size, err; |
| 894 | u32 changed = BSS_CHANGED_BEACON; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 895 | |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 896 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
| 897 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 898 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 899 | /* Need to have a beacon head if we don't have one yet */ |
| 900 | if (!params->head && !old) |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 901 | return -EINVAL; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 902 | |
| 903 | /* new or old head? */ |
| 904 | if (params->head) |
| 905 | new_head_len = params->head_len; |
| 906 | else |
| 907 | new_head_len = old->head_len; |
| 908 | |
| 909 | /* new or old tail? */ |
| 910 | if (params->tail || !old) |
| 911 | /* params->tail_len will be zero for !params->tail */ |
| 912 | new_tail_len = params->tail_len; |
| 913 | else |
| 914 | new_tail_len = old->tail_len; |
| 915 | |
| 916 | size = sizeof(*new) + new_head_len + new_tail_len; |
| 917 | |
| 918 | new = kzalloc(size, GFP_KERNEL); |
| 919 | if (!new) |
| 920 | return -ENOMEM; |
| 921 | |
| 922 | /* start filling the new info now */ |
| 923 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 924 | /* |
| 925 | * pointers go into the block we allocated, |
| 926 | * memory is | beacon_data | head | tail | |
| 927 | */ |
| 928 | new->head = ((u8 *) new) + sizeof(*new); |
| 929 | new->tail = new->head + new_head_len; |
| 930 | new->head_len = new_head_len; |
| 931 | new->tail_len = new_tail_len; |
| 932 | |
| 933 | /* copy in head */ |
| 934 | if (params->head) |
| 935 | memcpy(new->head, params->head, new_head_len); |
| 936 | else |
| 937 | memcpy(new->head, old->head, new_head_len); |
| 938 | |
| 939 | /* copy in optional tail */ |
| 940 | if (params->tail) |
| 941 | memcpy(new->tail, params->tail, new_tail_len); |
| 942 | else |
| 943 | if (old) |
| 944 | memcpy(new->tail, old->tail, new_tail_len); |
| 945 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 946 | err = ieee80211_set_probe_resp(sdata, params->probe_resp, |
| 947 | params->probe_resp_len); |
| 948 | if (err < 0) |
| 949 | return err; |
| 950 | if (err == 0) |
| 951 | changed |= BSS_CHANGED_AP_PROBE_RESP; |
Johannes Berg | 19885c4 | 2010-02-05 11:45:06 +0100 | [diff] [blame] | 952 | |
Eric Dumazet | cf778b0 | 2012-01-12 04:41:32 +0000 | [diff] [blame] | 953 | rcu_assign_pointer(sdata->u.ap.beacon, new); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 954 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 955 | if (old) |
| 956 | kfree_rcu(old, rcu_head); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 957 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 958 | return changed; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 959 | } |
| 960 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 961 | static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, |
| 962 | struct cfg80211_ap_settings *params) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 963 | { |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 964 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 965 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 966 | struct beacon_data *old; |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 967 | struct ieee80211_sub_if_data *vlan; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 968 | u32 changed = BSS_CHANGED_BEACON_INT | |
| 969 | BSS_CHANGED_BEACON_ENABLED | |
| 970 | BSS_CHANGED_BEACON | |
Johannes Berg | 339afbf | 2012-11-14 15:21:17 +0100 | [diff] [blame] | 971 | BSS_CHANGED_SSID | |
| 972 | BSS_CHANGED_P2P_PS; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 973 | int err; |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 974 | |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 975 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 976 | if (old) |
| 977 | return -EALREADY; |
| 978 | |
Johannes Berg | 04ecd25 | 2012-09-11 14:34:12 +0200 | [diff] [blame] | 979 | /* TODO: make hostapd tell us what it wants */ |
| 980 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
| 981 | sdata->needed_rx_chains = sdata->local->rx_chains; |
| 982 | |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 983 | mutex_lock(&local->mtx); |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 984 | err = ieee80211_vif_use_channel(sdata, ¶ms->chandef, |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 985 | IEEE80211_CHANCTX_SHARED); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 986 | mutex_unlock(&local->mtx); |
Johannes Berg | aa430da | 2012-05-16 23:50:18 +0200 | [diff] [blame] | 987 | if (err) |
| 988 | return err; |
Johannes Berg | 1f4ac5a | 2013-02-08 12:07:44 +0100 | [diff] [blame] | 989 | ieee80211_vif_copy_chanctx_to_vlans(sdata, false); |
Johannes Berg | aa430da | 2012-05-16 23:50:18 +0200 | [diff] [blame] | 990 | |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 991 | /* |
| 992 | * Apply control port protocol, this allows us to |
| 993 | * not encrypt dynamic WEP control frames. |
| 994 | */ |
| 995 | sdata->control_port_protocol = params->crypto.control_port_ethertype; |
| 996 | sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt; |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 997 | sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local, |
| 998 | ¶ms->crypto, |
| 999 | sdata->vif.type); |
| 1000 | |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 1001 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { |
| 1002 | vlan->control_port_protocol = |
| 1003 | params->crypto.control_port_ethertype; |
| 1004 | vlan->control_port_no_encrypt = |
| 1005 | params->crypto.control_port_no_encrypt; |
Max Stepanov | 2475b1cc | 2013-03-24 14:23:27 +0200 | [diff] [blame] | 1006 | vlan->encrypt_headroom = |
| 1007 | ieee80211_cs_headroom(sdata->local, |
| 1008 | ¶ms->crypto, |
| 1009 | vlan->vif.type); |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 1010 | } |
| 1011 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1012 | sdata->vif.bss_conf.beacon_int = params->beacon_interval; |
| 1013 | sdata->vif.bss_conf.dtim_period = params->dtim_period; |
Johannes Berg | d6a8322 | 2012-12-14 14:06:28 +0100 | [diff] [blame] | 1014 | sdata->vif.bss_conf.enable_beacon = true; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1015 | |
| 1016 | sdata->vif.bss_conf.ssid_len = params->ssid_len; |
| 1017 | if (params->ssid_len) |
| 1018 | memcpy(sdata->vif.bss_conf.ssid, params->ssid, |
| 1019 | params->ssid_len); |
| 1020 | sdata->vif.bss_conf.hidden_ssid = |
| 1021 | (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); |
| 1022 | |
Janusz Dziedzic | 67baf66 | 2013-03-21 15:47:56 +0100 | [diff] [blame] | 1023 | memset(&sdata->vif.bss_conf.p2p_noa_attr, 0, |
| 1024 | sizeof(sdata->vif.bss_conf.p2p_noa_attr)); |
| 1025 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow = |
| 1026 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; |
| 1027 | if (params->p2p_opp_ps) |
| 1028 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= |
| 1029 | IEEE80211_P2P_OPPPS_ENABLE_BIT; |
Johannes Berg | 339afbf | 2012-11-14 15:21:17 +0100 | [diff] [blame] | 1030 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1031 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon); |
Emmanuel Grumbach | 0297ea1 | 2014-01-27 11:07:42 +0200 | [diff] [blame] | 1032 | if (err < 0) { |
| 1033 | ieee80211_vif_release_channel(sdata); |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1034 | return err; |
Emmanuel Grumbach | 0297ea1 | 2014-01-27 11:07:42 +0200 | [diff] [blame] | 1035 | } |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1036 | changed |= err; |
| 1037 | |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 1038 | err = drv_start_ap(sdata->local, sdata); |
| 1039 | if (err) { |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 1040 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
| 1041 | |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 1042 | if (old) |
| 1043 | kfree_rcu(old, rcu_head); |
| 1044 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); |
Emmanuel Grumbach | 0297ea1 | 2014-01-27 11:07:42 +0200 | [diff] [blame] | 1045 | ieee80211_vif_release_channel(sdata); |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 1046 | return err; |
| 1047 | } |
| 1048 | |
Thomas Pedersen | 057d5f4 | 2013-12-19 10:25:15 -0800 | [diff] [blame] | 1049 | ieee80211_recalc_dtim(local, sdata); |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1050 | ieee80211_bss_info_change_notify(sdata, changed); |
| 1051 | |
Johannes Berg | 3edaf3e | 2012-04-03 10:24:00 +0200 | [diff] [blame] | 1052 | netif_carrier_on(dev); |
| 1053 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
| 1054 | netif_carrier_on(vlan->dev); |
| 1055 | |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 1056 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1057 | } |
| 1058 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1059 | static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 1060 | struct cfg80211_beacon_data *params) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1061 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1062 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1063 | struct beacon_data *old; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1064 | int err; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1065 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1066 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Michal Kazior | dbd7285 | 2014-01-29 07:56:21 +0100 | [diff] [blame] | 1067 | sdata_assert_lock(sdata); |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1068 | |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 1069 | /* don't allow changing the beacon while CSA is in place - offset |
| 1070 | * of channel switch counter may change |
| 1071 | */ |
| 1072 | if (sdata->vif.csa_active) |
| 1073 | return -EBUSY; |
| 1074 | |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 1075 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1076 | if (!old) |
| 1077 | return -ENOENT; |
| 1078 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1079 | err = ieee80211_assign_beacon(sdata, params); |
| 1080 | if (err < 0) |
| 1081 | return err; |
| 1082 | ieee80211_bss_info_change_notify(sdata, err); |
| 1083 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1084 | } |
| 1085 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1086 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1087 | { |
Johannes Berg | 7b20b8e | 2012-10-25 19:02:42 +0200 | [diff] [blame] | 1088 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1089 | struct ieee80211_sub_if_data *vlan; |
| 1090 | struct ieee80211_local *local = sdata->local; |
| 1091 | struct beacon_data *old_beacon; |
| 1092 | struct probe_resp *old_probe_resp; |
Janusz Dziedzic | d2859df | 2013-11-06 13:55:51 +0100 | [diff] [blame] | 1093 | struct cfg80211_chan_def chandef; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1094 | |
Michal Kazior | dbd7285 | 2014-01-29 07:56:21 +0100 | [diff] [blame] | 1095 | sdata_assert_lock(sdata); |
| 1096 | |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 1097 | old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata); |
Johannes Berg | 7b20b8e | 2012-10-25 19:02:42 +0200 | [diff] [blame] | 1098 | if (!old_beacon) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1099 | return -ENOENT; |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 1100 | old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1101 | |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 1102 | /* abort any running channel switch */ |
| 1103 | sdata->vif.csa_active = false; |
Simon Wunderlich | 1f3b8a2 | 2013-11-21 18:19:53 +0100 | [diff] [blame] | 1104 | kfree(sdata->u.ap.next_beacon); |
| 1105 | sdata->u.ap.next_beacon = NULL; |
| 1106 | |
Johannes Berg | 7b20b8e | 2012-10-25 19:02:42 +0200 | [diff] [blame] | 1107 | /* turn off carrier for this interface and dependent VLANs */ |
Johannes Berg | 3edaf3e | 2012-04-03 10:24:00 +0200 | [diff] [blame] | 1108 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
| 1109 | netif_carrier_off(vlan->dev); |
| 1110 | netif_carrier_off(dev); |
| 1111 | |
Johannes Berg | 7b20b8e | 2012-10-25 19:02:42 +0200 | [diff] [blame] | 1112 | /* remove beacon and probe response */ |
Stephen Hemminger | a9b3cd7 | 2011-08-01 16:19:00 +0000 | [diff] [blame] | 1113 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); |
Johannes Berg | 7b20b8e | 2012-10-25 19:02:42 +0200 | [diff] [blame] | 1114 | RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL); |
| 1115 | kfree_rcu(old_beacon, rcu_head); |
| 1116 | if (old_probe_resp) |
| 1117 | kfree_rcu(old_probe_resp, rcu_head); |
Emmanuel Grumbach | 8ffcc70 | 2014-01-23 14:28:16 +0200 | [diff] [blame] | 1118 | sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1119 | |
Johannes Berg | e716251 | 2013-12-04 23:18:37 +0100 | [diff] [blame] | 1120 | __sta_info_flush(sdata, true); |
Johannes Berg | 7907c7d | 2013-12-04 23:47:09 +0100 | [diff] [blame] | 1121 | ieee80211_free_keys(sdata, true); |
Johannes Berg | 75de911 | 2012-12-14 14:56:03 +0100 | [diff] [blame] | 1122 | |
Johannes Berg | d6a8322 | 2012-12-14 14:06:28 +0100 | [diff] [blame] | 1123 | sdata->vif.bss_conf.enable_beacon = false; |
Marek Puzyniak | 0eabccd | 2013-04-10 13:47:45 +0200 | [diff] [blame] | 1124 | sdata->vif.bss_conf.ssid_len = 0; |
Johannes Berg | d6a8322 | 2012-12-14 14:06:28 +0100 | [diff] [blame] | 1125 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1126 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 1127 | |
Simon Wunderlich | a6b368f | 2013-06-11 10:44:39 +0200 | [diff] [blame] | 1128 | if (sdata->wdev.cac_started) { |
Janusz Dziedzic | d2859df | 2013-11-06 13:55:51 +0100 | [diff] [blame] | 1129 | chandef = sdata->vif.bss_conf.chandef; |
Simon Wunderlich | a6b368f | 2013-06-11 10:44:39 +0200 | [diff] [blame] | 1130 | cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); |
Janusz Dziedzic | d2859df | 2013-11-06 13:55:51 +0100 | [diff] [blame] | 1131 | cfg80211_cac_event(sdata->dev, &chandef, |
| 1132 | NL80211_RADAR_CAC_ABORTED, |
Simon Wunderlich | a6b368f | 2013-06-11 10:44:39 +0200 | [diff] [blame] | 1133 | GFP_KERNEL); |
| 1134 | } |
| 1135 | |
Johannes Berg | 1041638 | 2012-10-19 15:44:42 +0200 | [diff] [blame] | 1136 | drv_stop_ap(sdata->local, sdata); |
| 1137 | |
Johannes Berg | 7b20b8e | 2012-10-25 19:02:42 +0200 | [diff] [blame] | 1138 | /* free all potentially still buffered bcast frames */ |
| 1139 | local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf); |
| 1140 | skb_queue_purge(&sdata->u.ap.ps.bc_buf); |
| 1141 | |
Johannes Berg | 1f4ac5a | 2013-02-08 12:07:44 +0100 | [diff] [blame] | 1142 | ieee80211_vif_copy_chanctx_to_vlans(sdata, true); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 1143 | mutex_lock(&local->mtx); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1144 | ieee80211_vif_release_channel(sdata); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 1145 | mutex_unlock(&local->mtx); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1146 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1147 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1148 | } |
| 1149 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1150 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
| 1151 | struct iapp_layer2_update { |
| 1152 | u8 da[ETH_ALEN]; /* broadcast */ |
| 1153 | u8 sa[ETH_ALEN]; /* STA addr */ |
| 1154 | __be16 len; /* 6 */ |
| 1155 | u8 dsap; /* 0 */ |
| 1156 | u8 ssap; /* 0 */ |
| 1157 | u8 control; |
| 1158 | u8 xid_info[3]; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 1159 | } __packed; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1160 | |
| 1161 | static void ieee80211_send_layer2_update(struct sta_info *sta) |
| 1162 | { |
| 1163 | struct iapp_layer2_update *msg; |
| 1164 | struct sk_buff *skb; |
| 1165 | |
| 1166 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 |
| 1167 | * bridge devices */ |
| 1168 | |
| 1169 | skb = dev_alloc_skb(sizeof(*msg)); |
| 1170 | if (!skb) |
| 1171 | return; |
| 1172 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); |
| 1173 | |
| 1174 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) |
| 1175 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ |
| 1176 | |
Johannes Berg | e83e654 | 2012-07-13 16:23:07 +0200 | [diff] [blame] | 1177 | eth_broadcast_addr(msg->da); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1178 | memcpy(msg->sa, sta->sta.addr, ETH_ALEN); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1179 | msg->len = htons(6); |
| 1180 | msg->dsap = 0; |
| 1181 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ |
| 1182 | msg->control = 0xaf; /* XID response lsb.1111F101. |
| 1183 | * F=0 (no poll command; unsolicited frame) */ |
| 1184 | msg->xid_info[0] = 0x81; /* XID format identifier */ |
| 1185 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ |
| 1186 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ |
| 1187 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1188 | skb->dev = sta->sdata->dev; |
| 1189 | skb->protocol = eth_type_trans(skb, sta->sdata->dev); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1190 | memset(skb->cb, 0, sizeof(skb->cb)); |
John W. Linville | 06ee1c2 | 2010-07-19 11:52:59 -0400 | [diff] [blame] | 1191 | netif_rx_ni(skb); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1192 | } |
| 1193 | |
Johannes Berg | d582cff | 2012-10-26 17:53:44 +0200 | [diff] [blame] | 1194 | static int sta_apply_auth_flags(struct ieee80211_local *local, |
| 1195 | struct sta_info *sta, |
| 1196 | u32 mask, u32 set) |
| 1197 | { |
| 1198 | int ret; |
| 1199 | |
| 1200 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && |
| 1201 | set & BIT(NL80211_STA_FLAG_AUTHENTICATED) && |
| 1202 | !test_sta_flag(sta, WLAN_STA_AUTH)) { |
| 1203 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); |
| 1204 | if (ret) |
| 1205 | return ret; |
| 1206 | } |
| 1207 | |
| 1208 | if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && |
| 1209 | set & BIT(NL80211_STA_FLAG_ASSOCIATED) && |
| 1210 | !test_sta_flag(sta, WLAN_STA_ASSOC)) { |
| 1211 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); |
| 1212 | if (ret) |
| 1213 | return ret; |
| 1214 | } |
| 1215 | |
| 1216 | if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
| 1217 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
| 1218 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); |
| 1219 | else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
| 1220 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); |
| 1221 | else |
| 1222 | ret = 0; |
| 1223 | if (ret) |
| 1224 | return ret; |
| 1225 | } |
| 1226 | |
| 1227 | if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && |
| 1228 | !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) && |
| 1229 | test_sta_flag(sta, WLAN_STA_ASSOC)) { |
| 1230 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); |
| 1231 | if (ret) |
| 1232 | return ret; |
| 1233 | } |
| 1234 | |
| 1235 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && |
| 1236 | !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) && |
| 1237 | test_sta_flag(sta, WLAN_STA_AUTH)) { |
| 1238 | ret = sta_info_move_state(sta, IEEE80211_STA_NONE); |
| 1239 | if (ret) |
| 1240 | return ret; |
| 1241 | } |
| 1242 | |
| 1243 | return 0; |
| 1244 | } |
| 1245 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1246 | static int sta_apply_parameters(struct ieee80211_local *local, |
| 1247 | struct sta_info *sta, |
| 1248 | struct station_parameters *params) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1249 | { |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1250 | int ret = 0; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 1251 | struct ieee80211_supported_band *sband; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1252 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1253 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1254 | u32 mask, set; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1255 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1256 | sband = local->hw.wiphy->bands[band]; |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1257 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1258 | mask = params->sta_flags_mask; |
| 1259 | set = params->sta_flags_set; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1260 | |
Johannes Berg | d582cff | 2012-10-26 17:53:44 +0200 | [diff] [blame] | 1261 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
| 1262 | /* |
| 1263 | * In mesh mode, ASSOCIATED isn't part of the nl80211 |
| 1264 | * API but must follow AUTHENTICATED for driver state. |
| 1265 | */ |
| 1266 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) |
| 1267 | mask |= BIT(NL80211_STA_FLAG_ASSOCIATED); |
| 1268 | if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) |
| 1269 | set |= BIT(NL80211_STA_FLAG_ASSOCIATED); |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1270 | } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { |
| 1271 | /* |
| 1272 | * TDLS -- everything follows authorized, but |
| 1273 | * only becoming authorized is possible, not |
| 1274 | * going back |
| 1275 | */ |
| 1276 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
| 1277 | set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | |
| 1278 | BIT(NL80211_STA_FLAG_ASSOCIATED); |
| 1279 | mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | |
| 1280 | BIT(NL80211_STA_FLAG_ASSOCIATED); |
| 1281 | } |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1282 | } |
| 1283 | |
Johannes Berg | d582cff | 2012-10-26 17:53:44 +0200 | [diff] [blame] | 1284 | ret = sta_apply_auth_flags(local, sta, mask, set); |
| 1285 | if (ret) |
| 1286 | return ret; |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1287 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1288 | if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1289 | if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1290 | set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); |
| 1291 | else |
| 1292 | clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1293 | } |
| 1294 | |
| 1295 | if (mask & BIT(NL80211_STA_FLAG_WME)) { |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 1296 | if (set & BIT(NL80211_STA_FLAG_WME)) { |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1297 | set_sta_flag(sta, WLAN_STA_WME); |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 1298 | sta->sta.wme = true; |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1299 | } else { |
| 1300 | clear_sta_flag(sta, WLAN_STA_WME); |
| 1301 | sta->sta.wme = false; |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 1302 | } |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | if (mask & BIT(NL80211_STA_FLAG_MFP)) { |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1306 | if (set & BIT(NL80211_STA_FLAG_MFP)) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1307 | set_sta_flag(sta, WLAN_STA_MFP); |
| 1308 | else |
| 1309 | clear_sta_flag(sta, WLAN_STA_MFP); |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1310 | } |
Javier Cardona | b39c48f | 2011-04-07 15:08:30 -0700 | [diff] [blame] | 1311 | |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame] | 1312 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame] | 1313 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1314 | set_sta_flag(sta, WLAN_STA_TDLS_PEER); |
| 1315 | else |
| 1316 | clear_sta_flag(sta, WLAN_STA_TDLS_PEER); |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame] | 1317 | } |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1318 | |
Johannes Berg | 3b9ce80 | 2011-09-27 20:56:12 +0200 | [diff] [blame] | 1319 | if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) { |
| 1320 | sta->sta.uapsd_queues = params->uapsd_queues; |
| 1321 | sta->sta.max_sp = params->max_sp; |
| 1322 | } |
Eliad Peller | 9533b4a | 2011-08-23 14:37:47 +0300 | [diff] [blame] | 1323 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1324 | /* |
Johannes Berg | 51b50fb | 2009-05-24 16:42:30 +0200 | [diff] [blame] | 1325 | * cfg80211 validates this (1-2007) and allows setting the AID |
| 1326 | * only when creating a new station entry |
| 1327 | */ |
| 1328 | if (params->aid) |
| 1329 | sta->sta.aid = params->aid; |
| 1330 | |
| 1331 | /* |
Johannes Berg | ba23d20 | 2012-12-27 17:32:09 +0100 | [diff] [blame] | 1332 | * Some of the following updates would be racy if called on an |
| 1333 | * existing station, via ieee80211_change_station(). However, |
| 1334 | * all such changes are rejected by cfg80211 except for updates |
| 1335 | * changing the supported rates on an existing but not yet used |
| 1336 | * TDLS peer. |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1337 | */ |
| 1338 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1339 | if (params->listen_interval >= 0) |
| 1340 | sta->listen_interval = params->listen_interval; |
| 1341 | |
| 1342 | if (params->supported_rates) { |
Simon Wunderlich | 2103dec | 2013-07-08 16:55:53 +0200 | [diff] [blame] | 1343 | ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef, |
| 1344 | sband, params->supported_rates, |
| 1345 | params->supported_rates_len, |
| 1346 | &sta->sta.supp_rates[band]); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1347 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1348 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 1349 | if (params->ht_capa) |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 1350 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, |
Johannes Berg | e1a0c6b | 2013-02-07 11:47:44 +0100 | [diff] [blame] | 1351 | params->ht_capa, sta); |
Jouni Malinen | 36aedc9 | 2008-08-25 11:58:58 +0300 | [diff] [blame] | 1352 | |
Mahesh Palivela | f461be3e | 2012-10-11 08:04:52 +0000 | [diff] [blame] | 1353 | if (params->vht_capa) |
| 1354 | ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband, |
Johannes Berg | 4a34215 | 2013-02-07 11:58:58 +0100 | [diff] [blame] | 1355 | params->vht_capa, sta); |
Mahesh Palivela | f461be3e | 2012-10-11 08:04:52 +0000 | [diff] [blame] | 1356 | |
Marek Kwaczynski | b1bce14a | 2014-02-03 14:44:44 +0100 | [diff] [blame] | 1357 | if (params->opmode_notif_used) { |
Marek Kwaczynski | b1bce14a | 2014-02-03 14:44:44 +0100 | [diff] [blame] | 1358 | /* returned value is only needed for rc update, but the |
| 1359 | * rc isn't initialized here yet, so ignore it |
| 1360 | */ |
| 1361 | __ieee80211_vht_handle_opmode(sdata, sta, |
| 1362 | params->opmode_notif, |
| 1363 | band, false); |
| 1364 | } |
| 1365 | |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 1366 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Yogesh Ashok Powar | 4daf50f | 2011-05-12 09:32:17 -0400 | [diff] [blame] | 1367 | #ifdef CONFIG_MAC80211_MESH |
Thomas Pedersen | 39886b6 | 2013-02-13 12:14:19 -0800 | [diff] [blame] | 1368 | u32 changed = 0; |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1369 | |
| 1370 | if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) { |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 1371 | switch (params->plink_state) { |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 1372 | case NL80211_PLINK_ESTAB: |
Marco Porsch | 1617bab | 2013-01-07 16:04:49 +0100 | [diff] [blame] | 1373 | if (sta->plink_state != NL80211_PLINK_ESTAB) |
| 1374 | changed = mesh_plink_inc_estab_count( |
| 1375 | sdata); |
| 1376 | sta->plink_state = params->plink_state; |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 1377 | |
| 1378 | ieee80211_mps_sta_status_update(sta); |
Thomas Pedersen | 39886b6 | 2013-02-13 12:14:19 -0800 | [diff] [blame] | 1379 | changed |= ieee80211_mps_set_sta_local_pm(sta, |
| 1380 | sdata->u.mesh.mshcfg.power_mode); |
Marco Porsch | 1617bab | 2013-01-07 16:04:49 +0100 | [diff] [blame] | 1381 | break; |
| 1382 | case NL80211_PLINK_LISTEN: |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 1383 | case NL80211_PLINK_BLOCKED: |
Marco Porsch | 1617bab | 2013-01-07 16:04:49 +0100 | [diff] [blame] | 1384 | case NL80211_PLINK_OPN_SNT: |
| 1385 | case NL80211_PLINK_OPN_RCVD: |
| 1386 | case NL80211_PLINK_CNF_RCVD: |
| 1387 | case NL80211_PLINK_HOLDING: |
| 1388 | if (sta->plink_state == NL80211_PLINK_ESTAB) |
| 1389 | changed = mesh_plink_dec_estab_count( |
| 1390 | sdata); |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 1391 | sta->plink_state = params->plink_state; |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 1392 | |
| 1393 | ieee80211_mps_sta_status_update(sta); |
Marco Porsch | 446075d | 2013-10-15 12:29:24 +0200 | [diff] [blame] | 1394 | changed |= ieee80211_mps_set_sta_local_pm(sta, |
| 1395 | NL80211_MESH_POWER_UNKNOWN); |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 1396 | break; |
| 1397 | default: |
| 1398 | /* nothing */ |
| 1399 | break; |
| 1400 | } |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | switch (params->plink_action) { |
| 1404 | case NL80211_PLINK_ACTION_NO_ACTION: |
| 1405 | /* nothing */ |
| 1406 | break; |
| 1407 | case NL80211_PLINK_ACTION_OPEN: |
| 1408 | changed |= mesh_plink_open(sta); |
| 1409 | break; |
| 1410 | case NL80211_PLINK_ACTION_BLOCK: |
| 1411 | changed |= mesh_plink_block(sta); |
| 1412 | break; |
Marco Porsch | 1617bab | 2013-01-07 16:04:49 +0100 | [diff] [blame] | 1413 | } |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 1414 | |
| 1415 | if (params->local_pm) |
Thomas Pedersen | 39886b6 | 2013-02-13 12:14:19 -0800 | [diff] [blame] | 1416 | changed |= |
| 1417 | ieee80211_mps_set_sta_local_pm(sta, |
| 1418 | params->local_pm); |
Javier Lopez | 6c751ef | 2013-11-06 10:04:29 -0800 | [diff] [blame] | 1419 | ieee80211_mbss_info_change_notify(sdata, changed); |
Yogesh Ashok Powar | 4daf50f | 2011-05-12 09:32:17 -0400 | [diff] [blame] | 1420 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 1421 | } |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1422 | |
| 1423 | return 0; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1424 | } |
| 1425 | |
| 1426 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
| 1427 | u8 *mac, struct station_parameters *params) |
| 1428 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1429 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1430 | struct sta_info *sta; |
| 1431 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1432 | int err; |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 1433 | int layer2_update; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1434 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1435 | if (params->vlan) { |
| 1436 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 1437 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 1438 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 1439 | sdata->vif.type != NL80211_IFTYPE_AP) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1440 | return -EINVAL; |
| 1441 | } else |
| 1442 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1443 | |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 1444 | if (ether_addr_equal(mac, sdata->vif.addr)) |
Johannes Berg | 03e4497 | 2008-02-27 09:56:40 +0100 | [diff] [blame] | 1445 | return -EINVAL; |
| 1446 | |
| 1447 | if (is_multicast_ether_addr(mac)) |
| 1448 | return -EINVAL; |
| 1449 | |
| 1450 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1451 | if (!sta) |
| 1452 | return -ENOMEM; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1453 | |
Johannes Berg | d582cff | 2012-10-26 17:53:44 +0200 | [diff] [blame] | 1454 | /* |
| 1455 | * defaults -- if userspace wants something else we'll |
| 1456 | * change it accordingly in sta_apply_parameters() |
| 1457 | */ |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1458 | if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) { |
| 1459 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); |
| 1460 | sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); |
| 1461 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1462 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1463 | err = sta_apply_parameters(local, sta, params); |
| 1464 | if (err) { |
| 1465 | sta_info_free(local, sta); |
| 1466 | return err; |
| 1467 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1468 | |
Arik Nemtsov | d64cf63 | 2011-11-07 23:24:39 +0200 | [diff] [blame] | 1469 | /* |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1470 | * for TDLS, rate control should be initialized only when |
| 1471 | * rates are known and station is marked authorized |
Arik Nemtsov | d64cf63 | 2011-11-07 23:24:39 +0200 | [diff] [blame] | 1472 | */ |
| 1473 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) |
| 1474 | rate_control_rate_init(sta); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1475 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 1476 | layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
| 1477 | sdata->vif.type == NL80211_IFTYPE_AP; |
| 1478 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1479 | err = sta_info_insert_rcu(sta); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1480 | if (err) { |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1481 | rcu_read_unlock(); |
| 1482 | return err; |
| 1483 | } |
| 1484 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 1485 | if (layer2_update) |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1486 | ieee80211_send_layer2_update(sta); |
| 1487 | |
| 1488 | rcu_read_unlock(); |
| 1489 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1490 | return 0; |
| 1491 | } |
| 1492 | |
| 1493 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 1494 | u8 *mac) |
| 1495 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1496 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1497 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1498 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1499 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1500 | if (mac) |
| 1501 | return sta_info_destroy_addr_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1502 | |
Johannes Berg | b998e8b | 2012-12-13 23:07:46 +0100 | [diff] [blame] | 1503 | sta_info_flush(sdata); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1504 | return 0; |
| 1505 | } |
| 1506 | |
| 1507 | static int ieee80211_change_station(struct wiphy *wiphy, |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1508 | struct net_device *dev, u8 *mac, |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1509 | struct station_parameters *params) |
| 1510 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1511 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1512 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1513 | struct sta_info *sta; |
| 1514 | struct ieee80211_sub_if_data *vlansdata; |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1515 | enum cfg80211_station_type statype; |
Eliad Peller | 35b8862 | 2011-12-29 14:41:39 +0200 | [diff] [blame] | 1516 | int err; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1517 | |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1518 | mutex_lock(&local->sta_mtx); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1519 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 1520 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1521 | if (!sta) { |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1522 | err = -ENOENT; |
| 1523 | goto out_err; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1524 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1525 | |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1526 | switch (sdata->vif.type) { |
| 1527 | case NL80211_IFTYPE_MESH_POINT: |
Thomas Pedersen | a6dad6a | 2013-03-04 13:06:12 -0800 | [diff] [blame] | 1528 | if (sdata->u.mesh.user_mpm) |
Thomas Pedersen | eef941e | 2013-03-04 13:06:11 -0800 | [diff] [blame] | 1529 | statype = CFG80211_STA_MESH_PEER_USER; |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1530 | else |
Thomas Pedersen | eef941e | 2013-03-04 13:06:11 -0800 | [diff] [blame] | 1531 | statype = CFG80211_STA_MESH_PEER_KERNEL; |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1532 | break; |
| 1533 | case NL80211_IFTYPE_ADHOC: |
| 1534 | statype = CFG80211_STA_IBSS; |
| 1535 | break; |
| 1536 | case NL80211_IFTYPE_STATION: |
| 1537 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { |
| 1538 | statype = CFG80211_STA_AP_STA; |
| 1539 | break; |
| 1540 | } |
| 1541 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
| 1542 | statype = CFG80211_STA_TDLS_PEER_ACTIVE; |
| 1543 | else |
| 1544 | statype = CFG80211_STA_TDLS_PEER_SETUP; |
| 1545 | break; |
| 1546 | case NL80211_IFTYPE_AP: |
| 1547 | case NL80211_IFTYPE_AP_VLAN: |
| 1548 | statype = CFG80211_STA_AP_CLIENT; |
| 1549 | break; |
| 1550 | default: |
| 1551 | err = -EOPNOTSUPP; |
| 1552 | goto out_err; |
Johannes Berg | bdd90d5 | 2011-12-14 12:20:27 +0100 | [diff] [blame] | 1553 | } |
| 1554 | |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1555 | err = cfg80211_check_station_change(wiphy, params, statype); |
| 1556 | if (err) |
| 1557 | goto out_err; |
| 1558 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1559 | if (params->vlan && params->vlan != sta->sdata->dev) { |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1560 | bool prev_4addr = false; |
| 1561 | bool new_4addr = false; |
| 1562 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1563 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 1564 | |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 1565 | if (params->vlan->ieee80211_ptr->use_4addr) { |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 1566 | if (vlansdata->u.vlan.sta) { |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1567 | err = -EBUSY; |
| 1568 | goto out_err; |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 1569 | } |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 1570 | |
Eric Dumazet | cf778b0 | 2012-01-12 04:41:32 +0000 | [diff] [blame] | 1571 | rcu_assign_pointer(vlansdata->u.vlan.sta, sta); |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1572 | new_4addr = true; |
| 1573 | } |
| 1574 | |
| 1575 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
| 1576 | sta->sdata->u.vlan.sta) { |
Monam Agarwal | 0c2bef46 | 2014-03-24 00:51:43 +0530 | [diff] [blame] | 1577 | RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL); |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1578 | prev_4addr = true; |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 1579 | } |
| 1580 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1581 | sta->sdata = vlansdata; |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1582 | |
| 1583 | if (sta->sta_state == IEEE80211_STA_AUTHORIZED && |
| 1584 | prev_4addr != new_4addr) { |
| 1585 | if (new_4addr) |
| 1586 | atomic_dec(&sta->sdata->bss->num_mcast_sta); |
| 1587 | else |
| 1588 | atomic_inc(&sta->sdata->bss->num_mcast_sta); |
| 1589 | } |
| 1590 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1591 | ieee80211_send_layer2_update(sta); |
| 1592 | } |
| 1593 | |
Eliad Peller | 35b8862 | 2011-12-29 14:41:39 +0200 | [diff] [blame] | 1594 | err = sta_apply_parameters(local, sta, params); |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1595 | if (err) |
| 1596 | goto out_err; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1597 | |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1598 | /* When peer becomes authorized, init rate control as well */ |
| 1599 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && |
| 1600 | test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
Arik Nemtsov | d64cf63 | 2011-11-07 23:24:39 +0200 | [diff] [blame] | 1601 | rate_control_rate_init(sta); |
| 1602 | |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1603 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1604 | |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 1605 | if ((sdata->vif.type == NL80211_IFTYPE_AP || |
| 1606 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && |
| 1607 | sta->known_smps_mode != sta->sdata->bss->req_smps && |
| 1608 | test_sta_flag(sta, WLAN_STA_AUTHORIZED) && |
| 1609 | sta_info_tx_streams(sta) != 1) { |
| 1610 | ht_dbg(sta->sdata, |
| 1611 | "%pM just authorized and MIMO capable - update SMPS\n", |
| 1612 | sta->sta.addr); |
| 1613 | ieee80211_send_smps_action(sta->sdata, |
| 1614 | sta->sdata->bss->req_smps, |
| 1615 | sta->sta.addr, |
| 1616 | sta->sdata->vif.bss_conf.bssid); |
| 1617 | } |
| 1618 | |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 1619 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
Eliad Peller | ab09587 | 2012-07-27 12:33:22 +0300 | [diff] [blame] | 1620 | params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 1621 | ieee80211_recalc_ps(local, -1); |
Eliad Peller | ab09587 | 2012-07-27 12:33:22 +0300 | [diff] [blame] | 1622 | ieee80211_recalc_ps_vif(sdata); |
| 1623 | } |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1624 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1625 | return 0; |
Johannes Berg | 77ee7c8 | 2013-02-15 00:48:33 +0100 | [diff] [blame] | 1626 | out_err: |
| 1627 | mutex_unlock(&local->sta_mtx); |
| 1628 | return err; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1629 | } |
| 1630 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1631 | #ifdef CONFIG_MAC80211_MESH |
| 1632 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1633 | u8 *dst, u8 *next_hop) |
| 1634 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1635 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1636 | struct mesh_path *mpath; |
| 1637 | struct sta_info *sta; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1638 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1639 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1640 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1641 | rcu_read_lock(); |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1642 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1643 | if (!sta) { |
| 1644 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1645 | return -ENOENT; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1646 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1647 | |
Bob Copeland | ae76eef | 2013-03-29 09:38:39 -0400 | [diff] [blame] | 1648 | mpath = mesh_path_add(sdata, dst); |
| 1649 | if (IS_ERR(mpath)) { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1650 | rcu_read_unlock(); |
Bob Copeland | ae76eef | 2013-03-29 09:38:39 -0400 | [diff] [blame] | 1651 | return PTR_ERR(mpath); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1652 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1653 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1654 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1655 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1656 | rcu_read_unlock(); |
| 1657 | return 0; |
| 1658 | } |
| 1659 | |
| 1660 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | bf7cd94 | 2013-02-15 14:40:31 +0100 | [diff] [blame] | 1661 | u8 *dst) |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1662 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1663 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1664 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1665 | if (dst) |
Johannes Berg | bf7cd94 | 2013-02-15 14:40:31 +0100 | [diff] [blame] | 1666 | return mesh_path_del(sdata, dst); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1667 | |
Javier Cardona | ece1a2e | 2011-08-29 13:23:04 -0700 | [diff] [blame] | 1668 | mesh_path_flush_by_iface(sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1669 | return 0; |
| 1670 | } |
| 1671 | |
| 1672 | static int ieee80211_change_mpath(struct wiphy *wiphy, |
| 1673 | struct net_device *dev, |
| 1674 | u8 *dst, u8 *next_hop) |
| 1675 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1676 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1677 | struct mesh_path *mpath; |
| 1678 | struct sta_info *sta; |
| 1679 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1680 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1681 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1682 | rcu_read_lock(); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1683 | |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1684 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1685 | if (!sta) { |
| 1686 | rcu_read_unlock(); |
| 1687 | return -ENOENT; |
| 1688 | } |
| 1689 | |
Johannes Berg | bf7cd94 | 2013-02-15 14:40:31 +0100 | [diff] [blame] | 1690 | mpath = mesh_path_lookup(sdata, dst); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1691 | if (!mpath) { |
| 1692 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1693 | return -ENOENT; |
| 1694 | } |
| 1695 | |
| 1696 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1697 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1698 | rcu_read_unlock(); |
| 1699 | return 0; |
| 1700 | } |
| 1701 | |
| 1702 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, |
| 1703 | struct mpath_info *pinfo) |
| 1704 | { |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 1705 | struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop); |
| 1706 | |
| 1707 | if (next_hop_sta) |
| 1708 | memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1709 | else |
| 1710 | memset(next_hop, 0, ETH_ALEN); |
| 1711 | |
LEO Airwarosu Yoichi Shinoda | 7ce8c7a | 2012-08-27 22:28:16 +0900 | [diff] [blame] | 1712 | memset(pinfo, 0, sizeof(*pinfo)); |
| 1713 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 1714 | pinfo->generation = mesh_paths_generation; |
| 1715 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1716 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1717 | MPATH_INFO_SN | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1718 | MPATH_INFO_METRIC | |
| 1719 | MPATH_INFO_EXPTIME | |
| 1720 | MPATH_INFO_DISCOVERY_TIMEOUT | |
| 1721 | MPATH_INFO_DISCOVERY_RETRIES | |
| 1722 | MPATH_INFO_FLAGS; |
| 1723 | |
| 1724 | pinfo->frame_qlen = mpath->frame_queue.qlen; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1725 | pinfo->sn = mpath->sn; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1726 | pinfo->metric = mpath->metric; |
| 1727 | if (time_before(jiffies, mpath->exp_time)) |
| 1728 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); |
| 1729 | pinfo->discovery_timeout = |
| 1730 | jiffies_to_msecs(mpath->discovery_timeout); |
| 1731 | pinfo->discovery_retries = mpath->discovery_retries; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1732 | if (mpath->flags & MESH_PATH_ACTIVE) |
| 1733 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; |
| 1734 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 1735 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1736 | if (mpath->flags & MESH_PATH_SN_VALID) |
| 1737 | pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1738 | if (mpath->flags & MESH_PATH_FIXED) |
| 1739 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; |
LEO Airwarosu Yoichi Shinoda | 7ce8c7a | 2012-08-27 22:28:16 +0900 | [diff] [blame] | 1740 | if (mpath->flags & MESH_PATH_RESOLVED) |
| 1741 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1742 | } |
| 1743 | |
| 1744 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1745 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) |
| 1746 | |
| 1747 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1748 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1749 | struct mesh_path *mpath; |
| 1750 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1751 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1752 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1753 | rcu_read_lock(); |
Johannes Berg | bf7cd94 | 2013-02-15 14:40:31 +0100 | [diff] [blame] | 1754 | mpath = mesh_path_lookup(sdata, dst); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1755 | if (!mpath) { |
| 1756 | rcu_read_unlock(); |
| 1757 | return -ENOENT; |
| 1758 | } |
| 1759 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 1760 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 1761 | rcu_read_unlock(); |
| 1762 | return 0; |
| 1763 | } |
| 1764 | |
| 1765 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1766 | int idx, u8 *dst, u8 *next_hop, |
| 1767 | struct mpath_info *pinfo) |
| 1768 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1769 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1770 | struct mesh_path *mpath; |
| 1771 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1772 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1773 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1774 | rcu_read_lock(); |
Johannes Berg | bf7cd94 | 2013-02-15 14:40:31 +0100 | [diff] [blame] | 1775 | mpath = mesh_path_lookup_by_idx(sdata, idx); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1776 | if (!mpath) { |
| 1777 | rcu_read_unlock(); |
| 1778 | return -ENOENT; |
| 1779 | } |
| 1780 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 1781 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 1782 | rcu_read_unlock(); |
| 1783 | return 0; |
| 1784 | } |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1785 | |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 1786 | static int ieee80211_get_mesh_config(struct wiphy *wiphy, |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1787 | struct net_device *dev, |
| 1788 | struct mesh_config *conf) |
| 1789 | { |
| 1790 | struct ieee80211_sub_if_data *sdata; |
| 1791 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1792 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1793 | memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); |
| 1794 | return 0; |
| 1795 | } |
| 1796 | |
| 1797 | static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask) |
| 1798 | { |
| 1799 | return (mask >> (parm-1)) & 0x1; |
| 1800 | } |
| 1801 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1802 | static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh, |
| 1803 | const struct mesh_setup *setup) |
| 1804 | { |
| 1805 | u8 *new_ie; |
| 1806 | const u8 *old_ie; |
Chun-Yeow Yeoh | 4bb6234 | 2011-11-24 17:15:20 -0800 | [diff] [blame] | 1807 | struct ieee80211_sub_if_data *sdata = container_of(ifmsh, |
| 1808 | struct ieee80211_sub_if_data, u.mesh); |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1809 | |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1810 | /* allocate information elements */ |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1811 | new_ie = NULL; |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1812 | old_ie = ifmsh->ie; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1813 | |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1814 | if (setup->ie_len) { |
| 1815 | new_ie = kmemdup(setup->ie, setup->ie_len, |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1816 | GFP_KERNEL); |
| 1817 | if (!new_ie) |
| 1818 | return -ENOMEM; |
| 1819 | } |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1820 | ifmsh->ie_len = setup->ie_len; |
| 1821 | ifmsh->ie = new_ie; |
| 1822 | kfree(old_ie); |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1823 | |
| 1824 | /* now copy the rest of the setup parameters */ |
| 1825 | ifmsh->mesh_id_len = setup->mesh_id_len; |
| 1826 | memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); |
Javier Cardona | d299a1f | 2012-03-31 11:31:33 -0700 | [diff] [blame] | 1827 | ifmsh->mesh_sp_id = setup->sync_method; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1828 | ifmsh->mesh_pp_id = setup->path_sel_proto; |
| 1829 | ifmsh->mesh_pm_id = setup->path_metric; |
Thomas Pedersen | a6dad6a | 2013-03-04 13:06:12 -0800 | [diff] [blame] | 1830 | ifmsh->user_mpm = setup->user_mpm; |
Colleen Twitty | 0d4261a | 2013-05-08 11:46:00 -0700 | [diff] [blame] | 1831 | ifmsh->mesh_auth_id = setup->auth_id; |
Javier Cardona | b130e5c | 2011-05-03 16:57:07 -0700 | [diff] [blame] | 1832 | ifmsh->security = IEEE80211_MESH_SEC_NONE; |
| 1833 | if (setup->is_authenticated) |
| 1834 | ifmsh->security |= IEEE80211_MESH_SEC_AUTHED; |
| 1835 | if (setup->is_secure) |
| 1836 | ifmsh->security |= IEEE80211_MESH_SEC_SECURED; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1837 | |
Chun-Yeow Yeoh | 4bb6234 | 2011-11-24 17:15:20 -0800 | [diff] [blame] | 1838 | /* mcast rate setting in Mesh Node */ |
| 1839 | memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate, |
| 1840 | sizeof(setup->mcast_rate)); |
Ashok Nagarajan | ffb3cf3 | 2013-06-03 10:33:36 -0700 | [diff] [blame] | 1841 | sdata->vif.bss_conf.basic_rates = setup->basic_rates; |
Chun-Yeow Yeoh | 4bb6234 | 2011-11-24 17:15:20 -0800 | [diff] [blame] | 1842 | |
Marco Porsch | 9bdbf04 | 2013-01-07 16:04:51 +0100 | [diff] [blame] | 1843 | sdata->vif.bss_conf.beacon_int = setup->beacon_interval; |
| 1844 | sdata->vif.bss_conf.dtim_period = setup->dtim_period; |
| 1845 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1846 | return 0; |
| 1847 | } |
| 1848 | |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 1849 | static int ieee80211_update_mesh_config(struct wiphy *wiphy, |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1850 | struct net_device *dev, u32 mask, |
| 1851 | const struct mesh_config *nconf) |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1852 | { |
| 1853 | struct mesh_config *conf; |
| 1854 | struct ieee80211_sub_if_data *sdata; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1855 | struct ieee80211_if_mesh *ifmsh; |
| 1856 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1857 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1858 | ifmsh = &sdata->u.mesh; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1859 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1860 | /* Set the config options which we are interested in setting */ |
| 1861 | conf = &(sdata->u.mesh.mshcfg); |
| 1862 | if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) |
| 1863 | conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; |
| 1864 | if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) |
| 1865 | conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; |
| 1866 | if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) |
| 1867 | conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; |
| 1868 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) |
| 1869 | conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; |
| 1870 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) |
| 1871 | conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; |
| 1872 | if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) |
| 1873 | conf->dot11MeshTTL = nconf->dot11MeshTTL; |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 1874 | if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask)) |
Chun-Yeow Yeoh | 58886a9 | 2012-06-15 00:23:53 +0800 | [diff] [blame] | 1875 | conf->element_ttl = nconf->element_ttl; |
Thomas Pedersen | 146bb48 | 2013-03-04 13:06:14 -0800 | [diff] [blame] | 1876 | if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) { |
| 1877 | if (ifmsh->user_mpm) |
| 1878 | return -EBUSY; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1879 | conf->auto_open_plinks = nconf->auto_open_plinks; |
Thomas Pedersen | 146bb48 | 2013-03-04 13:06:14 -0800 | [diff] [blame] | 1880 | } |
Javier Cardona | d299a1f | 2012-03-31 11:31:33 -0700 | [diff] [blame] | 1881 | if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask)) |
| 1882 | conf->dot11MeshNbrOffsetMaxNeighbor = |
| 1883 | nconf->dot11MeshNbrOffsetMaxNeighbor; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1884 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) |
| 1885 | conf->dot11MeshHWMPmaxPREQretries = |
| 1886 | nconf->dot11MeshHWMPmaxPREQretries; |
| 1887 | if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) |
| 1888 | conf->path_refresh_time = nconf->path_refresh_time; |
| 1889 | if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) |
| 1890 | conf->min_discovery_timeout = nconf->min_discovery_timeout; |
| 1891 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) |
| 1892 | conf->dot11MeshHWMPactivePathTimeout = |
| 1893 | nconf->dot11MeshHWMPactivePathTimeout; |
| 1894 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) |
| 1895 | conf->dot11MeshHWMPpreqMinInterval = |
| 1896 | nconf->dot11MeshHWMPpreqMinInterval; |
Thomas Pedersen | dca7e94 | 2011-11-24 17:15:24 -0800 | [diff] [blame] | 1897 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask)) |
| 1898 | conf->dot11MeshHWMPperrMinInterval = |
| 1899 | nconf->dot11MeshHWMPperrMinInterval; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1900 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
| 1901 | mask)) |
| 1902 | conf->dot11MeshHWMPnetDiameterTraversalTime = |
| 1903 | nconf->dot11MeshHWMPnetDiameterTraversalTime; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1904 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) { |
| 1905 | conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode; |
| 1906 | ieee80211_mesh_root_setup(ifmsh); |
| 1907 | } |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 1908 | if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) { |
Thomas Pedersen | c6133661 | 2011-08-25 10:36:14 -0700 | [diff] [blame] | 1909 | /* our current gate announcement implementation rides on root |
| 1910 | * announcements, so require this ifmsh to also be a root node |
| 1911 | * */ |
| 1912 | if (nconf->dot11MeshGateAnnouncementProtocol && |
Chun-Yeow Yeoh | dbb912c | 2012-06-14 02:06:09 +0800 | [diff] [blame] | 1913 | !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) { |
| 1914 | conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN; |
Thomas Pedersen | c6133661 | 2011-08-25 10:36:14 -0700 | [diff] [blame] | 1915 | ieee80211_mesh_root_setup(ifmsh); |
| 1916 | } |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 1917 | conf->dot11MeshGateAnnouncementProtocol = |
| 1918 | nconf->dot11MeshGateAnnouncementProtocol; |
| 1919 | } |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 1920 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame] | 1921 | conf->dot11MeshHWMPRannInterval = |
| 1922 | nconf->dot11MeshHWMPRannInterval; |
Chun-Yeow Yeoh | 94f9065 | 2012-01-21 01:02:16 +0800 | [diff] [blame] | 1923 | if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask)) |
| 1924 | conf->dot11MeshForwarding = nconf->dot11MeshForwarding; |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 1925 | if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) { |
| 1926 | /* our RSSI threshold implementation is supported only for |
| 1927 | * devices that report signal in dBm. |
| 1928 | */ |
| 1929 | if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)) |
| 1930 | return -ENOTSUPP; |
| 1931 | conf->rssi_threshold = nconf->rssi_threshold; |
| 1932 | } |
Ashok Nagarajan | 70c33ea | 2012-04-30 14:20:32 -0700 | [diff] [blame] | 1933 | if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) { |
| 1934 | conf->ht_opmode = nconf->ht_opmode; |
| 1935 | sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode; |
| 1936 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); |
| 1937 | } |
Chun-Yeow Yeoh | ac1073a | 2012-06-14 02:06:06 +0800 | [diff] [blame] | 1938 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask)) |
| 1939 | conf->dot11MeshHWMPactivePathToRootTimeout = |
| 1940 | nconf->dot11MeshHWMPactivePathToRootTimeout; |
| 1941 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask)) |
| 1942 | conf->dot11MeshHWMProotInterval = |
| 1943 | nconf->dot11MeshHWMProotInterval; |
Chun-Yeow Yeoh | 728b19e | 2012-06-14 02:06:10 +0800 | [diff] [blame] | 1944 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask)) |
| 1945 | conf->dot11MeshHWMPconfirmationInterval = |
| 1946 | nconf->dot11MeshHWMPconfirmationInterval; |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 1947 | if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) { |
| 1948 | conf->power_mode = nconf->power_mode; |
| 1949 | ieee80211_mps_local_status_update(sdata); |
| 1950 | } |
Thomas Pedersen | 2b5e196 | 2013-02-14 11:20:13 -0800 | [diff] [blame] | 1951 | if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask)) |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 1952 | conf->dot11MeshAwakeWindowDuration = |
| 1953 | nconf->dot11MeshAwakeWindowDuration; |
Colleen Twitty | 66de671 | 2013-06-03 09:53:40 -0700 | [diff] [blame] | 1954 | if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask)) |
| 1955 | conf->plink_timeout = nconf->plink_timeout; |
Thomas Pedersen | 2b5e196 | 2013-02-14 11:20:13 -0800 | [diff] [blame] | 1956 | ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON); |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1957 | return 0; |
| 1958 | } |
| 1959 | |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1960 | static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev, |
| 1961 | const struct mesh_config *conf, |
| 1962 | const struct mesh_setup *setup) |
| 1963 | { |
| 1964 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1965 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1966 | int err; |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1967 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1968 | memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config)); |
| 1969 | err = copy_mesh_setup(ifmsh, setup); |
| 1970 | if (err) |
| 1971 | return err; |
Johannes Berg | cc1d280 | 2012-05-16 23:50:20 +0200 | [diff] [blame] | 1972 | |
Johannes Berg | 04ecd25 | 2012-09-11 14:34:12 +0200 | [diff] [blame] | 1973 | /* can mesh use other SMPS modes? */ |
| 1974 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
| 1975 | sdata->needed_rx_chains = sdata->local->rx_chains; |
| 1976 | |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 1977 | mutex_lock(&sdata->local->mtx); |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 1978 | err = ieee80211_vif_use_channel(sdata, &setup->chandef, |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1979 | IEEE80211_CHANCTX_SHARED); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 1980 | mutex_unlock(&sdata->local->mtx); |
Johannes Berg | cc1d280 | 2012-05-16 23:50:20 +0200 | [diff] [blame] | 1981 | if (err) |
| 1982 | return err; |
| 1983 | |
Thomas Pedersen | 2b5e196 | 2013-02-14 11:20:13 -0800 | [diff] [blame] | 1984 | return ieee80211_start_mesh(sdata); |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1985 | } |
| 1986 | |
| 1987 | static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) |
| 1988 | { |
| 1989 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1990 | |
| 1991 | ieee80211_stop_mesh(sdata); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 1992 | mutex_lock(&sdata->local->mtx); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1993 | ieee80211_vif_release_channel(sdata); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 1994 | mutex_unlock(&sdata->local->mtx); |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1995 | |
| 1996 | return 0; |
| 1997 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1998 | #endif |
| 1999 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2000 | static int ieee80211_change_bss(struct wiphy *wiphy, |
| 2001 | struct net_device *dev, |
| 2002 | struct bss_parameters *params) |
| 2003 | { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 2004 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2005 | enum ieee80211_band band; |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2006 | u32 changed = 0; |
| 2007 | |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 2008 | if (!sdata_dereference(sdata->u.ap.beacon, sdata)) |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 2009 | return -ENOENT; |
| 2010 | |
| 2011 | band = ieee80211_get_sdata_band(sdata); |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2012 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2013 | if (params->use_cts_prot >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 2014 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2015 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
| 2016 | } |
| 2017 | if (params->use_short_preamble >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 2018 | sdata->vif.bss_conf.use_short_preamble = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2019 | params->use_short_preamble; |
| 2020 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
| 2021 | } |
Felix Fietkau | 43d3534 | 2010-01-15 03:00:48 +0100 | [diff] [blame] | 2022 | |
| 2023 | if (!sdata->vif.bss_conf.use_short_slot && |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 2024 | band == IEEE80211_BAND_5GHZ) { |
Felix Fietkau | 43d3534 | 2010-01-15 03:00:48 +0100 | [diff] [blame] | 2025 | sdata->vif.bss_conf.use_short_slot = true; |
| 2026 | changed |= BSS_CHANGED_ERP_SLOT; |
| 2027 | } |
| 2028 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2029 | if (params->use_short_slot_time >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 2030 | sdata->vif.bss_conf.use_short_slot = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2031 | params->use_short_slot_time; |
| 2032 | changed |= BSS_CHANGED_ERP_SLOT; |
| 2033 | } |
| 2034 | |
Jouni Malinen | 90c97a0 | 2008-10-30 16:59:22 +0200 | [diff] [blame] | 2035 | if (params->basic_rates) { |
Simon Wunderlich | 2103dec | 2013-07-08 16:55:53 +0200 | [diff] [blame] | 2036 | ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef, |
| 2037 | wiphy->bands[band], |
| 2038 | params->basic_rates, |
| 2039 | params->basic_rates_len, |
| 2040 | &sdata->vif.bss_conf.basic_rates); |
Jouni Malinen | 90c97a0 | 2008-10-30 16:59:22 +0200 | [diff] [blame] | 2041 | changed |= BSS_CHANGED_BASIC_RATES; |
| 2042 | } |
| 2043 | |
Felix Fietkau | 7b7b5e5 | 2010-04-27 01:23:36 +0200 | [diff] [blame] | 2044 | if (params->ap_isolate >= 0) { |
| 2045 | if (params->ap_isolate) |
| 2046 | sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 2047 | else |
| 2048 | sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 2049 | } |
| 2050 | |
Helmut Schaa | 80d7e40 | 2010-11-19 12:40:26 +0100 | [diff] [blame] | 2051 | if (params->ht_opmode >= 0) { |
| 2052 | sdata->vif.bss_conf.ht_operation_mode = |
| 2053 | (u16) params->ht_opmode; |
| 2054 | changed |= BSS_CHANGED_HT; |
| 2055 | } |
| 2056 | |
Johannes Berg | 339afbf | 2012-11-14 15:21:17 +0100 | [diff] [blame] | 2057 | if (params->p2p_ctwindow >= 0) { |
Janusz Dziedzic | 67baf66 | 2013-03-21 15:47:56 +0100 | [diff] [blame] | 2058 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= |
| 2059 | ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK; |
| 2060 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= |
| 2061 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; |
Johannes Berg | 339afbf | 2012-11-14 15:21:17 +0100 | [diff] [blame] | 2062 | changed |= BSS_CHANGED_P2P_PS; |
| 2063 | } |
| 2064 | |
Janusz Dziedzic | 67baf66 | 2013-03-21 15:47:56 +0100 | [diff] [blame] | 2065 | if (params->p2p_opp_ps > 0) { |
| 2066 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= |
| 2067 | IEEE80211_P2P_OPPPS_ENABLE_BIT; |
| 2068 | changed |= BSS_CHANGED_P2P_PS; |
| 2069 | } else if (params->p2p_opp_ps == 0) { |
| 2070 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= |
| 2071 | ~IEEE80211_P2P_OPPPS_ENABLE_BIT; |
Johannes Berg | 339afbf | 2012-11-14 15:21:17 +0100 | [diff] [blame] | 2072 | changed |= BSS_CHANGED_P2P_PS; |
| 2073 | } |
| 2074 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2075 | ieee80211_bss_info_change_notify(sdata, changed); |
| 2076 | |
| 2077 | return 0; |
| 2078 | } |
| 2079 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 2080 | static int ieee80211_set_txq_params(struct wiphy *wiphy, |
Eliad Peller | f70f01c | 2011-09-25 20:06:53 +0300 | [diff] [blame] | 2081 | struct net_device *dev, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 2082 | struct ieee80211_txq_params *params) |
| 2083 | { |
| 2084 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 2085 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 2086 | struct ieee80211_tx_queue_params p; |
| 2087 | |
| 2088 | if (!local->ops->conf_tx) |
| 2089 | return -EOPNOTSUPP; |
| 2090 | |
Johannes Berg | 54bcbc6 | 2012-03-28 11:04:25 +0200 | [diff] [blame] | 2091 | if (local->hw.queues < IEEE80211_NUM_ACS) |
| 2092 | return -EOPNOTSUPP; |
| 2093 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 2094 | memset(&p, 0, sizeof(p)); |
| 2095 | p.aifs = params->aifs; |
| 2096 | p.cw_max = params->cwmax; |
| 2097 | p.cw_min = params->cwmin; |
| 2098 | p.txop = params->txop; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 2099 | |
| 2100 | /* |
| 2101 | * Setting tx queue params disables u-apsd because it's only |
| 2102 | * called in master mode. |
| 2103 | */ |
| 2104 | p.uapsd = false; |
| 2105 | |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 2106 | sdata->tx_conf[params->ac] = p; |
| 2107 | if (drv_conf_tx(local, sdata, params->ac, &p)) { |
Joe Perches | 0fb9a9e | 2010-08-20 16:25:38 -0700 | [diff] [blame] | 2108 | wiphy_debug(local->hw.wiphy, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 2109 | "failed to set TX queue parameters for AC %d\n", |
| 2110 | params->ac); |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 2111 | return -EINVAL; |
| 2112 | } |
| 2113 | |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 2114 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS); |
| 2115 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 2116 | return 0; |
| 2117 | } |
| 2118 | |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 2119 | #ifdef CONFIG_PM |
Johannes Berg | ff1b6e6 | 2011-05-04 15:37:28 +0200 | [diff] [blame] | 2120 | static int ieee80211_suspend(struct wiphy *wiphy, |
| 2121 | struct cfg80211_wowlan *wowlan) |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 2122 | { |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 2123 | return __ieee80211_suspend(wiphy_priv(wiphy), wowlan); |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 2124 | } |
| 2125 | |
| 2126 | static int ieee80211_resume(struct wiphy *wiphy) |
| 2127 | { |
| 2128 | return __ieee80211_resume(wiphy_priv(wiphy)); |
| 2129 | } |
| 2130 | #else |
| 2131 | #define ieee80211_suspend NULL |
| 2132 | #define ieee80211_resume NULL |
| 2133 | #endif |
| 2134 | |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 2135 | static int ieee80211_scan(struct wiphy *wiphy, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 2136 | struct cfg80211_scan_request *req) |
| 2137 | { |
Johannes Berg | fd01428 | 2012-06-18 19:17:03 +0200 | [diff] [blame] | 2138 | struct ieee80211_sub_if_data *sdata; |
| 2139 | |
| 2140 | sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev); |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 2141 | |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 2142 | switch (ieee80211_vif_type_p2p(&sdata->vif)) { |
| 2143 | case NL80211_IFTYPE_STATION: |
| 2144 | case NL80211_IFTYPE_ADHOC: |
| 2145 | case NL80211_IFTYPE_MESH_POINT: |
| 2146 | case NL80211_IFTYPE_P2P_CLIENT: |
Johannes Berg | f142c6b | 2012-06-18 20:07:15 +0200 | [diff] [blame] | 2147 | case NL80211_IFTYPE_P2P_DEVICE: |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 2148 | break; |
| 2149 | case NL80211_IFTYPE_P2P_GO: |
| 2150 | if (sdata->local->ops->hw_scan) |
| 2151 | break; |
Johannes Berg | e9d7732 | 2011-02-01 15:35:36 +0100 | [diff] [blame] | 2152 | /* |
| 2153 | * FIXME: implement NoA while scanning in software, |
| 2154 | * for now fall through to allow scanning only when |
| 2155 | * beaconing hasn't been configured yet |
| 2156 | */ |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 2157 | case NL80211_IFTYPE_AP: |
Antonio Quartulli | 5c95b94 | 2012-10-16 08:39:22 +0200 | [diff] [blame] | 2158 | /* |
| 2159 | * If the scan has been forced (and the driver supports |
| 2160 | * forcing), don't care about being beaconing already. |
| 2161 | * This will create problems to the attached stations (e.g. all |
| 2162 | * the frames sent while scanning on other channel will be |
| 2163 | * lost) |
| 2164 | */ |
| 2165 | if (sdata->u.ap.beacon && |
| 2166 | (!(wiphy->features & NL80211_FEATURE_AP_SCAN) || |
| 2167 | !(req->flags & NL80211_SCAN_FLAG_AP))) |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 2168 | return -EOPNOTSUPP; |
| 2169 | break; |
| 2170 | default: |
| 2171 | return -EOPNOTSUPP; |
| 2172 | } |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 2173 | |
| 2174 | return ieee80211_request_scan(sdata, req); |
| 2175 | } |
| 2176 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 2177 | static int |
| 2178 | ieee80211_sched_scan_start(struct wiphy *wiphy, |
| 2179 | struct net_device *dev, |
| 2180 | struct cfg80211_sched_scan_request *req) |
| 2181 | { |
| 2182 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2183 | |
| 2184 | if (!sdata->local->ops->sched_scan_start) |
| 2185 | return -EOPNOTSUPP; |
| 2186 | |
| 2187 | return ieee80211_request_sched_scan_start(sdata, req); |
| 2188 | } |
| 2189 | |
| 2190 | static int |
Luciano Coelho | 85a9994 | 2011-05-12 16:28:29 +0300 | [diff] [blame] | 2191 | ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev) |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 2192 | { |
| 2193 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2194 | |
| 2195 | if (!sdata->local->ops->sched_scan_stop) |
| 2196 | return -EOPNOTSUPP; |
| 2197 | |
Luciano Coelho | 85a9994 | 2011-05-12 16:28:29 +0300 | [diff] [blame] | 2198 | return ieee80211_request_sched_scan_stop(sdata); |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 2199 | } |
| 2200 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2201 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
| 2202 | struct cfg80211_auth_request *req) |
| 2203 | { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2204 | return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2205 | } |
| 2206 | |
| 2207 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, |
| 2208 | struct cfg80211_assoc_request *req) |
| 2209 | { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 2210 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2211 | } |
| 2212 | |
| 2213 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 2214 | struct cfg80211_deauth_request *req) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2215 | { |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 2216 | return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2217 | } |
| 2218 | |
| 2219 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 2220 | struct cfg80211_disassoc_request *req) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2221 | { |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 2222 | return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2223 | } |
| 2224 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 2225 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
| 2226 | struct cfg80211_ibss_params *params) |
| 2227 | { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 2228 | return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 2229 | } |
| 2230 | |
| 2231 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) |
| 2232 | { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 2233 | return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev)); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 2234 | } |
| 2235 | |
Antonio Quartulli | 391e53e | 2012-11-02 13:27:49 +0100 | [diff] [blame] | 2236 | static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, |
| 2237 | int rate[IEEE80211_NUM_BANDS]) |
| 2238 | { |
| 2239 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2240 | |
Cong Ding | 9887dbf | 2013-02-06 17:23:45 +0100 | [diff] [blame] | 2241 | memcpy(sdata->vif.bss_conf.mcast_rate, rate, |
| 2242 | sizeof(int) * IEEE80211_NUM_BANDS); |
Antonio Quartulli | 391e53e | 2012-11-02 13:27:49 +0100 | [diff] [blame] | 2243 | |
| 2244 | return 0; |
| 2245 | } |
| 2246 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2247 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 2248 | { |
| 2249 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 2250 | int err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2251 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 2252 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 2253 | err = drv_set_frag_threshold(local, wiphy->frag_threshold); |
| 2254 | |
| 2255 | if (err) |
| 2256 | return err; |
| 2257 | } |
| 2258 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 2259 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) { |
| 2260 | err = drv_set_coverage_class(local, wiphy->coverage_class); |
| 2261 | |
| 2262 | if (err) |
| 2263 | return err; |
| 2264 | } |
| 2265 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2266 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 2267 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2268 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 2269 | if (err) |
| 2270 | return err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2271 | } |
| 2272 | |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 2273 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 2274 | if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY) |
| 2275 | return -EINVAL; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2276 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 2277 | } |
| 2278 | if (changed & WIPHY_PARAM_RETRY_LONG) { |
| 2279 | if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY) |
| 2280 | return -EINVAL; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2281 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
Johannes Berg | 8bc83c2 | 2012-11-09 18:38:32 +0100 | [diff] [blame] | 2282 | } |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2283 | if (changed & |
| 2284 | (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) |
| 2285 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); |
| 2286 | |
| 2287 | return 0; |
| 2288 | } |
| 2289 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2290 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
Johannes Berg | c844211 | 2012-10-24 10:17:18 +0200 | [diff] [blame] | 2291 | struct wireless_dev *wdev, |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 2292 | enum nl80211_tx_power_setting type, int mbm) |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2293 | { |
| 2294 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 2295 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2296 | |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 2297 | if (wdev) { |
| 2298 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
| 2299 | |
| 2300 | switch (type) { |
| 2301 | case NL80211_TX_POWER_AUTOMATIC: |
| 2302 | sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL; |
| 2303 | break; |
| 2304 | case NL80211_TX_POWER_LIMITED: |
| 2305 | case NL80211_TX_POWER_FIXED: |
| 2306 | if (mbm < 0 || (mbm % 100)) |
| 2307 | return -EOPNOTSUPP; |
| 2308 | sdata->user_power_level = MBM_TO_DBM(mbm); |
| 2309 | break; |
| 2310 | } |
| 2311 | |
| 2312 | ieee80211_recalc_txpower(sdata); |
| 2313 | |
| 2314 | return 0; |
| 2315 | } |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 2316 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2317 | switch (type) { |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 2318 | case NL80211_TX_POWER_AUTOMATIC: |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 2319 | local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2320 | break; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 2321 | case NL80211_TX_POWER_LIMITED: |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 2322 | case NL80211_TX_POWER_FIXED: |
| 2323 | if (mbm < 0 || (mbm % 100)) |
| 2324 | return -EOPNOTSUPP; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 2325 | local->user_power_level = MBM_TO_DBM(mbm); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2326 | break; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2327 | } |
| 2328 | |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 2329 | mutex_lock(&local->iflist_mtx); |
| 2330 | list_for_each_entry(sdata, &local->interfaces, list) |
| 2331 | sdata->user_power_level = local->user_power_level; |
| 2332 | list_for_each_entry(sdata, &local->interfaces, list) |
| 2333 | ieee80211_recalc_txpower(sdata); |
| 2334 | mutex_unlock(&local->iflist_mtx); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2335 | |
| 2336 | return 0; |
| 2337 | } |
| 2338 | |
Johannes Berg | c844211 | 2012-10-24 10:17:18 +0200 | [diff] [blame] | 2339 | static int ieee80211_get_tx_power(struct wiphy *wiphy, |
| 2340 | struct wireless_dev *wdev, |
| 2341 | int *dbm) |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2342 | { |
| 2343 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 2344 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2345 | |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 2346 | if (!local->use_chanctx) |
| 2347 | *dbm = local->hw.conf.power_level; |
| 2348 | else |
| 2349 | *dbm = sdata->vif.bss_conf.txpower; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2350 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2351 | return 0; |
| 2352 | } |
| 2353 | |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 2354 | static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 388ac77 | 2010-10-07 13:11:09 +0200 | [diff] [blame] | 2355 | const u8 *addr) |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 2356 | { |
| 2357 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2358 | |
| 2359 | memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN); |
| 2360 | |
| 2361 | return 0; |
| 2362 | } |
| 2363 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 2364 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) |
| 2365 | { |
| 2366 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2367 | |
| 2368 | drv_rfkill_poll(local); |
| 2369 | } |
| 2370 | |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 2371 | #ifdef CONFIG_NL80211_TESTMODE |
David Spinadel | fc73f11 | 2013-07-31 18:04:15 +0300 | [diff] [blame] | 2372 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, |
| 2373 | struct wireless_dev *wdev, |
| 2374 | void *data, int len) |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 2375 | { |
| 2376 | struct ieee80211_local *local = wiphy_priv(wiphy); |
David Spinadel | 52981cd | 2013-07-31 18:06:22 +0300 | [diff] [blame] | 2377 | struct ieee80211_vif *vif = NULL; |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 2378 | |
| 2379 | if (!local->ops->testmode_cmd) |
| 2380 | return -EOPNOTSUPP; |
| 2381 | |
David Spinadel | 52981cd | 2013-07-31 18:06:22 +0300 | [diff] [blame] | 2382 | if (wdev) { |
| 2383 | struct ieee80211_sub_if_data *sdata; |
| 2384 | |
| 2385 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
| 2386 | if (sdata->flags & IEEE80211_SDATA_IN_DRIVER) |
| 2387 | vif = &sdata->vif; |
| 2388 | } |
| 2389 | |
| 2390 | return local->ops->testmode_cmd(&local->hw, vif, data, len); |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 2391 | } |
Wey-Yi Guy | 71063f0 | 2011-05-20 09:05:54 -0700 | [diff] [blame] | 2392 | |
| 2393 | static int ieee80211_testmode_dump(struct wiphy *wiphy, |
| 2394 | struct sk_buff *skb, |
| 2395 | struct netlink_callback *cb, |
| 2396 | void *data, int len) |
| 2397 | { |
| 2398 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2399 | |
| 2400 | if (!local->ops->testmode_dump) |
| 2401 | return -EOPNOTSUPP; |
| 2402 | |
| 2403 | return local->ops->testmode_dump(&local->hw, skb, cb, data, len); |
| 2404 | } |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 2405 | #endif |
| 2406 | |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 2407 | int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata, |
| 2408 | enum ieee80211_smps_mode smps_mode) |
| 2409 | { |
| 2410 | struct sta_info *sta; |
| 2411 | enum ieee80211_smps_mode old_req; |
| 2412 | int i; |
| 2413 | |
| 2414 | if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP)) |
| 2415 | return -EINVAL; |
| 2416 | |
| 2417 | if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) |
| 2418 | return 0; |
| 2419 | |
| 2420 | old_req = sdata->u.ap.req_smps; |
| 2421 | sdata->u.ap.req_smps = smps_mode; |
| 2422 | |
| 2423 | /* AUTOMATIC doesn't mean much for AP - don't allow it */ |
| 2424 | if (old_req == smps_mode || |
| 2425 | smps_mode == IEEE80211_SMPS_AUTOMATIC) |
| 2426 | return 0; |
| 2427 | |
| 2428 | /* If no associated stations, there's no need to do anything */ |
| 2429 | if (!atomic_read(&sdata->u.ap.num_mcast_sta)) { |
| 2430 | sdata->smps_mode = smps_mode; |
| 2431 | ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps); |
| 2432 | return 0; |
| 2433 | } |
| 2434 | |
| 2435 | ht_dbg(sdata, |
| 2436 | "SMSP %d requested in AP mode, sending Action frame to %d stations\n", |
| 2437 | smps_mode, atomic_read(&sdata->u.ap.num_mcast_sta)); |
| 2438 | |
| 2439 | mutex_lock(&sdata->local->sta_mtx); |
| 2440 | for (i = 0; i < STA_HASH_SIZE; i++) { |
| 2441 | for (sta = rcu_dereference_protected(sdata->local->sta_hash[i], |
| 2442 | lockdep_is_held(&sdata->local->sta_mtx)); |
| 2443 | sta; |
| 2444 | sta = rcu_dereference_protected(sta->hnext, |
| 2445 | lockdep_is_held(&sdata->local->sta_mtx))) { |
| 2446 | /* |
| 2447 | * Only stations associated to our AP and |
| 2448 | * associated VLANs |
| 2449 | */ |
| 2450 | if (sta->sdata->bss != &sdata->u.ap) |
| 2451 | continue; |
| 2452 | |
| 2453 | /* This station doesn't support MIMO - skip it */ |
| 2454 | if (sta_info_tx_streams(sta) == 1) |
| 2455 | continue; |
| 2456 | |
| 2457 | /* |
| 2458 | * Don't wake up a STA just to send the action frame |
| 2459 | * unless we are getting more restrictive. |
| 2460 | */ |
| 2461 | if (test_sta_flag(sta, WLAN_STA_PS_STA) && |
| 2462 | !ieee80211_smps_is_restrictive(sta->known_smps_mode, |
| 2463 | smps_mode)) { |
| 2464 | ht_dbg(sdata, |
| 2465 | "Won't send SMPS to sleeping STA %pM\n", |
| 2466 | sta->sta.addr); |
| 2467 | continue; |
| 2468 | } |
| 2469 | |
| 2470 | /* |
| 2471 | * If the STA is not authorized, wait until it gets |
| 2472 | * authorized and the action frame will be sent then. |
| 2473 | */ |
| 2474 | if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
| 2475 | continue; |
| 2476 | |
| 2477 | ht_dbg(sdata, "Sending SMPS to %pM\n", sta->sta.addr); |
| 2478 | ieee80211_send_smps_action(sdata, smps_mode, |
| 2479 | sta->sta.addr, |
| 2480 | sdata->vif.bss_conf.bssid); |
| 2481 | } |
| 2482 | } |
| 2483 | mutex_unlock(&sdata->local->sta_mtx); |
| 2484 | |
| 2485 | sdata->smps_mode = smps_mode; |
| 2486 | ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps); |
| 2487 | |
| 2488 | return 0; |
| 2489 | } |
| 2490 | |
| 2491 | int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata, |
| 2492 | enum ieee80211_smps_mode smps_mode) |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2493 | { |
| 2494 | const u8 *ap; |
| 2495 | enum ieee80211_smps_mode old_req; |
| 2496 | int err; |
| 2497 | |
Johannes Berg | 8d61ffa | 2013-05-10 12:32:47 +0200 | [diff] [blame] | 2498 | lockdep_assert_held(&sdata->wdev.mtx); |
Johannes Berg | 243e6df | 2011-04-19 20:44:04 +0200 | [diff] [blame] | 2499 | |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 2500 | if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) |
| 2501 | return -EINVAL; |
| 2502 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2503 | old_req = sdata->u.mgd.req_smps; |
| 2504 | sdata->u.mgd.req_smps = smps_mode; |
| 2505 | |
| 2506 | if (old_req == smps_mode && |
| 2507 | smps_mode != IEEE80211_SMPS_AUTOMATIC) |
| 2508 | return 0; |
| 2509 | |
| 2510 | /* |
| 2511 | * If not associated, or current association is not an HT |
Johannes Berg | 04ecd25 | 2012-09-11 14:34:12 +0200 | [diff] [blame] | 2512 | * association, there's no need to do anything, just store |
| 2513 | * the new value until we associate. |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2514 | */ |
| 2515 | if (!sdata->u.mgd.associated || |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 2516 | sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2517 | return 0; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2518 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 2519 | ap = sdata->u.mgd.associated->bssid; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2520 | |
| 2521 | if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { |
| 2522 | if (sdata->u.mgd.powersave) |
| 2523 | smps_mode = IEEE80211_SMPS_DYNAMIC; |
| 2524 | else |
| 2525 | smps_mode = IEEE80211_SMPS_OFF; |
| 2526 | } |
| 2527 | |
| 2528 | /* send SM PS frame to AP */ |
| 2529 | err = ieee80211_send_smps_action(sdata, smps_mode, |
| 2530 | ap, ap); |
| 2531 | if (err) |
| 2532 | sdata->u.mgd.req_smps = old_req; |
| 2533 | |
| 2534 | return err; |
| 2535 | } |
| 2536 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2537 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 2538 | bool enabled, int timeout) |
| 2539 | { |
| 2540 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2541 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2542 | |
Bob Copeland | 2d3db21 | 2013-10-29 18:11:59 -0400 | [diff] [blame] | 2543 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
Benoit Papillault | e5de30c | 2010-01-15 12:21:37 +0100 | [diff] [blame] | 2544 | return -EOPNOTSUPP; |
| 2545 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2546 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) |
| 2547 | return -EOPNOTSUPP; |
| 2548 | |
| 2549 | if (enabled == sdata->u.mgd.powersave && |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 2550 | timeout == local->dynamic_ps_forced_timeout) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2551 | return 0; |
| 2552 | |
| 2553 | sdata->u.mgd.powersave = enabled; |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 2554 | local->dynamic_ps_forced_timeout = timeout; |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2555 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2556 | /* no change, but if automatic follow powersave */ |
Johannes Berg | ed405be | 2013-06-03 13:51:59 +0200 | [diff] [blame] | 2557 | sdata_lock(sdata); |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 2558 | __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps); |
Johannes Berg | ed405be | 2013-06-03 13:51:59 +0200 | [diff] [blame] | 2559 | sdata_unlock(sdata); |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2560 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2561 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) |
| 2562 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 2563 | |
| 2564 | ieee80211_recalc_ps(local, -1); |
Eliad Peller | ab09587 | 2012-07-27 12:33:22 +0300 | [diff] [blame] | 2565 | ieee80211_recalc_ps_vif(sdata); |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2566 | |
| 2567 | return 0; |
| 2568 | } |
| 2569 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2570 | static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, |
| 2571 | struct net_device *dev, |
| 2572 | s32 rssi_thold, u32 rssi_hyst) |
| 2573 | { |
| 2574 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2575 | struct ieee80211_vif *vif = &sdata->vif; |
| 2576 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
| 2577 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2578 | if (rssi_thold == bss_conf->cqm_rssi_thold && |
| 2579 | rssi_hyst == bss_conf->cqm_rssi_hyst) |
| 2580 | return 0; |
| 2581 | |
| 2582 | bss_conf->cqm_rssi_thold = rssi_thold; |
| 2583 | bss_conf->cqm_rssi_hyst = rssi_hyst; |
| 2584 | |
| 2585 | /* tell the driver upon association, unless already associated */ |
Johannes Berg | ea08635 | 2012-01-19 09:29:58 +0100 | [diff] [blame] | 2586 | if (sdata->u.mgd.associated && |
| 2587 | sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI) |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2588 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM); |
| 2589 | |
| 2590 | return 0; |
| 2591 | } |
| 2592 | |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2593 | static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, |
| 2594 | struct net_device *dev, |
| 2595 | const u8 *addr, |
| 2596 | const struct cfg80211_bitrate_mask *mask) |
| 2597 | { |
| 2598 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2599 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 2600 | int i, ret; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2601 | |
Eliad Peller | 554a43d | 2012-06-12 12:41:15 +0300 | [diff] [blame] | 2602 | if (!ieee80211_sdata_running(sdata)) |
| 2603 | return -ENETDOWN; |
| 2604 | |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 2605 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) { |
| 2606 | ret = drv_set_bitrate_mask(local, sdata, mask); |
| 2607 | if (ret) |
| 2608 | return ret; |
| 2609 | } |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2610 | |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 2611 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) { |
Felix Fietkau | 2ffbe6d | 2013-04-16 13:38:42 +0200 | [diff] [blame] | 2612 | struct ieee80211_supported_band *sband = wiphy->bands[i]; |
| 2613 | int j; |
| 2614 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 2615 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
Janusz Dziedzic | d1e33e6 | 2013-12-05 10:02:15 +0100 | [diff] [blame] | 2616 | memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs, |
| 2617 | sizeof(mask->control[i].ht_mcs)); |
Felix Fietkau | 2ffbe6d | 2013-04-16 13:38:42 +0200 | [diff] [blame] | 2618 | |
| 2619 | sdata->rc_has_mcs_mask[i] = false; |
| 2620 | if (!sband) |
| 2621 | continue; |
| 2622 | |
| 2623 | for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) |
| 2624 | if (~sdata->rc_rateidx_mcs_mask[i][j]) { |
| 2625 | sdata->rc_has_mcs_mask[i] = true; |
| 2626 | break; |
| 2627 | } |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 2628 | } |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2629 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 2630 | return 0; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2631 | } |
| 2632 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2633 | static int ieee80211_start_roc_work(struct ieee80211_local *local, |
| 2634 | struct ieee80211_sub_if_data *sdata, |
| 2635 | struct ieee80211_channel *channel, |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2636 | unsigned int duration, u64 *cookie, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2637 | struct sk_buff *txskb, |
| 2638 | enum ieee80211_roc_type type) |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2639 | { |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2640 | struct ieee80211_roc_work *roc, *tmp; |
| 2641 | bool queued = false; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2642 | int ret; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2643 | |
| 2644 | lockdep_assert_held(&local->mtx); |
| 2645 | |
Johannes Berg | fe57d9f | 2012-07-26 14:55:08 +0200 | [diff] [blame] | 2646 | if (local->use_chanctx && !local->ops->remain_on_channel) |
| 2647 | return -EOPNOTSUPP; |
| 2648 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2649 | roc = kzalloc(sizeof(*roc), GFP_KERNEL); |
| 2650 | if (!roc) |
| 2651 | return -ENOMEM; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2652 | |
Ilan Peer | 2fae062 | 2013-12-19 13:25:29 +0200 | [diff] [blame] | 2653 | /* |
| 2654 | * If the duration is zero, then the driver |
| 2655 | * wouldn't actually do anything. Set it to |
| 2656 | * 10 for now. |
| 2657 | * |
| 2658 | * TODO: cancel the off-channel operation |
| 2659 | * when we get the SKB's TX status and |
| 2660 | * the wait time was zero before. |
| 2661 | */ |
| 2662 | if (!duration) |
| 2663 | duration = 10; |
| 2664 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2665 | roc->chan = channel; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2666 | roc->duration = duration; |
| 2667 | roc->req_duration = duration; |
| 2668 | roc->frame = txskb; |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2669 | roc->type = type; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2670 | roc->mgmt_tx_cookie = (unsigned long)txskb; |
| 2671 | roc->sdata = sdata; |
| 2672 | INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work); |
| 2673 | INIT_LIST_HEAD(&roc->dependents); |
| 2674 | |
Eliad Peller | 2f61743 | 2014-01-12 11:06:37 +0200 | [diff] [blame] | 2675 | /* |
| 2676 | * cookie is either the roc cookie (for normal roc) |
| 2677 | * or the SKB (for mgmt TX) |
| 2678 | */ |
| 2679 | if (!txskb) { |
| 2680 | /* local->mtx protects this */ |
| 2681 | local->roc_cookie_counter++; |
| 2682 | roc->cookie = local->roc_cookie_counter; |
| 2683 | /* wow, you wrapped 64 bits ... more likely a bug */ |
| 2684 | if (WARN_ON(roc->cookie == 0)) { |
| 2685 | roc->cookie = 1; |
| 2686 | local->roc_cookie_counter++; |
| 2687 | } |
| 2688 | *cookie = roc->cookie; |
| 2689 | } else { |
| 2690 | *cookie = (unsigned long)txskb; |
| 2691 | } |
| 2692 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2693 | /* if there's one pending or we're scanning, queue this one */ |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2694 | if (!list_empty(&local->roc_list) || |
| 2695 | local->scanning || local->radar_detect_enabled) |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2696 | goto out_check_combine; |
| 2697 | |
| 2698 | /* if not HW assist, just queue & schedule work */ |
| 2699 | if (!local->ops->remain_on_channel) { |
| 2700 | ieee80211_queue_delayed_work(&local->hw, &roc->work, 0); |
| 2701 | goto out_queue; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2702 | } |
| 2703 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2704 | /* otherwise actually kick it off here (for error handling) */ |
| 2705 | |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2706 | ret = drv_remain_on_channel(local, sdata, channel, duration, type); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2707 | if (ret) { |
| 2708 | kfree(roc); |
| 2709 | return ret; |
| 2710 | } |
| 2711 | |
| 2712 | roc->started = true; |
| 2713 | goto out_queue; |
| 2714 | |
| 2715 | out_check_combine: |
| 2716 | list_for_each_entry(tmp, &local->roc_list, list) { |
Johannes Berg | 42d97a5 | 2012-11-08 18:31:02 +0100 | [diff] [blame] | 2717 | if (tmp->chan != channel || tmp->sdata != sdata) |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2718 | continue; |
| 2719 | |
| 2720 | /* |
| 2721 | * Extend this ROC if possible: |
| 2722 | * |
| 2723 | * If it hasn't started yet, just increase the duration |
| 2724 | * and add the new one to the list of dependents. |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2725 | * If the type of the new ROC has higher priority, modify the |
| 2726 | * type of the previous one to match that of the new one. |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2727 | */ |
| 2728 | if (!tmp->started) { |
| 2729 | list_add_tail(&roc->list, &tmp->dependents); |
| 2730 | tmp->duration = max(tmp->duration, roc->duration); |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2731 | tmp->type = max(tmp->type, roc->type); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2732 | queued = true; |
| 2733 | break; |
| 2734 | } |
| 2735 | |
| 2736 | /* If it has already started, it's more difficult ... */ |
| 2737 | if (local->ops->remain_on_channel) { |
| 2738 | unsigned long j = jiffies; |
| 2739 | |
| 2740 | /* |
| 2741 | * In the offloaded ROC case, if it hasn't begun, add |
| 2742 | * this new one to the dependent list to be handled |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2743 | * when the master one begins. If it has begun, |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2744 | * check that there's still a minimum time left and |
| 2745 | * if so, start this one, transmitting the frame, but |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2746 | * add it to the list directly after this one with |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2747 | * a reduced time so we'll ask the driver to execute |
| 2748 | * it right after finishing the previous one, in the |
| 2749 | * hope that it'll also be executed right afterwards, |
| 2750 | * effectively extending the old one. |
| 2751 | * If there's no minimum time left, just add it to the |
| 2752 | * normal list. |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2753 | * TODO: the ROC type is ignored here, assuming that it |
| 2754 | * is better to immediately use the current ROC. |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2755 | */ |
| 2756 | if (!tmp->hw_begun) { |
| 2757 | list_add_tail(&roc->list, &tmp->dependents); |
| 2758 | queued = true; |
| 2759 | break; |
| 2760 | } |
| 2761 | |
| 2762 | if (time_before(j + IEEE80211_ROC_MIN_LEFT, |
| 2763 | tmp->hw_start_time + |
| 2764 | msecs_to_jiffies(tmp->duration))) { |
| 2765 | int new_dur; |
| 2766 | |
| 2767 | ieee80211_handle_roc_started(roc); |
| 2768 | |
| 2769 | new_dur = roc->duration - |
| 2770 | jiffies_to_msecs(tmp->hw_start_time + |
| 2771 | msecs_to_jiffies( |
| 2772 | tmp->duration) - |
| 2773 | j); |
| 2774 | |
| 2775 | if (new_dur > 0) { |
| 2776 | /* add right after tmp */ |
| 2777 | list_add(&roc->list, &tmp->list); |
| 2778 | } else { |
| 2779 | list_add_tail(&roc->list, |
| 2780 | &tmp->dependents); |
| 2781 | } |
| 2782 | queued = true; |
| 2783 | } |
| 2784 | } else if (del_timer_sync(&tmp->work.timer)) { |
| 2785 | unsigned long new_end; |
| 2786 | |
| 2787 | /* |
| 2788 | * In the software ROC case, cancel the timer, if |
| 2789 | * that fails then the finish work is already |
| 2790 | * queued/pending and thus we queue the new ROC |
| 2791 | * normally, if that succeeds then we can extend |
| 2792 | * the timer duration and TX the frame (if any.) |
| 2793 | */ |
| 2794 | |
| 2795 | list_add_tail(&roc->list, &tmp->dependents); |
| 2796 | queued = true; |
| 2797 | |
| 2798 | new_end = jiffies + msecs_to_jiffies(roc->duration); |
| 2799 | |
| 2800 | /* ok, it was started & we canceled timer */ |
| 2801 | if (time_after(new_end, tmp->work.timer.expires)) |
| 2802 | mod_timer(&tmp->work.timer, new_end); |
| 2803 | else |
| 2804 | add_timer(&tmp->work.timer); |
| 2805 | |
| 2806 | ieee80211_handle_roc_started(roc); |
| 2807 | } |
| 2808 | break; |
| 2809 | } |
| 2810 | |
| 2811 | out_queue: |
| 2812 | if (!queued) |
| 2813 | list_add_tail(&roc->list, &local->roc_list); |
| 2814 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2815 | return 0; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2816 | } |
| 2817 | |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2818 | static int ieee80211_remain_on_channel(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2819 | struct wireless_dev *wdev, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2820 | struct ieee80211_channel *chan, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2821 | unsigned int duration, |
| 2822 | u64 *cookie) |
| 2823 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2824 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2825 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2826 | int ret; |
| 2827 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2828 | mutex_lock(&local->mtx); |
Johannes Berg | 42d97a5 | 2012-11-08 18:31:02 +0100 | [diff] [blame] | 2829 | ret = ieee80211_start_roc_work(local, sdata, chan, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2830 | duration, cookie, NULL, |
| 2831 | IEEE80211_ROC_TYPE_NORMAL); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2832 | mutex_unlock(&local->mtx); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2833 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2834 | return ret; |
| 2835 | } |
| 2836 | |
| 2837 | static int ieee80211_cancel_roc(struct ieee80211_local *local, |
| 2838 | u64 cookie, bool mgmt_tx) |
| 2839 | { |
| 2840 | struct ieee80211_roc_work *roc, *tmp, *found = NULL; |
| 2841 | int ret; |
| 2842 | |
| 2843 | mutex_lock(&local->mtx); |
| 2844 | list_for_each_entry_safe(roc, tmp, &local->roc_list, list) { |
Johannes Berg | e979e33 | 2012-06-11 17:09:41 +0200 | [diff] [blame] | 2845 | struct ieee80211_roc_work *dep, *tmp2; |
| 2846 | |
| 2847 | list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) { |
Johannes Berg | 50febf6 | 2012-10-26 16:13:06 +0200 | [diff] [blame] | 2848 | if (!mgmt_tx && dep->cookie != cookie) |
Johannes Berg | e979e33 | 2012-06-11 17:09:41 +0200 | [diff] [blame] | 2849 | continue; |
| 2850 | else if (mgmt_tx && dep->mgmt_tx_cookie != cookie) |
| 2851 | continue; |
| 2852 | /* found dependent item -- just remove it */ |
| 2853 | list_del(&dep->list); |
| 2854 | mutex_unlock(&local->mtx); |
| 2855 | |
Johannes Berg | 3fbd45c | 2013-03-25 11:51:14 +0100 | [diff] [blame] | 2856 | ieee80211_roc_notify_destroy(dep, true); |
Johannes Berg | e979e33 | 2012-06-11 17:09:41 +0200 | [diff] [blame] | 2857 | return 0; |
| 2858 | } |
| 2859 | |
Johannes Berg | 50febf6 | 2012-10-26 16:13:06 +0200 | [diff] [blame] | 2860 | if (!mgmt_tx && roc->cookie != cookie) |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2861 | continue; |
| 2862 | else if (mgmt_tx && roc->mgmt_tx_cookie != cookie) |
| 2863 | continue; |
| 2864 | |
| 2865 | found = roc; |
| 2866 | break; |
| 2867 | } |
| 2868 | |
| 2869 | if (!found) { |
| 2870 | mutex_unlock(&local->mtx); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2871 | return -ENOENT; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2872 | } |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2873 | |
Johannes Berg | e979e33 | 2012-06-11 17:09:41 +0200 | [diff] [blame] | 2874 | /* |
| 2875 | * We found the item to cancel, so do that. Note that it |
| 2876 | * may have dependents, which we also cancel (and send |
| 2877 | * the expired signal for.) Not doing so would be quite |
| 2878 | * tricky here, but we may need to fix it later. |
| 2879 | */ |
| 2880 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2881 | if (local->ops->remain_on_channel) { |
| 2882 | if (found->started) { |
| 2883 | ret = drv_cancel_remain_on_channel(local); |
| 2884 | if (WARN_ON_ONCE(ret)) { |
| 2885 | mutex_unlock(&local->mtx); |
| 2886 | return ret; |
| 2887 | } |
| 2888 | } |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2889 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2890 | list_del(&found->list); |
| 2891 | |
Johannes Berg | 0f6b3f5 | 2012-06-20 20:11:33 +0200 | [diff] [blame] | 2892 | if (found->started) |
| 2893 | ieee80211_start_next_roc(local); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2894 | mutex_unlock(&local->mtx); |
| 2895 | |
Johannes Berg | 3fbd45c | 2013-03-25 11:51:14 +0100 | [diff] [blame] | 2896 | ieee80211_roc_notify_destroy(found, true); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2897 | } else { |
| 2898 | /* work may be pending so use it all the time */ |
| 2899 | found->abort = true; |
| 2900 | ieee80211_queue_delayed_work(&local->hw, &found->work, 0); |
| 2901 | |
| 2902 | mutex_unlock(&local->mtx); |
| 2903 | |
| 2904 | /* work will clean up etc */ |
| 2905 | flush_delayed_work(&found->work); |
Johannes Berg | 3fbd45c | 2013-03-25 11:51:14 +0100 | [diff] [blame] | 2906 | WARN_ON(!found->to_be_freed); |
| 2907 | kfree(found); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2908 | } |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2909 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2910 | return 0; |
| 2911 | } |
| 2912 | |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2913 | static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2914 | struct wireless_dev *wdev, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2915 | u64 cookie) |
| 2916 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2917 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2918 | struct ieee80211_local *local = sdata->local; |
| 2919 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2920 | return ieee80211_cancel_roc(local, cookie, false); |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2921 | } |
| 2922 | |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2923 | static int ieee80211_start_radar_detection(struct wiphy *wiphy, |
| 2924 | struct net_device *dev, |
Janusz Dziedzic | 31559f3 | 2014-02-21 19:46:13 +0100 | [diff] [blame] | 2925 | struct cfg80211_chan_def *chandef, |
| 2926 | u32 cac_time_ms) |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2927 | { |
| 2928 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2929 | struct ieee80211_local *local = sdata->local; |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2930 | int err; |
| 2931 | |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 2932 | mutex_lock(&local->mtx); |
| 2933 | if (!list_empty(&local->roc_list) || local->scanning) { |
| 2934 | err = -EBUSY; |
| 2935 | goto out_unlock; |
| 2936 | } |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2937 | |
| 2938 | /* whatever, but channel contexts should not complain about that one */ |
| 2939 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
| 2940 | sdata->needed_rx_chains = local->rx_chains; |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2941 | |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2942 | err = ieee80211_vif_use_channel(sdata, chandef, |
| 2943 | IEEE80211_CHANCTX_SHARED); |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2944 | if (err) |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 2945 | goto out_unlock; |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2946 | |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2947 | ieee80211_queue_delayed_work(&sdata->local->hw, |
Janusz Dziedzic | 31559f3 | 2014-02-21 19:46:13 +0100 | [diff] [blame] | 2948 | &sdata->dfs_cac_timer_work, |
| 2949 | msecs_to_jiffies(cac_time_ms)); |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2950 | |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 2951 | out_unlock: |
| 2952 | mutex_unlock(&local->mtx); |
| 2953 | return err; |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 2954 | } |
| 2955 | |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 2956 | static struct cfg80211_beacon_data * |
| 2957 | cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) |
| 2958 | { |
| 2959 | struct cfg80211_beacon_data *new_beacon; |
| 2960 | u8 *pos; |
| 2961 | int len; |
| 2962 | |
| 2963 | len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len + |
| 2964 | beacon->proberesp_ies_len + beacon->assocresp_ies_len + |
| 2965 | beacon->probe_resp_len; |
| 2966 | |
| 2967 | new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL); |
| 2968 | if (!new_beacon) |
| 2969 | return NULL; |
| 2970 | |
| 2971 | pos = (u8 *)(new_beacon + 1); |
| 2972 | if (beacon->head_len) { |
| 2973 | new_beacon->head_len = beacon->head_len; |
| 2974 | new_beacon->head = pos; |
| 2975 | memcpy(pos, beacon->head, beacon->head_len); |
| 2976 | pos += beacon->head_len; |
| 2977 | } |
| 2978 | if (beacon->tail_len) { |
| 2979 | new_beacon->tail_len = beacon->tail_len; |
| 2980 | new_beacon->tail = pos; |
| 2981 | memcpy(pos, beacon->tail, beacon->tail_len); |
| 2982 | pos += beacon->tail_len; |
| 2983 | } |
| 2984 | if (beacon->beacon_ies_len) { |
| 2985 | new_beacon->beacon_ies_len = beacon->beacon_ies_len; |
| 2986 | new_beacon->beacon_ies = pos; |
| 2987 | memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len); |
| 2988 | pos += beacon->beacon_ies_len; |
| 2989 | } |
| 2990 | if (beacon->proberesp_ies_len) { |
| 2991 | new_beacon->proberesp_ies_len = beacon->proberesp_ies_len; |
| 2992 | new_beacon->proberesp_ies = pos; |
| 2993 | memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len); |
| 2994 | pos += beacon->proberesp_ies_len; |
| 2995 | } |
| 2996 | if (beacon->assocresp_ies_len) { |
| 2997 | new_beacon->assocresp_ies_len = beacon->assocresp_ies_len; |
| 2998 | new_beacon->assocresp_ies = pos; |
| 2999 | memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len); |
| 3000 | pos += beacon->assocresp_ies_len; |
| 3001 | } |
| 3002 | if (beacon->probe_resp_len) { |
| 3003 | new_beacon->probe_resp_len = beacon->probe_resp_len; |
| 3004 | beacon->probe_resp = pos; |
| 3005 | memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); |
| 3006 | pos += beacon->probe_resp_len; |
| 3007 | } |
| 3008 | |
| 3009 | return new_beacon; |
| 3010 | } |
| 3011 | |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3012 | void ieee80211_csa_finish(struct ieee80211_vif *vif) |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3013 | { |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3014 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
| 3015 | |
| 3016 | ieee80211_queue_work(&sdata->local->hw, |
| 3017 | &sdata->csa_finalize_work); |
| 3018 | } |
| 3019 | EXPORT_SYMBOL(ieee80211_csa_finish); |
| 3020 | |
| 3021 | static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) |
| 3022 | { |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3023 | struct ieee80211_local *local = sdata->local; |
Michal Kazior | 0951ebb | 2013-10-18 14:57:00 -0700 | [diff] [blame] | 3024 | int err, changed = 0; |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3025 | |
Michal Kazior | dbd7285 | 2014-01-29 07:56:21 +0100 | [diff] [blame] | 3026 | sdata_assert_lock(sdata); |
| 3027 | |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 3028 | mutex_lock(&local->mtx); |
Michal Kazior | cc901de | 2014-01-29 07:56:20 +0100 | [diff] [blame] | 3029 | sdata->radar_required = sdata->csa_radar_required; |
Luciano Coelho | 33787fc | 2013-11-11 20:34:54 +0200 | [diff] [blame] | 3030 | err = ieee80211_vif_change_channel(sdata, &changed); |
Johannes Berg | 34a3740 | 2013-12-18 09:43:33 +0100 | [diff] [blame] | 3031 | mutex_unlock(&local->mtx); |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3032 | if (WARN_ON(err < 0)) |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3033 | return; |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3034 | |
Arik Nemtsov | 7578d57 | 2013-09-01 17:15:51 +0300 | [diff] [blame] | 3035 | if (!local->use_chanctx) { |
Luciano Coelho | 33787fc | 2013-11-11 20:34:54 +0200 | [diff] [blame] | 3036 | local->_oper_chandef = sdata->csa_chandef; |
Arik Nemtsov | 7578d57 | 2013-09-01 17:15:51 +0300 | [diff] [blame] | 3037 | ieee80211_hw_config(local, 0); |
| 3038 | } |
| 3039 | |
Simon Wunderlich | e487eae | 2013-11-21 18:19:51 +0100 | [diff] [blame] | 3040 | sdata->vif.csa_active = false; |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3041 | switch (sdata->vif.type) { |
| 3042 | case NL80211_IFTYPE_AP: |
| 3043 | err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon); |
Michal Kazior | 97518af1 | 2014-01-29 07:56:18 +0100 | [diff] [blame] | 3044 | kfree(sdata->u.ap.next_beacon); |
| 3045 | sdata->u.ap.next_beacon = NULL; |
| 3046 | |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3047 | if (err < 0) |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3048 | return; |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3049 | changed |= err; |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3050 | break; |
| 3051 | case NL80211_IFTYPE_ADHOC: |
Michal Kazior | faf046e | 2014-01-29 07:56:17 +0100 | [diff] [blame] | 3052 | err = ieee80211_ibss_finish_csa(sdata); |
| 3053 | if (err < 0) |
| 3054 | return; |
| 3055 | changed |= err; |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3056 | break; |
Chun-Yeow Yeoh | b8456a1 | 2013-10-17 15:55:02 -0700 | [diff] [blame] | 3057 | #ifdef CONFIG_MAC80211_MESH |
| 3058 | case NL80211_IFTYPE_MESH_POINT: |
| 3059 | err = ieee80211_mesh_finish_csa(sdata); |
| 3060 | if (err < 0) |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3061 | return; |
Michal Kazior | faf046e | 2014-01-29 07:56:17 +0100 | [diff] [blame] | 3062 | changed |= err; |
Chun-Yeow Yeoh | b8456a1 | 2013-10-17 15:55:02 -0700 | [diff] [blame] | 3063 | break; |
| 3064 | #endif |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3065 | default: |
| 3066 | WARN_ON(1); |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3067 | return; |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3068 | } |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3069 | |
Michal Kazior | faf046e | 2014-01-29 07:56:17 +0100 | [diff] [blame] | 3070 | ieee80211_bss_info_change_notify(sdata, changed); |
| 3071 | |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3072 | ieee80211_wake_queues_by_reason(&sdata->local->hw, |
| 3073 | IEEE80211_MAX_QUEUE_MAP, |
| 3074 | IEEE80211_QUEUE_STOP_REASON_CSA); |
| 3075 | |
Luciano Coelho | 33787fc | 2013-11-11 20:34:54 +0200 | [diff] [blame] | 3076 | cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef); |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3077 | } |
| 3078 | |
| 3079 | void ieee80211_csa_finalize_work(struct work_struct *work) |
| 3080 | { |
| 3081 | struct ieee80211_sub_if_data *sdata = |
| 3082 | container_of(work, struct ieee80211_sub_if_data, |
| 3083 | csa_finalize_work); |
| 3084 | |
| 3085 | sdata_lock(sdata); |
| 3086 | /* AP might have been stopped while waiting for the lock. */ |
| 3087 | if (!sdata->vif.csa_active) |
| 3088 | goto unlock; |
| 3089 | |
| 3090 | if (!ieee80211_sdata_running(sdata)) |
| 3091 | goto unlock; |
| 3092 | |
| 3093 | ieee80211_csa_finalize(sdata); |
Simon Wunderlich | e487eae | 2013-11-21 18:19:51 +0100 | [diff] [blame] | 3094 | |
| 3095 | unlock: |
| 3096 | sdata_unlock(sdata); |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3097 | } |
| 3098 | |
Michal Kazior | 37fa2bd | 2014-02-28 15:59:06 +0100 | [diff] [blame] | 3099 | static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata, |
| 3100 | struct cfg80211_csa_settings *params, |
| 3101 | u32 *changed) |
| 3102 | { |
| 3103 | int err; |
| 3104 | |
| 3105 | switch (sdata->vif.type) { |
| 3106 | case NL80211_IFTYPE_AP: |
| 3107 | sdata->u.ap.next_beacon = |
| 3108 | cfg80211_beacon_dup(¶ms->beacon_after); |
| 3109 | if (!sdata->u.ap.next_beacon) |
| 3110 | return -ENOMEM; |
| 3111 | |
| 3112 | /* |
| 3113 | * With a count of 0, we don't have to wait for any |
| 3114 | * TBTT before switching, so complete the CSA |
| 3115 | * immediately. In theory, with a count == 1 we |
| 3116 | * should delay the switch until just before the next |
| 3117 | * TBTT, but that would complicate things so we switch |
| 3118 | * immediately too. If we would delay the switch |
| 3119 | * until the next TBTT, we would have to set the probe |
| 3120 | * response here. |
| 3121 | * |
| 3122 | * TODO: A channel switch with count <= 1 without |
| 3123 | * sending a CSA action frame is kind of useless, |
| 3124 | * because the clients won't know we're changing |
| 3125 | * channels. The action frame must be implemented |
| 3126 | * either here or in the userspace. |
| 3127 | */ |
| 3128 | if (params->count <= 1) |
| 3129 | break; |
| 3130 | |
| 3131 | sdata->csa_counter_offset_beacon = |
| 3132 | params->counter_offset_beacon; |
| 3133 | sdata->csa_counter_offset_presp = params->counter_offset_presp; |
| 3134 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa); |
| 3135 | if (err < 0) { |
| 3136 | kfree(sdata->u.ap.next_beacon); |
| 3137 | return err; |
| 3138 | } |
| 3139 | *changed |= err; |
| 3140 | |
| 3141 | break; |
| 3142 | case NL80211_IFTYPE_ADHOC: |
| 3143 | if (!sdata->vif.bss_conf.ibss_joined) |
| 3144 | return -EINVAL; |
| 3145 | |
| 3146 | if (params->chandef.width != sdata->u.ibss.chandef.width) |
| 3147 | return -EINVAL; |
| 3148 | |
| 3149 | switch (params->chandef.width) { |
| 3150 | case NL80211_CHAN_WIDTH_40: |
| 3151 | if (cfg80211_get_chandef_type(¶ms->chandef) != |
| 3152 | cfg80211_get_chandef_type(&sdata->u.ibss.chandef)) |
| 3153 | return -EINVAL; |
| 3154 | case NL80211_CHAN_WIDTH_5: |
| 3155 | case NL80211_CHAN_WIDTH_10: |
| 3156 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 3157 | case NL80211_CHAN_WIDTH_20: |
| 3158 | break; |
| 3159 | default: |
| 3160 | return -EINVAL; |
| 3161 | } |
| 3162 | |
| 3163 | /* changes into another band are not supported */ |
| 3164 | if (sdata->u.ibss.chandef.chan->band != |
| 3165 | params->chandef.chan->band) |
| 3166 | return -EINVAL; |
| 3167 | |
| 3168 | /* see comments in the NL80211_IFTYPE_AP block */ |
| 3169 | if (params->count > 1) { |
| 3170 | err = ieee80211_ibss_csa_beacon(sdata, params); |
| 3171 | if (err < 0) |
| 3172 | return err; |
| 3173 | *changed |= err; |
| 3174 | } |
| 3175 | |
| 3176 | ieee80211_send_action_csa(sdata, params); |
| 3177 | |
| 3178 | break; |
| 3179 | #ifdef CONFIG_MAC80211_MESH |
| 3180 | case NL80211_IFTYPE_MESH_POINT: { |
| 3181 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
| 3182 | |
| 3183 | if (params->chandef.width != sdata->vif.bss_conf.chandef.width) |
| 3184 | return -EINVAL; |
| 3185 | |
| 3186 | /* changes into another band are not supported */ |
| 3187 | if (sdata->vif.bss_conf.chandef.chan->band != |
| 3188 | params->chandef.chan->band) |
| 3189 | return -EINVAL; |
| 3190 | |
| 3191 | if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) { |
| 3192 | ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT; |
| 3193 | if (!ifmsh->pre_value) |
| 3194 | ifmsh->pre_value = 1; |
| 3195 | else |
| 3196 | ifmsh->pre_value++; |
| 3197 | } |
| 3198 | |
| 3199 | /* see comments in the NL80211_IFTYPE_AP block */ |
| 3200 | if (params->count > 1) { |
| 3201 | err = ieee80211_mesh_csa_beacon(sdata, params); |
| 3202 | if (err < 0) { |
| 3203 | ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE; |
| 3204 | return err; |
| 3205 | } |
| 3206 | *changed |= err; |
| 3207 | } |
| 3208 | |
| 3209 | if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT) |
| 3210 | ieee80211_send_action_csa(sdata, params); |
| 3211 | |
| 3212 | break; |
| 3213 | } |
| 3214 | #endif |
| 3215 | default: |
| 3216 | return -EOPNOTSUPP; |
| 3217 | } |
| 3218 | |
| 3219 | return 0; |
| 3220 | } |
| 3221 | |
Luciano Coelho | 82a8e17 | 2013-12-13 21:13:50 +0200 | [diff] [blame] | 3222 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
| 3223 | struct cfg80211_csa_settings *params) |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3224 | { |
| 3225 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 3226 | struct ieee80211_local *local = sdata->local; |
| 3227 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 3228 | struct ieee80211_chanctx *chanctx; |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3229 | int err, num_chanctx, changed = 0; |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3230 | |
Michal Kazior | dbd7285 | 2014-01-29 07:56:21 +0100 | [diff] [blame] | 3231 | sdata_assert_lock(sdata); |
Simon Wunderlich | 7ca133b | 2013-11-21 18:19:50 +0100 | [diff] [blame] | 3232 | |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3233 | if (!list_empty(&local->roc_list) || local->scanning) |
| 3234 | return -EBUSY; |
| 3235 | |
| 3236 | if (sdata->wdev.cac_started) |
| 3237 | return -EBUSY; |
| 3238 | |
| 3239 | if (cfg80211_chandef_identical(¶ms->chandef, |
| 3240 | &sdata->vif.bss_conf.chandef)) |
| 3241 | return -EINVAL; |
| 3242 | |
| 3243 | rcu_read_lock(); |
| 3244 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 3245 | if (!chanctx_conf) { |
| 3246 | rcu_read_unlock(); |
| 3247 | return -EBUSY; |
| 3248 | } |
| 3249 | |
| 3250 | /* don't handle for multi-VIF cases */ |
| 3251 | chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf); |
| 3252 | if (chanctx->refcount > 1) { |
| 3253 | rcu_read_unlock(); |
| 3254 | return -EBUSY; |
| 3255 | } |
| 3256 | num_chanctx = 0; |
| 3257 | list_for_each_entry_rcu(chanctx, &local->chanctx_list, list) |
| 3258 | num_chanctx++; |
| 3259 | rcu_read_unlock(); |
| 3260 | |
| 3261 | if (num_chanctx > 1) |
| 3262 | return -EBUSY; |
| 3263 | |
| 3264 | /* don't allow another channel switch if one is already active. */ |
| 3265 | if (sdata->vif.csa_active) |
| 3266 | return -EBUSY; |
| 3267 | |
Michal Kazior | 37fa2bd | 2014-02-28 15:59:06 +0100 | [diff] [blame] | 3268 | err = ieee80211_set_csa_beacon(sdata, params, &changed); |
| 3269 | if (err) |
| 3270 | return err; |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3271 | |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3272 | sdata->csa_radar_required = params->radar_required; |
| 3273 | |
| 3274 | if (params->block_tx) |
| 3275 | ieee80211_stop_queues_by_reason(&local->hw, |
| 3276 | IEEE80211_MAX_QUEUE_MAP, |
| 3277 | IEEE80211_QUEUE_STOP_REASON_CSA); |
| 3278 | |
Luciano Coelho | 33787fc | 2013-11-11 20:34:54 +0200 | [diff] [blame] | 3279 | sdata->csa_chandef = params->chandef; |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3280 | sdata->vif.csa_active = true; |
| 3281 | |
Luciano Coelho | 66e01cf | 2014-01-13 19:43:00 +0200 | [diff] [blame] | 3282 | if (changed) { |
| 3283 | ieee80211_bss_info_change_notify(sdata, changed); |
| 3284 | drv_channel_switch_beacon(sdata, ¶ms->chandef); |
| 3285 | } else { |
| 3286 | /* if the beacon didn't change, we can finalize immediately */ |
| 3287 | ieee80211_csa_finalize(sdata); |
| 3288 | } |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 3289 | |
| 3290 | return 0; |
| 3291 | } |
| 3292 | |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 3293 | static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3294 | struct cfg80211_mgmt_tx_params *params, |
| 3295 | u64 *cookie) |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 3296 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 3297 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 3298 | struct ieee80211_local *local = sdata->local; |
| 3299 | struct sk_buff *skb; |
| 3300 | struct sta_info *sta; |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3301 | const struct ieee80211_mgmt *mgmt = (void *)params->buf; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3302 | bool need_offchan = false; |
Johannes Berg | e247bd90 | 2011-11-04 11:18:21 +0100 | [diff] [blame] | 3303 | u32 flags; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3304 | int ret; |
Johannes Berg | f7ca38d | 2010-11-25 10:02:29 +0100 | [diff] [blame] | 3305 | |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3306 | if (params->dont_wait_for_ack) |
Johannes Berg | e247bd90 | 2011-11-04 11:18:21 +0100 | [diff] [blame] | 3307 | flags = IEEE80211_TX_CTL_NO_ACK; |
| 3308 | else |
| 3309 | flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | |
| 3310 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
| 3311 | |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3312 | if (params->no_cck) |
Rajkumar Manoharan | aad14ce | 2011-09-25 14:53:31 +0530 | [diff] [blame] | 3313 | flags |= IEEE80211_TX_CTL_NO_CCK_RATE; |
| 3314 | |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 3315 | switch (sdata->vif.type) { |
| 3316 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3317 | if (!sdata->vif.bss_conf.ibss_joined) |
| 3318 | need_offchan = true; |
| 3319 | /* fall through */ |
| 3320 | #ifdef CONFIG_MAC80211_MESH |
| 3321 | case NL80211_IFTYPE_MESH_POINT: |
| 3322 | if (ieee80211_vif_is_mesh(&sdata->vif) && |
| 3323 | !sdata->u.mesh.mesh_id_len) |
| 3324 | need_offchan = true; |
| 3325 | /* fall through */ |
| 3326 | #endif |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 3327 | case NL80211_IFTYPE_AP: |
| 3328 | case NL80211_IFTYPE_AP_VLAN: |
| 3329 | case NL80211_IFTYPE_P2P_GO: |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3330 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC && |
| 3331 | !ieee80211_vif_is_mesh(&sdata->vif) && |
| 3332 | !rcu_access_pointer(sdata->bss->beacon)) |
| 3333 | need_offchan = true; |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 3334 | if (!ieee80211_is_action(mgmt->frame_control) || |
Thomas Pedersen | ac49e1a | 2013-06-20 23:50:58 -0700 | [diff] [blame] | 3335 | mgmt->u.action.category == WLAN_CATEGORY_PUBLIC || |
Simon Wunderlich | cd7760e | 2013-08-28 13:41:31 +0200 | [diff] [blame] | 3336 | mgmt->u.action.category == WLAN_CATEGORY_SELF_PROTECTED || |
| 3337 | mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 3338 | break; |
| 3339 | rcu_read_lock(); |
| 3340 | sta = sta_info_get(sdata, mgmt->da); |
| 3341 | rcu_read_unlock(); |
| 3342 | if (!sta) |
| 3343 | return -ENOLINK; |
| 3344 | break; |
| 3345 | case NL80211_IFTYPE_STATION: |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 3346 | case NL80211_IFTYPE_P2P_CLIENT: |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3347 | if (!sdata->u.mgd.associated) |
| 3348 | need_offchan = true; |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 3349 | break; |
Johannes Berg | f142c6b | 2012-06-18 20:07:15 +0200 | [diff] [blame] | 3350 | case NL80211_IFTYPE_P2P_DEVICE: |
| 3351 | need_offchan = true; |
| 3352 | break; |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 3353 | default: |
| 3354 | return -EOPNOTSUPP; |
| 3355 | } |
| 3356 | |
Antonio Quartulli | f7aeb6f | 2013-06-11 14:20:00 +0200 | [diff] [blame] | 3357 | /* configurations requiring offchan cannot work if no channel has been |
| 3358 | * specified |
| 3359 | */ |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3360 | if (need_offchan && !params->chan) |
Antonio Quartulli | f7aeb6f | 2013-06-11 14:20:00 +0200 | [diff] [blame] | 3361 | return -EINVAL; |
| 3362 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3363 | mutex_lock(&local->mtx); |
| 3364 | |
| 3365 | /* Check if the operating channel is the requested channel */ |
| 3366 | if (!need_offchan) { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3367 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 3368 | |
| 3369 | rcu_read_lock(); |
| 3370 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 3371 | |
Antonio Quartulli | f7aeb6f | 2013-06-11 14:20:00 +0200 | [diff] [blame] | 3372 | if (chanctx_conf) { |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3373 | need_offchan = params->chan && |
| 3374 | (params->chan != |
| 3375 | chanctx_conf->def.chan); |
| 3376 | } else if (!params->chan) { |
Antonio Quartulli | f7aeb6f | 2013-06-11 14:20:00 +0200 | [diff] [blame] | 3377 | ret = -EINVAL; |
| 3378 | rcu_read_unlock(); |
| 3379 | goto out_unlock; |
| 3380 | } else { |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3381 | need_offchan = true; |
Antonio Quartulli | f7aeb6f | 2013-06-11 14:20:00 +0200 | [diff] [blame] | 3382 | } |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3383 | rcu_read_unlock(); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3384 | } |
| 3385 | |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3386 | if (need_offchan && !params->offchan) { |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3387 | ret = -EBUSY; |
| 3388 | goto out_unlock; |
| 3389 | } |
| 3390 | |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3391 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + params->len); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3392 | if (!skb) { |
| 3393 | ret = -ENOMEM; |
| 3394 | goto out_unlock; |
| 3395 | } |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 3396 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 3397 | |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3398 | memcpy(skb_put(skb, params->len), params->buf, params->len); |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 3399 | |
| 3400 | IEEE80211_SKB_CB(skb)->flags = flags; |
| 3401 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3402 | skb->dev = sdata->dev; |
| 3403 | |
| 3404 | if (!need_offchan) { |
Nicolas Cavallari | 7f9f78a | 2012-07-16 18:36:52 +0200 | [diff] [blame] | 3405 | *cookie = (unsigned long) skb; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3406 | ieee80211_tx_skb(sdata, skb); |
| 3407 | ret = 0; |
| 3408 | goto out_unlock; |
| 3409 | } |
| 3410 | |
Seth Forshee | 6c17b77 | 2013-02-11 11:21:07 -0600 | [diff] [blame] | 3411 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN | |
| 3412 | IEEE80211_TX_INTFL_OFFCHAN_TX_OK; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3413 | if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL) |
Johannes Berg | 3a25a8c | 2012-04-03 16:28:50 +0200 | [diff] [blame] | 3414 | IEEE80211_SKB_CB(skb)->hw_queue = |
| 3415 | local->hw.offchannel_tx_hw_queue; |
| 3416 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3417 | /* This will handle all kinds of coalescing and immediate TX */ |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 3418 | ret = ieee80211_start_roc_work(local, sdata, params->chan, |
| 3419 | params->wait, cookie, skb, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 3420 | IEEE80211_ROC_TYPE_MGMT_TX); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3421 | if (ret) |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 3422 | kfree_skb(skb); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3423 | out_unlock: |
| 3424 | mutex_unlock(&local->mtx); |
| 3425 | return ret; |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 3426 | } |
| 3427 | |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 3428 | static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 3429 | struct wireless_dev *wdev, |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 3430 | u64 cookie) |
| 3431 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 3432 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 3433 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 3434 | return ieee80211_cancel_roc(local, cookie, true); |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 3435 | } |
| 3436 | |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 3437 | static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 3438 | struct wireless_dev *wdev, |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 3439 | u16 frame_type, bool reg) |
| 3440 | { |
| 3441 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 3442 | |
Will Hawkins | 6abe056 | 2012-06-20 11:51:14 -0400 | [diff] [blame] | 3443 | switch (frame_type) { |
Will Hawkins | 6abe056 | 2012-06-20 11:51:14 -0400 | [diff] [blame] | 3444 | case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ: |
| 3445 | if (reg) |
| 3446 | local->probe_req_reg++; |
| 3447 | else |
| 3448 | local->probe_req_reg--; |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 3449 | |
Felix Fietkau | 35f5149 | 2012-10-31 15:50:34 +0100 | [diff] [blame] | 3450 | if (!local->open_count) |
| 3451 | break; |
| 3452 | |
Will Hawkins | 6abe056 | 2012-06-20 11:51:14 -0400 | [diff] [blame] | 3453 | ieee80211_queue_work(&local->hw, &local->reconfig_filter); |
| 3454 | break; |
| 3455 | default: |
| 3456 | break; |
| 3457 | } |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 3458 | } |
| 3459 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 3460 | static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant) |
| 3461 | { |
| 3462 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 3463 | |
| 3464 | if (local->started) |
| 3465 | return -EOPNOTSUPP; |
| 3466 | |
| 3467 | return drv_set_antenna(local, tx_ant, rx_ant); |
| 3468 | } |
| 3469 | |
| 3470 | static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant) |
| 3471 | { |
| 3472 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 3473 | |
| 3474 | return drv_get_antenna(local, tx_ant, rx_ant); |
| 3475 | } |
| 3476 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 3477 | static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx) |
| 3478 | { |
| 3479 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 3480 | |
| 3481 | return drv_set_ringparam(local, tx, rx); |
| 3482 | } |
| 3483 | |
| 3484 | static void ieee80211_get_ringparam(struct wiphy *wiphy, |
| 3485 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 3486 | { |
| 3487 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 3488 | |
| 3489 | drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 3490 | } |
| 3491 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 3492 | static int ieee80211_set_rekey_data(struct wiphy *wiphy, |
| 3493 | struct net_device *dev, |
| 3494 | struct cfg80211_gtk_rekey_data *data) |
| 3495 | { |
| 3496 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 3497 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 3498 | |
| 3499 | if (!local->ops->set_rekey_data) |
| 3500 | return -EOPNOTSUPP; |
| 3501 | |
| 3502 | drv_set_rekey_data(local, sdata, data); |
| 3503 | |
| 3504 | return 0; |
| 3505 | } |
| 3506 | |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3507 | static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb) |
| 3508 | { |
| 3509 | u8 *pos = (void *)skb_put(skb, 7); |
| 3510 | |
| 3511 | *pos++ = WLAN_EID_EXT_CAPABILITY; |
| 3512 | *pos++ = 5; /* len */ |
| 3513 | *pos++ = 0x0; |
| 3514 | *pos++ = 0x0; |
| 3515 | *pos++ = 0x0; |
| 3516 | *pos++ = 0x0; |
| 3517 | *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED; |
| 3518 | } |
| 3519 | |
| 3520 | static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata) |
| 3521 | { |
| 3522 | struct ieee80211_local *local = sdata->local; |
| 3523 | u16 capab; |
| 3524 | |
| 3525 | capab = 0; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3526 | if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ) |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3527 | return capab; |
| 3528 | |
| 3529 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) |
| 3530 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; |
| 3531 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) |
| 3532 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; |
| 3533 | |
| 3534 | return capab; |
| 3535 | } |
| 3536 | |
| 3537 | static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr, |
| 3538 | u8 *peer, u8 *bssid) |
| 3539 | { |
| 3540 | struct ieee80211_tdls_lnkie *lnkid; |
| 3541 | |
| 3542 | lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie)); |
| 3543 | |
| 3544 | lnkid->ie_type = WLAN_EID_LINK_ID; |
| 3545 | lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2; |
| 3546 | |
| 3547 | memcpy(lnkid->bssid, bssid, ETH_ALEN); |
| 3548 | memcpy(lnkid->init_sta, src_addr, ETH_ALEN); |
| 3549 | memcpy(lnkid->resp_sta, peer, ETH_ALEN); |
| 3550 | } |
| 3551 | |
| 3552 | static int |
| 3553 | ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, |
| 3554 | u8 *peer, u8 action_code, u8 dialog_token, |
| 3555 | u16 status_code, struct sk_buff *skb) |
| 3556 | { |
| 3557 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3558 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3559 | struct ieee80211_tdls_data *tf; |
| 3560 | |
| 3561 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); |
| 3562 | |
| 3563 | memcpy(tf->da, peer, ETH_ALEN); |
| 3564 | memcpy(tf->sa, sdata->vif.addr, ETH_ALEN); |
| 3565 | tf->ether_type = cpu_to_be16(ETH_P_TDLS); |
| 3566 | tf->payload_type = WLAN_TDLS_SNAP_RFTYPE; |
| 3567 | |
| 3568 | switch (action_code) { |
| 3569 | case WLAN_TDLS_SETUP_REQUEST: |
| 3570 | tf->category = WLAN_CATEGORY_TDLS; |
| 3571 | tf->action_code = WLAN_TDLS_SETUP_REQUEST; |
| 3572 | |
| 3573 | skb_put(skb, sizeof(tf->u.setup_req)); |
| 3574 | tf->u.setup_req.dialog_token = dialog_token; |
| 3575 | tf->u.setup_req.capability = |
| 3576 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 3577 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3578 | ieee80211_add_srates_ie(sdata, skb, false, band); |
| 3579 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3580 | ieee80211_tdls_add_ext_capab(skb); |
| 3581 | break; |
| 3582 | case WLAN_TDLS_SETUP_RESPONSE: |
| 3583 | tf->category = WLAN_CATEGORY_TDLS; |
| 3584 | tf->action_code = WLAN_TDLS_SETUP_RESPONSE; |
| 3585 | |
| 3586 | skb_put(skb, sizeof(tf->u.setup_resp)); |
| 3587 | tf->u.setup_resp.status_code = cpu_to_le16(status_code); |
| 3588 | tf->u.setup_resp.dialog_token = dialog_token; |
| 3589 | tf->u.setup_resp.capability = |
| 3590 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 3591 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3592 | ieee80211_add_srates_ie(sdata, skb, false, band); |
| 3593 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3594 | ieee80211_tdls_add_ext_capab(skb); |
| 3595 | break; |
| 3596 | case WLAN_TDLS_SETUP_CONFIRM: |
| 3597 | tf->category = WLAN_CATEGORY_TDLS; |
| 3598 | tf->action_code = WLAN_TDLS_SETUP_CONFIRM; |
| 3599 | |
| 3600 | skb_put(skb, sizeof(tf->u.setup_cfm)); |
| 3601 | tf->u.setup_cfm.status_code = cpu_to_le16(status_code); |
| 3602 | tf->u.setup_cfm.dialog_token = dialog_token; |
| 3603 | break; |
| 3604 | case WLAN_TDLS_TEARDOWN: |
| 3605 | tf->category = WLAN_CATEGORY_TDLS; |
| 3606 | tf->action_code = WLAN_TDLS_TEARDOWN; |
| 3607 | |
| 3608 | skb_put(skb, sizeof(tf->u.teardown)); |
| 3609 | tf->u.teardown.reason_code = cpu_to_le16(status_code); |
| 3610 | break; |
| 3611 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 3612 | tf->category = WLAN_CATEGORY_TDLS; |
| 3613 | tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST; |
| 3614 | |
| 3615 | skb_put(skb, sizeof(tf->u.discover_req)); |
| 3616 | tf->u.discover_req.dialog_token = dialog_token; |
| 3617 | break; |
| 3618 | default: |
| 3619 | return -EINVAL; |
| 3620 | } |
| 3621 | |
| 3622 | return 0; |
| 3623 | } |
| 3624 | |
| 3625 | static int |
| 3626 | ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, |
| 3627 | u8 *peer, u8 action_code, u8 dialog_token, |
| 3628 | u16 status_code, struct sk_buff *skb) |
| 3629 | { |
| 3630 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3631 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3632 | struct ieee80211_mgmt *mgmt; |
| 3633 | |
| 3634 | mgmt = (void *)skb_put(skb, 24); |
| 3635 | memset(mgmt, 0, 24); |
| 3636 | memcpy(mgmt->da, peer, ETH_ALEN); |
| 3637 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
| 3638 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
| 3639 | |
| 3640 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 3641 | IEEE80211_STYPE_ACTION); |
| 3642 | |
| 3643 | switch (action_code) { |
| 3644 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 3645 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp)); |
| 3646 | mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; |
| 3647 | mgmt->u.action.u.tdls_discover_resp.action_code = |
| 3648 | WLAN_PUB_ACTION_TDLS_DISCOVER_RES; |
| 3649 | mgmt->u.action.u.tdls_discover_resp.dialog_token = |
| 3650 | dialog_token; |
| 3651 | mgmt->u.action.u.tdls_discover_resp.capability = |
| 3652 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 3653 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3654 | ieee80211_add_srates_ie(sdata, skb, false, band); |
| 3655 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3656 | ieee80211_tdls_add_ext_capab(skb); |
| 3657 | break; |
| 3658 | default: |
| 3659 | return -EINVAL; |
| 3660 | } |
| 3661 | |
| 3662 | return 0; |
| 3663 | } |
| 3664 | |
| 3665 | static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 3666 | u8 *peer, u8 action_code, u8 dialog_token, |
Sunil Dutt Undekari | df942e7 | 2014-02-20 16:22:09 +0530 | [diff] [blame] | 3667 | u16 status_code, u32 peer_capability, |
| 3668 | const u8 *extra_ies, size_t extra_ies_len) |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3669 | { |
| 3670 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 3671 | struct ieee80211_local *local = sdata->local; |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3672 | struct sk_buff *skb = NULL; |
| 3673 | bool send_direct; |
| 3674 | int ret; |
| 3675 | |
| 3676 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) |
| 3677 | return -ENOTSUPP; |
| 3678 | |
| 3679 | /* make sure we are in managed mode, and associated */ |
| 3680 | if (sdata->vif.type != NL80211_IFTYPE_STATION || |
| 3681 | !sdata->u.mgd.associated) |
| 3682 | return -EINVAL; |
| 3683 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3684 | tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n", |
| 3685 | action_code, peer); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3686 | |
| 3687 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
| 3688 | max(sizeof(struct ieee80211_mgmt), |
| 3689 | sizeof(struct ieee80211_tdls_data)) + |
| 3690 | 50 + /* supported rates */ |
| 3691 | 7 + /* ext capab */ |
| 3692 | extra_ies_len + |
| 3693 | sizeof(struct ieee80211_tdls_lnkie)); |
| 3694 | if (!skb) |
| 3695 | return -ENOMEM; |
| 3696 | |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3697 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 3698 | |
| 3699 | switch (action_code) { |
| 3700 | case WLAN_TDLS_SETUP_REQUEST: |
| 3701 | case WLAN_TDLS_SETUP_RESPONSE: |
| 3702 | case WLAN_TDLS_SETUP_CONFIRM: |
| 3703 | case WLAN_TDLS_TEARDOWN: |
| 3704 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 3705 | ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer, |
| 3706 | action_code, dialog_token, |
| 3707 | status_code, skb); |
| 3708 | send_direct = false; |
| 3709 | break; |
| 3710 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 3711 | ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code, |
| 3712 | dialog_token, status_code, |
| 3713 | skb); |
| 3714 | send_direct = true; |
| 3715 | break; |
| 3716 | default: |
| 3717 | ret = -ENOTSUPP; |
| 3718 | break; |
| 3719 | } |
| 3720 | |
| 3721 | if (ret < 0) |
| 3722 | goto fail; |
| 3723 | |
| 3724 | if (extra_ies_len) |
| 3725 | memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len); |
| 3726 | |
| 3727 | /* the TDLS link IE is always added last */ |
| 3728 | switch (action_code) { |
| 3729 | case WLAN_TDLS_SETUP_REQUEST: |
| 3730 | case WLAN_TDLS_SETUP_CONFIRM: |
| 3731 | case WLAN_TDLS_TEARDOWN: |
| 3732 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 3733 | /* we are the initiator */ |
| 3734 | ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer, |
| 3735 | sdata->u.mgd.bssid); |
| 3736 | break; |
| 3737 | case WLAN_TDLS_SETUP_RESPONSE: |
| 3738 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 3739 | /* we are the responder */ |
| 3740 | ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr, |
| 3741 | sdata->u.mgd.bssid); |
| 3742 | break; |
| 3743 | default: |
| 3744 | ret = -ENOTSUPP; |
| 3745 | goto fail; |
| 3746 | } |
| 3747 | |
| 3748 | if (send_direct) { |
| 3749 | ieee80211_tx_skb(sdata, skb); |
| 3750 | return 0; |
| 3751 | } |
| 3752 | |
| 3753 | /* |
| 3754 | * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise |
| 3755 | * we should default to AC_VI. |
| 3756 | */ |
| 3757 | switch (action_code) { |
| 3758 | case WLAN_TDLS_SETUP_REQUEST: |
| 3759 | case WLAN_TDLS_SETUP_RESPONSE: |
| 3760 | skb_set_queue_mapping(skb, IEEE80211_AC_BK); |
| 3761 | skb->priority = 2; |
| 3762 | break; |
| 3763 | default: |
| 3764 | skb_set_queue_mapping(skb, IEEE80211_AC_VI); |
| 3765 | skb->priority = 5; |
| 3766 | break; |
| 3767 | } |
| 3768 | |
| 3769 | /* disable bottom halves when entering the Tx path */ |
| 3770 | local_bh_disable(); |
| 3771 | ret = ieee80211_subif_start_xmit(skb, dev); |
| 3772 | local_bh_enable(); |
| 3773 | |
| 3774 | return ret; |
| 3775 | |
| 3776 | fail: |
| 3777 | dev_kfree_skb(skb); |
| 3778 | return ret; |
| 3779 | } |
| 3780 | |
| 3781 | static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 3782 | u8 *peer, enum nl80211_tdls_operation oper) |
| 3783 | { |
Arik Nemtsov | 941c93c | 2011-09-28 14:12:54 +0300 | [diff] [blame] | 3784 | struct sta_info *sta; |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3785 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 3786 | |
| 3787 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) |
| 3788 | return -ENOTSUPP; |
| 3789 | |
| 3790 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 3791 | return -EINVAL; |
| 3792 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 3793 | tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3794 | |
| 3795 | switch (oper) { |
| 3796 | case NL80211_TDLS_ENABLE_LINK: |
Arik Nemtsov | 941c93c | 2011-09-28 14:12:54 +0300 | [diff] [blame] | 3797 | rcu_read_lock(); |
| 3798 | sta = sta_info_get(sdata, peer); |
| 3799 | if (!sta) { |
| 3800 | rcu_read_unlock(); |
| 3801 | return -ENOLINK; |
| 3802 | } |
| 3803 | |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 3804 | set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH); |
Arik Nemtsov | 941c93c | 2011-09-28 14:12:54 +0300 | [diff] [blame] | 3805 | rcu_read_unlock(); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3806 | break; |
| 3807 | case NL80211_TDLS_DISABLE_LINK: |
| 3808 | return sta_info_destroy_addr(sdata, peer); |
| 3809 | case NL80211_TDLS_TEARDOWN: |
| 3810 | case NL80211_TDLS_SETUP: |
| 3811 | case NL80211_TDLS_DISCOVERY_REQ: |
| 3812 | /* We don't support in-driver setup/teardown/discovery */ |
| 3813 | return -ENOTSUPP; |
| 3814 | default: |
| 3815 | return -ENOTSUPP; |
| 3816 | } |
| 3817 | |
| 3818 | return 0; |
| 3819 | } |
| 3820 | |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3821 | static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, |
| 3822 | const u8 *peer, u64 *cookie) |
| 3823 | { |
| 3824 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 3825 | struct ieee80211_local *local = sdata->local; |
| 3826 | struct ieee80211_qos_hdr *nullfunc; |
| 3827 | struct sk_buff *skb; |
| 3828 | int size = sizeof(*nullfunc); |
| 3829 | __le16 fc; |
| 3830 | bool qos; |
| 3831 | struct ieee80211_tx_info *info; |
| 3832 | struct sta_info *sta; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3833 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 3834 | enum ieee80211_band band; |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3835 | |
| 3836 | rcu_read_lock(); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3837 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 3838 | if (WARN_ON(!chanctx_conf)) { |
| 3839 | rcu_read_unlock(); |
| 3840 | return -EINVAL; |
| 3841 | } |
Johannes Berg | 4bf8853 | 2012-11-09 11:39:59 +0100 | [diff] [blame] | 3842 | band = chanctx_conf->def.chan->band; |
Felix Fietkau | 03bb7f4 | 2013-09-29 21:39:33 +0200 | [diff] [blame] | 3843 | sta = sta_info_get_bss(sdata, peer); |
Johannes Berg | b4487c2 | 2011-11-11 20:22:30 +0100 | [diff] [blame] | 3844 | if (sta) { |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3845 | qos = test_sta_flag(sta, WLAN_STA_WME); |
Johannes Berg | b4487c2 | 2011-11-11 20:22:30 +0100 | [diff] [blame] | 3846 | } else { |
| 3847 | rcu_read_unlock(); |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3848 | return -ENOLINK; |
Johannes Berg | b4487c2 | 2011-11-11 20:22:30 +0100 | [diff] [blame] | 3849 | } |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3850 | |
| 3851 | if (qos) { |
| 3852 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 3853 | IEEE80211_STYPE_QOS_NULLFUNC | |
| 3854 | IEEE80211_FCTL_FROMDS); |
| 3855 | } else { |
| 3856 | size -= 2; |
| 3857 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 3858 | IEEE80211_STYPE_NULLFUNC | |
| 3859 | IEEE80211_FCTL_FROMDS); |
| 3860 | } |
| 3861 | |
| 3862 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3863 | if (!skb) { |
| 3864 | rcu_read_unlock(); |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3865 | return -ENOMEM; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3866 | } |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3867 | |
| 3868 | skb->dev = dev; |
| 3869 | |
| 3870 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 3871 | |
| 3872 | nullfunc = (void *) skb_put(skb, size); |
| 3873 | nullfunc->frame_control = fc; |
| 3874 | nullfunc->duration_id = 0; |
| 3875 | memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); |
| 3876 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); |
| 3877 | memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); |
| 3878 | nullfunc->seq_ctrl = 0; |
| 3879 | |
| 3880 | info = IEEE80211_SKB_CB(skb); |
| 3881 | |
| 3882 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | |
| 3883 | IEEE80211_TX_INTFL_NL80211_FRAME_TX; |
| 3884 | |
| 3885 | skb_set_queue_mapping(skb, IEEE80211_AC_VO); |
| 3886 | skb->priority = 7; |
| 3887 | if (qos) |
| 3888 | nullfunc->qos_ctrl = cpu_to_le16(7); |
| 3889 | |
| 3890 | local_bh_disable(); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3891 | ieee80211_xmit(sdata, skb, band); |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3892 | local_bh_enable(); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3893 | rcu_read_unlock(); |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3894 | |
| 3895 | *cookie = (unsigned long) skb; |
| 3896 | return 0; |
| 3897 | } |
| 3898 | |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 3899 | static int ieee80211_cfg_get_channel(struct wiphy *wiphy, |
| 3900 | struct wireless_dev *wdev, |
| 3901 | struct cfg80211_chan_def *chandef) |
Johannes Berg | 5b7ccaf | 2012-07-12 19:45:08 +0200 | [diff] [blame] | 3902 | { |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3903 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Felix Fietkau | cb601ff | 2013-02-23 19:02:14 +0100 | [diff] [blame] | 3904 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3905 | struct ieee80211_chanctx_conf *chanctx_conf; |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 3906 | int ret = -ENODATA; |
Johannes Berg | 5b7ccaf | 2012-07-12 19:45:08 +0200 | [diff] [blame] | 3907 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3908 | rcu_read_lock(); |
Johannes Berg | feda302 | 2013-02-28 09:59:22 +0100 | [diff] [blame] | 3909 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 3910 | if (chanctx_conf) { |
| 3911 | *chandef = chanctx_conf->def; |
| 3912 | ret = 0; |
| 3913 | } else if (local->open_count > 0 && |
| 3914 | local->open_count == local->monitors && |
| 3915 | sdata->vif.type == NL80211_IFTYPE_MONITOR) { |
| 3916 | if (local->use_chanctx) |
| 3917 | *chandef = local->monitor_chandef; |
| 3918 | else |
Karl Beldan | 675a0b0 | 2013-03-25 16:26:57 +0100 | [diff] [blame] | 3919 | *chandef = local->_oper_chandef; |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 3920 | ret = 0; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 3921 | } |
| 3922 | rcu_read_unlock(); |
| 3923 | |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 3924 | return ret; |
Johannes Berg | 5b7ccaf | 2012-07-12 19:45:08 +0200 | [diff] [blame] | 3925 | } |
| 3926 | |
Johannes Berg | 6d52563 | 2012-04-04 15:05:25 +0200 | [diff] [blame] | 3927 | #ifdef CONFIG_PM |
| 3928 | static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled) |
| 3929 | { |
| 3930 | drv_set_wakeup(wiphy_priv(wiphy), enabled); |
| 3931 | } |
| 3932 | #endif |
| 3933 | |
Kyeyoon Park | 32db6b5 | 2013-12-16 23:04:43 -0800 | [diff] [blame] | 3934 | static int ieee80211_set_qos_map(struct wiphy *wiphy, |
| 3935 | struct net_device *dev, |
| 3936 | struct cfg80211_qos_map *qos_map) |
| 3937 | { |
| 3938 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 3939 | struct mac80211_qos_map *new_qos_map, *old_qos_map; |
| 3940 | |
| 3941 | if (qos_map) { |
| 3942 | new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL); |
| 3943 | if (!new_qos_map) |
| 3944 | return -ENOMEM; |
| 3945 | memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map)); |
| 3946 | } else { |
| 3947 | /* A NULL qos_map was passed to disable QoS mapping */ |
| 3948 | new_qos_map = NULL; |
| 3949 | } |
| 3950 | |
Johannes Berg | 194ff52 | 2013-12-30 23:12:37 +0100 | [diff] [blame] | 3951 | old_qos_map = sdata_dereference(sdata->qos_map, sdata); |
Kyeyoon Park | 32db6b5 | 2013-12-16 23:04:43 -0800 | [diff] [blame] | 3952 | rcu_assign_pointer(sdata->qos_map, new_qos_map); |
| 3953 | if (old_qos_map) |
| 3954 | kfree_rcu(old_qos_map, rcu_head); |
| 3955 | |
| 3956 | return 0; |
| 3957 | } |
| 3958 | |
Johannes Berg | 8a47cea | 2014-01-20 23:55:44 +0100 | [diff] [blame] | 3959 | const struct cfg80211_ops mac80211_config_ops = { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 3960 | .add_virtual_intf = ieee80211_add_iface, |
| 3961 | .del_virtual_intf = ieee80211_del_iface, |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 3962 | .change_virtual_intf = ieee80211_change_iface, |
Johannes Berg | f142c6b | 2012-06-18 20:07:15 +0200 | [diff] [blame] | 3963 | .start_p2p_device = ieee80211_start_p2p_device, |
| 3964 | .stop_p2p_device = ieee80211_stop_p2p_device, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 3965 | .add_key = ieee80211_add_key, |
| 3966 | .del_key = ieee80211_del_key, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 3967 | .get_key = ieee80211_get_key, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 3968 | .set_default_key = ieee80211_config_default_key, |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 3969 | .set_default_mgmt_key = ieee80211_config_default_mgmt_key, |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 3970 | .start_ap = ieee80211_start_ap, |
| 3971 | .change_beacon = ieee80211_change_beacon, |
| 3972 | .stop_ap = ieee80211_stop_ap, |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 3973 | .add_station = ieee80211_add_station, |
| 3974 | .del_station = ieee80211_del_station, |
| 3975 | .change_station = ieee80211_change_station, |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 3976 | .get_station = ieee80211_get_station, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 3977 | .dump_station = ieee80211_dump_station, |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 3978 | .dump_survey = ieee80211_dump_survey, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 3979 | #ifdef CONFIG_MAC80211_MESH |
| 3980 | .add_mpath = ieee80211_add_mpath, |
| 3981 | .del_mpath = ieee80211_del_mpath, |
| 3982 | .change_mpath = ieee80211_change_mpath, |
| 3983 | .get_mpath = ieee80211_get_mpath, |
| 3984 | .dump_mpath = ieee80211_dump_mpath, |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 3985 | .update_mesh_config = ieee80211_update_mesh_config, |
| 3986 | .get_mesh_config = ieee80211_get_mesh_config, |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 3987 | .join_mesh = ieee80211_join_mesh, |
| 3988 | .leave_mesh = ieee80211_leave_mesh, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 3989 | #endif |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 3990 | .change_bss = ieee80211_change_bss, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 3991 | .set_txq_params = ieee80211_set_txq_params, |
Johannes Berg | e8c9bd5 | 2012-06-06 08:18:22 +0200 | [diff] [blame] | 3992 | .set_monitor_channel = ieee80211_set_monitor_channel, |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 3993 | .suspend = ieee80211_suspend, |
| 3994 | .resume = ieee80211_resume, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 3995 | .scan = ieee80211_scan, |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 3996 | .sched_scan_start = ieee80211_sched_scan_start, |
| 3997 | .sched_scan_stop = ieee80211_sched_scan_stop, |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 3998 | .auth = ieee80211_auth, |
| 3999 | .assoc = ieee80211_assoc, |
| 4000 | .deauth = ieee80211_deauth, |
| 4001 | .disassoc = ieee80211_disassoc, |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 4002 | .join_ibss = ieee80211_join_ibss, |
| 4003 | .leave_ibss = ieee80211_leave_ibss, |
Antonio Quartulli | 391e53e | 2012-11-02 13:27:49 +0100 | [diff] [blame] | 4004 | .set_mcast_rate = ieee80211_set_mcast_rate, |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 4005 | .set_wiphy_params = ieee80211_set_wiphy_params, |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 4006 | .set_tx_power = ieee80211_set_tx_power, |
| 4007 | .get_tx_power = ieee80211_get_tx_power, |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 4008 | .set_wds_peer = ieee80211_set_wds_peer, |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 4009 | .rfkill_poll = ieee80211_rfkill_poll, |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 4010 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) |
Wey-Yi Guy | 71063f0 | 2011-05-20 09:05:54 -0700 | [diff] [blame] | 4011 | CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 4012 | .set_power_mgmt = ieee80211_set_power_mgmt, |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 4013 | .set_bitrate_mask = ieee80211_set_bitrate_mask, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 4014 | .remain_on_channel = ieee80211_remain_on_channel, |
| 4015 | .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, |
Johannes Berg | 2e161f78 | 2010-08-12 15:38:38 +0200 | [diff] [blame] | 4016 | .mgmt_tx = ieee80211_mgmt_tx, |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 4017 | .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait, |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 4018 | .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config, |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 4019 | .mgmt_frame_register = ieee80211_mgmt_frame_register, |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 4020 | .set_antenna = ieee80211_set_antenna, |
| 4021 | .get_antenna = ieee80211_get_antenna, |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 4022 | .set_ringparam = ieee80211_set_ringparam, |
| 4023 | .get_ringparam = ieee80211_get_ringparam, |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 4024 | .set_rekey_data = ieee80211_set_rekey_data, |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 4025 | .tdls_oper = ieee80211_tdls_oper, |
| 4026 | .tdls_mgmt = ieee80211_tdls_mgmt, |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 4027 | .probe_client = ieee80211_probe_client, |
Simon Wunderlich | b53be79 | 2011-11-18 14:20:44 +0100 | [diff] [blame] | 4028 | .set_noack_map = ieee80211_set_noack_map, |
Johannes Berg | 6d52563 | 2012-04-04 15:05:25 +0200 | [diff] [blame] | 4029 | #ifdef CONFIG_PM |
| 4030 | .set_wakeup = ieee80211_set_wakeup, |
| 4031 | #endif |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 4032 | .get_et_sset_count = ieee80211_get_et_sset_count, |
| 4033 | .get_et_stats = ieee80211_get_et_stats, |
| 4034 | .get_et_strings = ieee80211_get_et_strings, |
Johannes Berg | 5b7ccaf | 2012-07-12 19:45:08 +0200 | [diff] [blame] | 4035 | .get_channel = ieee80211_cfg_get_channel, |
Simon Wunderlich | 164eb02 | 2013-02-08 18:16:20 +0100 | [diff] [blame] | 4036 | .start_radar_detection = ieee80211_start_radar_detection, |
Simon Wunderlich | 73da7d5 | 2013-07-11 16:09:06 +0200 | [diff] [blame] | 4037 | .channel_switch = ieee80211_channel_switch, |
Kyeyoon Park | 32db6b5 | 2013-12-16 23:04:43 -0800 | [diff] [blame] | 4038 | .set_qos_map = ieee80211_set_qos_map, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 4039 | }; |