blob: 43dd7525bfcba54c02dbd9dde2bd89cfc2d29c97 [file] [log] [blame]
Jiri Bencf0706e82007-05-05 11:45:53 -07001/*
2 * mac80211 configuration hooks for cfg80211
3 *
Jouni Malinen026331c2010-02-15 12:53:10 +02004 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
Jiri Bencf0706e82007-05-05 11:45:53 -07005 *
6 * This file is GPLv2 as found in COPYING.
7 */
8
Johannes Berge8cbb4c2007-12-19 02:03:30 +01009#include <linux/ieee80211.h>
Jiri Bencf0706e82007-05-05 11:45:53 -070010#include <linux/nl80211.h>
11#include <linux/rtnetlink.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090012#include <linux/slab.h>
Eric W. Biederman881d9662007-09-17 11:56:21 -070013#include <net/net_namespace.h>
Johannes Berg5dfdaf52007-12-19 02:03:33 +010014#include <linux/rcupdate.h>
Arik Nemtsovdfe018b2011-09-28 14:12:52 +030015#include <linux/if_ether.h>
Jiri Bencf0706e82007-05-05 11:45:53 -070016#include <net/cfg80211.h>
17#include "ieee80211_i.h"
Johannes Berg24487982009-04-23 18:52:52 +020018#include "driver-ops.h"
Michael Wue0eb6852007-09-18 17:29:21 -040019#include "cfg.h"
Johannes Berg2c8dccc2008-04-08 15:14:40 -040020#include "rate.h"
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +010021#include "mesh.h"
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +010022
Johannes Berg552bff02012-09-19 09:26:06 +020023static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
24 const char *name,
Johannes Berg84efbb82012-06-16 00:00:26 +020025 enum nl80211_iftype type,
26 u32 *flags,
27 struct vif_params *params)
Jiri Bencf0706e82007-05-05 11:45:53 -070028{
29 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg84efbb82012-06-16 00:00:26 +020030 struct wireless_dev *wdev;
Michael Wu8cc9a732008-01-31 19:48:23 +010031 struct ieee80211_sub_if_data *sdata;
32 int err;
Jiri Bencf0706e82007-05-05 11:45:53 -070033
Johannes Berg84efbb82012-06-16 00:00:26 +020034 err = ieee80211_if_add(local, name, &wdev, type, params);
Johannes Bergf9e10ce2010-12-03 09:20:42 +010035 if (err)
36 return ERR_PTR(err);
Michael Wu8cc9a732008-01-31 19:48:23 +010037
Johannes Bergf9e10ce2010-12-03 09:20:42 +010038 if (type == NL80211_IFTYPE_MONITOR && flags) {
Johannes Berg84efbb82012-06-16 00:00:26 +020039 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
Johannes Bergf9e10ce2010-12-03 09:20:42 +010040 sdata->u.mntr_flags = *flags;
41 }
42
Johannes Berg84efbb82012-06-16 00:00:26 +020043 return wdev;
Jiri Bencf0706e82007-05-05 11:45:53 -070044}
45
Johannes Berg84efbb82012-06-16 00:00:26 +020046static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
Jiri Bencf0706e82007-05-05 11:45:53 -070047{
Johannes Berg84efbb82012-06-16 00:00:26 +020048 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
Jiri Bencf0706e82007-05-05 11:45:53 -070049
Johannes Berg75636522008-07-09 14:40:35 +020050 return 0;
Jiri Bencf0706e82007-05-05 11:45:53 -070051}
52
Johannes Berge36d56b2009-06-09 21:04:43 +020053static int ieee80211_change_iface(struct wiphy *wiphy,
54 struct net_device *dev,
Luis Carlos Cobo2ec600d2008-02-23 15:17:06 +010055 enum nl80211_iftype type, u32 *flags,
56 struct vif_params *params)
Johannes Berg42613db2007-09-28 21:52:27 +020057{
Johannes Berg9607e6b2009-12-23 13:15:31 +010058 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Bergf3947e22008-07-09 14:40:36 +020059 int ret;
Johannes Berg42613db2007-09-28 21:52:27 +020060
Johannes Berg05c914f2008-09-11 00:01:58 +020061 ret = ieee80211_if_change_type(sdata, type);
Johannes Bergf3947e22008-07-09 14:40:36 +020062 if (ret)
63 return ret;
Johannes Berg42613db2007-09-28 21:52:27 +020064
Johannes Berg9bc383d2009-11-19 11:55:19 +010065 if (type == NL80211_IFTYPE_AP_VLAN &&
66 params && params->use_4addr == 0)
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +000067 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
Johannes Berg9bc383d2009-11-19 11:55:19 +010068 else if (type == NL80211_IFTYPE_STATION &&
69 params && params->use_4addr >= 0)
70 sdata->u.mgd.use_4addr = params->use_4addr;
71
Christian Lamparter85416a42010-10-02 13:17:07 +020072 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
73 struct ieee80211_local *local = sdata->local;
74
75 if (ieee80211_sdata_running(sdata)) {
Felix Fietkau31eba5b2013-05-28 13:01:53 +020076 u32 mask = MONITOR_FLAG_COOK_FRAMES |
77 MONITOR_FLAG_ACTIVE;
78
Christian Lamparter85416a42010-10-02 13:17:07 +020079 /*
Felix Fietkau31eba5b2013-05-28 13:01:53 +020080 * Prohibit MONITOR_FLAG_COOK_FRAMES and
81 * MONITOR_FLAG_ACTIVE to be changed while the
82 * interface is up.
Christian Lamparter85416a42010-10-02 13:17:07 +020083 * Else we would need to add a lot of cruft
84 * to update everything:
85 * cooked_mntrs, monitor and all fif_* counters
86 * reconfigure hardware
87 */
Felix Fietkau31eba5b2013-05-28 13:01:53 +020088 if ((*flags & mask) != (sdata->u.mntr_flags & mask))
Christian Lamparter85416a42010-10-02 13:17:07 +020089 return -EBUSY;
90
91 ieee80211_adjust_monitor_flags(sdata, -1);
92 sdata->u.mntr_flags = *flags;
93 ieee80211_adjust_monitor_flags(sdata, 1);
94
95 ieee80211_configure_filter(local);
96 } else {
97 /*
98 * Because the interface is down, ieee80211_do_stop
99 * and ieee80211_do_open take care of "everything"
100 * mentioned in the comment above.
101 */
102 sdata->u.mntr_flags = *flags;
103 }
104 }
Felix Fietkauf7917af2010-04-27 00:26:34 +0200105
Johannes Berg42613db2007-09-28 21:52:27 +0200106 return 0;
107}
108
Johannes Bergf142c6b2012-06-18 20:07:15 +0200109static int ieee80211_start_p2p_device(struct wiphy *wiphy,
110 struct wireless_dev *wdev)
111{
112 return ieee80211_do_open(wdev, true);
113}
114
115static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
116 struct wireless_dev *wdev)
117{
118 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
119}
120
Simon Wunderlichb53be792011-11-18 14:20:44 +0100121static int ieee80211_set_noack_map(struct wiphy *wiphy,
122 struct net_device *dev,
123 u16 noack_map)
124{
125 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
126
127 sdata->noack_map = noack_map;
128 return 0;
129}
130
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100131static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200132 u8 key_idx, bool pairwise, const u8 *mac_addr,
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100133 struct key_params *params)
134{
Johannes Berg26a58452010-08-27 12:35:55 +0200135 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100136 struct sta_info *sta = NULL;
Johannes Bergdb4d1162008-02-25 16:27:45 +0100137 struct ieee80211_key *key;
Johannes Berg3b967662008-04-08 17:56:52 +0200138 int err;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100139
Johannes Berg26a58452010-08-27 12:35:55 +0200140 if (!ieee80211_sdata_running(sdata))
Johannes Bergad0e2b52010-06-01 10:19:19 +0200141 return -ENETDOWN;
142
Johannes Berg97359d12010-08-10 09:46:38 +0200143 /* reject WEP and TKIP keys if WEP failed to initialize */
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100144 switch (params->cipher) {
145 case WLAN_CIPHER_SUITE_WEP40:
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100146 case WLAN_CIPHER_SUITE_TKIP:
Johannes Berg97359d12010-08-10 09:46:38 +0200147 case WLAN_CIPHER_SUITE_WEP104:
148 if (IS_ERR(sdata->local->wep_tx_tfm))
149 return -EINVAL;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200150 break;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100151 default:
Johannes Berg97359d12010-08-10 09:46:38 +0200152 break;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100153 }
154
Johannes Berg97359d12010-08-10 09:46:38 +0200155 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
156 params->key, params->seq_len, params->seq);
Ben Hutchings1ac62ba2010-08-01 17:37:03 +0100157 if (IS_ERR(key))
158 return PTR_ERR(key);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100159
Johannes Berge31b8212010-10-05 19:39:30 +0200160 if (pairwise)
161 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
162
Johannes Bergad0e2b52010-06-01 10:19:19 +0200163 mutex_lock(&sdata->local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200164
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100165 if (mac_addr) {
Thomas Pedersenff973af2011-05-03 16:57:12 -0700166 if (ieee80211_vif_is_mesh(&sdata->vif))
167 sta = sta_info_get(sdata, mac_addr);
168 else
169 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Berg1626e0f2013-01-11 14:34:25 +0100170 /*
171 * The ASSOC test makes sure the driver is ready to
172 * receive the key. When wpa_supplicant has roamed
173 * using FT, it attempts to set the key before
174 * association has completed, this rejects that attempt
175 * so it will set the key again after assocation.
176 *
177 * TODO: accept the key if we have a station entry and
178 * add it to the device after the station.
179 */
180 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
Johannes Berg79cf2df2013-03-06 22:53:52 +0100181 ieee80211_key_free_unused(key);
Johannes Berg3b967662008-04-08 17:56:52 +0200182 err = -ENOENT;
183 goto out_unlock;
Johannes Bergdb4d1162008-02-25 16:27:45 +0100184 }
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100185 }
186
Johannes Berge548c492012-09-04 17:08:23 +0200187 switch (sdata->vif.type) {
188 case NL80211_IFTYPE_STATION:
189 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
190 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
191 break;
192 case NL80211_IFTYPE_AP:
193 case NL80211_IFTYPE_AP_VLAN:
194 /* Keys without a station are used for TX only */
195 if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP))
196 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
197 break;
198 case NL80211_IFTYPE_ADHOC:
199 /* no MFP (yet) */
200 break;
201 case NL80211_IFTYPE_MESH_POINT:
202#ifdef CONFIG_MAC80211_MESH
203 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
204 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
205 break;
206#endif
207 case NL80211_IFTYPE_WDS:
208 case NL80211_IFTYPE_MONITOR:
209 case NL80211_IFTYPE_P2P_DEVICE:
210 case NL80211_IFTYPE_UNSPECIFIED:
211 case NUM_NL80211_IFTYPES:
212 case NL80211_IFTYPE_P2P_CLIENT:
213 case NL80211_IFTYPE_P2P_GO:
214 /* shouldn't happen */
215 WARN_ON_ONCE(1);
216 break;
217 }
218
Johannes Berg3ffc2a92010-08-27 14:26:52 +0300219 err = ieee80211_key_link(key, sdata, sta);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100220
Johannes Berg3b967662008-04-08 17:56:52 +0200221 out_unlock:
Johannes Bergad0e2b52010-06-01 10:19:19 +0200222 mutex_unlock(&sdata->local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200223
224 return err;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100225}
226
227static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200228 u8 key_idx, bool pairwise, const u8 *mac_addr)
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100229{
Johannes Berg5c0c3642011-05-12 14:31:49 +0200230 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
231 struct ieee80211_local *local = sdata->local;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100232 struct sta_info *sta;
Johannes Berg5c0c3642011-05-12 14:31:49 +0200233 struct ieee80211_key *key = NULL;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100234 int ret;
235
Johannes Berg5c0c3642011-05-12 14:31:49 +0200236 mutex_lock(&local->sta_mtx);
237 mutex_lock(&local->key_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200238
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100239 if (mac_addr) {
Johannes Berg3b967662008-04-08 17:56:52 +0200240 ret = -ENOENT;
241
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100242 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100243 if (!sta)
Johannes Berg3b967662008-04-08 17:56:52 +0200244 goto out_unlock;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100245
Johannes Berg5c0c3642011-05-12 14:31:49 +0200246 if (pairwise)
Johannes Berg40b275b2011-05-13 14:15:49 +0200247 key = key_mtx_dereference(local, sta->ptk);
Johannes Berg5c0c3642011-05-12 14:31:49 +0200248 else
Johannes Berg40b275b2011-05-13 14:15:49 +0200249 key = key_mtx_dereference(local, sta->gtk[key_idx]);
Johannes Berg5c0c3642011-05-12 14:31:49 +0200250 } else
Johannes Berg40b275b2011-05-13 14:15:49 +0200251 key = key_mtx_dereference(local, sdata->keys[key_idx]);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100252
Johannes Berg5c0c3642011-05-12 14:31:49 +0200253 if (!key) {
Johannes Berg3b967662008-04-08 17:56:52 +0200254 ret = -ENOENT;
255 goto out_unlock;
256 }
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100257
Johannes Berg3b8d9c22013-03-06 22:58:23 +0100258 ieee80211_key_free(key, true);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100259
Johannes Berg3b967662008-04-08 17:56:52 +0200260 ret = 0;
261 out_unlock:
Johannes Berg5c0c3642011-05-12 14:31:49 +0200262 mutex_unlock(&local->key_mtx);
263 mutex_unlock(&local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200264
265 return ret;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100266}
267
Johannes Berg62da92f2007-12-19 02:03:31 +0100268static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200269 u8 key_idx, bool pairwise, const u8 *mac_addr,
270 void *cookie,
Johannes Berg62da92f2007-12-19 02:03:31 +0100271 void (*callback)(void *cookie,
272 struct key_params *params))
273{
Johannes Berg14db74b2008-07-29 13:22:52 +0200274 struct ieee80211_sub_if_data *sdata;
Johannes Berg62da92f2007-12-19 02:03:31 +0100275 struct sta_info *sta = NULL;
276 u8 seq[6] = {0};
277 struct key_params params;
Johannes Berge31b8212010-10-05 19:39:30 +0200278 struct ieee80211_key *key = NULL;
Johannes Bergaba83a0b2011-07-06 21:59:39 +0200279 u64 pn64;
Johannes Berg62da92f2007-12-19 02:03:31 +0100280 u32 iv32;
281 u16 iv16;
282 int err = -ENOENT;
283
Johannes Berg14db74b2008-07-29 13:22:52 +0200284 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
285
Johannes Berg3b967662008-04-08 17:56:52 +0200286 rcu_read_lock();
287
Johannes Berg62da92f2007-12-19 02:03:31 +0100288 if (mac_addr) {
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100289 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Berg62da92f2007-12-19 02:03:31 +0100290 if (!sta)
291 goto out;
292
Johannes Berge31b8212010-10-05 19:39:30 +0200293 if (pairwise)
Johannes Berga3836e02011-05-12 15:11:37 +0200294 key = rcu_dereference(sta->ptk);
Johannes Berge31b8212010-10-05 19:39:30 +0200295 else if (key_idx < NUM_DEFAULT_KEYS)
Johannes Berga3836e02011-05-12 15:11:37 +0200296 key = rcu_dereference(sta->gtk[key_idx]);
Johannes Berg62da92f2007-12-19 02:03:31 +0100297 } else
Johannes Berga3836e02011-05-12 15:11:37 +0200298 key = rcu_dereference(sdata->keys[key_idx]);
Johannes Berg62da92f2007-12-19 02:03:31 +0100299
300 if (!key)
301 goto out;
302
303 memset(&params, 0, sizeof(params));
304
Johannes Berg97359d12010-08-10 09:46:38 +0200305 params.cipher = key->conf.cipher;
Johannes Berg62da92f2007-12-19 02:03:31 +0100306
Johannes Berg97359d12010-08-10 09:46:38 +0200307 switch (key->conf.cipher) {
308 case WLAN_CIPHER_SUITE_TKIP:
Harvey Harrisonb0f76b32008-05-14 16:26:19 -0700309 iv32 = key->u.tkip.tx.iv32;
310 iv16 = key->u.tkip.tx.iv16;
Johannes Berg62da92f2007-12-19 02:03:31 +0100311
Johannes Berg24487982009-04-23 18:52:52 +0200312 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
313 drv_get_tkip_seq(sdata->local,
314 key->conf.hw_key_idx,
315 &iv32, &iv16);
Johannes Berg62da92f2007-12-19 02:03:31 +0100316
317 seq[0] = iv16 & 0xff;
318 seq[1] = (iv16 >> 8) & 0xff;
319 seq[2] = iv32 & 0xff;
320 seq[3] = (iv32 >> 8) & 0xff;
321 seq[4] = (iv32 >> 16) & 0xff;
322 seq[5] = (iv32 >> 24) & 0xff;
323 params.seq = seq;
324 params.seq_len = 6;
325 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200326 case WLAN_CIPHER_SUITE_CCMP:
Johannes Bergaba83a0b2011-07-06 21:59:39 +0200327 pn64 = atomic64_read(&key->u.ccmp.tx_pn);
328 seq[0] = pn64;
329 seq[1] = pn64 >> 8;
330 seq[2] = pn64 >> 16;
331 seq[3] = pn64 >> 24;
332 seq[4] = pn64 >> 32;
333 seq[5] = pn64 >> 40;
Johannes Berg62da92f2007-12-19 02:03:31 +0100334 params.seq = seq;
335 params.seq_len = 6;
336 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200337 case WLAN_CIPHER_SUITE_AES_CMAC:
Johannes Berg75396ae2011-07-06 22:00:35 +0200338 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
339 seq[0] = pn64;
340 seq[1] = pn64 >> 8;
341 seq[2] = pn64 >> 16;
342 seq[3] = pn64 >> 24;
343 seq[4] = pn64 >> 32;
344 seq[5] = pn64 >> 40;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200345 params.seq = seq;
346 params.seq_len = 6;
347 break;
Johannes Berg62da92f2007-12-19 02:03:31 +0100348 }
349
350 params.key = key->conf.key;
351 params.key_len = key->conf.keylen;
352
353 callback(cookie, &params);
354 err = 0;
355
356 out:
Johannes Berg3b967662008-04-08 17:56:52 +0200357 rcu_read_unlock();
Johannes Berg62da92f2007-12-19 02:03:31 +0100358 return err;
359}
360
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100361static int ieee80211_config_default_key(struct wiphy *wiphy,
362 struct net_device *dev,
Johannes Bergdbd2fd62010-12-09 19:58:59 +0100363 u8 key_idx, bool uni,
364 bool multi)
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100365{
Johannes Bergad0e2b52010-06-01 10:19:19 +0200366 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100367
Johannes Bergf7e01042010-12-09 19:49:02 +0100368 ieee80211_set_default_key(sdata, key_idx, uni, multi);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100369
370 return 0;
371}
372
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200373static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
374 struct net_device *dev,
375 u8 key_idx)
376{
Johannes Berg66c52422010-07-22 13:58:51 +0200377 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200378
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200379 ieee80211_set_default_mgmt_key(sdata, key_idx);
380
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200381 return 0;
382}
383
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800384void sta_set_rate_info_tx(struct sta_info *sta,
385 const struct ieee80211_tx_rate *rate,
386 struct rate_info *rinfo)
387{
388 rinfo->flags = 0;
Johannes Berg8bc83c22012-11-09 18:38:32 +0100389 if (rate->flags & IEEE80211_TX_RC_MCS) {
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800390 rinfo->flags |= RATE_INFO_FLAGS_MCS;
Johannes Berg8bc83c22012-11-09 18:38:32 +0100391 rinfo->mcs = rate->idx;
392 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
393 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
394 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
395 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
396 } else {
397 struct ieee80211_supported_band *sband;
398 sband = sta->local->hw.wiphy->bands[
399 ieee80211_get_sdata_band(sta->sdata)];
400 rinfo->legacy = sband->bitrates[rate->idx].bitrate;
401 }
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800402 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
403 rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
Johannes Berg8bc83c22012-11-09 18:38:32 +0100404 if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
405 rinfo->flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
406 if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
407 rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH;
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800408 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
409 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800410}
411
Saravana003e6762012-11-28 18:29:38 +0530412void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
413{
414 rinfo->flags = 0;
415
416 if (sta->last_rx_rate_flag & RX_FLAG_HT) {
417 rinfo->flags |= RATE_INFO_FLAGS_MCS;
418 rinfo->mcs = sta->last_rx_rate_idx;
419 } else if (sta->last_rx_rate_flag & RX_FLAG_VHT) {
420 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
421 rinfo->nss = sta->last_rx_rate_vht_nss;
422 rinfo->mcs = sta->last_rx_rate_idx;
423 } else {
424 struct ieee80211_supported_band *sband;
425
426 sband = sta->local->hw.wiphy->bands[
427 ieee80211_get_sdata_band(sta->sdata)];
428 rinfo->legacy =
429 sband->bitrates[sta->last_rx_rate_idx].bitrate;
430 }
431
432 if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
433 rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
434 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
435 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
436 if (sta->last_rx_rate_flag & RX_FLAG_80MHZ)
437 rinfo->flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
438 if (sta->last_rx_rate_flag & RX_FLAG_80P80MHZ)
439 rinfo->flags |= RATE_INFO_FLAGS_80P80_MHZ_WIDTH;
440 if (sta->last_rx_rate_flag & RX_FLAG_160MHZ)
441 rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH;
442}
443
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100444static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
445{
Johannes Bergd0709a62008-02-25 16:27:46 +0100446 struct ieee80211_sub_if_data *sdata = sta->sdata;
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300447 struct ieee80211_local *local = sdata->local;
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530448 struct timespec uptime;
Johannes Berg560d2682013-02-05 10:55:21 +0100449 u64 packets = 0;
Felix Fietkauef0621e2013-04-22 16:29:31 +0200450 int i, ac;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100451
Johannes Bergf5ea9122009-08-07 16:17:38 +0200452 sinfo->generation = sdata->local->sta_generation;
453
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100454 sinfo->filled = STATION_INFO_INACTIVE_TIME |
Johannes Berg560d2682013-02-05 10:55:21 +0100455 STATION_INFO_RX_BYTES64 |
456 STATION_INFO_TX_BYTES64 |
Jouni Malinen98c8a60a2009-02-17 13:24:57 +0200457 STATION_INFO_RX_PACKETS |
458 STATION_INFO_TX_PACKETS |
Bruno Randolfb206b4e2010-10-06 18:34:12 +0900459 STATION_INFO_TX_RETRIES |
460 STATION_INFO_TX_FAILED |
Ben Greear5a5c7312010-10-07 16:39:20 -0700461 STATION_INFO_TX_BITRATE |
Felix Fietkau3af63342011-02-27 22:08:01 +0100462 STATION_INFO_RX_BITRATE |
Paul Stewartf4263c92011-03-31 09:25:41 -0700463 STATION_INFO_RX_DROP_MISC |
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530464 STATION_INFO_BSS_PARAM |
Helmut Schaa7a724762011-10-13 16:30:40 +0200465 STATION_INFO_CONNECTED_TIME |
Paul Stewarta85e1d52011-12-09 11:01:49 -0800466 STATION_INFO_STA_FLAGS |
467 STATION_INFO_BEACON_LOSS_COUNT;
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530468
469 do_posix_clock_monotonic_gettime(&uptime);
470 sinfo->connected_time = uptime.tv_sec - sta->last_connected;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100471
472 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
Johannes Berg560d2682013-02-05 10:55:21 +0100473 sinfo->tx_bytes = 0;
474 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
475 sinfo->tx_bytes += sta->tx_bytes[ac];
476 packets += sta->tx_packets[ac];
477 }
478 sinfo->tx_packets = packets;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100479 sinfo->rx_bytes = sta->rx_bytes;
Jouni Malinen98c8a60a2009-02-17 13:24:57 +0200480 sinfo->rx_packets = sta->rx_packets;
Bruno Randolfb206b4e2010-10-06 18:34:12 +0900481 sinfo->tx_retries = sta->tx_retry_count;
482 sinfo->tx_failed = sta->tx_retry_failed;
Ben Greear5a5c7312010-10-07 16:39:20 -0700483 sinfo->rx_dropped_misc = sta->rx_dropped;
Paul Stewarta85e1d52011-12-09 11:01:49 -0800484 sinfo->beacon_loss_count = sta->beacon_loss_count;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100485
John W. Linville19deffb2009-12-08 17:10:13 -0500486 if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
487 (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
Bruno Randolf541a45a2010-12-02 19:12:43 +0900488 sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300489 if (!local->ops->get_rssi ||
490 drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal))
491 sinfo->signal = (s8)sta->last_signal;
Bruno Randolf541a45a2010-12-02 19:12:43 +0900492 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100493 }
Felix Fietkauef0621e2013-04-22 16:29:31 +0200494 if (sta->chains) {
495 sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
496 STATION_INFO_CHAIN_SIGNAL_AVG;
497
498 sinfo->chains = sta->chains;
499 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
500 sinfo->chain_signal[i] = sta->chain_signal_last[i];
501 sinfo->chain_signal_avg[i] =
502 (s8) -ewma_read(&sta->chain_signal_avg[i]);
503 }
504 }
Henning Rogge420e7fa2008-12-11 22:04:19 +0100505
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800506 sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
Saravana003e6762012-11-28 18:29:38 +0530507 sta_set_rate_info_rx(sta, &sinfo->rxrate);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100508
Johannes Berg902acc72008-02-23 15:17:19 +0100509 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100510#ifdef CONFIG_MAC80211_MESH
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100511 sinfo->filled |= STATION_INFO_LLID |
512 STATION_INFO_PLID |
Marco Porsch3f52b7e2013-01-30 18:14:08 +0100513 STATION_INFO_PLINK_STATE |
514 STATION_INFO_LOCAL_PM |
515 STATION_INFO_PEER_PM |
516 STATION_INFO_NONPEER_PM;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100517
518 sinfo->llid = le16_to_cpu(sta->llid);
519 sinfo->plid = le16_to_cpu(sta->plid);
520 sinfo->plink_state = sta->plink_state;
Javier Cardonad299a1f2012-03-31 11:31:33 -0700521 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
522 sinfo->filled |= STATION_INFO_T_OFFSET;
523 sinfo->t_offset = sta->t_offset;
524 }
Marco Porsch3f52b7e2013-01-30 18:14:08 +0100525 sinfo->local_pm = sta->local_pm;
526 sinfo->peer_pm = sta->peer_pm;
527 sinfo->nonpeer_pm = sta->nonpeer_pm;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100528#endif
Johannes Berg902acc72008-02-23 15:17:19 +0100529 }
Paul Stewartf4263c92011-03-31 09:25:41 -0700530
531 sinfo->bss_param.flags = 0;
532 if (sdata->vif.bss_conf.use_cts_prot)
533 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
534 if (sdata->vif.bss_conf.use_short_preamble)
535 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
536 if (sdata->vif.bss_conf.use_short_slot)
537 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
538 sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
539 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
Helmut Schaa7a724762011-10-13 16:30:40 +0200540
541 sinfo->sta_flags.set = 0;
542 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
543 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
544 BIT(NL80211_STA_FLAG_WME) |
545 BIT(NL80211_STA_FLAG_MFP) |
Helmut Schaae4121562011-11-05 14:15:24 +0100546 BIT(NL80211_STA_FLAG_AUTHENTICATED) |
Johannes Bergd582cff2012-10-26 17:53:44 +0200547 BIT(NL80211_STA_FLAG_ASSOCIATED) |
Helmut Schaae4121562011-11-05 14:15:24 +0100548 BIT(NL80211_STA_FLAG_TDLS_PEER);
Helmut Schaa7a724762011-10-13 16:30:40 +0200549 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
550 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
551 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
552 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
553 if (test_sta_flag(sta, WLAN_STA_WME))
554 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
555 if (test_sta_flag(sta, WLAN_STA_MFP))
556 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
557 if (test_sta_flag(sta, WLAN_STA_AUTH))
558 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
Johannes Bergd582cff2012-10-26 17:53:44 +0200559 if (test_sta_flag(sta, WLAN_STA_ASSOC))
560 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
Helmut Schaae4121562011-11-05 14:15:24 +0100561 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
562 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100563}
564
Ben Greearb1ab7922012-04-23 12:50:30 -0700565static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
566 "rx_packets", "rx_bytes", "wep_weak_iv_count",
567 "rx_duplicates", "rx_fragments", "rx_dropped",
568 "tx_packets", "tx_bytes", "tx_fragments",
569 "tx_filtered", "tx_retry_failed", "tx_retries",
Ben Greear3073a7c2012-04-23 12:50:32 -0700570 "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
571 "channel", "noise", "ch_time", "ch_time_busy",
572 "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
Ben Greearb1ab7922012-04-23 12:50:30 -0700573};
574#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
575
576static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
577 struct net_device *dev,
578 int sset)
579{
Ben Greeare3521142012-04-23 12:50:31 -0700580 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
581 int rv = 0;
Ben Greearb1ab7922012-04-23 12:50:30 -0700582
Ben Greeare3521142012-04-23 12:50:31 -0700583 if (sset == ETH_SS_STATS)
584 rv += STA_STATS_LEN;
585
586 rv += drv_get_et_sset_count(sdata, sset);
587
588 if (rv == 0)
589 return -EOPNOTSUPP;
590 return rv;
Ben Greearb1ab7922012-04-23 12:50:30 -0700591}
592
593static void ieee80211_get_et_stats(struct wiphy *wiphy,
594 struct net_device *dev,
595 struct ethtool_stats *stats,
596 u64 *data)
597{
598 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg55de9082012-07-26 17:24:39 +0200599 struct ieee80211_chanctx_conf *chanctx_conf;
600 struct ieee80211_channel *channel;
Ben Greearb1ab7922012-04-23 12:50:30 -0700601 struct sta_info *sta;
602 struct ieee80211_local *local = sdata->local;
Ben Greear3073a7c2012-04-23 12:50:32 -0700603 struct station_info sinfo;
604 struct survey_info survey;
605 int i, q;
606#define STA_STATS_SURVEY_LEN 7
Ben Greearb1ab7922012-04-23 12:50:30 -0700607
608 memset(data, 0, sizeof(u64) * STA_STATS_LEN);
609
610#define ADD_STA_STATS(sta) \
611 do { \
612 data[i++] += sta->rx_packets; \
613 data[i++] += sta->rx_bytes; \
614 data[i++] += sta->wep_weak_iv_count; \
615 data[i++] += sta->num_duplicates; \
616 data[i++] += sta->rx_fragments; \
617 data[i++] += sta->rx_dropped; \
618 \
Johannes Berg560d2682013-02-05 10:55:21 +0100619 data[i++] += sinfo.tx_packets; \
620 data[i++] += sinfo.tx_bytes; \
Ben Greearb1ab7922012-04-23 12:50:30 -0700621 data[i++] += sta->tx_fragments; \
622 data[i++] += sta->tx_filtered_count; \
623 data[i++] += sta->tx_retry_failed; \
624 data[i++] += sta->tx_retry_count; \
625 data[i++] += sta->beacon_loss_count; \
626 } while (0)
627
628 /* For Managed stations, find the single station based on BSSID
629 * and use that. For interface types, iterate through all available
630 * stations and add stats for any station that is assigned to this
631 * network device.
632 */
633
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300634 mutex_lock(&local->sta_mtx);
Ben Greearb1ab7922012-04-23 12:50:30 -0700635
636 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
637 sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
Ben Greear3073a7c2012-04-23 12:50:32 -0700638
639 if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
640 goto do_survey;
641
Johannes Berg560d2682013-02-05 10:55:21 +0100642 sinfo.filled = 0;
643 sta_set_sinfo(sta, &sinfo);
644
Ben Greear3073a7c2012-04-23 12:50:32 -0700645 i = 0;
646 ADD_STA_STATS(sta);
647
648 data[i++] = sta->sta_state;
649
Ben Greear3073a7c2012-04-23 12:50:32 -0700650
Joe Perches52042672012-05-30 13:25:54 -0700651 if (sinfo.filled & STATION_INFO_TX_BITRATE)
Ben Greear3073a7c2012-04-23 12:50:32 -0700652 data[i] = 100000 *
653 cfg80211_calculate_bitrate(&sinfo.txrate);
654 i++;
Joe Perches52042672012-05-30 13:25:54 -0700655 if (sinfo.filled & STATION_INFO_RX_BITRATE)
Ben Greear3073a7c2012-04-23 12:50:32 -0700656 data[i] = 100000 *
657 cfg80211_calculate_bitrate(&sinfo.rxrate);
658 i++;
659
Joe Perches52042672012-05-30 13:25:54 -0700660 if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
Ben Greear3073a7c2012-04-23 12:50:32 -0700661 data[i] = (u8)sinfo.signal_avg;
662 i++;
Ben Greearb1ab7922012-04-23 12:50:30 -0700663 } else {
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300664 list_for_each_entry(sta, &local->sta_list, list) {
Ben Greearb1ab7922012-04-23 12:50:30 -0700665 /* Make sure this station belongs to the proper dev */
666 if (sta->sdata->dev != dev)
667 continue;
668
Johannes Berge13bae42013-07-08 10:43:31 +0200669 sinfo.filled = 0;
670 sta_set_sinfo(sta, &sinfo);
Ben Greearb1ab7922012-04-23 12:50:30 -0700671 i = 0;
672 ADD_STA_STATS(sta);
Ben Greearb1ab7922012-04-23 12:50:30 -0700673 }
674 }
675
Ben Greear3073a7c2012-04-23 12:50:32 -0700676do_survey:
677 i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
678 /* Get survey stats for current channel */
Johannes Berg55de9082012-07-26 17:24:39 +0200679 survey.filled = 0;
Ben Greear3073a7c2012-04-23 12:50:32 -0700680
Johannes Berg55de9082012-07-26 17:24:39 +0200681 rcu_read_lock();
682 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
683 if (chanctx_conf)
Johannes Berg4bf88532012-11-09 11:39:59 +0100684 channel = chanctx_conf->def.chan;
Johannes Berg55de9082012-07-26 17:24:39 +0200685 else
686 channel = NULL;
687 rcu_read_unlock();
688
689 if (channel) {
690 q = 0;
691 do {
692 survey.filled = 0;
693 if (drv_get_survey(local, q, &survey) != 0) {
694 survey.filled = 0;
695 break;
696 }
697 q++;
698 } while (channel != survey.channel);
Ben Greear3073a7c2012-04-23 12:50:32 -0700699 }
700
701 if (survey.filled)
702 data[i++] = survey.channel->center_freq;
703 else
704 data[i++] = 0;
705 if (survey.filled & SURVEY_INFO_NOISE_DBM)
706 data[i++] = (u8)survey.noise;
707 else
708 data[i++] = -1LL;
709 if (survey.filled & SURVEY_INFO_CHANNEL_TIME)
710 data[i++] = survey.channel_time;
711 else
712 data[i++] = -1LL;
713 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY)
714 data[i++] = survey.channel_time_busy;
715 else
716 data[i++] = -1LL;
717 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY)
718 data[i++] = survey.channel_time_ext_busy;
719 else
720 data[i++] = -1LL;
721 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX)
722 data[i++] = survey.channel_time_rx;
723 else
724 data[i++] = -1LL;
725 if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX)
726 data[i++] = survey.channel_time_tx;
727 else
728 data[i++] = -1LL;
729
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300730 mutex_unlock(&local->sta_mtx);
Ben Greeare3521142012-04-23 12:50:31 -0700731
Ben Greear3073a7c2012-04-23 12:50:32 -0700732 if (WARN_ON(i != STA_STATS_LEN))
733 return;
734
Ben Greeare3521142012-04-23 12:50:31 -0700735 drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
Ben Greearb1ab7922012-04-23 12:50:30 -0700736}
737
738static void ieee80211_get_et_strings(struct wiphy *wiphy,
739 struct net_device *dev,
740 u32 sset, u8 *data)
741{
Ben Greeare3521142012-04-23 12:50:31 -0700742 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
743 int sz_sta_stats = 0;
744
Ben Greearb1ab7922012-04-23 12:50:30 -0700745 if (sset == ETH_SS_STATS) {
Ben Greeare3521142012-04-23 12:50:31 -0700746 sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
Johannes Bergbd500af2013-05-06 21:09:46 +0200747 memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats);
Ben Greearb1ab7922012-04-23 12:50:30 -0700748 }
Ben Greeare3521142012-04-23 12:50:31 -0700749 drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
Ben Greearb1ab7922012-04-23 12:50:30 -0700750}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100751
752static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
753 int idx, u8 *mac, struct station_info *sinfo)
754{
Johannes Berg3b53fde82009-11-16 12:00:37 +0100755 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300756 struct ieee80211_local *local = sdata->local;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100757 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100758 int ret = -ENOENT;
759
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300760 mutex_lock(&local->sta_mtx);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100761
Johannes Berg3b53fde82009-11-16 12:00:37 +0100762 sta = sta_info_get_by_idx(sdata, idx);
Johannes Bergd0709a62008-02-25 16:27:46 +0100763 if (sta) {
764 ret = 0;
Johannes Berg17741cd2008-09-11 00:02:02 +0200765 memcpy(mac, sta->sta.addr, ETH_ALEN);
Johannes Bergd0709a62008-02-25 16:27:46 +0100766 sta_set_sinfo(sta, sinfo);
767 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100768
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300769 mutex_unlock(&local->sta_mtx);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100770
Johannes Bergd0709a62008-02-25 16:27:46 +0100771 return ret;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100772}
773
Holger Schurig12897232010-04-19 10:23:57 +0200774static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
775 int idx, struct survey_info *survey)
776{
777 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
778
Holger Schurig12897232010-04-19 10:23:57 +0200779 return drv_get_survey(local, idx, survey);
780}
781
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100782static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Luis Carlos Cobo2ec600d2008-02-23 15:17:06 +0100783 u8 *mac, struct station_info *sinfo)
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100784{
Johannes Bergabe60632009-11-25 17:46:18 +0100785 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300786 struct ieee80211_local *local = sdata->local;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100787 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100788 int ret = -ENOENT;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100789
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300790 mutex_lock(&local->sta_mtx);
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100791
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100792 sta = sta_info_get_bss(sdata, mac);
Johannes Bergd0709a62008-02-25 16:27:46 +0100793 if (sta) {
794 ret = 0;
795 sta_set_sinfo(sta, sinfo);
796 }
797
Victor Goldenshtein66572cf2012-06-21 10:56:46 +0300798 mutex_unlock(&local->sta_mtx);
Johannes Bergd0709a62008-02-25 16:27:46 +0100799
800 return ret;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100801}
802
Johannes Berge8c9bd52012-06-06 08:18:22 +0200803static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
Johannes Berg683b6d32012-11-08 21:25:48 +0100804 struct cfg80211_chan_def *chandef)
Johannes Berge8c9bd52012-06-06 08:18:22 +0200805{
Johannes Berg55de9082012-07-26 17:24:39 +0200806 struct ieee80211_local *local = wiphy_priv(wiphy);
807 struct ieee80211_sub_if_data *sdata;
808 int ret = 0;
809
Johannes Berg4bf88532012-11-09 11:39:59 +0100810 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
Johannes Berg55de9082012-07-26 17:24:39 +0200811 return 0;
812
813 mutex_lock(&local->iflist_mtx);
814 if (local->use_chanctx) {
815 sdata = rcu_dereference_protected(
816 local->monitor_sdata,
817 lockdep_is_held(&local->iflist_mtx));
818 if (sdata) {
819 ieee80211_vif_release_channel(sdata);
Johannes Berg4bf88532012-11-09 11:39:59 +0100820 ret = ieee80211_vif_use_channel(sdata, chandef,
Johannes Berg55de9082012-07-26 17:24:39 +0200821 IEEE80211_CHANCTX_EXCLUSIVE);
822 }
823 } else if (local->open_count == local->monitors) {
Karl Beldan675a0b02013-03-25 16:26:57 +0100824 local->_oper_chandef = *chandef;
Johannes Berg55de9082012-07-26 17:24:39 +0200825 ieee80211_hw_config(local, 0);
826 }
827
Johannes Berg4bf88532012-11-09 11:39:59 +0100828 if (ret == 0)
829 local->monitor_chandef = *chandef;
Johannes Berg55de9082012-07-26 17:24:39 +0200830 mutex_unlock(&local->iflist_mtx);
831
832 return ret;
Johannes Berge8c9bd52012-06-06 08:18:22 +0200833}
834
Arik Nemtsov02945822011-11-10 11:28:57 +0200835static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
Johannes Berg88600202012-02-13 15:17:18 +0100836 const u8 *resp, size_t resp_len)
Arik Nemtsov02945822011-11-10 11:28:57 +0200837{
Eyal Shapiraaa7a0082012-08-06 14:26:16 +0300838 struct probe_resp *new, *old;
Arik Nemtsov02945822011-11-10 11:28:57 +0200839
840 if (!resp || !resp_len)
Sujith Manoharanaba4e6f2012-08-22 14:21:07 +0530841 return 1;
Arik Nemtsov02945822011-11-10 11:28:57 +0200842
Arik Nemtsovf7248282011-11-19 10:51:26 +0200843 old = rtnl_dereference(sdata->u.ap.probe_resp);
Arik Nemtsov02945822011-11-10 11:28:57 +0200844
Eyal Shapiraaa7a0082012-08-06 14:26:16 +0300845 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
Arik Nemtsov02945822011-11-10 11:28:57 +0200846 if (!new)
847 return -ENOMEM;
848
Eyal Shapiraaa7a0082012-08-06 14:26:16 +0300849 new->len = resp_len;
850 memcpy(new->data, resp, resp_len);
Arik Nemtsov02945822011-11-10 11:28:57 +0200851
852 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
Eyal Shapiraaa7a0082012-08-06 14:26:16 +0300853 if (old)
854 kfree_rcu(old, rcu_head);
Arik Nemtsov02945822011-11-10 11:28:57 +0200855
856 return 0;
857}
858
Johannes Berg88600202012-02-13 15:17:18 +0100859static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
860 struct cfg80211_beacon_data *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100861{
862 struct beacon_data *new, *old;
863 int new_head_len, new_tail_len;
Johannes Berg88600202012-02-13 15:17:18 +0100864 int size, err;
865 u32 changed = BSS_CHANGED_BEACON;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100866
Johannes Berg40b275b2011-05-13 14:15:49 +0200867 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100868
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100869 /* Need to have a beacon head if we don't have one yet */
870 if (!params->head && !old)
Johannes Berg88600202012-02-13 15:17:18 +0100871 return -EINVAL;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100872
873 /* new or old head? */
874 if (params->head)
875 new_head_len = params->head_len;
876 else
877 new_head_len = old->head_len;
878
879 /* new or old tail? */
880 if (params->tail || !old)
881 /* params->tail_len will be zero for !params->tail */
882 new_tail_len = params->tail_len;
883 else
884 new_tail_len = old->tail_len;
885
886 size = sizeof(*new) + new_head_len + new_tail_len;
887
888 new = kzalloc(size, GFP_KERNEL);
889 if (!new)
890 return -ENOMEM;
891
892 /* start filling the new info now */
893
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100894 /*
895 * pointers go into the block we allocated,
896 * memory is | beacon_data | head | tail |
897 */
898 new->head = ((u8 *) new) + sizeof(*new);
899 new->tail = new->head + new_head_len;
900 new->head_len = new_head_len;
901 new->tail_len = new_tail_len;
902
903 /* copy in head */
904 if (params->head)
905 memcpy(new->head, params->head, new_head_len);
906 else
907 memcpy(new->head, old->head, new_head_len);
908
909 /* copy in optional tail */
910 if (params->tail)
911 memcpy(new->tail, params->tail, new_tail_len);
912 else
913 if (old)
914 memcpy(new->tail, old->tail, new_tail_len);
915
Johannes Berg88600202012-02-13 15:17:18 +0100916 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
917 params->probe_resp_len);
918 if (err < 0)
919 return err;
920 if (err == 0)
921 changed |= BSS_CHANGED_AP_PROBE_RESP;
Johannes Berg19885c42010-02-05 11:45:06 +0100922
Eric Dumazetcf778b02012-01-12 04:41:32 +0000923 rcu_assign_pointer(sdata->u.ap.beacon, new);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100924
Johannes Berg88600202012-02-13 15:17:18 +0100925 if (old)
926 kfree_rcu(old, rcu_head);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100927
Johannes Berg88600202012-02-13 15:17:18 +0100928 return changed;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100929}
930
Johannes Berg88600202012-02-13 15:17:18 +0100931static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
932 struct cfg80211_ap_settings *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100933{
Johannes Berg88600202012-02-13 15:17:18 +0100934 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100935 struct beacon_data *old;
Johannes Berg665c93a2011-11-04 11:18:11 +0100936 struct ieee80211_sub_if_data *vlan;
Johannes Berg88600202012-02-13 15:17:18 +0100937 u32 changed = BSS_CHANGED_BEACON_INT |
938 BSS_CHANGED_BEACON_ENABLED |
939 BSS_CHANGED_BEACON |
Johannes Berg339afbf2012-11-14 15:21:17 +0100940 BSS_CHANGED_SSID |
941 BSS_CHANGED_P2P_PS;
Johannes Berg88600202012-02-13 15:17:18 +0100942 int err;
Johannes Berg14db74b2008-07-29 13:22:52 +0200943
Johannes Berg40b275b2011-05-13 14:15:49 +0200944 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100945 if (old)
946 return -EALREADY;
947
Johannes Berg04ecd252012-09-11 14:34:12 +0200948 /* TODO: make hostapd tell us what it wants */
949 sdata->smps_mode = IEEE80211_SMPS_OFF;
950 sdata->needed_rx_chains = sdata->local->rx_chains;
Simon Wunderlich164eb022013-02-08 18:16:20 +0100951 sdata->radar_required = params->radar_required;
Johannes Berg04ecd252012-09-11 14:34:12 +0200952
Johannes Berg4bf88532012-11-09 11:39:59 +0100953 err = ieee80211_vif_use_channel(sdata, &params->chandef,
Johannes Berg55de9082012-07-26 17:24:39 +0200954 IEEE80211_CHANCTX_SHARED);
Johannes Bergaa430da2012-05-16 23:50:18 +0200955 if (err)
956 return err;
Johannes Berg1f4ac5a2013-02-08 12:07:44 +0100957 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
Johannes Bergaa430da2012-05-16 23:50:18 +0200958
Johannes Berg665c93a2011-11-04 11:18:11 +0100959 /*
960 * Apply control port protocol, this allows us to
961 * not encrypt dynamic WEP control frames.
962 */
963 sdata->control_port_protocol = params->crypto.control_port_ethertype;
964 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
965 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
966 vlan->control_port_protocol =
967 params->crypto.control_port_ethertype;
968 vlan->control_port_no_encrypt =
969 params->crypto.control_port_no_encrypt;
970 }
971
Johannes Berg88600202012-02-13 15:17:18 +0100972 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
973 sdata->vif.bss_conf.dtim_period = params->dtim_period;
Johannes Bergd6a83222012-12-14 14:06:28 +0100974 sdata->vif.bss_conf.enable_beacon = true;
Johannes Berg88600202012-02-13 15:17:18 +0100975
976 sdata->vif.bss_conf.ssid_len = params->ssid_len;
977 if (params->ssid_len)
978 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
979 params->ssid_len);
980 sdata->vif.bss_conf.hidden_ssid =
981 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
982
Janusz Dziedzic67baf662013-03-21 15:47:56 +0100983 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
984 sizeof(sdata->vif.bss_conf.p2p_noa_attr));
985 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow =
986 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
987 if (params->p2p_opp_ps)
988 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
989 IEEE80211_P2P_OPPPS_ENABLE_BIT;
Johannes Berg339afbf2012-11-14 15:21:17 +0100990
Johannes Berg88600202012-02-13 15:17:18 +0100991 err = ieee80211_assign_beacon(sdata, &params->beacon);
992 if (err < 0)
993 return err;
994 changed |= err;
995
Johannes Berg10416382012-10-19 15:44:42 +0200996 err = drv_start_ap(sdata->local, sdata);
997 if (err) {
998 old = rtnl_dereference(sdata->u.ap.beacon);
999 if (old)
1000 kfree_rcu(old, rcu_head);
1001 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1002 return err;
1003 }
1004
Johannes Berg88600202012-02-13 15:17:18 +01001005 ieee80211_bss_info_change_notify(sdata, changed);
1006
Johannes Berg3edaf3e2012-04-03 10:24:00 +02001007 netif_carrier_on(dev);
1008 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1009 netif_carrier_on(vlan->dev);
1010
Johannes Berg665c93a2011-11-04 11:18:11 +01001011 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001012}
1013
Johannes Berg88600202012-02-13 15:17:18 +01001014static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1015 struct cfg80211_beacon_data *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001016{
Johannes Berg14db74b2008-07-29 13:22:52 +02001017 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001018 struct beacon_data *old;
Johannes Berg88600202012-02-13 15:17:18 +01001019 int err;
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001020
Johannes Berg14db74b2008-07-29 13:22:52 +02001021 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1022
Johannes Berg40b275b2011-05-13 14:15:49 +02001023 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001024 if (!old)
1025 return -ENOENT;
1026
Johannes Berg88600202012-02-13 15:17:18 +01001027 err = ieee80211_assign_beacon(sdata, params);
1028 if (err < 0)
1029 return err;
1030 ieee80211_bss_info_change_notify(sdata, err);
1031 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001032}
1033
Johannes Berg88600202012-02-13 15:17:18 +01001034static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001035{
Johannes Berg7b20b8e2012-10-25 19:02:42 +02001036 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1037 struct ieee80211_sub_if_data *vlan;
1038 struct ieee80211_local *local = sdata->local;
1039 struct beacon_data *old_beacon;
1040 struct probe_resp *old_probe_resp;
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001041
Johannes Berg7b20b8e2012-10-25 19:02:42 +02001042 old_beacon = rtnl_dereference(sdata->u.ap.beacon);
1043 if (!old_beacon)
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001044 return -ENOENT;
Johannes Berg7b20b8e2012-10-25 19:02:42 +02001045 old_probe_resp = rtnl_dereference(sdata->u.ap.probe_resp);
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001046
Johannes Berg7b20b8e2012-10-25 19:02:42 +02001047 /* turn off carrier for this interface and dependent VLANs */
Johannes Berg3edaf3e2012-04-03 10:24:00 +02001048 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1049 netif_carrier_off(vlan->dev);
1050 netif_carrier_off(dev);
1051
Johannes Berg7b20b8e2012-10-25 19:02:42 +02001052 /* remove beacon and probe response */
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +00001053 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
Johannes Berg7b20b8e2012-10-25 19:02:42 +02001054 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
1055 kfree_rcu(old_beacon, rcu_head);
1056 if (old_probe_resp)
1057 kfree_rcu(old_probe_resp, rcu_head);
Johannes Berg88600202012-02-13 15:17:18 +01001058
Felix Fietkau2d4072a2012-12-10 20:02:34 +01001059 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
Johannes Berg75de9112012-12-14 14:56:03 +01001060 sta_info_flush_defer(vlan);
1061 sta_info_flush_defer(sdata);
Bob Copeland8ceb5952013-04-18 18:26:49 -04001062 synchronize_net();
Johannes Berg75de9112012-12-14 14:56:03 +01001063 rcu_barrier();
Johannes Berg7b4396b2013-02-23 01:14:20 +01001064 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
Johannes Berg75de9112012-12-14 14:56:03 +01001065 sta_info_flush_cleanup(vlan);
Johannes Berg7b4396b2013-02-23 01:14:20 +01001066 ieee80211_free_keys(vlan);
1067 }
Johannes Berg75de9112012-12-14 14:56:03 +01001068 sta_info_flush_cleanup(sdata);
Johannes Berg7b4396b2013-02-23 01:14:20 +01001069 ieee80211_free_keys(sdata);
Johannes Berg75de9112012-12-14 14:56:03 +01001070
Johannes Bergd6a83222012-12-14 14:06:28 +01001071 sdata->vif.bss_conf.enable_beacon = false;
Marek Puzyniak0eabccd2013-04-10 13:47:45 +02001072 sdata->vif.bss_conf.ssid_len = 0;
Johannes Bergd6a83222012-12-14 14:06:28 +01001073 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001074 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
Johannes Berg88600202012-02-13 15:17:18 +01001075
Simon Wunderlicha6b368f2013-06-11 10:44:39 +02001076 if (sdata->wdev.cac_started) {
1077 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1078 cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
1079 GFP_KERNEL);
1080 }
1081
Johannes Berg10416382012-10-19 15:44:42 +02001082 drv_stop_ap(sdata->local, sdata);
1083
Johannes Berg7b20b8e2012-10-25 19:02:42 +02001084 /* free all potentially still buffered bcast frames */
1085 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1086 skb_queue_purge(&sdata->u.ap.ps.bc_buf);
1087
Johannes Berg1f4ac5a2013-02-08 12:07:44 +01001088 ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
Johannes Berg55de9082012-07-26 17:24:39 +02001089 ieee80211_vif_release_channel(sdata);
1090
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001091 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +01001092}
1093
Johannes Berg4fd69312007-12-19 02:03:35 +01001094/* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
1095struct iapp_layer2_update {
1096 u8 da[ETH_ALEN]; /* broadcast */
1097 u8 sa[ETH_ALEN]; /* STA addr */
1098 __be16 len; /* 6 */
1099 u8 dsap; /* 0 */
1100 u8 ssap; /* 0 */
1101 u8 control;
1102 u8 xid_info[3];
Eric Dumazetbc105022010-06-03 03:21:52 -07001103} __packed;
Johannes Berg4fd69312007-12-19 02:03:35 +01001104
1105static void ieee80211_send_layer2_update(struct sta_info *sta)
1106{
1107 struct iapp_layer2_update *msg;
1108 struct sk_buff *skb;
1109
1110 /* Send Level 2 Update Frame to update forwarding tables in layer 2
1111 * bridge devices */
1112
1113 skb = dev_alloc_skb(sizeof(*msg));
1114 if (!skb)
1115 return;
1116 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
1117
1118 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
1119 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
1120
Johannes Berge83e6542012-07-13 16:23:07 +02001121 eth_broadcast_addr(msg->da);
Johannes Berg17741cd2008-09-11 00:02:02 +02001122 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
Johannes Berg4fd69312007-12-19 02:03:35 +01001123 msg->len = htons(6);
1124 msg->dsap = 0;
1125 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
1126 msg->control = 0xaf; /* XID response lsb.1111F101.
1127 * F=0 (no poll command; unsolicited frame) */
1128 msg->xid_info[0] = 0x81; /* XID format identifier */
1129 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
1130 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
1131
Johannes Bergd0709a62008-02-25 16:27:46 +01001132 skb->dev = sta->sdata->dev;
1133 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
Johannes Berg4fd69312007-12-19 02:03:35 +01001134 memset(skb->cb, 0, sizeof(skb->cb));
John W. Linville06ee1c22010-07-19 11:52:59 -04001135 netif_rx_ni(skb);
Johannes Berg4fd69312007-12-19 02:03:35 +01001136}
1137
Johannes Bergd582cff2012-10-26 17:53:44 +02001138static int sta_apply_auth_flags(struct ieee80211_local *local,
1139 struct sta_info *sta,
1140 u32 mask, u32 set)
1141{
1142 int ret;
1143
1144 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1145 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1146 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1147 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1148 if (ret)
1149 return ret;
1150 }
1151
1152 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1153 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1154 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1155 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1156 if (ret)
1157 return ret;
1158 }
1159
1160 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1161 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1162 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1163 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1164 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1165 else
1166 ret = 0;
1167 if (ret)
1168 return ret;
1169 }
1170
1171 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1172 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1173 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1174 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1175 if (ret)
1176 return ret;
1177 }
1178
1179 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1180 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1181 test_sta_flag(sta, WLAN_STA_AUTH)) {
1182 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1183 if (ret)
1184 return ret;
1185 }
1186
1187 return 0;
1188}
1189
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001190static int sta_apply_parameters(struct ieee80211_local *local,
1191 struct sta_info *sta,
1192 struct station_parameters *params)
Johannes Berg4fd69312007-12-19 02:03:35 +01001193{
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001194 int ret = 0;
Johannes Berg4fd69312007-12-19 02:03:35 +01001195 u32 rates;
1196 int i, j;
Johannes Berg8318d782008-01-24 19:38:38 +01001197 struct ieee80211_supported_band *sband;
Johannes Bergd0709a62008-02-25 16:27:46 +01001198 struct ieee80211_sub_if_data *sdata = sta->sdata;
Johannes Berg55de9082012-07-26 17:24:39 +02001199 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
Johannes Bergeccb8e82009-05-11 21:57:56 +03001200 u32 mask, set;
Johannes Berg4fd69312007-12-19 02:03:35 +01001201
Johannes Berg55de9082012-07-26 17:24:39 +02001202 sband = local->hw.wiphy->bands[band];
Johannes Bergae5eb022008-10-14 16:58:37 +02001203
Johannes Bergeccb8e82009-05-11 21:57:56 +03001204 mask = params->sta_flags_mask;
1205 set = params->sta_flags_set;
Johannes Berg73651ee2008-02-25 16:27:47 +01001206
Johannes Bergd582cff2012-10-26 17:53:44 +02001207 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1208 /*
1209 * In mesh mode, ASSOCIATED isn't part of the nl80211
1210 * API but must follow AUTHENTICATED for driver state.
1211 */
1212 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1213 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1214 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1215 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
Johannes Berg77ee7c82013-02-15 00:48:33 +01001216 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1217 /*
1218 * TDLS -- everything follows authorized, but
1219 * only becoming authorized is possible, not
1220 * going back
1221 */
1222 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1223 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1224 BIT(NL80211_STA_FLAG_ASSOCIATED);
1225 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1226 BIT(NL80211_STA_FLAG_ASSOCIATED);
1227 }
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001228 }
1229
Johannes Bergd582cff2012-10-26 17:53:44 +02001230 ret = sta_apply_auth_flags(local, sta, mask, set);
1231 if (ret)
1232 return ret;
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001233
Johannes Bergeccb8e82009-05-11 21:57:56 +03001234 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +03001235 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
Johannes Bergc2c98fd2011-09-29 16:04:36 +02001236 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1237 else
1238 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
Johannes Bergeccb8e82009-05-11 21:57:56 +03001239 }
1240
1241 if (mask & BIT(NL80211_STA_FLAG_WME)) {
Arik Nemtsov39df6002011-06-27 23:58:45 +03001242 if (set & BIT(NL80211_STA_FLAG_WME)) {
Johannes Bergc2c98fd2011-09-29 16:04:36 +02001243 set_sta_flag(sta, WLAN_STA_WME);
Arik Nemtsov39df6002011-06-27 23:58:45 +03001244 sta->sta.wme = true;
Johannes Bergc2c98fd2011-09-29 16:04:36 +02001245 } else {
1246 clear_sta_flag(sta, WLAN_STA_WME);
1247 sta->sta.wme = false;
Arik Nemtsov39df6002011-06-27 23:58:45 +03001248 }
Johannes Bergeccb8e82009-05-11 21:57:56 +03001249 }
1250
1251 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +03001252 if (set & BIT(NL80211_STA_FLAG_MFP))
Johannes Bergc2c98fd2011-09-29 16:04:36 +02001253 set_sta_flag(sta, WLAN_STA_MFP);
1254 else
1255 clear_sta_flag(sta, WLAN_STA_MFP);
Johannes Bergeccb8e82009-05-11 21:57:56 +03001256 }
Javier Cardonab39c48f2011-04-07 15:08:30 -07001257
Arik Nemtsov07ba55d2011-09-28 14:12:53 +03001258 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Arik Nemtsov07ba55d2011-09-28 14:12:53 +03001259 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
Johannes Bergc2c98fd2011-09-29 16:04:36 +02001260 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1261 else
1262 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
Arik Nemtsov07ba55d2011-09-28 14:12:53 +03001263 }
Johannes Bergeccb8e82009-05-11 21:57:56 +03001264
Johannes Berg3b9ce802011-09-27 20:56:12 +02001265 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1266 sta->sta.uapsd_queues = params->uapsd_queues;
1267 sta->sta.max_sp = params->max_sp;
1268 }
Eliad Peller9533b4a2011-08-23 14:37:47 +03001269
Johannes Berg73651ee2008-02-25 16:27:47 +01001270 /*
Johannes Berg51b50fb2009-05-24 16:42:30 +02001271 * cfg80211 validates this (1-2007) and allows setting the AID
1272 * only when creating a new station entry
1273 */
1274 if (params->aid)
1275 sta->sta.aid = params->aid;
1276
1277 /*
Johannes Bergba23d202012-12-27 17:32:09 +01001278 * Some of the following updates would be racy if called on an
1279 * existing station, via ieee80211_change_station(). However,
1280 * all such changes are rejected by cfg80211 except for updates
1281 * changing the supported rates on an existing but not yet used
1282 * TDLS peer.
Johannes Berg73651ee2008-02-25 16:27:47 +01001283 */
1284
Johannes Berg4fd69312007-12-19 02:03:35 +01001285 if (params->listen_interval >= 0)
1286 sta->listen_interval = params->listen_interval;
1287
1288 if (params->supported_rates) {
1289 rates = 0;
Johannes Berg8318d782008-01-24 19:38:38 +01001290
Johannes Berg4fd69312007-12-19 02:03:35 +01001291 for (i = 0; i < params->supported_rates_len; i++) {
1292 int rate = (params->supported_rates[i] & 0x7f) * 5;
Johannes Berg8318d782008-01-24 19:38:38 +01001293 for (j = 0; j < sband->n_bitrates; j++) {
1294 if (sband->bitrates[j].bitrate == rate)
Johannes Berg4fd69312007-12-19 02:03:35 +01001295 rates |= BIT(j);
1296 }
1297 }
Johannes Berg55de9082012-07-26 17:24:39 +02001298 sta->sta.supp_rates[band] = rates;
Johannes Berg4fd69312007-12-19 02:03:35 +01001299 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001300
Johannes Bergd9fe60d2008-10-09 12:13:49 +02001301 if (params->ht_capa)
Ben Greearef96a8422011-11-18 11:32:00 -08001302 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
Johannes Berge1a0c6b2013-02-07 11:47:44 +01001303 params->ht_capa, sta);
Jouni Malinen36aedc902008-08-25 11:58:58 +03001304
Mahesh Palivelaf461be3e2012-10-11 08:04:52 +00001305 if (params->vht_capa)
1306 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
Johannes Berg4a342152013-02-07 11:58:58 +01001307 params->vht_capa, sta);
Mahesh Palivelaf461be3e2012-10-11 08:04:52 +00001308
Javier Cardona9c3990a2011-05-03 16:57:11 -07001309 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -04001310#ifdef CONFIG_MAC80211_MESH
Thomas Pedersen39886b62013-02-13 12:14:19 -08001311 u32 changed = 0;
Johannes Berg77ee7c82013-02-15 00:48:33 +01001312
1313 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
Javier Cardona9c3990a2011-05-03 16:57:11 -07001314 switch (params->plink_state) {
Javier Cardona57cf8042011-05-13 10:45:43 -07001315 case NL80211_PLINK_ESTAB:
Marco Porsch1617bab2013-01-07 16:04:49 +01001316 if (sta->plink_state != NL80211_PLINK_ESTAB)
1317 changed = mesh_plink_inc_estab_count(
1318 sdata);
1319 sta->plink_state = params->plink_state;
Marco Porsch3f52b7e2013-01-30 18:14:08 +01001320
1321 ieee80211_mps_sta_status_update(sta);
Thomas Pedersen39886b62013-02-13 12:14:19 -08001322 changed |= ieee80211_mps_set_sta_local_pm(sta,
1323 sdata->u.mesh.mshcfg.power_mode);
Marco Porsch1617bab2013-01-07 16:04:49 +01001324 break;
1325 case NL80211_PLINK_LISTEN:
Javier Cardona57cf8042011-05-13 10:45:43 -07001326 case NL80211_PLINK_BLOCKED:
Marco Porsch1617bab2013-01-07 16:04:49 +01001327 case NL80211_PLINK_OPN_SNT:
1328 case NL80211_PLINK_OPN_RCVD:
1329 case NL80211_PLINK_CNF_RCVD:
1330 case NL80211_PLINK_HOLDING:
1331 if (sta->plink_state == NL80211_PLINK_ESTAB)
1332 changed = mesh_plink_dec_estab_count(
1333 sdata);
Javier Cardona9c3990a2011-05-03 16:57:11 -07001334 sta->plink_state = params->plink_state;
Marco Porsch3f52b7e2013-01-30 18:14:08 +01001335
1336 ieee80211_mps_sta_status_update(sta);
Thomas Pedersen39886b62013-02-13 12:14:19 -08001337 changed |=
1338 ieee80211_mps_local_status_update(sdata);
Javier Cardona9c3990a2011-05-03 16:57:11 -07001339 break;
1340 default:
1341 /* nothing */
1342 break;
1343 }
Johannes Berg77ee7c82013-02-15 00:48:33 +01001344 }
1345
1346 switch (params->plink_action) {
1347 case NL80211_PLINK_ACTION_NO_ACTION:
1348 /* nothing */
1349 break;
1350 case NL80211_PLINK_ACTION_OPEN:
1351 changed |= mesh_plink_open(sta);
1352 break;
1353 case NL80211_PLINK_ACTION_BLOCK:
1354 changed |= mesh_plink_block(sta);
1355 break;
Marco Porsch1617bab2013-01-07 16:04:49 +01001356 }
Marco Porsch3f52b7e2013-01-30 18:14:08 +01001357
1358 if (params->local_pm)
Thomas Pedersen39886b62013-02-13 12:14:19 -08001359 changed |=
1360 ieee80211_mps_set_sta_local_pm(sta,
1361 params->local_pm);
1362 ieee80211_bss_info_change_notify(sdata, changed);
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -04001363#endif
Johannes Berg902acc72008-02-23 15:17:19 +01001364 }
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001365
1366 return 0;
Johannes Berg4fd69312007-12-19 02:03:35 +01001367}
1368
1369static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1370 u8 *mac, struct station_parameters *params)
1371{
Johannes Berg14db74b2008-07-29 13:22:52 +02001372 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +01001373 struct sta_info *sta;
1374 struct ieee80211_sub_if_data *sdata;
Johannes Berg73651ee2008-02-25 16:27:47 +01001375 int err;
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001376 int layer2_update;
Johannes Berg4fd69312007-12-19 02:03:35 +01001377
Johannes Berg4fd69312007-12-19 02:03:35 +01001378 if (params->vlan) {
1379 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1380
Johannes Berg05c914f2008-09-11 00:01:58 +02001381 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1382 sdata->vif.type != NL80211_IFTYPE_AP)
Johannes Berg4fd69312007-12-19 02:03:35 +01001383 return -EINVAL;
1384 } else
1385 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1386
Joe Perchesb203ca32012-05-08 18:56:52 +00001387 if (ether_addr_equal(mac, sdata->vif.addr))
Johannes Berg03e44972008-02-27 09:56:40 +01001388 return -EINVAL;
1389
1390 if (is_multicast_ether_addr(mac))
1391 return -EINVAL;
1392
1393 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +01001394 if (!sta)
1395 return -ENOMEM;
Johannes Berg4fd69312007-12-19 02:03:35 +01001396
Johannes Bergd582cff2012-10-26 17:53:44 +02001397 /*
1398 * defaults -- if userspace wants something else we'll
1399 * change it accordingly in sta_apply_parameters()
1400 */
Johannes Berg77ee7c82013-02-15 00:48:33 +01001401 if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) {
1402 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1403 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1404 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001405
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001406 err = sta_apply_parameters(local, sta, params);
1407 if (err) {
1408 sta_info_free(local, sta);
1409 return err;
1410 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001411
Arik Nemtsovd64cf632011-11-07 23:24:39 +02001412 /*
Johannes Berg77ee7c82013-02-15 00:48:33 +01001413 * for TDLS, rate control should be initialized only when
1414 * rates are known and station is marked authorized
Arik Nemtsovd64cf632011-11-07 23:24:39 +02001415 */
1416 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER))
1417 rate_control_rate_init(sta);
Johannes Berg4fd69312007-12-19 02:03:35 +01001418
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001419 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1420 sdata->vif.type == NL80211_IFTYPE_AP;
1421
Johannes Berg34e89502010-02-03 13:59:58 +01001422 err = sta_info_insert_rcu(sta);
Johannes Berg73651ee2008-02-25 16:27:47 +01001423 if (err) {
Johannes Berg73651ee2008-02-25 16:27:47 +01001424 rcu_read_unlock();
1425 return err;
1426 }
1427
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001428 if (layer2_update)
Johannes Berg73651ee2008-02-25 16:27:47 +01001429 ieee80211_send_layer2_update(sta);
1430
1431 rcu_read_unlock();
1432
Johannes Berg4fd69312007-12-19 02:03:35 +01001433 return 0;
1434}
1435
1436static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1437 u8 *mac)
1438{
Johannes Berg14db74b2008-07-29 13:22:52 +02001439 struct ieee80211_sub_if_data *sdata;
Johannes Berg4fd69312007-12-19 02:03:35 +01001440
Johannes Berg14db74b2008-07-29 13:22:52 +02001441 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1442
Johannes Berg34e89502010-02-03 13:59:58 +01001443 if (mac)
1444 return sta_info_destroy_addr_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001445
Johannes Bergb998e8b2012-12-13 23:07:46 +01001446 sta_info_flush(sdata);
Johannes Berg4fd69312007-12-19 02:03:35 +01001447 return 0;
1448}
1449
1450static int ieee80211_change_station(struct wiphy *wiphy,
Johannes Berg77ee7c82013-02-15 00:48:33 +01001451 struct net_device *dev, u8 *mac,
Johannes Berg4fd69312007-12-19 02:03:35 +01001452 struct station_parameters *params)
1453{
Johannes Bergabe60632009-11-25 17:46:18 +01001454 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg14db74b2008-07-29 13:22:52 +02001455 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +01001456 struct sta_info *sta;
1457 struct ieee80211_sub_if_data *vlansdata;
Johannes Berg77ee7c82013-02-15 00:48:33 +01001458 enum cfg80211_station_type statype;
Eliad Peller35b88622011-12-29 14:41:39 +02001459 int err;
Johannes Berg4fd69312007-12-19 02:03:35 +01001460
Johannes Berg87be1e12011-12-14 12:20:29 +01001461 mutex_lock(&local->sta_mtx);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001462
Felix Fietkau0e5ded52010-01-08 18:10:58 +01001463 sta = sta_info_get_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001464 if (!sta) {
Johannes Berg77ee7c82013-02-15 00:48:33 +01001465 err = -ENOENT;
1466 goto out_err;
Johannes Berg98dd6a52008-04-10 15:36:09 +02001467 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001468
Johannes Berg77ee7c82013-02-15 00:48:33 +01001469 switch (sdata->vif.type) {
1470 case NL80211_IFTYPE_MESH_POINT:
Thomas Pedersena6dad6a2013-03-04 13:06:12 -08001471 if (sdata->u.mesh.user_mpm)
Thomas Pederseneef941e2013-03-04 13:06:11 -08001472 statype = CFG80211_STA_MESH_PEER_USER;
Johannes Berg77ee7c82013-02-15 00:48:33 +01001473 else
Thomas Pederseneef941e2013-03-04 13:06:11 -08001474 statype = CFG80211_STA_MESH_PEER_KERNEL;
Johannes Berg77ee7c82013-02-15 00:48:33 +01001475 break;
1476 case NL80211_IFTYPE_ADHOC:
1477 statype = CFG80211_STA_IBSS;
1478 break;
1479 case NL80211_IFTYPE_STATION:
1480 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1481 statype = CFG80211_STA_AP_STA;
1482 break;
1483 }
1484 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1485 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
1486 else
1487 statype = CFG80211_STA_TDLS_PEER_SETUP;
1488 break;
1489 case NL80211_IFTYPE_AP:
1490 case NL80211_IFTYPE_AP_VLAN:
1491 statype = CFG80211_STA_AP_CLIENT;
1492 break;
1493 default:
1494 err = -EOPNOTSUPP;
1495 goto out_err;
Johannes Bergbdd90d52011-12-14 12:20:27 +01001496 }
1497
Johannes Berg77ee7c82013-02-15 00:48:33 +01001498 err = cfg80211_check_station_change(wiphy, params, statype);
1499 if (err)
1500 goto out_err;
1501
Johannes Bergd0709a62008-02-25 16:27:46 +01001502 if (params->vlan && params->vlan != sta->sdata->dev) {
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001503 bool prev_4addr = false;
1504 bool new_4addr = false;
1505
Johannes Berg4fd69312007-12-19 02:03:35 +01001506 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1507
Johannes Berg9bc383d2009-11-19 11:55:19 +01001508 if (params->vlan->ieee80211_ptr->use_4addr) {
Johannes Berg33054432009-11-20 10:09:14 +01001509 if (vlansdata->u.vlan.sta) {
Johannes Berg77ee7c82013-02-15 00:48:33 +01001510 err = -EBUSY;
1511 goto out_err;
Johannes Berg33054432009-11-20 10:09:14 +01001512 }
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001513
Eric Dumazetcf778b02012-01-12 04:41:32 +00001514 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001515 new_4addr = true;
1516 }
1517
1518 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1519 sta->sdata->u.vlan.sta) {
1520 rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL);
1521 prev_4addr = true;
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001522 }
1523
Johannes Berg14db74b2008-07-29 13:22:52 +02001524 sta->sdata = vlansdata;
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001525
1526 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
1527 prev_4addr != new_4addr) {
1528 if (new_4addr)
1529 atomic_dec(&sta->sdata->bss->num_mcast_sta);
1530 else
1531 atomic_inc(&sta->sdata->bss->num_mcast_sta);
1532 }
1533
Johannes Berg4fd69312007-12-19 02:03:35 +01001534 ieee80211_send_layer2_update(sta);
1535 }
1536
Eliad Peller35b88622011-12-29 14:41:39 +02001537 err = sta_apply_parameters(local, sta, params);
Johannes Berg77ee7c82013-02-15 00:48:33 +01001538 if (err)
1539 goto out_err;
Johannes Berg4fd69312007-12-19 02:03:35 +01001540
Johannes Berg77ee7c82013-02-15 00:48:33 +01001541 /* When peer becomes authorized, init rate control as well */
1542 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1543 test_sta_flag(sta, WLAN_STA_AUTHORIZED))
Arik Nemtsovd64cf632011-11-07 23:24:39 +02001544 rate_control_rate_init(sta);
1545
Johannes Berg87be1e12011-12-14 12:20:29 +01001546 mutex_unlock(&local->sta_mtx);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001547
Jason Young808118c2011-03-10 16:43:19 -08001548 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
Eliad Pellerab095872012-07-27 12:33:22 +03001549 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
Jason Young808118c2011-03-10 16:43:19 -08001550 ieee80211_recalc_ps(local, -1);
Eliad Pellerab095872012-07-27 12:33:22 +03001551 ieee80211_recalc_ps_vif(sdata);
1552 }
Johannes Berg77ee7c82013-02-15 00:48:33 +01001553
Johannes Berg4fd69312007-12-19 02:03:35 +01001554 return 0;
Johannes Berg77ee7c82013-02-15 00:48:33 +01001555out_err:
1556 mutex_unlock(&local->sta_mtx);
1557 return err;
Johannes Berg4fd69312007-12-19 02:03:35 +01001558}
1559
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001560#ifdef CONFIG_MAC80211_MESH
1561static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1562 u8 *dst, u8 *next_hop)
1563{
Johannes Berg14db74b2008-07-29 13:22:52 +02001564 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001565 struct mesh_path *mpath;
1566 struct sta_info *sta;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001567
Johannes Berg14db74b2008-07-29 13:22:52 +02001568 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1569
Johannes Bergd0709a62008-02-25 16:27:46 +01001570 rcu_read_lock();
Johannes Bergabe60632009-11-25 17:46:18 +01001571 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +01001572 if (!sta) {
1573 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001574 return -ENOENT;
Johannes Bergd0709a62008-02-25 16:27:46 +01001575 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001576
Bob Copelandae76eef2013-03-29 09:38:39 -04001577 mpath = mesh_path_add(sdata, dst);
1578 if (IS_ERR(mpath)) {
Johannes Bergd0709a62008-02-25 16:27:46 +01001579 rcu_read_unlock();
Bob Copelandae76eef2013-03-29 09:38:39 -04001580 return PTR_ERR(mpath);
Johannes Bergd0709a62008-02-25 16:27:46 +01001581 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001582
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001583 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +01001584
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001585 rcu_read_unlock();
1586 return 0;
1587}
1588
1589static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
Johannes Bergbf7cd942013-02-15 14:40:31 +01001590 u8 *dst)
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001591{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001592 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001593
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001594 if (dst)
Johannes Bergbf7cd942013-02-15 14:40:31 +01001595 return mesh_path_del(sdata, dst);
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001596
Javier Cardonaece1a2e2011-08-29 13:23:04 -07001597 mesh_path_flush_by_iface(sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001598 return 0;
1599}
1600
1601static int ieee80211_change_mpath(struct wiphy *wiphy,
1602 struct net_device *dev,
1603 u8 *dst, u8 *next_hop)
1604{
Johannes Berg14db74b2008-07-29 13:22:52 +02001605 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001606 struct mesh_path *mpath;
1607 struct sta_info *sta;
1608
Johannes Berg14db74b2008-07-29 13:22:52 +02001609 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1610
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001611 rcu_read_lock();
Johannes Bergd0709a62008-02-25 16:27:46 +01001612
Johannes Bergabe60632009-11-25 17:46:18 +01001613 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +01001614 if (!sta) {
1615 rcu_read_unlock();
1616 return -ENOENT;
1617 }
1618
Johannes Bergbf7cd942013-02-15 14:40:31 +01001619 mpath = mesh_path_lookup(sdata, dst);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001620 if (!mpath) {
1621 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001622 return -ENOENT;
1623 }
1624
1625 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +01001626
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001627 rcu_read_unlock();
1628 return 0;
1629}
1630
1631static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1632 struct mpath_info *pinfo)
1633{
Johannes Berga3836e02011-05-12 15:11:37 +02001634 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1635
1636 if (next_hop_sta)
1637 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001638 else
1639 memset(next_hop, 0, ETH_ALEN);
1640
LEO Airwarosu Yoichi Shinoda7ce8c7a2012-08-27 22:28:16 +09001641 memset(pinfo, 0, sizeof(*pinfo));
1642
Johannes Bergf5ea9122009-08-07 16:17:38 +02001643 pinfo->generation = mesh_paths_generation;
1644
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001645 pinfo->filled = MPATH_INFO_FRAME_QLEN |
Rui Paulod19b3bf2009-11-09 23:46:55 +00001646 MPATH_INFO_SN |
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001647 MPATH_INFO_METRIC |
1648 MPATH_INFO_EXPTIME |
1649 MPATH_INFO_DISCOVERY_TIMEOUT |
1650 MPATH_INFO_DISCOVERY_RETRIES |
1651 MPATH_INFO_FLAGS;
1652
1653 pinfo->frame_qlen = mpath->frame_queue.qlen;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001654 pinfo->sn = mpath->sn;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001655 pinfo->metric = mpath->metric;
1656 if (time_before(jiffies, mpath->exp_time))
1657 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1658 pinfo->discovery_timeout =
1659 jiffies_to_msecs(mpath->discovery_timeout);
1660 pinfo->discovery_retries = mpath->discovery_retries;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001661 if (mpath->flags & MESH_PATH_ACTIVE)
1662 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1663 if (mpath->flags & MESH_PATH_RESOLVING)
1664 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001665 if (mpath->flags & MESH_PATH_SN_VALID)
1666 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001667 if (mpath->flags & MESH_PATH_FIXED)
1668 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
LEO Airwarosu Yoichi Shinoda7ce8c7a2012-08-27 22:28:16 +09001669 if (mpath->flags & MESH_PATH_RESOLVED)
1670 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001671}
1672
1673static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1674 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1675
1676{
Johannes Berg14db74b2008-07-29 13:22:52 +02001677 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001678 struct mesh_path *mpath;
1679
Johannes Berg14db74b2008-07-29 13:22:52 +02001680 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1681
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001682 rcu_read_lock();
Johannes Bergbf7cd942013-02-15 14:40:31 +01001683 mpath = mesh_path_lookup(sdata, dst);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001684 if (!mpath) {
1685 rcu_read_unlock();
1686 return -ENOENT;
1687 }
1688 memcpy(dst, mpath->dst, ETH_ALEN);
1689 mpath_set_pinfo(mpath, next_hop, pinfo);
1690 rcu_read_unlock();
1691 return 0;
1692}
1693
1694static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1695 int idx, u8 *dst, u8 *next_hop,
1696 struct mpath_info *pinfo)
1697{
Johannes Berg14db74b2008-07-29 13:22:52 +02001698 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001699 struct mesh_path *mpath;
1700
Johannes Berg14db74b2008-07-29 13:22:52 +02001701 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1702
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001703 rcu_read_lock();
Johannes Bergbf7cd942013-02-15 14:40:31 +01001704 mpath = mesh_path_lookup_by_idx(sdata, idx);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001705 if (!mpath) {
1706 rcu_read_unlock();
1707 return -ENOENT;
1708 }
1709 memcpy(dst, mpath->dst, ETH_ALEN);
1710 mpath_set_pinfo(mpath, next_hop, pinfo);
1711 rcu_read_unlock();
1712 return 0;
1713}
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001714
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001715static int ieee80211_get_mesh_config(struct wiphy *wiphy,
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001716 struct net_device *dev,
1717 struct mesh_config *conf)
1718{
1719 struct ieee80211_sub_if_data *sdata;
1720 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1721
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001722 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1723 return 0;
1724}
1725
1726static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1727{
1728 return (mask >> (parm-1)) & 0x1;
1729}
1730
Javier Cardonac80d5452010-12-16 17:37:49 -08001731static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1732 const struct mesh_setup *setup)
1733{
1734 u8 *new_ie;
1735 const u8 *old_ie;
Chun-Yeow Yeoh4bb62342011-11-24 17:15:20 -08001736 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
1737 struct ieee80211_sub_if_data, u.mesh);
Javier Cardonac80d5452010-12-16 17:37:49 -08001738
Javier Cardona581a8b02011-04-07 15:08:27 -07001739 /* allocate information elements */
Javier Cardonac80d5452010-12-16 17:37:49 -08001740 new_ie = NULL;
Javier Cardona581a8b02011-04-07 15:08:27 -07001741 old_ie = ifmsh->ie;
Javier Cardonac80d5452010-12-16 17:37:49 -08001742
Javier Cardona581a8b02011-04-07 15:08:27 -07001743 if (setup->ie_len) {
1744 new_ie = kmemdup(setup->ie, setup->ie_len,
Javier Cardonac80d5452010-12-16 17:37:49 -08001745 GFP_KERNEL);
1746 if (!new_ie)
1747 return -ENOMEM;
1748 }
Javier Cardona581a8b02011-04-07 15:08:27 -07001749 ifmsh->ie_len = setup->ie_len;
1750 ifmsh->ie = new_ie;
1751 kfree(old_ie);
Javier Cardonac80d5452010-12-16 17:37:49 -08001752
1753 /* now copy the rest of the setup parameters */
1754 ifmsh->mesh_id_len = setup->mesh_id_len;
1755 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
Javier Cardonad299a1f2012-03-31 11:31:33 -07001756 ifmsh->mesh_sp_id = setup->sync_method;
Javier Cardonac80d5452010-12-16 17:37:49 -08001757 ifmsh->mesh_pp_id = setup->path_sel_proto;
1758 ifmsh->mesh_pm_id = setup->path_metric;
Thomas Pedersena6dad6a2013-03-04 13:06:12 -08001759 ifmsh->user_mpm = setup->user_mpm;
Colleen Twitty0d4261a2013-05-08 11:46:00 -07001760 ifmsh->mesh_auth_id = setup->auth_id;
Javier Cardonab130e5c2011-05-03 16:57:07 -07001761 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1762 if (setup->is_authenticated)
1763 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1764 if (setup->is_secure)
1765 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
Javier Cardonac80d5452010-12-16 17:37:49 -08001766
Chun-Yeow Yeoh4bb62342011-11-24 17:15:20 -08001767 /* mcast rate setting in Mesh Node */
1768 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
1769 sizeof(setup->mcast_rate));
Ashok Nagarajanffb3cf32013-06-03 10:33:36 -07001770 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
Chun-Yeow Yeoh4bb62342011-11-24 17:15:20 -08001771
Marco Porsch9bdbf042013-01-07 16:04:51 +01001772 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
1773 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
1774
Javier Cardonac80d5452010-12-16 17:37:49 -08001775 return 0;
1776}
1777
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001778static int ieee80211_update_mesh_config(struct wiphy *wiphy,
Johannes Berg29cbe682010-12-03 09:20:44 +01001779 struct net_device *dev, u32 mask,
1780 const struct mesh_config *nconf)
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001781{
1782 struct mesh_config *conf;
1783 struct ieee80211_sub_if_data *sdata;
Rui Paulo63c57232009-11-09 23:46:57 +00001784 struct ieee80211_if_mesh *ifmsh;
1785
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001786 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Rui Paulo63c57232009-11-09 23:46:57 +00001787 ifmsh = &sdata->u.mesh;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001788
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001789 /* Set the config options which we are interested in setting */
1790 conf = &(sdata->u.mesh.mshcfg);
1791 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1792 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1793 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1794 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1795 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1796 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1797 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1798 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1799 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1800 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1801 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1802 conf->dot11MeshTTL = nconf->dot11MeshTTL;
Javier Cardona45904f22010-12-03 09:20:40 +01001803 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
Chun-Yeow Yeoh58886a92012-06-15 00:23:53 +08001804 conf->element_ttl = nconf->element_ttl;
Thomas Pedersen146bb482013-03-04 13:06:14 -08001805 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
1806 if (ifmsh->user_mpm)
1807 return -EBUSY;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001808 conf->auto_open_plinks = nconf->auto_open_plinks;
Thomas Pedersen146bb482013-03-04 13:06:14 -08001809 }
Javier Cardonad299a1f2012-03-31 11:31:33 -07001810 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
1811 conf->dot11MeshNbrOffsetMaxNeighbor =
1812 nconf->dot11MeshNbrOffsetMaxNeighbor;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001813 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1814 conf->dot11MeshHWMPmaxPREQretries =
1815 nconf->dot11MeshHWMPmaxPREQretries;
1816 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1817 conf->path_refresh_time = nconf->path_refresh_time;
1818 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1819 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1820 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1821 conf->dot11MeshHWMPactivePathTimeout =
1822 nconf->dot11MeshHWMPactivePathTimeout;
1823 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1824 conf->dot11MeshHWMPpreqMinInterval =
1825 nconf->dot11MeshHWMPpreqMinInterval;
Thomas Pedersendca7e942011-11-24 17:15:24 -08001826 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
1827 conf->dot11MeshHWMPperrMinInterval =
1828 nconf->dot11MeshHWMPperrMinInterval;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001829 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1830 mask))
1831 conf->dot11MeshHWMPnetDiameterTraversalTime =
1832 nconf->dot11MeshHWMPnetDiameterTraversalTime;
Rui Paulo63c57232009-11-09 23:46:57 +00001833 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1834 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1835 ieee80211_mesh_root_setup(ifmsh);
1836 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001837 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
Thomas Pedersenc61336612011-08-25 10:36:14 -07001838 /* our current gate announcement implementation rides on root
1839 * announcements, so require this ifmsh to also be a root node
1840 * */
1841 if (nconf->dot11MeshGateAnnouncementProtocol &&
Chun-Yeow Yeohdbb912c2012-06-14 02:06:09 +08001842 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
1843 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
Thomas Pedersenc61336612011-08-25 10:36:14 -07001844 ieee80211_mesh_root_setup(ifmsh);
1845 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001846 conf->dot11MeshGateAnnouncementProtocol =
1847 nconf->dot11MeshGateAnnouncementProtocol;
1848 }
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +08001849 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
Javier Cardona0507e152011-08-09 16:45:10 -07001850 conf->dot11MeshHWMPRannInterval =
1851 nconf->dot11MeshHWMPRannInterval;
Chun-Yeow Yeoh94f90652012-01-21 01:02:16 +08001852 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1853 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
Ashok Nagarajan55335132012-02-28 17:04:08 -08001854 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
1855 /* our RSSI threshold implementation is supported only for
1856 * devices that report signal in dBm.
1857 */
1858 if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM))
1859 return -ENOTSUPP;
1860 conf->rssi_threshold = nconf->rssi_threshold;
1861 }
Ashok Nagarajan70c33ea2012-04-30 14:20:32 -07001862 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
1863 conf->ht_opmode = nconf->ht_opmode;
1864 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
1865 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1866 }
Chun-Yeow Yeohac1073a2012-06-14 02:06:06 +08001867 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
1868 conf->dot11MeshHWMPactivePathToRootTimeout =
1869 nconf->dot11MeshHWMPactivePathToRootTimeout;
1870 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
1871 conf->dot11MeshHWMProotInterval =
1872 nconf->dot11MeshHWMProotInterval;
Chun-Yeow Yeoh728b19e2012-06-14 02:06:10 +08001873 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
1874 conf->dot11MeshHWMPconfirmationInterval =
1875 nconf->dot11MeshHWMPconfirmationInterval;
Marco Porsch3f52b7e2013-01-30 18:14:08 +01001876 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
1877 conf->power_mode = nconf->power_mode;
1878 ieee80211_mps_local_status_update(sdata);
1879 }
Thomas Pedersen2b5e1962013-02-14 11:20:13 -08001880 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
Marco Porsch3f52b7e2013-01-30 18:14:08 +01001881 conf->dot11MeshAwakeWindowDuration =
1882 nconf->dot11MeshAwakeWindowDuration;
Colleen Twitty66de6712013-06-03 09:53:40 -07001883 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
1884 conf->plink_timeout = nconf->plink_timeout;
Thomas Pedersen2b5e1962013-02-14 11:20:13 -08001885 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001886 return 0;
1887}
1888
Johannes Berg29cbe682010-12-03 09:20:44 +01001889static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1890 const struct mesh_config *conf,
1891 const struct mesh_setup *setup)
1892{
1893 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1894 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
Javier Cardonac80d5452010-12-16 17:37:49 -08001895 int err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001896
Javier Cardonac80d5452010-12-16 17:37:49 -08001897 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1898 err = copy_mesh_setup(ifmsh, setup);
1899 if (err)
1900 return err;
Johannes Bergcc1d2802012-05-16 23:50:20 +02001901
Johannes Berg04ecd252012-09-11 14:34:12 +02001902 /* can mesh use other SMPS modes? */
1903 sdata->smps_mode = IEEE80211_SMPS_OFF;
1904 sdata->needed_rx_chains = sdata->local->rx_chains;
1905
Johannes Berg4bf88532012-11-09 11:39:59 +01001906 err = ieee80211_vif_use_channel(sdata, &setup->chandef,
Johannes Berg55de9082012-07-26 17:24:39 +02001907 IEEE80211_CHANCTX_SHARED);
Johannes Bergcc1d2802012-05-16 23:50:20 +02001908 if (err)
1909 return err;
1910
Thomas Pedersen2b5e1962013-02-14 11:20:13 -08001911 return ieee80211_start_mesh(sdata);
Johannes Berg29cbe682010-12-03 09:20:44 +01001912}
1913
1914static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1915{
1916 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1917
1918 ieee80211_stop_mesh(sdata);
Johannes Berg55de9082012-07-26 17:24:39 +02001919 ieee80211_vif_release_channel(sdata);
Johannes Berg29cbe682010-12-03 09:20:44 +01001920
1921 return 0;
1922}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001923#endif
1924
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001925static int ieee80211_change_bss(struct wiphy *wiphy,
1926 struct net_device *dev,
1927 struct bss_parameters *params)
1928{
Johannes Berg55de9082012-07-26 17:24:39 +02001929 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1930 enum ieee80211_band band;
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001931 u32 changed = 0;
1932
Johannes Berg55de9082012-07-26 17:24:39 +02001933 if (!rtnl_dereference(sdata->u.ap.beacon))
1934 return -ENOENT;
1935
1936 band = ieee80211_get_sdata_band(sdata);
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001937
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001938 if (params->use_cts_prot >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001939 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001940 changed |= BSS_CHANGED_ERP_CTS_PROT;
1941 }
1942 if (params->use_short_preamble >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001943 sdata->vif.bss_conf.use_short_preamble =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001944 params->use_short_preamble;
1945 changed |= BSS_CHANGED_ERP_PREAMBLE;
1946 }
Felix Fietkau43d35342010-01-15 03:00:48 +01001947
1948 if (!sdata->vif.bss_conf.use_short_slot &&
Johannes Berg55de9082012-07-26 17:24:39 +02001949 band == IEEE80211_BAND_5GHZ) {
Felix Fietkau43d35342010-01-15 03:00:48 +01001950 sdata->vif.bss_conf.use_short_slot = true;
1951 changed |= BSS_CHANGED_ERP_SLOT;
1952 }
1953
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001954 if (params->use_short_slot_time >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001955 sdata->vif.bss_conf.use_short_slot =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001956 params->use_short_slot_time;
1957 changed |= BSS_CHANGED_ERP_SLOT;
1958 }
1959
Jouni Malinen90c97a02008-10-30 16:59:22 +02001960 if (params->basic_rates) {
1961 int i, j;
1962 u32 rates = 0;
Johannes Berg55de9082012-07-26 17:24:39 +02001963 struct ieee80211_supported_band *sband = wiphy->bands[band];
Jouni Malinen90c97a02008-10-30 16:59:22 +02001964
1965 for (i = 0; i < params->basic_rates_len; i++) {
1966 int rate = (params->basic_rates[i] & 0x7f) * 5;
1967 for (j = 0; j < sband->n_bitrates; j++) {
1968 if (sband->bitrates[j].bitrate == rate)
1969 rates |= BIT(j);
1970 }
1971 }
1972 sdata->vif.bss_conf.basic_rates = rates;
1973 changed |= BSS_CHANGED_BASIC_RATES;
1974 }
1975
Felix Fietkau7b7b5e52010-04-27 01:23:36 +02001976 if (params->ap_isolate >= 0) {
1977 if (params->ap_isolate)
1978 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1979 else
1980 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1981 }
1982
Helmut Schaa80d7e402010-11-19 12:40:26 +01001983 if (params->ht_opmode >= 0) {
1984 sdata->vif.bss_conf.ht_operation_mode =
1985 (u16) params->ht_opmode;
1986 changed |= BSS_CHANGED_HT;
1987 }
1988
Johannes Berg339afbf2012-11-14 15:21:17 +01001989 if (params->p2p_ctwindow >= 0) {
Janusz Dziedzic67baf662013-03-21 15:47:56 +01001990 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
1991 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1992 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
1993 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
Johannes Berg339afbf2012-11-14 15:21:17 +01001994 changed |= BSS_CHANGED_P2P_PS;
1995 }
1996
Janusz Dziedzic67baf662013-03-21 15:47:56 +01001997 if (params->p2p_opp_ps > 0) {
1998 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
1999 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2000 changed |= BSS_CHANGED_P2P_PS;
2001 } else if (params->p2p_opp_ps == 0) {
2002 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2003 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
Johannes Berg339afbf2012-11-14 15:21:17 +01002004 changed |= BSS_CHANGED_P2P_PS;
2005 }
2006
Jouni Malinen9f1ba902008-08-07 20:07:01 +03002007 ieee80211_bss_info_change_notify(sdata, changed);
2008
2009 return 0;
2010}
2011
Jouni Malinen31888482008-10-30 16:59:24 +02002012static int ieee80211_set_txq_params(struct wiphy *wiphy,
Eliad Pellerf70f01c2011-09-25 20:06:53 +03002013 struct net_device *dev,
Jouni Malinen31888482008-10-30 16:59:24 +02002014 struct ieee80211_txq_params *params)
2015{
2016 struct ieee80211_local *local = wiphy_priv(wiphy);
Eliad Pellerf6f3def2011-09-25 20:06:54 +03002017 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen31888482008-10-30 16:59:24 +02002018 struct ieee80211_tx_queue_params p;
2019
2020 if (!local->ops->conf_tx)
2021 return -EOPNOTSUPP;
2022
Johannes Berg54bcbc62012-03-28 11:04:25 +02002023 if (local->hw.queues < IEEE80211_NUM_ACS)
2024 return -EOPNOTSUPP;
2025
Jouni Malinen31888482008-10-30 16:59:24 +02002026 memset(&p, 0, sizeof(p));
2027 p.aifs = params->aifs;
2028 p.cw_max = params->cwmax;
2029 p.cw_min = params->cwmin;
2030 p.txop = params->txop;
Kalle Valoab133152010-01-12 10:42:31 +02002031
2032 /*
2033 * Setting tx queue params disables u-apsd because it's only
2034 * called in master mode.
2035 */
2036 p.uapsd = false;
2037
Johannes Berga3304b02012-03-28 11:04:24 +02002038 sdata->tx_conf[params->ac] = p;
2039 if (drv_conf_tx(local, sdata, params->ac, &p)) {
Joe Perches0fb9a9e2010-08-20 16:25:38 -07002040 wiphy_debug(local->hw.wiphy,
Johannes Berga3304b02012-03-28 11:04:24 +02002041 "failed to set TX queue parameters for AC %d\n",
2042 params->ac);
Jouni Malinen31888482008-10-30 16:59:24 +02002043 return -EINVAL;
2044 }
2045
Johannes Berg7d257452012-07-06 17:37:43 +02002046 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
2047
Jouni Malinen31888482008-10-30 16:59:24 +02002048 return 0;
2049}
2050
Bob Copeland665af4f2009-01-19 11:20:53 -05002051#ifdef CONFIG_PM
Johannes Bergff1b6e62011-05-04 15:37:28 +02002052static int ieee80211_suspend(struct wiphy *wiphy,
2053 struct cfg80211_wowlan *wowlan)
Bob Copeland665af4f2009-01-19 11:20:53 -05002054{
Johannes Bergeecc4802011-05-04 15:37:29 +02002055 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
Bob Copeland665af4f2009-01-19 11:20:53 -05002056}
2057
2058static int ieee80211_resume(struct wiphy *wiphy)
2059{
2060 return __ieee80211_resume(wiphy_priv(wiphy));
2061}
2062#else
2063#define ieee80211_suspend NULL
2064#define ieee80211_resume NULL
2065#endif
2066
Johannes Berg2a519312009-02-10 21:25:55 +01002067static int ieee80211_scan(struct wiphy *wiphy,
Johannes Berg2a519312009-02-10 21:25:55 +01002068 struct cfg80211_scan_request *req)
2069{
Johannes Bergfd014282012-06-18 19:17:03 +02002070 struct ieee80211_sub_if_data *sdata;
2071
2072 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
Johannes Berg2a519312009-02-10 21:25:55 +01002073
Johannes Berg2ca27bc2010-09-16 14:58:23 +02002074 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2075 case NL80211_IFTYPE_STATION:
2076 case NL80211_IFTYPE_ADHOC:
2077 case NL80211_IFTYPE_MESH_POINT:
2078 case NL80211_IFTYPE_P2P_CLIENT:
Johannes Bergf142c6b2012-06-18 20:07:15 +02002079 case NL80211_IFTYPE_P2P_DEVICE:
Johannes Berg2ca27bc2010-09-16 14:58:23 +02002080 break;
2081 case NL80211_IFTYPE_P2P_GO:
2082 if (sdata->local->ops->hw_scan)
2083 break;
Johannes Berge9d77322011-02-01 15:35:36 +01002084 /*
2085 * FIXME: implement NoA while scanning in software,
2086 * for now fall through to allow scanning only when
2087 * beaconing hasn't been configured yet
2088 */
Johannes Berg2ca27bc2010-09-16 14:58:23 +02002089 case NL80211_IFTYPE_AP:
Antonio Quartulli5c95b942012-10-16 08:39:22 +02002090 /*
2091 * If the scan has been forced (and the driver supports
2092 * forcing), don't care about being beaconing already.
2093 * This will create problems to the attached stations (e.g. all
2094 * the frames sent while scanning on other channel will be
2095 * lost)
2096 */
2097 if (sdata->u.ap.beacon &&
2098 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2099 !(req->flags & NL80211_SCAN_FLAG_AP)))
Johannes Berg2ca27bc2010-09-16 14:58:23 +02002100 return -EOPNOTSUPP;
2101 break;
2102 default:
2103 return -EOPNOTSUPP;
2104 }
Johannes Berg2a519312009-02-10 21:25:55 +01002105
2106 return ieee80211_request_scan(sdata, req);
2107}
2108
Luciano Coelho79f460c2011-05-11 17:09:36 +03002109static int
2110ieee80211_sched_scan_start(struct wiphy *wiphy,
2111 struct net_device *dev,
2112 struct cfg80211_sched_scan_request *req)
2113{
2114 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2115
2116 if (!sdata->local->ops->sched_scan_start)
2117 return -EOPNOTSUPP;
2118
2119 return ieee80211_request_sched_scan_start(sdata, req);
2120}
2121
2122static int
Luciano Coelho85a99942011-05-12 16:28:29 +03002123ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
Luciano Coelho79f460c2011-05-11 17:09:36 +03002124{
2125 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2126
2127 if (!sdata->local->ops->sched_scan_stop)
2128 return -EOPNOTSUPP;
2129
Luciano Coelho85a99942011-05-12 16:28:29 +03002130 return ieee80211_request_sched_scan_stop(sdata);
Luciano Coelho79f460c2011-05-11 17:09:36 +03002131}
2132
Jouni Malinen636a5d32009-03-19 13:39:22 +02002133static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2134 struct cfg80211_auth_request *req)
2135{
Johannes Berg77fdaa12009-07-07 03:45:17 +02002136 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02002137}
2138
2139static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2140 struct cfg80211_assoc_request *req)
2141{
Johannes Berg77fdaa12009-07-07 03:45:17 +02002142 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02002143}
2144
2145static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg63c9c5e2012-02-24 13:50:51 +01002146 struct cfg80211_deauth_request *req)
Jouni Malinen636a5d32009-03-19 13:39:22 +02002147{
Johannes Berg63c9c5e2012-02-24 13:50:51 +01002148 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02002149}
2150
2151static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg63c9c5e2012-02-24 13:50:51 +01002152 struct cfg80211_disassoc_request *req)
Jouni Malinen636a5d32009-03-19 13:39:22 +02002153{
Johannes Berg63c9c5e2012-02-24 13:50:51 +01002154 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02002155}
2156
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02002157static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2158 struct cfg80211_ibss_params *params)
2159{
Johannes Berg55de9082012-07-26 17:24:39 +02002160 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02002161}
2162
2163static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2164{
Johannes Berg55de9082012-07-26 17:24:39 +02002165 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02002166}
2167
Antonio Quartulli391e53e2012-11-02 13:27:49 +01002168static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2169 int rate[IEEE80211_NUM_BANDS])
2170{
2171 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2172
Cong Ding9887dbf2013-02-06 17:23:45 +01002173 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2174 sizeof(int) * IEEE80211_NUM_BANDS);
Antonio Quartulli391e53e2012-11-02 13:27:49 +01002175
2176 return 0;
2177}
2178
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002179static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2180{
2181 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg24487982009-04-23 18:52:52 +02002182 int err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002183
Arik Nemtsovf23a4782010-11-08 11:51:06 +02002184 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2185 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2186
2187 if (err)
2188 return err;
2189 }
2190
Lukáš Turek310bc672009-12-21 22:50:48 +01002191 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
2192 err = drv_set_coverage_class(local, wiphy->coverage_class);
2193
2194 if (err)
2195 return err;
2196 }
2197
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002198 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
Johannes Berg24487982009-04-23 18:52:52 +02002199 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002200
Johannes Berg24487982009-04-23 18:52:52 +02002201 if (err)
2202 return err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002203 }
2204
Johannes Berg8bc83c22012-11-09 18:38:32 +01002205 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2206 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2207 return -EINVAL;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002208 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
Johannes Berg8bc83c22012-11-09 18:38:32 +01002209 }
2210 if (changed & WIPHY_PARAM_RETRY_LONG) {
2211 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2212 return -EINVAL;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002213 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
Johannes Berg8bc83c22012-11-09 18:38:32 +01002214 }
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002215 if (changed &
2216 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2217 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2218
2219 return 0;
2220}
2221
Johannes Berg7643a2c2009-06-02 13:01:39 +02002222static int ieee80211_set_tx_power(struct wiphy *wiphy,
Johannes Bergc8442112012-10-24 10:17:18 +02002223 struct wireless_dev *wdev,
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03002224 enum nl80211_tx_power_setting type, int mbm)
Johannes Berg7643a2c2009-06-02 13:01:39 +02002225{
2226 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg1ea6f9c2012-10-24 10:59:25 +02002227 struct ieee80211_sub_if_data *sdata;
Johannes Berg7643a2c2009-06-02 13:01:39 +02002228
Johannes Berg1ea6f9c2012-10-24 10:59:25 +02002229 if (wdev) {
2230 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2231
2232 switch (type) {
2233 case NL80211_TX_POWER_AUTOMATIC:
2234 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2235 break;
2236 case NL80211_TX_POWER_LIMITED:
2237 case NL80211_TX_POWER_FIXED:
2238 if (mbm < 0 || (mbm % 100))
2239 return -EOPNOTSUPP;
2240 sdata->user_power_level = MBM_TO_DBM(mbm);
2241 break;
2242 }
2243
2244 ieee80211_recalc_txpower(sdata);
2245
2246 return 0;
2247 }
Johannes Berg55de9082012-07-26 17:24:39 +02002248
Johannes Berg7643a2c2009-06-02 13:01:39 +02002249 switch (type) {
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03002250 case NL80211_TX_POWER_AUTOMATIC:
Johannes Berg1ea6f9c2012-10-24 10:59:25 +02002251 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
Johannes Berg7643a2c2009-06-02 13:01:39 +02002252 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03002253 case NL80211_TX_POWER_LIMITED:
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03002254 case NL80211_TX_POWER_FIXED:
2255 if (mbm < 0 || (mbm % 100))
2256 return -EOPNOTSUPP;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03002257 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02002258 break;
Johannes Berg7643a2c2009-06-02 13:01:39 +02002259 }
2260
Johannes Berg1ea6f9c2012-10-24 10:59:25 +02002261 mutex_lock(&local->iflist_mtx);
2262 list_for_each_entry(sdata, &local->interfaces, list)
2263 sdata->user_power_level = local->user_power_level;
2264 list_for_each_entry(sdata, &local->interfaces, list)
2265 ieee80211_recalc_txpower(sdata);
2266 mutex_unlock(&local->iflist_mtx);
Johannes Berg7643a2c2009-06-02 13:01:39 +02002267
2268 return 0;
2269}
2270
Johannes Bergc8442112012-10-24 10:17:18 +02002271static int ieee80211_get_tx_power(struct wiphy *wiphy,
2272 struct wireless_dev *wdev,
2273 int *dbm)
Johannes Berg7643a2c2009-06-02 13:01:39 +02002274{
2275 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg1ea6f9c2012-10-24 10:59:25 +02002276 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
Johannes Berg7643a2c2009-06-02 13:01:39 +02002277
Johannes Berg1ea6f9c2012-10-24 10:59:25 +02002278 if (!local->use_chanctx)
2279 *dbm = local->hw.conf.power_level;
2280 else
2281 *dbm = sdata->vif.bss_conf.txpower;
Johannes Berg7643a2c2009-06-02 13:01:39 +02002282
Johannes Berg7643a2c2009-06-02 13:01:39 +02002283 return 0;
2284}
2285
Johannes Bergab737a42009-07-01 21:26:58 +02002286static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg388ac772010-10-07 13:11:09 +02002287 const u8 *addr)
Johannes Bergab737a42009-07-01 21:26:58 +02002288{
2289 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2290
2291 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
2292
2293 return 0;
2294}
2295
Johannes Berg1f87f7d2009-06-02 13:01:41 +02002296static void ieee80211_rfkill_poll(struct wiphy *wiphy)
2297{
2298 struct ieee80211_local *local = wiphy_priv(wiphy);
2299
2300 drv_rfkill_poll(local);
2301}
2302
Johannes Bergaff89a92009-07-01 21:26:51 +02002303#ifdef CONFIG_NL80211_TESTMODE
Johannes Berg99783e22009-07-07 03:54:43 +02002304static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
Johannes Bergaff89a92009-07-01 21:26:51 +02002305{
2306 struct ieee80211_local *local = wiphy_priv(wiphy);
2307
2308 if (!local->ops->testmode_cmd)
2309 return -EOPNOTSUPP;
2310
2311 return local->ops->testmode_cmd(&local->hw, data, len);
2312}
Wey-Yi Guy71063f02011-05-20 09:05:54 -07002313
2314static int ieee80211_testmode_dump(struct wiphy *wiphy,
2315 struct sk_buff *skb,
2316 struct netlink_callback *cb,
2317 void *data, int len)
2318{
2319 struct ieee80211_local *local = wiphy_priv(wiphy);
2320
2321 if (!local->ops->testmode_dump)
2322 return -EOPNOTSUPP;
2323
2324 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
2325}
Johannes Bergaff89a92009-07-01 21:26:51 +02002326#endif
2327
Johannes Berg0f782312009-12-01 13:37:02 +01002328int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
2329 enum ieee80211_smps_mode smps_mode)
2330{
2331 const u8 *ap;
2332 enum ieee80211_smps_mode old_req;
2333 int err;
2334
Johannes Berg8d61ffa2013-05-10 12:32:47 +02002335 lockdep_assert_held(&sdata->wdev.mtx);
Johannes Berg243e6df2011-04-19 20:44:04 +02002336
Johannes Berg0f782312009-12-01 13:37:02 +01002337 old_req = sdata->u.mgd.req_smps;
2338 sdata->u.mgd.req_smps = smps_mode;
2339
2340 if (old_req == smps_mode &&
2341 smps_mode != IEEE80211_SMPS_AUTOMATIC)
2342 return 0;
2343
2344 /*
2345 * If not associated, or current association is not an HT
Johannes Berg04ecd252012-09-11 14:34:12 +02002346 * association, there's no need to do anything, just store
2347 * the new value until we associate.
Johannes Berg0f782312009-12-01 13:37:02 +01002348 */
2349 if (!sdata->u.mgd.associated ||
Johannes Berg4bf88532012-11-09 11:39:59 +01002350 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
Johannes Berg0f782312009-12-01 13:37:02 +01002351 return 0;
Johannes Berg0f782312009-12-01 13:37:02 +01002352
Johannes Berg0c1ad2c2009-12-23 13:15:39 +01002353 ap = sdata->u.mgd.associated->bssid;
Johannes Berg0f782312009-12-01 13:37:02 +01002354
2355 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
2356 if (sdata->u.mgd.powersave)
2357 smps_mode = IEEE80211_SMPS_DYNAMIC;
2358 else
2359 smps_mode = IEEE80211_SMPS_OFF;
2360 }
2361
2362 /* send SM PS frame to AP */
2363 err = ieee80211_send_smps_action(sdata, smps_mode,
2364 ap, ap);
2365 if (err)
2366 sdata->u.mgd.req_smps = old_req;
2367
2368 return err;
2369}
2370
Johannes Bergbc92afd2009-07-01 21:26:57 +02002371static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2372 bool enabled, int timeout)
2373{
2374 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2375 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Bergbc92afd2009-07-01 21:26:57 +02002376
Chun-Yeow Yeohee1f6682013-01-10 23:31:54 +08002377 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
2378 sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
Benoit Papillaulte5de30c2010-01-15 12:21:37 +01002379 return -EOPNOTSUPP;
2380
Johannes Bergbc92afd2009-07-01 21:26:57 +02002381 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
2382 return -EOPNOTSUPP;
2383
2384 if (enabled == sdata->u.mgd.powersave &&
Juuso Oikarinenff616382010-06-09 09:51:52 +03002385 timeout == local->dynamic_ps_forced_timeout)
Johannes Bergbc92afd2009-07-01 21:26:57 +02002386 return 0;
2387
2388 sdata->u.mgd.powersave = enabled;
Juuso Oikarinenff616382010-06-09 09:51:52 +03002389 local->dynamic_ps_forced_timeout = timeout;
Johannes Bergbc92afd2009-07-01 21:26:57 +02002390
Johannes Berg0f782312009-12-01 13:37:02 +01002391 /* no change, but if automatic follow powersave */
Johannes Berged405be2013-06-03 13:51:59 +02002392 sdata_lock(sdata);
Johannes Berg0f782312009-12-01 13:37:02 +01002393 __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
Johannes Berged405be2013-06-03 13:51:59 +02002394 sdata_unlock(sdata);
Johannes Berg0f782312009-12-01 13:37:02 +01002395
Johannes Bergbc92afd2009-07-01 21:26:57 +02002396 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
2397 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2398
2399 ieee80211_recalc_ps(local, -1);
Eliad Pellerab095872012-07-27 12:33:22 +03002400 ieee80211_recalc_ps_vif(sdata);
Johannes Bergbc92afd2009-07-01 21:26:57 +02002401
2402 return 0;
2403}
2404
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002405static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
2406 struct net_device *dev,
2407 s32 rssi_thold, u32 rssi_hyst)
2408{
2409 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002410 struct ieee80211_vif *vif = &sdata->vif;
2411 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2412
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002413 if (rssi_thold == bss_conf->cqm_rssi_thold &&
2414 rssi_hyst == bss_conf->cqm_rssi_hyst)
2415 return 0;
2416
2417 bss_conf->cqm_rssi_thold = rssi_thold;
2418 bss_conf->cqm_rssi_hyst = rssi_hyst;
2419
2420 /* tell the driver upon association, unless already associated */
Johannes Bergea086352012-01-19 09:29:58 +01002421 if (sdata->u.mgd.associated &&
2422 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002423 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2424
2425 return 0;
2426}
2427
Johannes Berg99303802009-07-01 21:26:59 +02002428static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
2429 struct net_device *dev,
2430 const u8 *addr,
2431 const struct cfg80211_bitrate_mask *mask)
2432{
2433 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2434 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05302435 int i, ret;
Johannes Berg99303802009-07-01 21:26:59 +02002436
Eliad Peller554a43d2012-06-12 12:41:15 +03002437 if (!ieee80211_sdata_running(sdata))
2438 return -ENETDOWN;
2439
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05302440 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
2441 ret = drv_set_bitrate_mask(local, sdata, mask);
2442 if (ret)
2443 return ret;
2444 }
Johannes Berg99303802009-07-01 21:26:59 +02002445
Simon Wunderlich19468412012-01-28 17:25:33 +01002446 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
Felix Fietkau2ffbe6d2013-04-16 13:38:42 +02002447 struct ieee80211_supported_band *sband = wiphy->bands[i];
2448 int j;
2449
Jouni Malinen37eb0b12010-01-06 13:09:08 +02002450 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
Simon Wunderlich19468412012-01-28 17:25:33 +01002451 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
2452 sizeof(mask->control[i].mcs));
Felix Fietkau2ffbe6d2013-04-16 13:38:42 +02002453
2454 sdata->rc_has_mcs_mask[i] = false;
2455 if (!sband)
2456 continue;
2457
2458 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
2459 if (~sdata->rc_rateidx_mcs_mask[i][j]) {
2460 sdata->rc_has_mcs_mask[i] = true;
2461 break;
2462 }
Simon Wunderlich19468412012-01-28 17:25:33 +01002463 }
Johannes Berg99303802009-07-01 21:26:59 +02002464
Jouni Malinen37eb0b12010-01-06 13:09:08 +02002465 return 0;
Johannes Berg99303802009-07-01 21:26:59 +02002466}
2467
Johannes Berg2eb278e2012-06-05 14:28:42 +02002468static int ieee80211_start_roc_work(struct ieee80211_local *local,
2469 struct ieee80211_sub_if_data *sdata,
2470 struct ieee80211_channel *channel,
Johannes Berg2eb278e2012-06-05 14:28:42 +02002471 unsigned int duration, u64 *cookie,
Ilan Peerd339d5c2013-02-12 09:34:13 +02002472 struct sk_buff *txskb,
2473 enum ieee80211_roc_type type)
Johannes Berg21f83582010-12-18 17:20:47 +01002474{
Johannes Berg2eb278e2012-06-05 14:28:42 +02002475 struct ieee80211_roc_work *roc, *tmp;
2476 bool queued = false;
Johannes Berg21f83582010-12-18 17:20:47 +01002477 int ret;
Johannes Berg21f83582010-12-18 17:20:47 +01002478
2479 lockdep_assert_held(&local->mtx);
2480
Johannes Bergfe57d9f2012-07-26 14:55:08 +02002481 if (local->use_chanctx && !local->ops->remain_on_channel)
2482 return -EOPNOTSUPP;
2483
Johannes Berg2eb278e2012-06-05 14:28:42 +02002484 roc = kzalloc(sizeof(*roc), GFP_KERNEL);
2485 if (!roc)
2486 return -ENOMEM;
Johannes Berg21f83582010-12-18 17:20:47 +01002487
Johannes Berg2eb278e2012-06-05 14:28:42 +02002488 roc->chan = channel;
Johannes Berg2eb278e2012-06-05 14:28:42 +02002489 roc->duration = duration;
2490 roc->req_duration = duration;
2491 roc->frame = txskb;
Ilan Peerd339d5c2013-02-12 09:34:13 +02002492 roc->type = type;
Johannes Berg2eb278e2012-06-05 14:28:42 +02002493 roc->mgmt_tx_cookie = (unsigned long)txskb;
2494 roc->sdata = sdata;
2495 INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
2496 INIT_LIST_HEAD(&roc->dependents);
2497
2498 /* if there's one pending or we're scanning, queue this one */
Simon Wunderlich164eb022013-02-08 18:16:20 +01002499 if (!list_empty(&local->roc_list) ||
2500 local->scanning || local->radar_detect_enabled)
Johannes Berg2eb278e2012-06-05 14:28:42 +02002501 goto out_check_combine;
2502
2503 /* if not HW assist, just queue & schedule work */
2504 if (!local->ops->remain_on_channel) {
2505 ieee80211_queue_delayed_work(&local->hw, &roc->work, 0);
2506 goto out_queue;
Johannes Berg21f83582010-12-18 17:20:47 +01002507 }
2508
Johannes Berg2eb278e2012-06-05 14:28:42 +02002509 /* otherwise actually kick it off here (for error handling) */
2510
2511 /*
2512 * If the duration is zero, then the driver
2513 * wouldn't actually do anything. Set it to
2514 * 10 for now.
2515 *
2516 * TODO: cancel the off-channel operation
2517 * when we get the SKB's TX status and
2518 * the wait time was zero before.
2519 */
2520 if (!duration)
2521 duration = 10;
2522
Ilan Peerd339d5c2013-02-12 09:34:13 +02002523 ret = drv_remain_on_channel(local, sdata, channel, duration, type);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002524 if (ret) {
2525 kfree(roc);
2526 return ret;
2527 }
2528
2529 roc->started = true;
2530 goto out_queue;
2531
2532 out_check_combine:
2533 list_for_each_entry(tmp, &local->roc_list, list) {
Johannes Berg42d97a52012-11-08 18:31:02 +01002534 if (tmp->chan != channel || tmp->sdata != sdata)
Johannes Berg2eb278e2012-06-05 14:28:42 +02002535 continue;
2536
2537 /*
2538 * Extend this ROC if possible:
2539 *
2540 * If it hasn't started yet, just increase the duration
2541 * and add the new one to the list of dependents.
Ilan Peerd339d5c2013-02-12 09:34:13 +02002542 * If the type of the new ROC has higher priority, modify the
2543 * type of the previous one to match that of the new one.
Johannes Berg2eb278e2012-06-05 14:28:42 +02002544 */
2545 if (!tmp->started) {
2546 list_add_tail(&roc->list, &tmp->dependents);
2547 tmp->duration = max(tmp->duration, roc->duration);
Ilan Peerd339d5c2013-02-12 09:34:13 +02002548 tmp->type = max(tmp->type, roc->type);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002549 queued = true;
2550 break;
2551 }
2552
2553 /* If it has already started, it's more difficult ... */
2554 if (local->ops->remain_on_channel) {
2555 unsigned long j = jiffies;
2556
2557 /*
2558 * In the offloaded ROC case, if it hasn't begun, add
2559 * this new one to the dependent list to be handled
Ilan Peerd339d5c2013-02-12 09:34:13 +02002560 * when the master one begins. If it has begun,
Johannes Berg2eb278e2012-06-05 14:28:42 +02002561 * check that there's still a minimum time left and
2562 * if so, start this one, transmitting the frame, but
Ilan Peerd339d5c2013-02-12 09:34:13 +02002563 * add it to the list directly after this one with
Johannes Berg2eb278e2012-06-05 14:28:42 +02002564 * a reduced time so we'll ask the driver to execute
2565 * it right after finishing the previous one, in the
2566 * hope that it'll also be executed right afterwards,
2567 * effectively extending the old one.
2568 * If there's no minimum time left, just add it to the
2569 * normal list.
Ilan Peerd339d5c2013-02-12 09:34:13 +02002570 * TODO: the ROC type is ignored here, assuming that it
2571 * is better to immediately use the current ROC.
Johannes Berg2eb278e2012-06-05 14:28:42 +02002572 */
2573 if (!tmp->hw_begun) {
2574 list_add_tail(&roc->list, &tmp->dependents);
2575 queued = true;
2576 break;
2577 }
2578
2579 if (time_before(j + IEEE80211_ROC_MIN_LEFT,
2580 tmp->hw_start_time +
2581 msecs_to_jiffies(tmp->duration))) {
2582 int new_dur;
2583
2584 ieee80211_handle_roc_started(roc);
2585
2586 new_dur = roc->duration -
2587 jiffies_to_msecs(tmp->hw_start_time +
2588 msecs_to_jiffies(
2589 tmp->duration) -
2590 j);
2591
2592 if (new_dur > 0) {
2593 /* add right after tmp */
2594 list_add(&roc->list, &tmp->list);
2595 } else {
2596 list_add_tail(&roc->list,
2597 &tmp->dependents);
2598 }
2599 queued = true;
2600 }
2601 } else if (del_timer_sync(&tmp->work.timer)) {
2602 unsigned long new_end;
2603
2604 /*
2605 * In the software ROC case, cancel the timer, if
2606 * that fails then the finish work is already
2607 * queued/pending and thus we queue the new ROC
2608 * normally, if that succeeds then we can extend
2609 * the timer duration and TX the frame (if any.)
2610 */
2611
2612 list_add_tail(&roc->list, &tmp->dependents);
2613 queued = true;
2614
2615 new_end = jiffies + msecs_to_jiffies(roc->duration);
2616
2617 /* ok, it was started & we canceled timer */
2618 if (time_after(new_end, tmp->work.timer.expires))
2619 mod_timer(&tmp->work.timer, new_end);
2620 else
2621 add_timer(&tmp->work.timer);
2622
2623 ieee80211_handle_roc_started(roc);
2624 }
2625 break;
2626 }
2627
2628 out_queue:
2629 if (!queued)
2630 list_add_tail(&roc->list, &local->roc_list);
2631
2632 /*
Johannes Berg50febf62012-10-26 16:13:06 +02002633 * cookie is either the roc cookie (for normal roc)
Johannes Berg2eb278e2012-06-05 14:28:42 +02002634 * or the SKB (for mgmt TX)
2635 */
Johannes Berg50febf62012-10-26 16:13:06 +02002636 if (!txskb) {
2637 /* local->mtx protects this */
2638 local->roc_cookie_counter++;
2639 roc->cookie = local->roc_cookie_counter;
2640 /* wow, you wrapped 64 bits ... more likely a bug */
2641 if (WARN_ON(roc->cookie == 0)) {
2642 roc->cookie = 1;
2643 local->roc_cookie_counter++;
2644 }
2645 *cookie = roc->cookie;
2646 } else {
Johannes Berg2eb278e2012-06-05 14:28:42 +02002647 *cookie = (unsigned long)txskb;
Johannes Berg50febf62012-10-26 16:13:06 +02002648 }
Johannes Berg2eb278e2012-06-05 14:28:42 +02002649
2650 return 0;
Johannes Berg21f83582010-12-18 17:20:47 +01002651}
2652
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002653static int ieee80211_remain_on_channel(struct wiphy *wiphy,
Johannes Berg71bbc992012-06-15 15:30:18 +02002654 struct wireless_dev *wdev,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002655 struct ieee80211_channel *chan,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002656 unsigned int duration,
2657 u64 *cookie)
2658{
Johannes Berg71bbc992012-06-15 15:30:18 +02002659 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
Johannes Berg21f83582010-12-18 17:20:47 +01002660 struct ieee80211_local *local = sdata->local;
Johannes Berg21f83582010-12-18 17:20:47 +01002661 int ret;
2662
Johannes Berg2eb278e2012-06-05 14:28:42 +02002663 mutex_lock(&local->mtx);
Johannes Berg42d97a52012-11-08 18:31:02 +01002664 ret = ieee80211_start_roc_work(local, sdata, chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +02002665 duration, cookie, NULL,
2666 IEEE80211_ROC_TYPE_NORMAL);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002667 mutex_unlock(&local->mtx);
Johannes Berg21f83582010-12-18 17:20:47 +01002668
Johannes Berg2eb278e2012-06-05 14:28:42 +02002669 return ret;
2670}
2671
2672static int ieee80211_cancel_roc(struct ieee80211_local *local,
2673 u64 cookie, bool mgmt_tx)
2674{
2675 struct ieee80211_roc_work *roc, *tmp, *found = NULL;
2676 int ret;
2677
2678 mutex_lock(&local->mtx);
2679 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
Johannes Berge979e332012-06-11 17:09:41 +02002680 struct ieee80211_roc_work *dep, *tmp2;
2681
2682 list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) {
Johannes Berg50febf62012-10-26 16:13:06 +02002683 if (!mgmt_tx && dep->cookie != cookie)
Johannes Berge979e332012-06-11 17:09:41 +02002684 continue;
2685 else if (mgmt_tx && dep->mgmt_tx_cookie != cookie)
2686 continue;
2687 /* found dependent item -- just remove it */
2688 list_del(&dep->list);
2689 mutex_unlock(&local->mtx);
2690
Johannes Berg3fbd45c2013-03-25 11:51:14 +01002691 ieee80211_roc_notify_destroy(dep, true);
Johannes Berge979e332012-06-11 17:09:41 +02002692 return 0;
2693 }
2694
Johannes Berg50febf62012-10-26 16:13:06 +02002695 if (!mgmt_tx && roc->cookie != cookie)
Johannes Berg2eb278e2012-06-05 14:28:42 +02002696 continue;
2697 else if (mgmt_tx && roc->mgmt_tx_cookie != cookie)
2698 continue;
2699
2700 found = roc;
2701 break;
2702 }
2703
2704 if (!found) {
2705 mutex_unlock(&local->mtx);
Johannes Berg21f83582010-12-18 17:20:47 +01002706 return -ENOENT;
Johannes Berg2eb278e2012-06-05 14:28:42 +02002707 }
Johannes Berg21f83582010-12-18 17:20:47 +01002708
Johannes Berge979e332012-06-11 17:09:41 +02002709 /*
2710 * We found the item to cancel, so do that. Note that it
2711 * may have dependents, which we also cancel (and send
2712 * the expired signal for.) Not doing so would be quite
2713 * tricky here, but we may need to fix it later.
2714 */
2715
Johannes Berg2eb278e2012-06-05 14:28:42 +02002716 if (local->ops->remain_on_channel) {
2717 if (found->started) {
2718 ret = drv_cancel_remain_on_channel(local);
2719 if (WARN_ON_ONCE(ret)) {
2720 mutex_unlock(&local->mtx);
2721 return ret;
2722 }
2723 }
Johannes Berg21f83582010-12-18 17:20:47 +01002724
Johannes Berg2eb278e2012-06-05 14:28:42 +02002725 list_del(&found->list);
2726
Johannes Berg0f6b3f52012-06-20 20:11:33 +02002727 if (found->started)
2728 ieee80211_start_next_roc(local);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002729 mutex_unlock(&local->mtx);
2730
Johannes Berg3fbd45c2013-03-25 11:51:14 +01002731 ieee80211_roc_notify_destroy(found, true);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002732 } else {
2733 /* work may be pending so use it all the time */
2734 found->abort = true;
2735 ieee80211_queue_delayed_work(&local->hw, &found->work, 0);
2736
2737 mutex_unlock(&local->mtx);
2738
2739 /* work will clean up etc */
2740 flush_delayed_work(&found->work);
Johannes Berg3fbd45c2013-03-25 11:51:14 +01002741 WARN_ON(!found->to_be_freed);
2742 kfree(found);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002743 }
Johannes Berg21f83582010-12-18 17:20:47 +01002744
Johannes Berg21f83582010-12-18 17:20:47 +01002745 return 0;
2746}
2747
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002748static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
Johannes Berg71bbc992012-06-15 15:30:18 +02002749 struct wireless_dev *wdev,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002750 u64 cookie)
2751{
Johannes Berg71bbc992012-06-15 15:30:18 +02002752 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
Johannes Berg21f83582010-12-18 17:20:47 +01002753 struct ieee80211_local *local = sdata->local;
2754
Johannes Berg2eb278e2012-06-05 14:28:42 +02002755 return ieee80211_cancel_roc(local, cookie, false);
Johannes Bergf30221e2010-11-25 10:02:30 +01002756}
2757
Simon Wunderlich164eb022013-02-08 18:16:20 +01002758static int ieee80211_start_radar_detection(struct wiphy *wiphy,
2759 struct net_device *dev,
2760 struct cfg80211_chan_def *chandef)
2761{
2762 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2763 struct ieee80211_local *local = sdata->local;
2764 unsigned long timeout;
2765 int err;
2766
2767 if (!list_empty(&local->roc_list) || local->scanning)
2768 return -EBUSY;
2769
2770 /* whatever, but channel contexts should not complain about that one */
2771 sdata->smps_mode = IEEE80211_SMPS_OFF;
2772 sdata->needed_rx_chains = local->rx_chains;
2773 sdata->radar_required = true;
2774
2775 mutex_lock(&local->iflist_mtx);
2776 err = ieee80211_vif_use_channel(sdata, chandef,
2777 IEEE80211_CHANCTX_SHARED);
2778 mutex_unlock(&local->iflist_mtx);
2779 if (err)
2780 return err;
2781
2782 timeout = msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS);
2783 ieee80211_queue_delayed_work(&sdata->local->hw,
2784 &sdata->dfs_cac_timer_work, timeout);
2785
2786 return 0;
2787}
2788
Johannes Berg71bbc992012-06-15 15:30:18 +02002789static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002790 struct ieee80211_channel *chan, bool offchan,
Johannes Berg42d97a52012-11-08 18:31:02 +01002791 unsigned int wait, const u8 *buf, size_t len,
2792 bool no_cck, bool dont_wait_for_ack, u64 *cookie)
Jouni Malinen026331c2010-02-15 12:53:10 +02002793{
Johannes Berg71bbc992012-06-15 15:30:18 +02002794 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
Johannes Berg9d38d852010-06-09 17:20:33 +02002795 struct ieee80211_local *local = sdata->local;
2796 struct sk_buff *skb;
2797 struct sta_info *sta;
2798 const struct ieee80211_mgmt *mgmt = (void *)buf;
Johannes Berg2eb278e2012-06-05 14:28:42 +02002799 bool need_offchan = false;
Johannes Berge247bd902011-11-04 11:18:21 +01002800 u32 flags;
Johannes Berg2eb278e2012-06-05 14:28:42 +02002801 int ret;
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002802
Johannes Berge247bd902011-11-04 11:18:21 +01002803 if (dont_wait_for_ack)
2804 flags = IEEE80211_TX_CTL_NO_ACK;
2805 else
2806 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
2807 IEEE80211_TX_CTL_REQ_TX_STATUS;
2808
Rajkumar Manoharanaad14ce2011-09-25 14:53:31 +05302809 if (no_cck)
2810 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
2811
Johannes Berg9d38d852010-06-09 17:20:33 +02002812 switch (sdata->vif.type) {
2813 case NL80211_IFTYPE_ADHOC:
Johannes Berg2eb278e2012-06-05 14:28:42 +02002814 if (!sdata->vif.bss_conf.ibss_joined)
2815 need_offchan = true;
2816 /* fall through */
2817#ifdef CONFIG_MAC80211_MESH
2818 case NL80211_IFTYPE_MESH_POINT:
2819 if (ieee80211_vif_is_mesh(&sdata->vif) &&
2820 !sdata->u.mesh.mesh_id_len)
2821 need_offchan = true;
2822 /* fall through */
2823#endif
Johannes Berg663fcaf2010-09-30 21:06:09 +02002824 case NL80211_IFTYPE_AP:
2825 case NL80211_IFTYPE_AP_VLAN:
2826 case NL80211_IFTYPE_P2P_GO:
Johannes Berg2eb278e2012-06-05 14:28:42 +02002827 if (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
2828 !ieee80211_vif_is_mesh(&sdata->vif) &&
2829 !rcu_access_pointer(sdata->bss->beacon))
2830 need_offchan = true;
Johannes Berg663fcaf2010-09-30 21:06:09 +02002831 if (!ieee80211_is_action(mgmt->frame_control) ||
Thomas Pedersenac49e1a2013-06-20 23:50:58 -07002832 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC ||
2833 mgmt->u.action.category == WLAN_CATEGORY_SELF_PROTECTED)
Johannes Berg9d38d852010-06-09 17:20:33 +02002834 break;
2835 rcu_read_lock();
2836 sta = sta_info_get(sdata, mgmt->da);
2837 rcu_read_unlock();
2838 if (!sta)
2839 return -ENOLINK;
2840 break;
2841 case NL80211_IFTYPE_STATION:
Johannes Berg663fcaf2010-09-30 21:06:09 +02002842 case NL80211_IFTYPE_P2P_CLIENT:
Johannes Berg2eb278e2012-06-05 14:28:42 +02002843 if (!sdata->u.mgd.associated)
2844 need_offchan = true;
Johannes Berg9d38d852010-06-09 17:20:33 +02002845 break;
Johannes Bergf142c6b2012-06-18 20:07:15 +02002846 case NL80211_IFTYPE_P2P_DEVICE:
2847 need_offchan = true;
2848 break;
Johannes Berg9d38d852010-06-09 17:20:33 +02002849 default:
2850 return -EOPNOTSUPP;
2851 }
2852
Antonio Quartullif7aeb6f2013-06-11 14:20:00 +02002853 /* configurations requiring offchan cannot work if no channel has been
2854 * specified
2855 */
2856 if (need_offchan && !chan)
2857 return -EINVAL;
2858
Johannes Berg2eb278e2012-06-05 14:28:42 +02002859 mutex_lock(&local->mtx);
2860
2861 /* Check if the operating channel is the requested channel */
2862 if (!need_offchan) {
Johannes Berg55de9082012-07-26 17:24:39 +02002863 struct ieee80211_chanctx_conf *chanctx_conf;
2864
2865 rcu_read_lock();
2866 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2867
Antonio Quartullif7aeb6f2013-06-11 14:20:00 +02002868 if (chanctx_conf) {
2869 need_offchan = chan && (chan != chanctx_conf->def.chan);
2870 } else if (!chan) {
2871 ret = -EINVAL;
2872 rcu_read_unlock();
2873 goto out_unlock;
2874 } else {
Johannes Berg2eb278e2012-06-05 14:28:42 +02002875 need_offchan = true;
Antonio Quartullif7aeb6f2013-06-11 14:20:00 +02002876 }
Johannes Berg55de9082012-07-26 17:24:39 +02002877 rcu_read_unlock();
Johannes Berg2eb278e2012-06-05 14:28:42 +02002878 }
2879
2880 if (need_offchan && !offchan) {
2881 ret = -EBUSY;
2882 goto out_unlock;
2883 }
2884
Johannes Berg9d38d852010-06-09 17:20:33 +02002885 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002886 if (!skb) {
2887 ret = -ENOMEM;
2888 goto out_unlock;
2889 }
Johannes Berg9d38d852010-06-09 17:20:33 +02002890 skb_reserve(skb, local->hw.extra_tx_headroom);
2891
2892 memcpy(skb_put(skb, len), buf, len);
2893
2894 IEEE80211_SKB_CB(skb)->flags = flags;
2895
Johannes Berg2eb278e2012-06-05 14:28:42 +02002896 skb->dev = sdata->dev;
2897
2898 if (!need_offchan) {
Nicolas Cavallari7f9f78a2012-07-16 18:36:52 +02002899 *cookie = (unsigned long) skb;
Johannes Berg2eb278e2012-06-05 14:28:42 +02002900 ieee80211_tx_skb(sdata, skb);
2901 ret = 0;
2902 goto out_unlock;
2903 }
2904
Seth Forshee6c17b772013-02-11 11:21:07 -06002905 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN |
2906 IEEE80211_TX_INTFL_OFFCHAN_TX_OK;
Johannes Berg2eb278e2012-06-05 14:28:42 +02002907 if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
Johannes Berg3a25a8c2012-04-03 16:28:50 +02002908 IEEE80211_SKB_CB(skb)->hw_queue =
2909 local->hw.offchannel_tx_hw_queue;
2910
Johannes Berg2eb278e2012-06-05 14:28:42 +02002911 /* This will handle all kinds of coalescing and immediate TX */
Johannes Berg42d97a52012-11-08 18:31:02 +01002912 ret = ieee80211_start_roc_work(local, sdata, chan,
Ilan Peerd339d5c2013-02-12 09:34:13 +02002913 wait, cookie, skb,
2914 IEEE80211_ROC_TYPE_MGMT_TX);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002915 if (ret)
Johannes Bergf30221e2010-11-25 10:02:30 +01002916 kfree_skb(skb);
Johannes Berg2eb278e2012-06-05 14:28:42 +02002917 out_unlock:
2918 mutex_unlock(&local->mtx);
2919 return ret;
Jouni Malinen026331c2010-02-15 12:53:10 +02002920}
2921
Johannes Bergf30221e2010-11-25 10:02:30 +01002922static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
Johannes Berg71bbc992012-06-15 15:30:18 +02002923 struct wireless_dev *wdev,
Johannes Bergf30221e2010-11-25 10:02:30 +01002924 u64 cookie)
2925{
Johannes Berg71bbc992012-06-15 15:30:18 +02002926 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Bergf30221e2010-11-25 10:02:30 +01002927
Johannes Berg2eb278e2012-06-05 14:28:42 +02002928 return ieee80211_cancel_roc(local, cookie, true);
Johannes Bergf30221e2010-11-25 10:02:30 +01002929}
2930
Johannes Berg7be50862010-10-13 12:06:24 +02002931static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
Johannes Berg71bbc992012-06-15 15:30:18 +02002932 struct wireless_dev *wdev,
Johannes Berg7be50862010-10-13 12:06:24 +02002933 u16 frame_type, bool reg)
2934{
2935 struct ieee80211_local *local = wiphy_priv(wiphy);
2936
Will Hawkins6abe0562012-06-20 11:51:14 -04002937 switch (frame_type) {
Will Hawkins6abe0562012-06-20 11:51:14 -04002938 case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ:
2939 if (reg)
2940 local->probe_req_reg++;
2941 else
2942 local->probe_req_reg--;
Johannes Berg7be50862010-10-13 12:06:24 +02002943
Felix Fietkau35f51492012-10-31 15:50:34 +01002944 if (!local->open_count)
2945 break;
2946
Will Hawkins6abe0562012-06-20 11:51:14 -04002947 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2948 break;
2949 default:
2950 break;
2951 }
Johannes Berg7be50862010-10-13 12:06:24 +02002952}
2953
Bruno Randolf15d96752010-11-10 12:50:56 +09002954static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
2955{
2956 struct ieee80211_local *local = wiphy_priv(wiphy);
2957
2958 if (local->started)
2959 return -EOPNOTSUPP;
2960
2961 return drv_set_antenna(local, tx_ant, rx_ant);
2962}
2963
2964static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
2965{
2966 struct ieee80211_local *local = wiphy_priv(wiphy);
2967
2968 return drv_get_antenna(local, tx_ant, rx_ant);
2969}
2970
John W. Linville38c09152011-03-07 16:19:18 -05002971static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2972{
2973 struct ieee80211_local *local = wiphy_priv(wiphy);
2974
2975 return drv_set_ringparam(local, tx, rx);
2976}
2977
2978static void ieee80211_get_ringparam(struct wiphy *wiphy,
2979 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2980{
2981 struct ieee80211_local *local = wiphy_priv(wiphy);
2982
2983 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2984}
2985
Johannes Bergc68f4b82011-07-05 16:35:41 +02002986static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2987 struct net_device *dev,
2988 struct cfg80211_gtk_rekey_data *data)
2989{
2990 struct ieee80211_local *local = wiphy_priv(wiphy);
2991 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2992
2993 if (!local->ops->set_rekey_data)
2994 return -EOPNOTSUPP;
2995
2996 drv_set_rekey_data(local, sdata, data);
2997
2998 return 0;
2999}
3000
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003001static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
3002{
3003 u8 *pos = (void *)skb_put(skb, 7);
3004
3005 *pos++ = WLAN_EID_EXT_CAPABILITY;
3006 *pos++ = 5; /* len */
3007 *pos++ = 0x0;
3008 *pos++ = 0x0;
3009 *pos++ = 0x0;
3010 *pos++ = 0x0;
3011 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
3012}
3013
3014static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
3015{
3016 struct ieee80211_local *local = sdata->local;
3017 u16 capab;
3018
3019 capab = 0;
Johannes Berg55de9082012-07-26 17:24:39 +02003020 if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ)
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003021 return capab;
3022
3023 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
3024 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
3025 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
3026 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
3027
3028 return capab;
3029}
3030
3031static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
3032 u8 *peer, u8 *bssid)
3033{
3034 struct ieee80211_tdls_lnkie *lnkid;
3035
3036 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
3037
3038 lnkid->ie_type = WLAN_EID_LINK_ID;
3039 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
3040
3041 memcpy(lnkid->bssid, bssid, ETH_ALEN);
3042 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
3043 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
3044}
3045
3046static int
3047ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
3048 u8 *peer, u8 action_code, u8 dialog_token,
3049 u16 status_code, struct sk_buff *skb)
3050{
3051 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg55de9082012-07-26 17:24:39 +02003052 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003053 struct ieee80211_tdls_data *tf;
3054
3055 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
3056
3057 memcpy(tf->da, peer, ETH_ALEN);
3058 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
3059 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
3060 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
3061
3062 switch (action_code) {
3063 case WLAN_TDLS_SETUP_REQUEST:
3064 tf->category = WLAN_CATEGORY_TDLS;
3065 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
3066
3067 skb_put(skb, sizeof(tf->u.setup_req));
3068 tf->u.setup_req.dialog_token = dialog_token;
3069 tf->u.setup_req.capability =
3070 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
3071
Johannes Berg55de9082012-07-26 17:24:39 +02003072 ieee80211_add_srates_ie(sdata, skb, false, band);
3073 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003074 ieee80211_tdls_add_ext_capab(skb);
3075 break;
3076 case WLAN_TDLS_SETUP_RESPONSE:
3077 tf->category = WLAN_CATEGORY_TDLS;
3078 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
3079
3080 skb_put(skb, sizeof(tf->u.setup_resp));
3081 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
3082 tf->u.setup_resp.dialog_token = dialog_token;
3083 tf->u.setup_resp.capability =
3084 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
3085
Johannes Berg55de9082012-07-26 17:24:39 +02003086 ieee80211_add_srates_ie(sdata, skb, false, band);
3087 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003088 ieee80211_tdls_add_ext_capab(skb);
3089 break;
3090 case WLAN_TDLS_SETUP_CONFIRM:
3091 tf->category = WLAN_CATEGORY_TDLS;
3092 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
3093
3094 skb_put(skb, sizeof(tf->u.setup_cfm));
3095 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
3096 tf->u.setup_cfm.dialog_token = dialog_token;
3097 break;
3098 case WLAN_TDLS_TEARDOWN:
3099 tf->category = WLAN_CATEGORY_TDLS;
3100 tf->action_code = WLAN_TDLS_TEARDOWN;
3101
3102 skb_put(skb, sizeof(tf->u.teardown));
3103 tf->u.teardown.reason_code = cpu_to_le16(status_code);
3104 break;
3105 case WLAN_TDLS_DISCOVERY_REQUEST:
3106 tf->category = WLAN_CATEGORY_TDLS;
3107 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
3108
3109 skb_put(skb, sizeof(tf->u.discover_req));
3110 tf->u.discover_req.dialog_token = dialog_token;
3111 break;
3112 default:
3113 return -EINVAL;
3114 }
3115
3116 return 0;
3117}
3118
3119static int
3120ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
3121 u8 *peer, u8 action_code, u8 dialog_token,
3122 u16 status_code, struct sk_buff *skb)
3123{
3124 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg55de9082012-07-26 17:24:39 +02003125 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003126 struct ieee80211_mgmt *mgmt;
3127
3128 mgmt = (void *)skb_put(skb, 24);
3129 memset(mgmt, 0, 24);
3130 memcpy(mgmt->da, peer, ETH_ALEN);
3131 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
3132 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
3133
3134 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
3135 IEEE80211_STYPE_ACTION);
3136
3137 switch (action_code) {
3138 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
3139 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
3140 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
3141 mgmt->u.action.u.tdls_discover_resp.action_code =
3142 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
3143 mgmt->u.action.u.tdls_discover_resp.dialog_token =
3144 dialog_token;
3145 mgmt->u.action.u.tdls_discover_resp.capability =
3146 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
3147
Johannes Berg55de9082012-07-26 17:24:39 +02003148 ieee80211_add_srates_ie(sdata, skb, false, band);
3149 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003150 ieee80211_tdls_add_ext_capab(skb);
3151 break;
3152 default:
3153 return -EINVAL;
3154 }
3155
3156 return 0;
3157}
3158
3159static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
3160 u8 *peer, u8 action_code, u8 dialog_token,
3161 u16 status_code, const u8 *extra_ies,
3162 size_t extra_ies_len)
3163{
3164 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3165 struct ieee80211_local *local = sdata->local;
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003166 struct sk_buff *skb = NULL;
3167 bool send_direct;
3168 int ret;
3169
3170 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
3171 return -ENOTSUPP;
3172
3173 /* make sure we are in managed mode, and associated */
3174 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
3175 !sdata->u.mgd.associated)
3176 return -EINVAL;
3177
Johannes Bergbdcbd8e2012-06-22 11:29:50 +02003178 tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n",
3179 action_code, peer);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003180
3181 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
3182 max(sizeof(struct ieee80211_mgmt),
3183 sizeof(struct ieee80211_tdls_data)) +
3184 50 + /* supported rates */
3185 7 + /* ext capab */
3186 extra_ies_len +
3187 sizeof(struct ieee80211_tdls_lnkie));
3188 if (!skb)
3189 return -ENOMEM;
3190
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003191 skb_reserve(skb, local->hw.extra_tx_headroom);
3192
3193 switch (action_code) {
3194 case WLAN_TDLS_SETUP_REQUEST:
3195 case WLAN_TDLS_SETUP_RESPONSE:
3196 case WLAN_TDLS_SETUP_CONFIRM:
3197 case WLAN_TDLS_TEARDOWN:
3198 case WLAN_TDLS_DISCOVERY_REQUEST:
3199 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
3200 action_code, dialog_token,
3201 status_code, skb);
3202 send_direct = false;
3203 break;
3204 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
3205 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
3206 dialog_token, status_code,
3207 skb);
3208 send_direct = true;
3209 break;
3210 default:
3211 ret = -ENOTSUPP;
3212 break;
3213 }
3214
3215 if (ret < 0)
3216 goto fail;
3217
3218 if (extra_ies_len)
3219 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
3220
3221 /* the TDLS link IE is always added last */
3222 switch (action_code) {
3223 case WLAN_TDLS_SETUP_REQUEST:
3224 case WLAN_TDLS_SETUP_CONFIRM:
3225 case WLAN_TDLS_TEARDOWN:
3226 case WLAN_TDLS_DISCOVERY_REQUEST:
3227 /* we are the initiator */
3228 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
3229 sdata->u.mgd.bssid);
3230 break;
3231 case WLAN_TDLS_SETUP_RESPONSE:
3232 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
3233 /* we are the responder */
3234 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
3235 sdata->u.mgd.bssid);
3236 break;
3237 default:
3238 ret = -ENOTSUPP;
3239 goto fail;
3240 }
3241
3242 if (send_direct) {
3243 ieee80211_tx_skb(sdata, skb);
3244 return 0;
3245 }
3246
3247 /*
3248 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
3249 * we should default to AC_VI.
3250 */
3251 switch (action_code) {
3252 case WLAN_TDLS_SETUP_REQUEST:
3253 case WLAN_TDLS_SETUP_RESPONSE:
3254 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
3255 skb->priority = 2;
3256 break;
3257 default:
3258 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
3259 skb->priority = 5;
3260 break;
3261 }
3262
3263 /* disable bottom halves when entering the Tx path */
3264 local_bh_disable();
3265 ret = ieee80211_subif_start_xmit(skb, dev);
3266 local_bh_enable();
3267
3268 return ret;
3269
3270fail:
3271 dev_kfree_skb(skb);
3272 return ret;
3273}
3274
3275static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
3276 u8 *peer, enum nl80211_tdls_operation oper)
3277{
Arik Nemtsov941c93c2011-09-28 14:12:54 +03003278 struct sta_info *sta;
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003279 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3280
3281 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
3282 return -ENOTSUPP;
3283
3284 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3285 return -EINVAL;
3286
Johannes Bergbdcbd8e2012-06-22 11:29:50 +02003287 tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003288
3289 switch (oper) {
3290 case NL80211_TDLS_ENABLE_LINK:
Arik Nemtsov941c93c2011-09-28 14:12:54 +03003291 rcu_read_lock();
3292 sta = sta_info_get(sdata, peer);
3293 if (!sta) {
3294 rcu_read_unlock();
3295 return -ENOLINK;
3296 }
3297
Johannes Bergc2c98fd2011-09-29 16:04:36 +02003298 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
Arik Nemtsov941c93c2011-09-28 14:12:54 +03003299 rcu_read_unlock();
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003300 break;
3301 case NL80211_TDLS_DISABLE_LINK:
3302 return sta_info_destroy_addr(sdata, peer);
3303 case NL80211_TDLS_TEARDOWN:
3304 case NL80211_TDLS_SETUP:
3305 case NL80211_TDLS_DISCOVERY_REQ:
3306 /* We don't support in-driver setup/teardown/discovery */
3307 return -ENOTSUPP;
3308 default:
3309 return -ENOTSUPP;
3310 }
3311
3312 return 0;
3313}
3314
Johannes Berg06500732011-11-04 11:18:16 +01003315static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3316 const u8 *peer, u64 *cookie)
3317{
3318 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3319 struct ieee80211_local *local = sdata->local;
3320 struct ieee80211_qos_hdr *nullfunc;
3321 struct sk_buff *skb;
3322 int size = sizeof(*nullfunc);
3323 __le16 fc;
3324 bool qos;
3325 struct ieee80211_tx_info *info;
3326 struct sta_info *sta;
Johannes Berg55de9082012-07-26 17:24:39 +02003327 struct ieee80211_chanctx_conf *chanctx_conf;
3328 enum ieee80211_band band;
Johannes Berg06500732011-11-04 11:18:16 +01003329
3330 rcu_read_lock();
Johannes Berg55de9082012-07-26 17:24:39 +02003331 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3332 if (WARN_ON(!chanctx_conf)) {
3333 rcu_read_unlock();
3334 return -EINVAL;
3335 }
Johannes Berg4bf88532012-11-09 11:39:59 +01003336 band = chanctx_conf->def.chan->band;
Johannes Berg06500732011-11-04 11:18:16 +01003337 sta = sta_info_get(sdata, peer);
Johannes Bergb4487c22011-11-11 20:22:30 +01003338 if (sta) {
Johannes Berg06500732011-11-04 11:18:16 +01003339 qos = test_sta_flag(sta, WLAN_STA_WME);
Johannes Bergb4487c22011-11-11 20:22:30 +01003340 } else {
3341 rcu_read_unlock();
Johannes Berg06500732011-11-04 11:18:16 +01003342 return -ENOLINK;
Johannes Bergb4487c22011-11-11 20:22:30 +01003343 }
Johannes Berg06500732011-11-04 11:18:16 +01003344
3345 if (qos) {
3346 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3347 IEEE80211_STYPE_QOS_NULLFUNC |
3348 IEEE80211_FCTL_FROMDS);
3349 } else {
3350 size -= 2;
3351 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3352 IEEE80211_STYPE_NULLFUNC |
3353 IEEE80211_FCTL_FROMDS);
3354 }
3355
3356 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
Johannes Berg55de9082012-07-26 17:24:39 +02003357 if (!skb) {
3358 rcu_read_unlock();
Johannes Berg06500732011-11-04 11:18:16 +01003359 return -ENOMEM;
Johannes Berg55de9082012-07-26 17:24:39 +02003360 }
Johannes Berg06500732011-11-04 11:18:16 +01003361
3362 skb->dev = dev;
3363
3364 skb_reserve(skb, local->hw.extra_tx_headroom);
3365
3366 nullfunc = (void *) skb_put(skb, size);
3367 nullfunc->frame_control = fc;
3368 nullfunc->duration_id = 0;
3369 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
3370 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
3371 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
3372 nullfunc->seq_ctrl = 0;
3373
3374 info = IEEE80211_SKB_CB(skb);
3375
3376 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
3377 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
3378
3379 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
3380 skb->priority = 7;
3381 if (qos)
3382 nullfunc->qos_ctrl = cpu_to_le16(7);
3383
3384 local_bh_disable();
Johannes Berg55de9082012-07-26 17:24:39 +02003385 ieee80211_xmit(sdata, skb, band);
Johannes Berg06500732011-11-04 11:18:16 +01003386 local_bh_enable();
Johannes Berg55de9082012-07-26 17:24:39 +02003387 rcu_read_unlock();
Johannes Berg06500732011-11-04 11:18:16 +01003388
3389 *cookie = (unsigned long) skb;
3390 return 0;
3391}
3392
Johannes Berg683b6d32012-11-08 21:25:48 +01003393static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3394 struct wireless_dev *wdev,
3395 struct cfg80211_chan_def *chandef)
Johannes Berg5b7ccaf2012-07-12 19:45:08 +02003396{
Johannes Berg55de9082012-07-26 17:24:39 +02003397 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
Felix Fietkaucb601ff2013-02-23 19:02:14 +01003398 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg55de9082012-07-26 17:24:39 +02003399 struct ieee80211_chanctx_conf *chanctx_conf;
Johannes Berg683b6d32012-11-08 21:25:48 +01003400 int ret = -ENODATA;
Johannes Berg5b7ccaf2012-07-12 19:45:08 +02003401
Johannes Berg55de9082012-07-26 17:24:39 +02003402 rcu_read_lock();
Johannes Bergfeda3022013-02-28 09:59:22 +01003403 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3404 if (chanctx_conf) {
3405 *chandef = chanctx_conf->def;
3406 ret = 0;
3407 } else if (local->open_count > 0 &&
3408 local->open_count == local->monitors &&
3409 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3410 if (local->use_chanctx)
3411 *chandef = local->monitor_chandef;
3412 else
Karl Beldan675a0b02013-03-25 16:26:57 +01003413 *chandef = local->_oper_chandef;
Johannes Berg683b6d32012-11-08 21:25:48 +01003414 ret = 0;
Johannes Berg55de9082012-07-26 17:24:39 +02003415 }
3416 rcu_read_unlock();
3417
Johannes Berg683b6d32012-11-08 21:25:48 +01003418 return ret;
Johannes Berg5b7ccaf2012-07-12 19:45:08 +02003419}
3420
Johannes Berg6d525632012-04-04 15:05:25 +02003421#ifdef CONFIG_PM
3422static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
3423{
3424 drv_set_wakeup(wiphy_priv(wiphy), enabled);
3425}
3426#endif
3427
Jiri Bencf0706e82007-05-05 11:45:53 -07003428struct cfg80211_ops mac80211_config_ops = {
3429 .add_virtual_intf = ieee80211_add_iface,
3430 .del_virtual_intf = ieee80211_del_iface,
Johannes Berg42613db2007-09-28 21:52:27 +02003431 .change_virtual_intf = ieee80211_change_iface,
Johannes Bergf142c6b2012-06-18 20:07:15 +02003432 .start_p2p_device = ieee80211_start_p2p_device,
3433 .stop_p2p_device = ieee80211_stop_p2p_device,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01003434 .add_key = ieee80211_add_key,
3435 .del_key = ieee80211_del_key,
Johannes Berg62da92f2007-12-19 02:03:31 +01003436 .get_key = ieee80211_get_key,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01003437 .set_default_key = ieee80211_config_default_key,
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +02003438 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
Johannes Berg88600202012-02-13 15:17:18 +01003439 .start_ap = ieee80211_start_ap,
3440 .change_beacon = ieee80211_change_beacon,
3441 .stop_ap = ieee80211_stop_ap,
Johannes Berg4fd69312007-12-19 02:03:35 +01003442 .add_station = ieee80211_add_station,
3443 .del_station = ieee80211_del_station,
3444 .change_station = ieee80211_change_station,
Johannes Berg7bbdd2d2007-12-19 02:03:37 +01003445 .get_station = ieee80211_get_station,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01003446 .dump_station = ieee80211_dump_station,
Holger Schurig12897232010-04-19 10:23:57 +02003447 .dump_survey = ieee80211_dump_survey,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01003448#ifdef CONFIG_MAC80211_MESH
3449 .add_mpath = ieee80211_add_mpath,
3450 .del_mpath = ieee80211_del_mpath,
3451 .change_mpath = ieee80211_change_mpath,
3452 .get_mpath = ieee80211_get_mpath,
3453 .dump_mpath = ieee80211_dump_mpath,
Javier Cardona24bdd9f2010-12-16 17:37:48 -08003454 .update_mesh_config = ieee80211_update_mesh_config,
3455 .get_mesh_config = ieee80211_get_mesh_config,
Johannes Berg29cbe682010-12-03 09:20:44 +01003456 .join_mesh = ieee80211_join_mesh,
3457 .leave_mesh = ieee80211_leave_mesh,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01003458#endif
Jouni Malinen9f1ba902008-08-07 20:07:01 +03003459 .change_bss = ieee80211_change_bss,
Jouni Malinen31888482008-10-30 16:59:24 +02003460 .set_txq_params = ieee80211_set_txq_params,
Johannes Berge8c9bd52012-06-06 08:18:22 +02003461 .set_monitor_channel = ieee80211_set_monitor_channel,
Bob Copeland665af4f2009-01-19 11:20:53 -05003462 .suspend = ieee80211_suspend,
3463 .resume = ieee80211_resume,
Johannes Berg2a519312009-02-10 21:25:55 +01003464 .scan = ieee80211_scan,
Luciano Coelho79f460c2011-05-11 17:09:36 +03003465 .sched_scan_start = ieee80211_sched_scan_start,
3466 .sched_scan_stop = ieee80211_sched_scan_stop,
Jouni Malinen636a5d32009-03-19 13:39:22 +02003467 .auth = ieee80211_auth,
3468 .assoc = ieee80211_assoc,
3469 .deauth = ieee80211_deauth,
3470 .disassoc = ieee80211_disassoc,
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02003471 .join_ibss = ieee80211_join_ibss,
3472 .leave_ibss = ieee80211_leave_ibss,
Antonio Quartulli391e53e2012-11-02 13:27:49 +01003473 .set_mcast_rate = ieee80211_set_mcast_rate,
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02003474 .set_wiphy_params = ieee80211_set_wiphy_params,
Johannes Berg7643a2c2009-06-02 13:01:39 +02003475 .set_tx_power = ieee80211_set_tx_power,
3476 .get_tx_power = ieee80211_get_tx_power,
Johannes Bergab737a42009-07-01 21:26:58 +02003477 .set_wds_peer = ieee80211_set_wds_peer,
Johannes Berg1f87f7d2009-06-02 13:01:41 +02003478 .rfkill_poll = ieee80211_rfkill_poll,
Johannes Bergaff89a92009-07-01 21:26:51 +02003479 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
Wey-Yi Guy71063f02011-05-20 09:05:54 -07003480 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
Johannes Bergbc92afd2009-07-01 21:26:57 +02003481 .set_power_mgmt = ieee80211_set_power_mgmt,
Johannes Berg99303802009-07-01 21:26:59 +02003482 .set_bitrate_mask = ieee80211_set_bitrate_mask,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01003483 .remain_on_channel = ieee80211_remain_on_channel,
3484 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
Johannes Berg2e161f72010-08-12 15:38:38 +02003485 .mgmt_tx = ieee80211_mgmt_tx,
Johannes Bergf30221e2010-11-25 10:02:30 +01003486 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02003487 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
Johannes Berg7be50862010-10-13 12:06:24 +02003488 .mgmt_frame_register = ieee80211_mgmt_frame_register,
Bruno Randolf15d96752010-11-10 12:50:56 +09003489 .set_antenna = ieee80211_set_antenna,
3490 .get_antenna = ieee80211_get_antenna,
John W. Linville38c09152011-03-07 16:19:18 -05003491 .set_ringparam = ieee80211_set_ringparam,
3492 .get_ringparam = ieee80211_get_ringparam,
Johannes Bergc68f4b82011-07-05 16:35:41 +02003493 .set_rekey_data = ieee80211_set_rekey_data,
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03003494 .tdls_oper = ieee80211_tdls_oper,
3495 .tdls_mgmt = ieee80211_tdls_mgmt,
Johannes Berg06500732011-11-04 11:18:16 +01003496 .probe_client = ieee80211_probe_client,
Simon Wunderlichb53be792011-11-18 14:20:44 +01003497 .set_noack_map = ieee80211_set_noack_map,
Johannes Berg6d525632012-04-04 15:05:25 +02003498#ifdef CONFIG_PM
3499 .set_wakeup = ieee80211_set_wakeup,
3500#endif
Ben Greearb1ab7922012-04-23 12:50:30 -07003501 .get_et_sset_count = ieee80211_get_et_sset_count,
3502 .get_et_stats = ieee80211_get_et_stats,
3503 .get_et_strings = ieee80211_get_et_strings,
Johannes Berg5b7ccaf2012-07-12 19:45:08 +02003504 .get_channel = ieee80211_cfg_get_channel,
Simon Wunderlich164eb022013-02-08 18:16:20 +01003505 .start_radar_detection = ieee80211_start_radar_detection,
Jiri Bencf0706e82007-05-05 11:45:53 -07003506};