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