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