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