blob: a38b26730652cfd1d733294b4d3ef445240a1c8b [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 Bergf9e10ce2010-12-03 09:20:42 +010023static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name,
24 enum nl80211_iftype type,
25 u32 *flags,
26 struct vif_params *params)
Jiri Bencf0706e82007-05-05 11:45:53 -070027{
28 struct ieee80211_local *local = wiphy_priv(wiphy);
Michael Wu8cc9a732008-01-31 19:48:23 +010029 struct net_device *dev;
30 struct ieee80211_sub_if_data *sdata;
31 int err;
Jiri Bencf0706e82007-05-05 11:45:53 -070032
Johannes Berg05c914f2008-09-11 00:01:58 +020033 err = ieee80211_if_add(local, name, &dev, type, params);
Johannes Bergf9e10ce2010-12-03 09:20:42 +010034 if (err)
35 return ERR_PTR(err);
Michael Wu8cc9a732008-01-31 19:48:23 +010036
Johannes Bergf9e10ce2010-12-03 09:20:42 +010037 if (type == NL80211_IFTYPE_MONITOR && flags) {
38 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
39 sdata->u.mntr_flags = *flags;
40 }
41
42 return dev;
Jiri Bencf0706e82007-05-05 11:45:53 -070043}
44
Johannes Berg463d0182009-07-14 00:33:35 +020045static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev)
Jiri Bencf0706e82007-05-05 11:45:53 -070046{
Johannes Berg463d0182009-07-14 00:33:35 +020047 ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev));
Jiri Bencf0706e82007-05-05 11:45:53 -070048
Johannes Berg75636522008-07-09 14:40:35 +020049 return 0;
Jiri Bencf0706e82007-05-05 11:45:53 -070050}
51
Johannes Berge36d56b2009-06-09 21:04:43 +020052static int ieee80211_change_iface(struct wiphy *wiphy,
53 struct net_device *dev,
Luis Carlos Cobo2ec600d2008-02-23 15:17:06 +010054 enum nl80211_iftype type, u32 *flags,
55 struct vif_params *params)
Johannes Berg42613db2007-09-28 21:52:27 +020056{
Johannes Berg9607e6b662009-12-23 13:15:31 +010057 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Bergf3947e22008-07-09 14:40:36 +020058 int ret;
Johannes Berg42613db2007-09-28 21:52:27 +020059
Johannes Berg05c914f2008-09-11 00:01:58 +020060 ret = ieee80211_if_change_type(sdata, type);
Johannes Bergf3947e22008-07-09 14:40:36 +020061 if (ret)
62 return ret;
Johannes Berg42613db2007-09-28 21:52:27 +020063
Johannes Berg9bc383d2009-11-19 11:55:19 +010064 if (type == NL80211_IFTYPE_AP_VLAN &&
65 params && params->use_4addr == 0)
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +000066 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
Johannes Berg9bc383d2009-11-19 11:55:19 +010067 else if (type == NL80211_IFTYPE_STATION &&
68 params && params->use_4addr >= 0)
69 sdata->u.mgd.use_4addr = params->use_4addr;
70
Christian Lamparter85416a42010-10-02 13:17:07 +020071 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
72 struct ieee80211_local *local = sdata->local;
73
74 if (ieee80211_sdata_running(sdata)) {
75 /*
76 * Prohibit MONITOR_FLAG_COOK_FRAMES to be
77 * changed while the interface is up.
78 * Else we would need to add a lot of cruft
79 * to update everything:
80 * cooked_mntrs, monitor and all fif_* counters
81 * reconfigure hardware
82 */
83 if ((*flags & MONITOR_FLAG_COOK_FRAMES) !=
84 (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
85 return -EBUSY;
86
87 ieee80211_adjust_monitor_flags(sdata, -1);
88 sdata->u.mntr_flags = *flags;
89 ieee80211_adjust_monitor_flags(sdata, 1);
90
91 ieee80211_configure_filter(local);
92 } else {
93 /*
94 * Because the interface is down, ieee80211_do_stop
95 * and ieee80211_do_open take care of "everything"
96 * mentioned in the comment above.
97 */
98 sdata->u.mntr_flags = *flags;
99 }
100 }
Felix Fietkauf7917af2010-04-27 00:26:34 +0200101
Johannes Berg42613db2007-09-28 21:52:27 +0200102 return 0;
103}
104
Simon Wunderlichb53be792011-11-18 14:20:44 +0100105static int ieee80211_set_noack_map(struct wiphy *wiphy,
106 struct net_device *dev,
107 u16 noack_map)
108{
109 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
110
111 sdata->noack_map = noack_map;
112 return 0;
113}
114
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100115static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200116 u8 key_idx, bool pairwise, const u8 *mac_addr,
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100117 struct key_params *params)
118{
Johannes Berg26a58452010-08-27 12:35:55 +0200119 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100120 struct sta_info *sta = NULL;
Johannes Bergdb4d1162008-02-25 16:27:45 +0100121 struct ieee80211_key *key;
Johannes Berg3b967662008-04-08 17:56:52 +0200122 int err;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100123
Johannes Berg26a58452010-08-27 12:35:55 +0200124 if (!ieee80211_sdata_running(sdata))
Johannes Bergad0e2b52010-06-01 10:19:19 +0200125 return -ENETDOWN;
126
Johannes Berg97359d12010-08-10 09:46:38 +0200127 /* reject WEP and TKIP keys if WEP failed to initialize */
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100128 switch (params->cipher) {
129 case WLAN_CIPHER_SUITE_WEP40:
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100130 case WLAN_CIPHER_SUITE_TKIP:
Johannes Berg97359d12010-08-10 09:46:38 +0200131 case WLAN_CIPHER_SUITE_WEP104:
132 if (IS_ERR(sdata->local->wep_tx_tfm))
133 return -EINVAL;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200134 break;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100135 default:
Johannes Berg97359d12010-08-10 09:46:38 +0200136 break;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100137 }
138
Johannes Berg97359d12010-08-10 09:46:38 +0200139 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
140 params->key, params->seq_len, params->seq);
Ben Hutchings1ac62ba2010-08-01 17:37:03 +0100141 if (IS_ERR(key))
142 return PTR_ERR(key);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100143
Johannes Berge31b8212010-10-05 19:39:30 +0200144 if (pairwise)
145 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
146
Johannes Bergad0e2b52010-06-01 10:19:19 +0200147 mutex_lock(&sdata->local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200148
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100149 if (mac_addr) {
Thomas Pedersenff973af2011-05-03 16:57:12 -0700150 if (ieee80211_vif_is_mesh(&sdata->vif))
151 sta = sta_info_get(sdata, mac_addr);
152 else
153 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100154 if (!sta) {
Jouni Malinen32162a42010-07-26 15:52:03 -0700155 ieee80211_key_free(sdata->local, key);
Johannes Berg3b967662008-04-08 17:56:52 +0200156 err = -ENOENT;
157 goto out_unlock;
Johannes Bergdb4d1162008-02-25 16:27:45 +0100158 }
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100159 }
160
Johannes Berg3ffc2a92010-08-27 14:26:52 +0300161 err = ieee80211_key_link(key, sdata, sta);
162 if (err)
163 ieee80211_key_free(sdata->local, key);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100164
Johannes Berg3b967662008-04-08 17:56:52 +0200165 out_unlock:
Johannes Bergad0e2b52010-06-01 10:19:19 +0200166 mutex_unlock(&sdata->local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200167
168 return err;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100169}
170
171static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200172 u8 key_idx, bool pairwise, const u8 *mac_addr)
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100173{
Johannes Berg5c0c3642011-05-12 14:31:49 +0200174 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
175 struct ieee80211_local *local = sdata->local;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100176 struct sta_info *sta;
Johannes Berg5c0c3642011-05-12 14:31:49 +0200177 struct ieee80211_key *key = NULL;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100178 int ret;
179
Johannes Berg5c0c3642011-05-12 14:31:49 +0200180 mutex_lock(&local->sta_mtx);
181 mutex_lock(&local->key_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200182
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100183 if (mac_addr) {
Johannes Berg3b967662008-04-08 17:56:52 +0200184 ret = -ENOENT;
185
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100186 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100187 if (!sta)
Johannes Berg3b967662008-04-08 17:56:52 +0200188 goto out_unlock;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100189
Johannes Berg5c0c3642011-05-12 14:31:49 +0200190 if (pairwise)
Johannes Berg40b275b2011-05-13 14:15:49 +0200191 key = key_mtx_dereference(local, sta->ptk);
Johannes Berg5c0c3642011-05-12 14:31:49 +0200192 else
Johannes Berg40b275b2011-05-13 14:15:49 +0200193 key = key_mtx_dereference(local, sta->gtk[key_idx]);
Johannes Berg5c0c3642011-05-12 14:31:49 +0200194 } else
Johannes Berg40b275b2011-05-13 14:15:49 +0200195 key = key_mtx_dereference(local, sdata->keys[key_idx]);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100196
Johannes Berg5c0c3642011-05-12 14:31:49 +0200197 if (!key) {
Johannes Berg3b967662008-04-08 17:56:52 +0200198 ret = -ENOENT;
199 goto out_unlock;
200 }
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100201
Johannes Berg5c0c3642011-05-12 14:31:49 +0200202 __ieee80211_key_free(key);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100203
Johannes Berg3b967662008-04-08 17:56:52 +0200204 ret = 0;
205 out_unlock:
Johannes Berg5c0c3642011-05-12 14:31:49 +0200206 mutex_unlock(&local->key_mtx);
207 mutex_unlock(&local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200208
209 return ret;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100210}
211
Johannes Berg62da92f2007-12-19 02:03:31 +0100212static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200213 u8 key_idx, bool pairwise, const u8 *mac_addr,
214 void *cookie,
Johannes Berg62da92f2007-12-19 02:03:31 +0100215 void (*callback)(void *cookie,
216 struct key_params *params))
217{
Johannes Berg14db74b2008-07-29 13:22:52 +0200218 struct ieee80211_sub_if_data *sdata;
Johannes Berg62da92f2007-12-19 02:03:31 +0100219 struct sta_info *sta = NULL;
220 u8 seq[6] = {0};
221 struct key_params params;
Johannes Berge31b8212010-10-05 19:39:30 +0200222 struct ieee80211_key *key = NULL;
Johannes Bergaba83a0b2011-07-06 21:59:39 +0200223 u64 pn64;
Johannes Berg62da92f2007-12-19 02:03:31 +0100224 u32 iv32;
225 u16 iv16;
226 int err = -ENOENT;
227
Johannes Berg14db74b2008-07-29 13:22:52 +0200228 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
229
Johannes Berg3b967662008-04-08 17:56:52 +0200230 rcu_read_lock();
231
Johannes Berg62da92f2007-12-19 02:03:31 +0100232 if (mac_addr) {
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100233 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Berg62da92f2007-12-19 02:03:31 +0100234 if (!sta)
235 goto out;
236
Johannes Berge31b8212010-10-05 19:39:30 +0200237 if (pairwise)
Johannes Berga3836e02011-05-12 15:11:37 +0200238 key = rcu_dereference(sta->ptk);
Johannes Berge31b8212010-10-05 19:39:30 +0200239 else if (key_idx < NUM_DEFAULT_KEYS)
Johannes Berga3836e02011-05-12 15:11:37 +0200240 key = rcu_dereference(sta->gtk[key_idx]);
Johannes Berg62da92f2007-12-19 02:03:31 +0100241 } else
Johannes Berga3836e02011-05-12 15:11:37 +0200242 key = rcu_dereference(sdata->keys[key_idx]);
Johannes Berg62da92f2007-12-19 02:03:31 +0100243
244 if (!key)
245 goto out;
246
247 memset(&params, 0, sizeof(params));
248
Johannes Berg97359d12010-08-10 09:46:38 +0200249 params.cipher = key->conf.cipher;
Johannes Berg62da92f2007-12-19 02:03:31 +0100250
Johannes Berg97359d12010-08-10 09:46:38 +0200251 switch (key->conf.cipher) {
252 case WLAN_CIPHER_SUITE_TKIP:
Harvey Harrisonb0f76b32008-05-14 16:26:19 -0700253 iv32 = key->u.tkip.tx.iv32;
254 iv16 = key->u.tkip.tx.iv16;
Johannes Berg62da92f2007-12-19 02:03:31 +0100255
Johannes Berg24487982009-04-23 18:52:52 +0200256 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
257 drv_get_tkip_seq(sdata->local,
258 key->conf.hw_key_idx,
259 &iv32, &iv16);
Johannes Berg62da92f2007-12-19 02:03:31 +0100260
261 seq[0] = iv16 & 0xff;
262 seq[1] = (iv16 >> 8) & 0xff;
263 seq[2] = iv32 & 0xff;
264 seq[3] = (iv32 >> 8) & 0xff;
265 seq[4] = (iv32 >> 16) & 0xff;
266 seq[5] = (iv32 >> 24) & 0xff;
267 params.seq = seq;
268 params.seq_len = 6;
269 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200270 case WLAN_CIPHER_SUITE_CCMP:
Johannes Bergaba83a0b2011-07-06 21:59:39 +0200271 pn64 = atomic64_read(&key->u.ccmp.tx_pn);
272 seq[0] = pn64;
273 seq[1] = pn64 >> 8;
274 seq[2] = pn64 >> 16;
275 seq[3] = pn64 >> 24;
276 seq[4] = pn64 >> 32;
277 seq[5] = pn64 >> 40;
Johannes Berg62da92f2007-12-19 02:03:31 +0100278 params.seq = seq;
279 params.seq_len = 6;
280 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200281 case WLAN_CIPHER_SUITE_AES_CMAC:
Johannes Berg75396ae2011-07-06 22:00:35 +0200282 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
283 seq[0] = pn64;
284 seq[1] = pn64 >> 8;
285 seq[2] = pn64 >> 16;
286 seq[3] = pn64 >> 24;
287 seq[4] = pn64 >> 32;
288 seq[5] = pn64 >> 40;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200289 params.seq = seq;
290 params.seq_len = 6;
291 break;
Johannes Berg62da92f2007-12-19 02:03:31 +0100292 }
293
294 params.key = key->conf.key;
295 params.key_len = key->conf.keylen;
296
297 callback(cookie, &params);
298 err = 0;
299
300 out:
Johannes Berg3b967662008-04-08 17:56:52 +0200301 rcu_read_unlock();
Johannes Berg62da92f2007-12-19 02:03:31 +0100302 return err;
303}
304
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100305static int ieee80211_config_default_key(struct wiphy *wiphy,
306 struct net_device *dev,
Johannes Bergdbd2fd62010-12-09 19:58:59 +0100307 u8 key_idx, bool uni,
308 bool multi)
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100309{
Johannes Bergad0e2b52010-06-01 10:19:19 +0200310 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100311
Johannes Bergf7e01042010-12-09 19:49:02 +0100312 ieee80211_set_default_key(sdata, key_idx, uni, multi);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100313
314 return 0;
315}
316
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200317static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
318 struct net_device *dev,
319 u8 key_idx)
320{
Johannes Berg66c52422010-07-22 13:58:51 +0200321 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200322
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200323 ieee80211_set_default_mgmt_key(sdata, key_idx);
324
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200325 return 0;
326}
327
Felix Fietkau3af63342011-02-27 22:08:01 +0100328static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
329{
330 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
331 struct ieee80211_supported_band *sband;
332 sband = sta->local->hw.wiphy->bands[
333 sta->local->hw.conf.channel->band];
334 rate->legacy = sband->bitrates[idx].bitrate;
335 } else
336 rate->mcs = idx;
337}
338
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800339void sta_set_rate_info_tx(struct sta_info *sta,
340 const struct ieee80211_tx_rate *rate,
341 struct rate_info *rinfo)
342{
343 rinfo->flags = 0;
344 if (rate->flags & IEEE80211_TX_RC_MCS)
345 rinfo->flags |= RATE_INFO_FLAGS_MCS;
346 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
347 rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
348 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
349 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
350 rate_idx_to_bitrate(rinfo, sta, rate->idx);
351}
352
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100353static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
354{
Johannes Bergd0709a62008-02-25 16:27:46 +0100355 struct ieee80211_sub_if_data *sdata = sta->sdata;
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530356 struct timespec uptime;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100357
Johannes Bergf5ea9122009-08-07 16:17:38 +0200358 sinfo->generation = sdata->local->sta_generation;
359
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100360 sinfo->filled = STATION_INFO_INACTIVE_TIME |
361 STATION_INFO_RX_BYTES |
Henning Rogge420e7fa2008-12-11 22:04:19 +0100362 STATION_INFO_TX_BYTES |
Jouni Malinen98c8a60a2009-02-17 13:24:57 +0200363 STATION_INFO_RX_PACKETS |
364 STATION_INFO_TX_PACKETS |
Bruno Randolfb206b4ef2010-10-06 18:34:12 +0900365 STATION_INFO_TX_RETRIES |
366 STATION_INFO_TX_FAILED |
Ben Greear5a5c7312010-10-07 16:39:20 -0700367 STATION_INFO_TX_BITRATE |
Felix Fietkau3af63342011-02-27 22:08:01 +0100368 STATION_INFO_RX_BITRATE |
Paul Stewartf4263c92011-03-31 09:25:41 -0700369 STATION_INFO_RX_DROP_MISC |
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530370 STATION_INFO_BSS_PARAM |
Helmut Schaa7a724762011-10-13 16:30:40 +0200371 STATION_INFO_CONNECTED_TIME |
Paul Stewarta85e1d52011-12-09 11:01:49 -0800372 STATION_INFO_STA_FLAGS |
373 STATION_INFO_BEACON_LOSS_COUNT;
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530374
375 do_posix_clock_monotonic_gettime(&uptime);
376 sinfo->connected_time = uptime.tv_sec - sta->last_connected;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100377
378 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
379 sinfo->rx_bytes = sta->rx_bytes;
380 sinfo->tx_bytes = sta->tx_bytes;
Jouni Malinen98c8a60a2009-02-17 13:24:57 +0200381 sinfo->rx_packets = sta->rx_packets;
382 sinfo->tx_packets = sta->tx_packets;
Bruno Randolfb206b4ef2010-10-06 18:34:12 +0900383 sinfo->tx_retries = sta->tx_retry_count;
384 sinfo->tx_failed = sta->tx_retry_failed;
Ben Greear5a5c7312010-10-07 16:39:20 -0700385 sinfo->rx_dropped_misc = sta->rx_dropped;
Paul Stewarta85e1d52011-12-09 11:01:49 -0800386 sinfo->beacon_loss_count = sta->beacon_loss_count;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100387
John W. Linville19deffb2009-12-08 17:10:13 -0500388 if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
389 (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
Bruno Randolf541a45a2010-12-02 19:12:43 +0900390 sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
Henning Rogge420e7fa2008-12-11 22:04:19 +0100391 sinfo->signal = (s8)sta->last_signal;
Bruno Randolf541a45a2010-12-02 19:12:43 +0900392 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100393 }
394
Thomas Pedersen6b62bf32012-03-05 15:31:48 -0800395 sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100396
Felix Fietkau3af63342011-02-27 22:08:01 +0100397 sinfo->rxrate.flags = 0;
398 if (sta->last_rx_rate_flag & RX_FLAG_HT)
399 sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
400 if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
401 sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
402 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
403 sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
404 rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100405
Johannes Berg902acc72008-02-23 15:17:19 +0100406 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100407#ifdef CONFIG_MAC80211_MESH
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100408 sinfo->filled |= STATION_INFO_LLID |
409 STATION_INFO_PLID |
410 STATION_INFO_PLINK_STATE;
411
412 sinfo->llid = le16_to_cpu(sta->llid);
413 sinfo->plid = le16_to_cpu(sta->plid);
414 sinfo->plink_state = sta->plink_state;
Javier Cardonad299a1f2012-03-31 11:31:33 -0700415 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
416 sinfo->filled |= STATION_INFO_T_OFFSET;
417 sinfo->t_offset = sta->t_offset;
418 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100419#endif
Johannes Berg902acc72008-02-23 15:17:19 +0100420 }
Paul Stewartf4263c92011-03-31 09:25:41 -0700421
422 sinfo->bss_param.flags = 0;
423 if (sdata->vif.bss_conf.use_cts_prot)
424 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
425 if (sdata->vif.bss_conf.use_short_preamble)
426 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
427 if (sdata->vif.bss_conf.use_short_slot)
428 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
429 sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
430 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
Helmut Schaa7a724762011-10-13 16:30:40 +0200431
432 sinfo->sta_flags.set = 0;
433 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
434 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
435 BIT(NL80211_STA_FLAG_WME) |
436 BIT(NL80211_STA_FLAG_MFP) |
Helmut Schaae4121562011-11-05 14:15:24 +0100437 BIT(NL80211_STA_FLAG_AUTHENTICATED) |
438 BIT(NL80211_STA_FLAG_TDLS_PEER);
Helmut Schaa7a724762011-10-13 16:30:40 +0200439 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
440 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
441 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
442 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
443 if (test_sta_flag(sta, WLAN_STA_WME))
444 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
445 if (test_sta_flag(sta, WLAN_STA_MFP))
446 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
447 if (test_sta_flag(sta, WLAN_STA_AUTH))
448 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
Helmut Schaae4121562011-11-05 14:15:24 +0100449 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
450 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100451}
452
Ben Greearb1ab7922012-04-23 12:50:30 -0700453static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
454 "rx_packets", "rx_bytes", "wep_weak_iv_count",
455 "rx_duplicates", "rx_fragments", "rx_dropped",
456 "tx_packets", "tx_bytes", "tx_fragments",
457 "tx_filtered", "tx_retry_failed", "tx_retries",
458 "beacon_loss"
459};
460#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
461
462static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
463 struct net_device *dev,
464 int sset)
465{
Ben Greeare3521142012-04-23 12:50:31 -0700466 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
467 int rv = 0;
Ben Greearb1ab7922012-04-23 12:50:30 -0700468
Ben Greeare3521142012-04-23 12:50:31 -0700469 if (sset == ETH_SS_STATS)
470 rv += STA_STATS_LEN;
471
472 rv += drv_get_et_sset_count(sdata, sset);
473
474 if (rv == 0)
475 return -EOPNOTSUPP;
476 return rv;
Ben Greearb1ab7922012-04-23 12:50:30 -0700477}
478
479static void ieee80211_get_et_stats(struct wiphy *wiphy,
480 struct net_device *dev,
481 struct ethtool_stats *stats,
482 u64 *data)
483{
484 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
485 struct sta_info *sta;
486 struct ieee80211_local *local = sdata->local;
487 int i;
488
489 memset(data, 0, sizeof(u64) * STA_STATS_LEN);
490
491#define ADD_STA_STATS(sta) \
492 do { \
493 data[i++] += sta->rx_packets; \
494 data[i++] += sta->rx_bytes; \
495 data[i++] += sta->wep_weak_iv_count; \
496 data[i++] += sta->num_duplicates; \
497 data[i++] += sta->rx_fragments; \
498 data[i++] += sta->rx_dropped; \
499 \
500 data[i++] += sta->tx_packets; \
501 data[i++] += sta->tx_bytes; \
502 data[i++] += sta->tx_fragments; \
503 data[i++] += sta->tx_filtered_count; \
504 data[i++] += sta->tx_retry_failed; \
505 data[i++] += sta->tx_retry_count; \
506 data[i++] += sta->beacon_loss_count; \
507 } while (0)
508
509 /* For Managed stations, find the single station based on BSSID
510 * and use that. For interface types, iterate through all available
511 * stations and add stats for any station that is assigned to this
512 * network device.
513 */
514
515 rcu_read_lock();
516
517 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
518 sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
519 if (sta && !WARN_ON(sta->sdata->dev != dev)) {
520 i = 0;
521 ADD_STA_STATS(sta);
522 BUG_ON(i != STA_STATS_LEN);
523 }
524 } else {
525 list_for_each_entry_rcu(sta, &local->sta_list, list) {
526 /* Make sure this station belongs to the proper dev */
527 if (sta->sdata->dev != dev)
528 continue;
529
530 i = 0;
531 ADD_STA_STATS(sta);
532 BUG_ON(i != STA_STATS_LEN);
533 }
534 }
535
536 rcu_read_unlock();
Ben Greeare3521142012-04-23 12:50:31 -0700537
538 drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
Ben Greearb1ab7922012-04-23 12:50:30 -0700539}
540
541static void ieee80211_get_et_strings(struct wiphy *wiphy,
542 struct net_device *dev,
543 u32 sset, u8 *data)
544{
Ben Greeare3521142012-04-23 12:50:31 -0700545 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
546 int sz_sta_stats = 0;
547
Ben Greearb1ab7922012-04-23 12:50:30 -0700548 if (sset == ETH_SS_STATS) {
Ben Greeare3521142012-04-23 12:50:31 -0700549 sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
Ben Greearb1ab7922012-04-23 12:50:30 -0700550 memcpy(data, *ieee80211_gstrings_sta_stats, sz_sta_stats);
551 }
Ben Greeare3521142012-04-23 12:50:31 -0700552 drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
Ben Greearb1ab7922012-04-23 12:50:30 -0700553}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100554
555static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
556 int idx, u8 *mac, struct station_info *sinfo)
557{
Johannes Berg3b53fde82009-11-16 12:00:37 +0100558 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100559 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100560 int ret = -ENOENT;
561
562 rcu_read_lock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100563
Johannes Berg3b53fde82009-11-16 12:00:37 +0100564 sta = sta_info_get_by_idx(sdata, idx);
Johannes Bergd0709a62008-02-25 16:27:46 +0100565 if (sta) {
566 ret = 0;
Johannes Berg17741cd2008-09-11 00:02:02 +0200567 memcpy(mac, sta->sta.addr, ETH_ALEN);
Johannes Bergd0709a62008-02-25 16:27:46 +0100568 sta_set_sinfo(sta, sinfo);
569 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100570
Johannes Bergd0709a62008-02-25 16:27:46 +0100571 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100572
Johannes Bergd0709a62008-02-25 16:27:46 +0100573 return ret;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100574}
575
Holger Schurig12897232010-04-19 10:23:57 +0200576static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
577 int idx, struct survey_info *survey)
578{
579 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
580
Holger Schurig12897232010-04-19 10:23:57 +0200581 return drv_get_survey(local, idx, survey);
582}
583
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100584static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Luis Carlos Cobo2ec600d2008-02-23 15:17:06 +0100585 u8 *mac, struct station_info *sinfo)
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100586{
Johannes Bergabe60632009-11-25 17:46:18 +0100587 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100588 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100589 int ret = -ENOENT;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100590
Johannes Bergd0709a62008-02-25 16:27:46 +0100591 rcu_read_lock();
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100592
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100593 sta = sta_info_get_bss(sdata, mac);
Johannes Bergd0709a62008-02-25 16:27:46 +0100594 if (sta) {
595 ret = 0;
596 sta_set_sinfo(sta, sinfo);
597 }
598
599 rcu_read_unlock();
600
601 return ret;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100602}
603
Arik Nemtsov02945822011-11-10 11:28:57 +0200604static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
Johannes Berg88600202012-02-13 15:17:18 +0100605 const u8 *resp, size_t resp_len)
Arik Nemtsov02945822011-11-10 11:28:57 +0200606{
607 struct sk_buff *new, *old;
608
609 if (!resp || !resp_len)
Johannes Berg88600202012-02-13 15:17:18 +0100610 return 1;
Arik Nemtsov02945822011-11-10 11:28:57 +0200611
Arik Nemtsovf7248282011-11-19 10:51:26 +0200612 old = rtnl_dereference(sdata->u.ap.probe_resp);
Arik Nemtsov02945822011-11-10 11:28:57 +0200613
614 new = dev_alloc_skb(resp_len);
615 if (!new)
616 return -ENOMEM;
617
618 memcpy(skb_put(new, resp_len), resp, resp_len);
619
620 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
Johannes Berg88600202012-02-13 15:17:18 +0100621 if (old) {
622 /* TODO: use call_rcu() */
623 synchronize_rcu();
Arik Nemtsov02945822011-11-10 11:28:57 +0200624 dev_kfree_skb(old);
Johannes Berg88600202012-02-13 15:17:18 +0100625 }
Arik Nemtsov02945822011-11-10 11:28:57 +0200626
627 return 0;
628}
629
Johannes Berg88600202012-02-13 15:17:18 +0100630static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
631 struct cfg80211_beacon_data *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100632{
633 struct beacon_data *new, *old;
634 int new_head_len, new_tail_len;
Johannes Berg88600202012-02-13 15:17:18 +0100635 int size, err;
636 u32 changed = BSS_CHANGED_BEACON;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100637
Johannes Berg40b275b2011-05-13 14:15:49 +0200638 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100639
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100640 /* Need to have a beacon head if we don't have one yet */
641 if (!params->head && !old)
Johannes Berg88600202012-02-13 15:17:18 +0100642 return -EINVAL;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100643
644 /* new or old head? */
645 if (params->head)
646 new_head_len = params->head_len;
647 else
648 new_head_len = old->head_len;
649
650 /* new or old tail? */
651 if (params->tail || !old)
652 /* params->tail_len will be zero for !params->tail */
653 new_tail_len = params->tail_len;
654 else
655 new_tail_len = old->tail_len;
656
657 size = sizeof(*new) + new_head_len + new_tail_len;
658
659 new = kzalloc(size, GFP_KERNEL);
660 if (!new)
661 return -ENOMEM;
662
663 /* start filling the new info now */
664
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100665 /*
666 * pointers go into the block we allocated,
667 * memory is | beacon_data | head | tail |
668 */
669 new->head = ((u8 *) new) + sizeof(*new);
670 new->tail = new->head + new_head_len;
671 new->head_len = new_head_len;
672 new->tail_len = new_tail_len;
673
674 /* copy in head */
675 if (params->head)
676 memcpy(new->head, params->head, new_head_len);
677 else
678 memcpy(new->head, old->head, new_head_len);
679
680 /* copy in optional tail */
681 if (params->tail)
682 memcpy(new->tail, params->tail, new_tail_len);
683 else
684 if (old)
685 memcpy(new->tail, old->tail, new_tail_len);
686
Johannes Berg88600202012-02-13 15:17:18 +0100687 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
688 params->probe_resp_len);
689 if (err < 0)
690 return err;
691 if (err == 0)
692 changed |= BSS_CHANGED_AP_PROBE_RESP;
Johannes Berg19885c42010-02-05 11:45:06 +0100693
Eric Dumazetcf778b02012-01-12 04:41:32 +0000694 rcu_assign_pointer(sdata->u.ap.beacon, new);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100695
Johannes Berg88600202012-02-13 15:17:18 +0100696 if (old)
697 kfree_rcu(old, rcu_head);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100698
Johannes Berg88600202012-02-13 15:17:18 +0100699 return changed;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100700}
701
Johannes Berg88600202012-02-13 15:17:18 +0100702static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
703 struct cfg80211_ap_settings *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100704{
Johannes Berg88600202012-02-13 15:17:18 +0100705 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100706 struct beacon_data *old;
Johannes Berg665c93a2011-11-04 11:18:11 +0100707 struct ieee80211_sub_if_data *vlan;
Johannes Berg88600202012-02-13 15:17:18 +0100708 u32 changed = BSS_CHANGED_BEACON_INT |
709 BSS_CHANGED_BEACON_ENABLED |
710 BSS_CHANGED_BEACON |
711 BSS_CHANGED_SSID;
712 int err;
Johannes Berg14db74b2008-07-29 13:22:52 +0200713
Johannes Berg40b275b2011-05-13 14:15:49 +0200714 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100715 if (old)
716 return -EALREADY;
717
Johannes Berg665c93a2011-11-04 11:18:11 +0100718 /*
719 * Apply control port protocol, this allows us to
720 * not encrypt dynamic WEP control frames.
721 */
722 sdata->control_port_protocol = params->crypto.control_port_ethertype;
723 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
724 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
725 vlan->control_port_protocol =
726 params->crypto.control_port_ethertype;
727 vlan->control_port_no_encrypt =
728 params->crypto.control_port_no_encrypt;
729 }
730
Johannes Berg88600202012-02-13 15:17:18 +0100731 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
732 sdata->vif.bss_conf.dtim_period = params->dtim_period;
733
734 sdata->vif.bss_conf.ssid_len = params->ssid_len;
735 if (params->ssid_len)
736 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
737 params->ssid_len);
738 sdata->vif.bss_conf.hidden_ssid =
739 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
740
741 err = ieee80211_assign_beacon(sdata, &params->beacon);
742 if (err < 0)
743 return err;
744 changed |= err;
745
746 ieee80211_bss_info_change_notify(sdata, changed);
747
Johannes Berg3edaf3e2012-04-03 10:24:00 +0200748 netif_carrier_on(dev);
749 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
750 netif_carrier_on(vlan->dev);
751
Johannes Berg665c93a2011-11-04 11:18:11 +0100752 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100753}
754
Johannes Berg88600202012-02-13 15:17:18 +0100755static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
756 struct cfg80211_beacon_data *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100757{
Johannes Berg14db74b2008-07-29 13:22:52 +0200758 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100759 struct beacon_data *old;
Johannes Berg88600202012-02-13 15:17:18 +0100760 int err;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100761
Johannes Berg14db74b2008-07-29 13:22:52 +0200762 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
763
Johannes Berg40b275b2011-05-13 14:15:49 +0200764 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100765 if (!old)
766 return -ENOENT;
767
Johannes Berg88600202012-02-13 15:17:18 +0100768 err = ieee80211_assign_beacon(sdata, params);
769 if (err < 0)
770 return err;
771 ieee80211_bss_info_change_notify(sdata, err);
772 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100773}
774
Johannes Berg88600202012-02-13 15:17:18 +0100775static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100776{
Johannes Berg3edaf3e2012-04-03 10:24:00 +0200777 struct ieee80211_sub_if_data *sdata, *vlan;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100778 struct beacon_data *old;
779
Johannes Berg14db74b2008-07-29 13:22:52 +0200780 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
781
Johannes Berg40b275b2011-05-13 14:15:49 +0200782 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100783 if (!old)
784 return -ENOENT;
785
Johannes Berg3edaf3e2012-04-03 10:24:00 +0200786 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
787 netif_carrier_off(vlan->dev);
788 netif_carrier_off(dev);
789
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +0000790 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
Johannes Berg88600202012-02-13 15:17:18 +0100791
792 kfree_rcu(old, rcu_head);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100793
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200794 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
Johannes Berg88600202012-02-13 15:17:18 +0100795
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200796 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100797}
798
Johannes Berg4fd69312007-12-19 02:03:35 +0100799/* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
800struct iapp_layer2_update {
801 u8 da[ETH_ALEN]; /* broadcast */
802 u8 sa[ETH_ALEN]; /* STA addr */
803 __be16 len; /* 6 */
804 u8 dsap; /* 0 */
805 u8 ssap; /* 0 */
806 u8 control;
807 u8 xid_info[3];
Eric Dumazetbc105022010-06-03 03:21:52 -0700808} __packed;
Johannes Berg4fd69312007-12-19 02:03:35 +0100809
810static void ieee80211_send_layer2_update(struct sta_info *sta)
811{
812 struct iapp_layer2_update *msg;
813 struct sk_buff *skb;
814
815 /* Send Level 2 Update Frame to update forwarding tables in layer 2
816 * bridge devices */
817
818 skb = dev_alloc_skb(sizeof(*msg));
819 if (!skb)
820 return;
821 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
822
823 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
824 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
825
826 memset(msg->da, 0xff, ETH_ALEN);
Johannes Berg17741cd2008-09-11 00:02:02 +0200827 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
Johannes Berg4fd69312007-12-19 02:03:35 +0100828 msg->len = htons(6);
829 msg->dsap = 0;
830 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
831 msg->control = 0xaf; /* XID response lsb.1111F101.
832 * F=0 (no poll command; unsolicited frame) */
833 msg->xid_info[0] = 0x81; /* XID format identifier */
834 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
835 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
836
Johannes Bergd0709a62008-02-25 16:27:46 +0100837 skb->dev = sta->sdata->dev;
838 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
Johannes Berg4fd69312007-12-19 02:03:35 +0100839 memset(skb->cb, 0, sizeof(skb->cb));
John W. Linville06ee1c22010-07-19 11:52:59 -0400840 netif_rx_ni(skb);
Johannes Berg4fd69312007-12-19 02:03:35 +0100841}
842
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100843static int sta_apply_parameters(struct ieee80211_local *local,
844 struct sta_info *sta,
845 struct station_parameters *params)
Johannes Berg4fd69312007-12-19 02:03:35 +0100846{
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100847 int ret = 0;
Johannes Berg4fd69312007-12-19 02:03:35 +0100848 u32 rates;
849 int i, j;
Johannes Berg8318d782008-01-24 19:38:38 +0100850 struct ieee80211_supported_band *sband;
Johannes Bergd0709a62008-02-25 16:27:46 +0100851 struct ieee80211_sub_if_data *sdata = sta->sdata;
Johannes Bergeccb8e82009-05-11 21:57:56 +0300852 u32 mask, set;
Johannes Berg4fd69312007-12-19 02:03:35 +0100853
Johannes Bergae5eb022008-10-14 16:58:37 +0200854 sband = local->hw.wiphy->bands[local->oper_channel->band];
855
Johannes Bergeccb8e82009-05-11 21:57:56 +0300856 mask = params->sta_flags_mask;
857 set = params->sta_flags_set;
Johannes Berg73651ee2008-02-25 16:27:47 +0100858
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100859 /*
860 * In mesh mode, we can clear AUTHENTICATED flag but must
861 * also make ASSOCIATED follow appropriately for the driver
862 * API. See also below, after AUTHORIZED changes.
863 */
864 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
865 /* cfg80211 should not allow this in non-mesh modes */
866 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
867 return -EINVAL;
868
869 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
870 !test_sta_flag(sta, WLAN_STA_AUTH)) {
Johannes Berg83d5cc02012-01-12 09:31:10 +0100871 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100872 if (ret)
873 return ret;
Johannes Berg83d5cc02012-01-12 09:31:10 +0100874 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100875 if (ret)
876 return ret;
877 }
878 }
879
Johannes Bergeccb8e82009-05-11 21:57:56 +0300880 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300881 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Johannes Berg83d5cc02012-01-12 09:31:10 +0100882 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
Johannes Berg543d1b92012-01-13 14:17:59 +0100883 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
Johannes Berg83d5cc02012-01-12 09:31:10 +0100884 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100885 if (ret)
886 return ret;
Johannes Berg4fd69312007-12-19 02:03:35 +0100887 }
888
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100889 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
890 /* cfg80211 should not allow this in non-mesh modes */
891 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
892 return -EINVAL;
893
894 if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
895 test_sta_flag(sta, WLAN_STA_AUTH)) {
Johannes Berg83d5cc02012-01-12 09:31:10 +0100896 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100897 if (ret)
898 return ret;
Johannes Berg83d5cc02012-01-12 09:31:10 +0100899 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100900 if (ret)
901 return ret;
902 }
903 }
904
905
Johannes Bergeccb8e82009-05-11 21:57:56 +0300906 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300907 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200908 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
909 else
910 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300911 }
912
913 if (mask & BIT(NL80211_STA_FLAG_WME)) {
Arik Nemtsov39df6002011-06-27 23:58:45 +0300914 if (set & BIT(NL80211_STA_FLAG_WME)) {
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200915 set_sta_flag(sta, WLAN_STA_WME);
Arik Nemtsov39df6002011-06-27 23:58:45 +0300916 sta->sta.wme = true;
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200917 } else {
918 clear_sta_flag(sta, WLAN_STA_WME);
919 sta->sta.wme = false;
Arik Nemtsov39df6002011-06-27 23:58:45 +0300920 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300921 }
922
923 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300924 if (set & BIT(NL80211_STA_FLAG_MFP))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200925 set_sta_flag(sta, WLAN_STA_MFP);
926 else
927 clear_sta_flag(sta, WLAN_STA_MFP);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300928 }
Javier Cardonab39c48f2011-04-07 15:08:30 -0700929
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300930 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300931 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200932 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
933 else
934 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300935 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300936
Johannes Berg3b9ce802011-09-27 20:56:12 +0200937 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
938 sta->sta.uapsd_queues = params->uapsd_queues;
939 sta->sta.max_sp = params->max_sp;
940 }
Eliad Peller9533b4a2011-08-23 14:37:47 +0300941
Johannes Berg73651ee2008-02-25 16:27:47 +0100942 /*
Johannes Berg51b50fb2009-05-24 16:42:30 +0200943 * cfg80211 validates this (1-2007) and allows setting the AID
944 * only when creating a new station entry
945 */
946 if (params->aid)
947 sta->sta.aid = params->aid;
948
949 /*
Johannes Berg73651ee2008-02-25 16:27:47 +0100950 * FIXME: updating the following information is racy when this
951 * function is called from ieee80211_change_station().
952 * However, all this information should be static so
953 * maybe we should just reject attemps to change it.
954 */
955
Johannes Berg4fd69312007-12-19 02:03:35 +0100956 if (params->listen_interval >= 0)
957 sta->listen_interval = params->listen_interval;
958
959 if (params->supported_rates) {
960 rates = 0;
Johannes Berg8318d782008-01-24 19:38:38 +0100961
Johannes Berg4fd69312007-12-19 02:03:35 +0100962 for (i = 0; i < params->supported_rates_len; i++) {
963 int rate = (params->supported_rates[i] & 0x7f) * 5;
Johannes Berg8318d782008-01-24 19:38:38 +0100964 for (j = 0; j < sband->n_bitrates; j++) {
965 if (sband->bitrates[j].bitrate == rate)
Johannes Berg4fd69312007-12-19 02:03:35 +0100966 rates |= BIT(j);
967 }
968 }
Johannes Berg323ce792008-09-11 02:45:11 +0200969 sta->sta.supp_rates[local->oper_channel->band] = rates;
Johannes Berg4fd69312007-12-19 02:03:35 +0100970 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100971
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200972 if (params->ht_capa)
Ben Greearef96a8422011-11-18 11:32:00 -0800973 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
Johannes Bergae5eb022008-10-14 16:58:37 +0200974 params->ht_capa,
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200975 &sta->sta.ht_cap);
Jouni Malinen36aedc92008-08-25 11:58:58 +0300976
Javier Cardona9c3990a2011-05-03 16:57:11 -0700977 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400978#ifdef CONFIG_MAC80211_MESH
Javier Cardona9c3990a2011-05-03 16:57:11 -0700979 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
980 switch (params->plink_state) {
Javier Cardona57cf8042011-05-13 10:45:43 -0700981 case NL80211_PLINK_LISTEN:
982 case NL80211_PLINK_ESTAB:
983 case NL80211_PLINK_BLOCKED:
Javier Cardona9c3990a2011-05-03 16:57:11 -0700984 sta->plink_state = params->plink_state;
985 break;
986 default:
987 /* nothing */
988 break;
989 }
990 else
991 switch (params->plink_action) {
992 case PLINK_ACTION_OPEN:
993 mesh_plink_open(sta);
994 break;
995 case PLINK_ACTION_BLOCK:
996 mesh_plink_block(sta);
997 break;
998 }
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400999#endif
Johannes Berg902acc72008-02-23 15:17:19 +01001000 }
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001001
1002 return 0;
Johannes Berg4fd69312007-12-19 02:03:35 +01001003}
1004
1005static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1006 u8 *mac, struct station_parameters *params)
1007{
Johannes Berg14db74b2008-07-29 13:22:52 +02001008 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +01001009 struct sta_info *sta;
1010 struct ieee80211_sub_if_data *sdata;
Johannes Berg73651ee2008-02-25 16:27:47 +01001011 int err;
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001012 int layer2_update;
Johannes Berg4fd69312007-12-19 02:03:35 +01001013
Johannes Berg4fd69312007-12-19 02:03:35 +01001014 if (params->vlan) {
1015 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1016
Johannes Berg05c914f2008-09-11 00:01:58 +02001017 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1018 sdata->vif.type != NL80211_IFTYPE_AP)
Johannes Berg4fd69312007-12-19 02:03:35 +01001019 return -EINVAL;
1020 } else
1021 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1022
Johannes Berg47846c92009-11-25 17:46:19 +01001023 if (compare_ether_addr(mac, sdata->vif.addr) == 0)
Johannes Berg03e44972008-02-27 09:56:40 +01001024 return -EINVAL;
1025
1026 if (is_multicast_ether_addr(mac))
1027 return -EINVAL;
1028
1029 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +01001030 if (!sta)
1031 return -ENOMEM;
Johannes Berg4fd69312007-12-19 02:03:35 +01001032
Johannes Berg83d5cc02012-01-12 09:31:10 +01001033 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1034 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
Johannes Berg4fd69312007-12-19 02:03:35 +01001035
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001036 err = sta_apply_parameters(local, sta, params);
1037 if (err) {
1038 sta_info_free(local, sta);
1039 return err;
1040 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001041
Arik Nemtsovd64cf632011-11-07 23:24:39 +02001042 /*
1043 * for TDLS, rate control should be initialized only when supported
1044 * rates are known.
1045 */
1046 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER))
1047 rate_control_rate_init(sta);
Johannes Berg4fd69312007-12-19 02:03:35 +01001048
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001049 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1050 sdata->vif.type == NL80211_IFTYPE_AP;
1051
Johannes Berg34e89502010-02-03 13:59:58 +01001052 err = sta_info_insert_rcu(sta);
Johannes Berg73651ee2008-02-25 16:27:47 +01001053 if (err) {
Johannes Berg73651ee2008-02-25 16:27:47 +01001054 rcu_read_unlock();
1055 return err;
1056 }
1057
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001058 if (layer2_update)
Johannes Berg73651ee2008-02-25 16:27:47 +01001059 ieee80211_send_layer2_update(sta);
1060
1061 rcu_read_unlock();
1062
Johannes Berg4fd69312007-12-19 02:03:35 +01001063 return 0;
1064}
1065
1066static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1067 u8 *mac)
1068{
Johannes Berg14db74b2008-07-29 13:22:52 +02001069 struct ieee80211_local *local = wiphy_priv(wiphy);
1070 struct ieee80211_sub_if_data *sdata;
Johannes Berg4fd69312007-12-19 02:03:35 +01001071
Johannes Berg14db74b2008-07-29 13:22:52 +02001072 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1073
Johannes Berg34e89502010-02-03 13:59:58 +01001074 if (mac)
1075 return sta_info_destroy_addr_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001076
Johannes Berg34e89502010-02-03 13:59:58 +01001077 sta_info_flush(local, sdata);
Johannes Berg4fd69312007-12-19 02:03:35 +01001078 return 0;
1079}
1080
1081static int ieee80211_change_station(struct wiphy *wiphy,
1082 struct net_device *dev,
1083 u8 *mac,
1084 struct station_parameters *params)
1085{
Johannes Bergabe60632009-11-25 17:46:18 +01001086 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg14db74b2008-07-29 13:22:52 +02001087 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +01001088 struct sta_info *sta;
1089 struct ieee80211_sub_if_data *vlansdata;
Eliad Peller35b88622011-12-29 14:41:39 +02001090 int err;
Johannes Berg4fd69312007-12-19 02:03:35 +01001091
Johannes Berg87be1e12011-12-14 12:20:29 +01001092 mutex_lock(&local->sta_mtx);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001093
Felix Fietkau0e5ded52010-01-08 18:10:58 +01001094 sta = sta_info_get_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001095 if (!sta) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001096 mutex_unlock(&local->sta_mtx);
Johannes Berg4fd69312007-12-19 02:03:35 +01001097 return -ENOENT;
Johannes Berg98dd6a52008-04-10 15:36:09 +02001098 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001099
Johannes Bergbdd90d52011-12-14 12:20:27 +01001100 /* in station mode, supported rates are only valid with TDLS */
1101 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1102 params->supported_rates &&
1103 !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001104 mutex_unlock(&local->sta_mtx);
Johannes Bergbdd90d52011-12-14 12:20:27 +01001105 return -EINVAL;
1106 }
1107
Johannes Bergd0709a62008-02-25 16:27:46 +01001108 if (params->vlan && params->vlan != sta->sdata->dev) {
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001109 bool prev_4addr = false;
1110 bool new_4addr = false;
1111
Johannes Berg4fd69312007-12-19 02:03:35 +01001112 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1113
Johannes Berg05c914f2008-09-11 00:01:58 +02001114 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1115 vlansdata->vif.type != NL80211_IFTYPE_AP) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001116 mutex_unlock(&local->sta_mtx);
Johannes Berg4fd69312007-12-19 02:03:35 +01001117 return -EINVAL;
Johannes Berg98dd6a52008-04-10 15:36:09 +02001118 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001119
Johannes Berg9bc383d2009-11-19 11:55:19 +01001120 if (params->vlan->ieee80211_ptr->use_4addr) {
Johannes Berg33054432009-11-20 10:09:14 +01001121 if (vlansdata->u.vlan.sta) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001122 mutex_unlock(&local->sta_mtx);
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001123 return -EBUSY;
Johannes Berg33054432009-11-20 10:09:14 +01001124 }
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001125
Eric Dumazetcf778b02012-01-12 04:41:32 +00001126 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001127 new_4addr = true;
1128 }
1129
1130 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1131 sta->sdata->u.vlan.sta) {
1132 rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL);
1133 prev_4addr = true;
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001134 }
1135
Johannes Berg14db74b2008-07-29 13:22:52 +02001136 sta->sdata = vlansdata;
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001137
1138 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
1139 prev_4addr != new_4addr) {
1140 if (new_4addr)
1141 atomic_dec(&sta->sdata->bss->num_mcast_sta);
1142 else
1143 atomic_inc(&sta->sdata->bss->num_mcast_sta);
1144 }
1145
Johannes Berg4fd69312007-12-19 02:03:35 +01001146 ieee80211_send_layer2_update(sta);
1147 }
1148
Eliad Peller35b88622011-12-29 14:41:39 +02001149 err = sta_apply_parameters(local, sta, params);
1150 if (err) {
1151 mutex_unlock(&local->sta_mtx);
1152 return err;
1153 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001154
Arik Nemtsovd64cf632011-11-07 23:24:39 +02001155 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates)
1156 rate_control_rate_init(sta);
1157
Johannes Berg87be1e12011-12-14 12:20:29 +01001158 mutex_unlock(&local->sta_mtx);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001159
Jason Young808118c2011-03-10 16:43:19 -08001160 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1161 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))
1162 ieee80211_recalc_ps(local, -1);
1163
Johannes Berg4fd69312007-12-19 02:03:35 +01001164 return 0;
1165}
1166
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001167#ifdef CONFIG_MAC80211_MESH
1168static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1169 u8 *dst, u8 *next_hop)
1170{
Johannes Berg14db74b2008-07-29 13:22:52 +02001171 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001172 struct mesh_path *mpath;
1173 struct sta_info *sta;
1174 int err;
1175
Johannes Berg14db74b2008-07-29 13:22:52 +02001176 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1177
Johannes Bergd0709a62008-02-25 16:27:46 +01001178 rcu_read_lock();
Johannes Bergabe60632009-11-25 17:46:18 +01001179 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +01001180 if (!sta) {
1181 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001182 return -ENOENT;
Johannes Bergd0709a62008-02-25 16:27:46 +01001183 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001184
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001185 err = mesh_path_add(dst, sdata);
Johannes Bergd0709a62008-02-25 16:27:46 +01001186 if (err) {
1187 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001188 return err;
Johannes Bergd0709a62008-02-25 16:27:46 +01001189 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001190
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001191 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001192 if (!mpath) {
1193 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001194 return -ENXIO;
1195 }
1196 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +01001197
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001198 rcu_read_unlock();
1199 return 0;
1200}
1201
1202static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1203 u8 *dst)
1204{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001205 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001206
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001207 if (dst)
1208 return mesh_path_del(dst, sdata);
1209
Javier Cardonaece1a2e2011-08-29 13:23:04 -07001210 mesh_path_flush_by_iface(sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001211 return 0;
1212}
1213
1214static int ieee80211_change_mpath(struct wiphy *wiphy,
1215 struct net_device *dev,
1216 u8 *dst, u8 *next_hop)
1217{
Johannes Berg14db74b2008-07-29 13:22:52 +02001218 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001219 struct mesh_path *mpath;
1220 struct sta_info *sta;
1221
Johannes Berg14db74b2008-07-29 13:22:52 +02001222 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1223
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001224 rcu_read_lock();
Johannes Bergd0709a62008-02-25 16:27:46 +01001225
Johannes Bergabe60632009-11-25 17:46:18 +01001226 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +01001227 if (!sta) {
1228 rcu_read_unlock();
1229 return -ENOENT;
1230 }
1231
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001232 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001233 if (!mpath) {
1234 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001235 return -ENOENT;
1236 }
1237
1238 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +01001239
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001240 rcu_read_unlock();
1241 return 0;
1242}
1243
1244static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1245 struct mpath_info *pinfo)
1246{
Johannes Berga3836e02011-05-12 15:11:37 +02001247 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1248
1249 if (next_hop_sta)
1250 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001251 else
1252 memset(next_hop, 0, ETH_ALEN);
1253
Johannes Bergf5ea9122009-08-07 16:17:38 +02001254 pinfo->generation = mesh_paths_generation;
1255
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001256 pinfo->filled = MPATH_INFO_FRAME_QLEN |
Rui Paulod19b3bf2009-11-09 23:46:55 +00001257 MPATH_INFO_SN |
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001258 MPATH_INFO_METRIC |
1259 MPATH_INFO_EXPTIME |
1260 MPATH_INFO_DISCOVERY_TIMEOUT |
1261 MPATH_INFO_DISCOVERY_RETRIES |
1262 MPATH_INFO_FLAGS;
1263
1264 pinfo->frame_qlen = mpath->frame_queue.qlen;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001265 pinfo->sn = mpath->sn;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001266 pinfo->metric = mpath->metric;
1267 if (time_before(jiffies, mpath->exp_time))
1268 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1269 pinfo->discovery_timeout =
1270 jiffies_to_msecs(mpath->discovery_timeout);
1271 pinfo->discovery_retries = mpath->discovery_retries;
1272 pinfo->flags = 0;
1273 if (mpath->flags & MESH_PATH_ACTIVE)
1274 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1275 if (mpath->flags & MESH_PATH_RESOLVING)
1276 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001277 if (mpath->flags & MESH_PATH_SN_VALID)
1278 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001279 if (mpath->flags & MESH_PATH_FIXED)
1280 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1281 if (mpath->flags & MESH_PATH_RESOLVING)
1282 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1283
1284 pinfo->flags = mpath->flags;
1285}
1286
1287static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1288 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1289
1290{
Johannes Berg14db74b2008-07-29 13:22:52 +02001291 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001292 struct mesh_path *mpath;
1293
Johannes Berg14db74b2008-07-29 13:22:52 +02001294 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1295
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001296 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001297 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001298 if (!mpath) {
1299 rcu_read_unlock();
1300 return -ENOENT;
1301 }
1302 memcpy(dst, mpath->dst, ETH_ALEN);
1303 mpath_set_pinfo(mpath, next_hop, pinfo);
1304 rcu_read_unlock();
1305 return 0;
1306}
1307
1308static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1309 int idx, u8 *dst, u8 *next_hop,
1310 struct mpath_info *pinfo)
1311{
Johannes Berg14db74b2008-07-29 13:22:52 +02001312 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001313 struct mesh_path *mpath;
1314
Johannes Berg14db74b2008-07-29 13:22:52 +02001315 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1316
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001317 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001318 mpath = mesh_path_lookup_by_idx(idx, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001319 if (!mpath) {
1320 rcu_read_unlock();
1321 return -ENOENT;
1322 }
1323 memcpy(dst, mpath->dst, ETH_ALEN);
1324 mpath_set_pinfo(mpath, next_hop, pinfo);
1325 rcu_read_unlock();
1326 return 0;
1327}
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001328
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001329static int ieee80211_get_mesh_config(struct wiphy *wiphy,
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001330 struct net_device *dev,
1331 struct mesh_config *conf)
1332{
1333 struct ieee80211_sub_if_data *sdata;
1334 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1335
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001336 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1337 return 0;
1338}
1339
1340static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1341{
1342 return (mask >> (parm-1)) & 0x1;
1343}
1344
Javier Cardonac80d5452010-12-16 17:37:49 -08001345static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1346 const struct mesh_setup *setup)
1347{
1348 u8 *new_ie;
1349 const u8 *old_ie;
Chun-Yeow Yeoh4bb62342011-11-24 17:15:20 -08001350 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
1351 struct ieee80211_sub_if_data, u.mesh);
Javier Cardonac80d5452010-12-16 17:37:49 -08001352
Javier Cardona581a8b02011-04-07 15:08:27 -07001353 /* allocate information elements */
Javier Cardonac80d5452010-12-16 17:37:49 -08001354 new_ie = NULL;
Javier Cardona581a8b02011-04-07 15:08:27 -07001355 old_ie = ifmsh->ie;
Javier Cardonac80d5452010-12-16 17:37:49 -08001356
Javier Cardona581a8b02011-04-07 15:08:27 -07001357 if (setup->ie_len) {
1358 new_ie = kmemdup(setup->ie, setup->ie_len,
Javier Cardonac80d5452010-12-16 17:37:49 -08001359 GFP_KERNEL);
1360 if (!new_ie)
1361 return -ENOMEM;
1362 }
Javier Cardona581a8b02011-04-07 15:08:27 -07001363 ifmsh->ie_len = setup->ie_len;
1364 ifmsh->ie = new_ie;
1365 kfree(old_ie);
Javier Cardonac80d5452010-12-16 17:37:49 -08001366
1367 /* now copy the rest of the setup parameters */
1368 ifmsh->mesh_id_len = setup->mesh_id_len;
1369 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
Javier Cardonad299a1f2012-03-31 11:31:33 -07001370 ifmsh->mesh_sp_id = setup->sync_method;
Javier Cardonac80d5452010-12-16 17:37:49 -08001371 ifmsh->mesh_pp_id = setup->path_sel_proto;
1372 ifmsh->mesh_pm_id = setup->path_metric;
Javier Cardonab130e5c2011-05-03 16:57:07 -07001373 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1374 if (setup->is_authenticated)
1375 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1376 if (setup->is_secure)
1377 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
Javier Cardonac80d5452010-12-16 17:37:49 -08001378
Chun-Yeow Yeoh4bb62342011-11-24 17:15:20 -08001379 /* mcast rate setting in Mesh Node */
1380 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
1381 sizeof(setup->mcast_rate));
1382
Javier Cardonac80d5452010-12-16 17:37:49 -08001383 return 0;
1384}
1385
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001386static int ieee80211_update_mesh_config(struct wiphy *wiphy,
Johannes Berg29cbe682010-12-03 09:20:44 +01001387 struct net_device *dev, u32 mask,
1388 const struct mesh_config *nconf)
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001389{
1390 struct mesh_config *conf;
1391 struct ieee80211_sub_if_data *sdata;
Rui Paulo63c57232009-11-09 23:46:57 +00001392 struct ieee80211_if_mesh *ifmsh;
1393
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001394 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Rui Paulo63c57232009-11-09 23:46:57 +00001395 ifmsh = &sdata->u.mesh;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001396
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001397 /* Set the config options which we are interested in setting */
1398 conf = &(sdata->u.mesh.mshcfg);
1399 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1400 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1401 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1402 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1403 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1404 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1405 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1406 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1407 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1408 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1409 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1410 conf->dot11MeshTTL = nconf->dot11MeshTTL;
Javier Cardona45904f22010-12-03 09:20:40 +01001411 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1412 conf->dot11MeshTTL = nconf->element_ttl;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001413 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
1414 conf->auto_open_plinks = nconf->auto_open_plinks;
Javier Cardonad299a1f2012-03-31 11:31:33 -07001415 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
1416 conf->dot11MeshNbrOffsetMaxNeighbor =
1417 nconf->dot11MeshNbrOffsetMaxNeighbor;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001418 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1419 conf->dot11MeshHWMPmaxPREQretries =
1420 nconf->dot11MeshHWMPmaxPREQretries;
1421 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1422 conf->path_refresh_time = nconf->path_refresh_time;
1423 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1424 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1425 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1426 conf->dot11MeshHWMPactivePathTimeout =
1427 nconf->dot11MeshHWMPactivePathTimeout;
1428 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1429 conf->dot11MeshHWMPpreqMinInterval =
1430 nconf->dot11MeshHWMPpreqMinInterval;
Thomas Pedersendca7e942011-11-24 17:15:24 -08001431 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
1432 conf->dot11MeshHWMPperrMinInterval =
1433 nconf->dot11MeshHWMPperrMinInterval;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001434 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1435 mask))
1436 conf->dot11MeshHWMPnetDiameterTraversalTime =
1437 nconf->dot11MeshHWMPnetDiameterTraversalTime;
Rui Paulo63c57232009-11-09 23:46:57 +00001438 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1439 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1440 ieee80211_mesh_root_setup(ifmsh);
1441 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001442 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
Thomas Pedersenc61336612011-08-25 10:36:14 -07001443 /* our current gate announcement implementation rides on root
1444 * announcements, so require this ifmsh to also be a root node
1445 * */
1446 if (nconf->dot11MeshGateAnnouncementProtocol &&
1447 !conf->dot11MeshHWMPRootMode) {
1448 conf->dot11MeshHWMPRootMode = 1;
1449 ieee80211_mesh_root_setup(ifmsh);
1450 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001451 conf->dot11MeshGateAnnouncementProtocol =
1452 nconf->dot11MeshGateAnnouncementProtocol;
1453 }
Javier Cardona0507e152011-08-09 16:45:10 -07001454 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) {
1455 conf->dot11MeshHWMPRannInterval =
1456 nconf->dot11MeshHWMPRannInterval;
1457 }
Chun-Yeow Yeoh94f90652012-01-21 01:02:16 +08001458 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1459 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
Ashok Nagarajan55335132012-02-28 17:04:08 -08001460 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
1461 /* our RSSI threshold implementation is supported only for
1462 * devices that report signal in dBm.
1463 */
1464 if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM))
1465 return -ENOTSUPP;
1466 conf->rssi_threshold = nconf->rssi_threshold;
1467 }
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001468 return 0;
1469}
1470
Johannes Berg29cbe682010-12-03 09:20:44 +01001471static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1472 const struct mesh_config *conf,
1473 const struct mesh_setup *setup)
1474{
1475 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1476 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
Javier Cardonac80d5452010-12-16 17:37:49 -08001477 int err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001478
Javier Cardonac80d5452010-12-16 17:37:49 -08001479 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1480 err = copy_mesh_setup(ifmsh, setup);
1481 if (err)
1482 return err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001483 ieee80211_start_mesh(sdata);
1484
1485 return 0;
1486}
1487
1488static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1489{
1490 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1491
1492 ieee80211_stop_mesh(sdata);
1493
1494 return 0;
1495}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001496#endif
1497
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001498static int ieee80211_change_bss(struct wiphy *wiphy,
1499 struct net_device *dev,
1500 struct bss_parameters *params)
1501{
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001502 struct ieee80211_sub_if_data *sdata;
1503 u32 changed = 0;
1504
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001505 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1506
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001507 if (params->use_cts_prot >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001508 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001509 changed |= BSS_CHANGED_ERP_CTS_PROT;
1510 }
1511 if (params->use_short_preamble >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001512 sdata->vif.bss_conf.use_short_preamble =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001513 params->use_short_preamble;
1514 changed |= BSS_CHANGED_ERP_PREAMBLE;
1515 }
Felix Fietkau43d35342010-01-15 03:00:48 +01001516
1517 if (!sdata->vif.bss_conf.use_short_slot &&
1518 sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) {
1519 sdata->vif.bss_conf.use_short_slot = true;
1520 changed |= BSS_CHANGED_ERP_SLOT;
1521 }
1522
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001523 if (params->use_short_slot_time >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001524 sdata->vif.bss_conf.use_short_slot =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001525 params->use_short_slot_time;
1526 changed |= BSS_CHANGED_ERP_SLOT;
1527 }
1528
Jouni Malinen90c97a02008-10-30 16:59:22 +02001529 if (params->basic_rates) {
1530 int i, j;
1531 u32 rates = 0;
1532 struct ieee80211_local *local = wiphy_priv(wiphy);
1533 struct ieee80211_supported_band *sband =
1534 wiphy->bands[local->oper_channel->band];
1535
1536 for (i = 0; i < params->basic_rates_len; i++) {
1537 int rate = (params->basic_rates[i] & 0x7f) * 5;
1538 for (j = 0; j < sband->n_bitrates; j++) {
1539 if (sband->bitrates[j].bitrate == rate)
1540 rates |= BIT(j);
1541 }
1542 }
1543 sdata->vif.bss_conf.basic_rates = rates;
1544 changed |= BSS_CHANGED_BASIC_RATES;
1545 }
1546
Felix Fietkau7b7b5e52010-04-27 01:23:36 +02001547 if (params->ap_isolate >= 0) {
1548 if (params->ap_isolate)
1549 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1550 else
1551 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1552 }
1553
Helmut Schaa80d7e402010-11-19 12:40:26 +01001554 if (params->ht_opmode >= 0) {
1555 sdata->vif.bss_conf.ht_operation_mode =
1556 (u16) params->ht_opmode;
1557 changed |= BSS_CHANGED_HT;
1558 }
1559
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001560 ieee80211_bss_info_change_notify(sdata, changed);
1561
1562 return 0;
1563}
1564
Jouni Malinen31888482008-10-30 16:59:24 +02001565static int ieee80211_set_txq_params(struct wiphy *wiphy,
Eliad Pellerf70f01c2011-09-25 20:06:53 +03001566 struct net_device *dev,
Jouni Malinen31888482008-10-30 16:59:24 +02001567 struct ieee80211_txq_params *params)
1568{
1569 struct ieee80211_local *local = wiphy_priv(wiphy);
Eliad Pellerf6f3def2011-09-25 20:06:54 +03001570 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen31888482008-10-30 16:59:24 +02001571 struct ieee80211_tx_queue_params p;
1572
1573 if (!local->ops->conf_tx)
1574 return -EOPNOTSUPP;
1575
Johannes Berg54bcbc62012-03-28 11:04:25 +02001576 if (local->hw.queues < IEEE80211_NUM_ACS)
1577 return -EOPNOTSUPP;
1578
Jouni Malinen31888482008-10-30 16:59:24 +02001579 memset(&p, 0, sizeof(p));
1580 p.aifs = params->aifs;
1581 p.cw_max = params->cwmax;
1582 p.cw_min = params->cwmin;
1583 p.txop = params->txop;
Kalle Valoab133152010-01-12 10:42:31 +02001584
1585 /*
1586 * Setting tx queue params disables u-apsd because it's only
1587 * called in master mode.
1588 */
1589 p.uapsd = false;
1590
Johannes Berga3304b02012-03-28 11:04:24 +02001591 sdata->tx_conf[params->ac] = p;
1592 if (drv_conf_tx(local, sdata, params->ac, &p)) {
Joe Perches0fb9a9e2010-08-20 16:25:38 -07001593 wiphy_debug(local->hw.wiphy,
Johannes Berga3304b02012-03-28 11:04:24 +02001594 "failed to set TX queue parameters for AC %d\n",
1595 params->ac);
Jouni Malinen31888482008-10-30 16:59:24 +02001596 return -EINVAL;
1597 }
1598
1599 return 0;
1600}
1601
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001602static int ieee80211_set_channel(struct wiphy *wiphy,
Johannes Bergf444de02010-05-05 15:25:02 +02001603 struct net_device *netdev,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001604 struct ieee80211_channel *chan,
Sujith094d05d2008-12-12 11:57:43 +05301605 enum nl80211_channel_type channel_type)
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001606{
1607 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg0aaffa92010-05-05 15:28:27 +02001608 struct ieee80211_sub_if_data *sdata = NULL;
Ben Greeareeabee72011-01-28 10:20:47 -08001609 struct ieee80211_channel *old_oper;
1610 enum nl80211_channel_type old_oper_type;
1611 enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001612
1613 if (netdev)
1614 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001615
Johannes Bergf444de02010-05-05 15:25:02 +02001616 switch (ieee80211_get_channel_mode(local, NULL)) {
1617 case CHAN_MODE_HOPPING:
1618 return -EBUSY;
1619 case CHAN_MODE_FIXED:
Johannes Berg0aaffa92010-05-05 15:28:27 +02001620 if (local->oper_channel != chan)
1621 return -EBUSY;
1622 if (!sdata && local->_oper_channel_type == channel_type)
Johannes Bergf444de02010-05-05 15:25:02 +02001623 return 0;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001624 break;
Johannes Bergf444de02010-05-05 15:25:02 +02001625 case CHAN_MODE_UNDEFINED:
1626 break;
1627 }
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001628
Ben Greeareeabee72011-01-28 10:20:47 -08001629 if (sdata)
1630 old_vif_oper_type = sdata->vif.bss_conf.channel_type;
1631 old_oper_type = local->_oper_channel_type;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001632
Johannes Berg0aaffa92010-05-05 15:28:27 +02001633 if (!ieee80211_set_channel_type(local, sdata, channel_type))
1634 return -EBUSY;
1635
Ben Greeareeabee72011-01-28 10:20:47 -08001636 old_oper = local->oper_channel;
1637 local->oper_channel = chan;
1638
1639 /* Update driver if changes were actually made. */
1640 if ((old_oper != local->oper_channel) ||
1641 (old_oper_type != local->_oper_channel_type))
1642 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1643
Johannes Bergef5af742011-10-18 13:39:14 +02001644 if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR &&
Ben Greeareeabee72011-01-28 10:20:47 -08001645 old_vif_oper_type != sdata->vif.bss_conf.channel_type)
Johannes Berg0aaffa92010-05-05 15:28:27 +02001646 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1647
1648 return 0;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001649}
1650
Bob Copeland665af4f2009-01-19 11:20:53 -05001651#ifdef CONFIG_PM
Johannes Bergff1b6e62011-05-04 15:37:28 +02001652static int ieee80211_suspend(struct wiphy *wiphy,
1653 struct cfg80211_wowlan *wowlan)
Bob Copeland665af4f2009-01-19 11:20:53 -05001654{
Johannes Bergeecc4802011-05-04 15:37:29 +02001655 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
Bob Copeland665af4f2009-01-19 11:20:53 -05001656}
1657
1658static int ieee80211_resume(struct wiphy *wiphy)
1659{
1660 return __ieee80211_resume(wiphy_priv(wiphy));
1661}
1662#else
1663#define ieee80211_suspend NULL
1664#define ieee80211_resume NULL
1665#endif
1666
Johannes Berg2a519312009-02-10 21:25:55 +01001667static int ieee80211_scan(struct wiphy *wiphy,
1668 struct net_device *dev,
1669 struct cfg80211_scan_request *req)
1670{
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001671 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg2a519312009-02-10 21:25:55 +01001672
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001673 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
1674 case NL80211_IFTYPE_STATION:
1675 case NL80211_IFTYPE_ADHOC:
1676 case NL80211_IFTYPE_MESH_POINT:
1677 case NL80211_IFTYPE_P2P_CLIENT:
1678 break;
1679 case NL80211_IFTYPE_P2P_GO:
1680 if (sdata->local->ops->hw_scan)
1681 break;
Johannes Berge9d77322011-02-01 15:35:36 +01001682 /*
1683 * FIXME: implement NoA while scanning in software,
1684 * for now fall through to allow scanning only when
1685 * beaconing hasn't been configured yet
1686 */
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001687 case NL80211_IFTYPE_AP:
1688 if (sdata->u.ap.beacon)
1689 return -EOPNOTSUPP;
1690 break;
1691 default:
1692 return -EOPNOTSUPP;
1693 }
Johannes Berg2a519312009-02-10 21:25:55 +01001694
1695 return ieee80211_request_scan(sdata, req);
1696}
1697
Luciano Coelho79f460c2011-05-11 17:09:36 +03001698static int
1699ieee80211_sched_scan_start(struct wiphy *wiphy,
1700 struct net_device *dev,
1701 struct cfg80211_sched_scan_request *req)
1702{
1703 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1704
1705 if (!sdata->local->ops->sched_scan_start)
1706 return -EOPNOTSUPP;
1707
1708 return ieee80211_request_sched_scan_start(sdata, req);
1709}
1710
1711static int
Luciano Coelho85a99942011-05-12 16:28:29 +03001712ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
Luciano Coelho79f460c2011-05-11 17:09:36 +03001713{
1714 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1715
1716 if (!sdata->local->ops->sched_scan_stop)
1717 return -EOPNOTSUPP;
1718
Luciano Coelho85a99942011-05-12 16:28:29 +03001719 return ieee80211_request_sched_scan_stop(sdata);
Luciano Coelho79f460c2011-05-11 17:09:36 +03001720}
1721
Jouni Malinen636a5d32009-03-19 13:39:22 +02001722static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1723 struct cfg80211_auth_request *req)
1724{
Johannes Berg77fdaa12009-07-07 03:45:17 +02001725 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001726}
1727
1728static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1729 struct cfg80211_assoc_request *req)
1730{
Johannes Bergf444de02010-05-05 15:25:02 +02001731 struct ieee80211_local *local = wiphy_priv(wiphy);
1732 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1733
1734 switch (ieee80211_get_channel_mode(local, sdata)) {
1735 case CHAN_MODE_HOPPING:
1736 return -EBUSY;
1737 case CHAN_MODE_FIXED:
1738 if (local->oper_channel == req->bss->channel)
1739 break;
1740 return -EBUSY;
1741 case CHAN_MODE_UNDEFINED:
1742 break;
1743 }
1744
Johannes Berg77fdaa12009-07-07 03:45:17 +02001745 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001746}
1747
1748static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001749 struct cfg80211_deauth_request *req)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001750{
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001751 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001752}
1753
1754static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001755 struct cfg80211_disassoc_request *req)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001756{
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001757 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001758}
1759
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001760static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1761 struct cfg80211_ibss_params *params)
1762{
Johannes Bergf444de02010-05-05 15:25:02 +02001763 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001764 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1765
Johannes Bergf444de02010-05-05 15:25:02 +02001766 switch (ieee80211_get_channel_mode(local, sdata)) {
1767 case CHAN_MODE_HOPPING:
1768 return -EBUSY;
1769 case CHAN_MODE_FIXED:
1770 if (!params->channel_fixed)
1771 return -EBUSY;
1772 if (local->oper_channel == params->channel)
1773 break;
1774 return -EBUSY;
1775 case CHAN_MODE_UNDEFINED:
1776 break;
1777 }
1778
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001779 return ieee80211_ibss_join(sdata, params);
1780}
1781
1782static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1783{
1784 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1785
1786 return ieee80211_ibss_leave(sdata);
1787}
1788
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001789static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1790{
1791 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg24487982009-04-23 18:52:52 +02001792 int err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001793
Arik Nemtsovf23a4782010-11-08 11:51:06 +02001794 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1795 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
1796
1797 if (err)
1798 return err;
1799 }
1800
Lukáš Turek310bc672009-12-21 22:50:48 +01001801 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
1802 err = drv_set_coverage_class(local, wiphy->coverage_class);
1803
1804 if (err)
1805 return err;
1806 }
1807
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001808 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
Johannes Berg24487982009-04-23 18:52:52 +02001809 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001810
Johannes Berg24487982009-04-23 18:52:52 +02001811 if (err)
1812 return err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001813 }
1814
1815 if (changed & WIPHY_PARAM_RETRY_SHORT)
1816 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
1817 if (changed & WIPHY_PARAM_RETRY_LONG)
1818 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
1819 if (changed &
1820 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
1821 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
1822
1823 return 0;
1824}
1825
Johannes Berg7643a2c2009-06-02 13:01:39 +02001826static int ieee80211_set_tx_power(struct wiphy *wiphy,
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001827 enum nl80211_tx_power_setting type, int mbm)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001828{
1829 struct ieee80211_local *local = wiphy_priv(wiphy);
1830 struct ieee80211_channel *chan = local->hw.conf.channel;
1831 u32 changes = 0;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001832
1833 switch (type) {
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001834 case NL80211_TX_POWER_AUTOMATIC:
Johannes Berg7643a2c2009-06-02 13:01:39 +02001835 local->user_power_level = -1;
1836 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001837 case NL80211_TX_POWER_LIMITED:
1838 if (mbm < 0 || (mbm % 100))
1839 return -EOPNOTSUPP;
1840 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001841 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001842 case NL80211_TX_POWER_FIXED:
1843 if (mbm < 0 || (mbm % 100))
1844 return -EOPNOTSUPP;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001845 /* TODO: move to cfg80211 when it knows the channel */
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001846 if (MBM_TO_DBM(mbm) > chan->max_power)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001847 return -EINVAL;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001848 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001849 break;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001850 }
1851
1852 ieee80211_hw_config(local, changes);
1853
1854 return 0;
1855}
1856
1857static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1858{
1859 struct ieee80211_local *local = wiphy_priv(wiphy);
1860
1861 *dbm = local->hw.conf.power_level;
1862
Johannes Berg7643a2c2009-06-02 13:01:39 +02001863 return 0;
1864}
1865
Johannes Bergab737a42009-07-01 21:26:58 +02001866static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg388ac772010-10-07 13:11:09 +02001867 const u8 *addr)
Johannes Bergab737a42009-07-01 21:26:58 +02001868{
1869 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1870
1871 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
1872
1873 return 0;
1874}
1875
Johannes Berg1f87f7d2009-06-02 13:01:41 +02001876static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1877{
1878 struct ieee80211_local *local = wiphy_priv(wiphy);
1879
1880 drv_rfkill_poll(local);
1881}
1882
Johannes Bergaff89a92009-07-01 21:26:51 +02001883#ifdef CONFIG_NL80211_TESTMODE
Johannes Berg99783e22009-07-07 03:54:43 +02001884static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
Johannes Bergaff89a92009-07-01 21:26:51 +02001885{
1886 struct ieee80211_local *local = wiphy_priv(wiphy);
1887
1888 if (!local->ops->testmode_cmd)
1889 return -EOPNOTSUPP;
1890
1891 return local->ops->testmode_cmd(&local->hw, data, len);
1892}
Wey-Yi Guy71063f02011-05-20 09:05:54 -07001893
1894static int ieee80211_testmode_dump(struct wiphy *wiphy,
1895 struct sk_buff *skb,
1896 struct netlink_callback *cb,
1897 void *data, int len)
1898{
1899 struct ieee80211_local *local = wiphy_priv(wiphy);
1900
1901 if (!local->ops->testmode_dump)
1902 return -EOPNOTSUPP;
1903
1904 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
1905}
Johannes Bergaff89a92009-07-01 21:26:51 +02001906#endif
1907
Johannes Berg0f782312009-12-01 13:37:02 +01001908int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1909 enum ieee80211_smps_mode smps_mode)
1910{
1911 const u8 *ap;
1912 enum ieee80211_smps_mode old_req;
1913 int err;
1914
Johannes Berg243e6df2011-04-19 20:44:04 +02001915 lockdep_assert_held(&sdata->u.mgd.mtx);
1916
Johannes Berg0f782312009-12-01 13:37:02 +01001917 old_req = sdata->u.mgd.req_smps;
1918 sdata->u.mgd.req_smps = smps_mode;
1919
1920 if (old_req == smps_mode &&
1921 smps_mode != IEEE80211_SMPS_AUTOMATIC)
1922 return 0;
1923
1924 /*
1925 * If not associated, or current association is not an HT
1926 * association, there's no need to send an action frame.
1927 */
1928 if (!sdata->u.mgd.associated ||
Johannes Berg0aaffa92010-05-05 15:28:27 +02001929 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
Johannes Berg0f782312009-12-01 13:37:02 +01001930 mutex_lock(&sdata->local->iflist_mtx);
Johannes Berg025e6be2010-10-05 10:41:47 +02001931 ieee80211_recalc_smps(sdata->local);
Johannes Berg0f782312009-12-01 13:37:02 +01001932 mutex_unlock(&sdata->local->iflist_mtx);
1933 return 0;
1934 }
1935
Johannes Berg0c1ad2c2009-12-23 13:15:39 +01001936 ap = sdata->u.mgd.associated->bssid;
Johannes Berg0f782312009-12-01 13:37:02 +01001937
1938 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
1939 if (sdata->u.mgd.powersave)
1940 smps_mode = IEEE80211_SMPS_DYNAMIC;
1941 else
1942 smps_mode = IEEE80211_SMPS_OFF;
1943 }
1944
1945 /* send SM PS frame to AP */
1946 err = ieee80211_send_smps_action(sdata, smps_mode,
1947 ap, ap);
1948 if (err)
1949 sdata->u.mgd.req_smps = old_req;
1950
1951 return err;
1952}
1953
Johannes Bergbc92afd2009-07-01 21:26:57 +02001954static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
1955 bool enabled, int timeout)
1956{
1957 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1958 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Bergbc92afd2009-07-01 21:26:57 +02001959
Benoit Papillaulte5de30c2010-01-15 12:21:37 +01001960 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1961 return -EOPNOTSUPP;
1962
Johannes Bergbc92afd2009-07-01 21:26:57 +02001963 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
1964 return -EOPNOTSUPP;
1965
1966 if (enabled == sdata->u.mgd.powersave &&
Juuso Oikarinenff616382010-06-09 09:51:52 +03001967 timeout == local->dynamic_ps_forced_timeout)
Johannes Bergbc92afd2009-07-01 21:26:57 +02001968 return 0;
1969
1970 sdata->u.mgd.powersave = enabled;
Juuso Oikarinenff616382010-06-09 09:51:52 +03001971 local->dynamic_ps_forced_timeout = timeout;
Johannes Bergbc92afd2009-07-01 21:26:57 +02001972
Johannes Berg0f782312009-12-01 13:37:02 +01001973 /* no change, but if automatic follow powersave */
1974 mutex_lock(&sdata->u.mgd.mtx);
1975 __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
1976 mutex_unlock(&sdata->u.mgd.mtx);
1977
Johannes Bergbc92afd2009-07-01 21:26:57 +02001978 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
1979 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
1980
1981 ieee80211_recalc_ps(local, -1);
1982
1983 return 0;
1984}
1985
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001986static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
1987 struct net_device *dev,
1988 s32 rssi_thold, u32 rssi_hyst)
1989{
1990 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001991 struct ieee80211_vif *vif = &sdata->vif;
1992 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1993
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001994 if (rssi_thold == bss_conf->cqm_rssi_thold &&
1995 rssi_hyst == bss_conf->cqm_rssi_hyst)
1996 return 0;
1997
1998 bss_conf->cqm_rssi_thold = rssi_thold;
1999 bss_conf->cqm_rssi_hyst = rssi_hyst;
2000
2001 /* tell the driver upon association, unless already associated */
Johannes Bergea086352012-01-19 09:29:58 +01002002 if (sdata->u.mgd.associated &&
2003 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002004 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2005
2006 return 0;
2007}
2008
Johannes Berg99303802009-07-01 21:26:59 +02002009static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
2010 struct net_device *dev,
2011 const u8 *addr,
2012 const struct cfg80211_bitrate_mask *mask)
2013{
2014 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2015 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05302016 int i, ret;
Johannes Berg99303802009-07-01 21:26:59 +02002017
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05302018 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
2019 ret = drv_set_bitrate_mask(local, sdata, mask);
2020 if (ret)
2021 return ret;
2022 }
Johannes Berg99303802009-07-01 21:26:59 +02002023
Simon Wunderlich19468412012-01-28 17:25:33 +01002024 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
Jouni Malinen37eb0b12010-01-06 13:09:08 +02002025 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
Simon Wunderlich19468412012-01-28 17:25:33 +01002026 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
2027 sizeof(mask->control[i].mcs));
2028 }
Johannes Berg99303802009-07-01 21:26:59 +02002029
Jouni Malinen37eb0b12010-01-06 13:09:08 +02002030 return 0;
Johannes Berg99303802009-07-01 21:26:59 +02002031}
2032
Johannes Berg21f83582010-12-18 17:20:47 +01002033static int ieee80211_remain_on_channel_hw(struct ieee80211_local *local,
2034 struct net_device *dev,
2035 struct ieee80211_channel *chan,
2036 enum nl80211_channel_type chantype,
2037 unsigned int duration, u64 *cookie)
2038{
2039 int ret;
2040 u32 random_cookie;
2041
2042 lockdep_assert_held(&local->mtx);
2043
2044 if (local->hw_roc_cookie)
2045 return -EBUSY;
2046 /* must be nonzero */
2047 random_cookie = random32() | 1;
2048
2049 *cookie = random_cookie;
2050 local->hw_roc_dev = dev;
2051 local->hw_roc_cookie = random_cookie;
2052 local->hw_roc_channel = chan;
2053 local->hw_roc_channel_type = chantype;
2054 local->hw_roc_duration = duration;
2055 ret = drv_remain_on_channel(local, chan, chantype, duration);
2056 if (ret) {
2057 local->hw_roc_channel = NULL;
2058 local->hw_roc_cookie = 0;
2059 }
2060
2061 return ret;
2062}
2063
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002064static int ieee80211_remain_on_channel(struct wiphy *wiphy,
2065 struct net_device *dev,
2066 struct ieee80211_channel *chan,
2067 enum nl80211_channel_type channel_type,
2068 unsigned int duration,
2069 u64 *cookie)
2070{
2071 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01002072 struct ieee80211_local *local = sdata->local;
2073
2074 if (local->ops->remain_on_channel) {
2075 int ret;
2076
2077 mutex_lock(&local->mtx);
2078 ret = ieee80211_remain_on_channel_hw(local, dev,
2079 chan, channel_type,
2080 duration, cookie);
Johannes Berg90fc4b32010-12-18 17:20:48 +01002081 local->hw_roc_for_tx = false;
Johannes Berg21f83582010-12-18 17:20:47 +01002082 mutex_unlock(&local->mtx);
2083
2084 return ret;
2085 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002086
2087 return ieee80211_wk_remain_on_channel(sdata, chan, channel_type,
2088 duration, cookie);
2089}
2090
Johannes Berg21f83582010-12-18 17:20:47 +01002091static int ieee80211_cancel_remain_on_channel_hw(struct ieee80211_local *local,
2092 u64 cookie)
2093{
2094 int ret;
2095
2096 lockdep_assert_held(&local->mtx);
2097
2098 if (local->hw_roc_cookie != cookie)
2099 return -ENOENT;
2100
2101 ret = drv_cancel_remain_on_channel(local);
2102 if (ret)
2103 return ret;
2104
2105 local->hw_roc_cookie = 0;
2106 local->hw_roc_channel = NULL;
2107
2108 ieee80211_recalc_idle(local);
2109
2110 return 0;
2111}
2112
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002113static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
2114 struct net_device *dev,
2115 u64 cookie)
2116{
2117 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01002118 struct ieee80211_local *local = sdata->local;
2119
2120 if (local->ops->cancel_remain_on_channel) {
2121 int ret;
2122
2123 mutex_lock(&local->mtx);
2124 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
2125 mutex_unlock(&local->mtx);
2126
2127 return ret;
2128 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002129
2130 return ieee80211_wk_cancel_remain_on_channel(sdata, cookie);
2131}
2132
Johannes Bergf30221e2010-11-25 10:02:30 +01002133static enum work_done_result
2134ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb)
2135{
2136 /*
2137 * Use the data embedded in the work struct for reporting
2138 * here so if the driver mangled the SKB before dropping
2139 * it (which is the only way we really should get here)
2140 * then we don't report mangled data.
2141 *
2142 * If there was no wait time, then by the time we get here
2143 * the driver will likely not have reported the status yet,
2144 * so in that case userspace will have to deal with it.
2145 */
2146
Johannes Berg28a1bcd2011-10-04 18:27:10 +02002147 if (wk->offchan_tx.wait && !wk->offchan_tx.status)
Johannes Bergf30221e2010-11-25 10:02:30 +01002148 cfg80211_mgmt_tx_status(wk->sdata->dev,
2149 (unsigned long) wk->offchan_tx.frame,
Johannes Berg66e67e42012-01-20 13:55:27 +01002150 wk->data, wk->data_len, false, GFP_KERNEL);
Johannes Bergf30221e2010-11-25 10:02:30 +01002151
2152 return WORK_DONE_DESTROY;
2153}
2154
Johannes Berg2e161f782010-08-12 15:38:38 +02002155static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002156 struct ieee80211_channel *chan, bool offchan,
Johannes Berg2e161f782010-08-12 15:38:38 +02002157 enum nl80211_channel_type channel_type,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002158 bool channel_type_valid, unsigned int wait,
Rajkumar Manoharane9f935e2011-09-25 14:53:30 +05302159 const u8 *buf, size_t len, bool no_cck,
Johannes Berge247bd902011-11-04 11:18:21 +01002160 bool dont_wait_for_ack, u64 *cookie)
Jouni Malinen026331c2010-02-15 12:53:10 +02002161{
Johannes Berg9d38d852010-06-09 17:20:33 +02002162 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2163 struct ieee80211_local *local = sdata->local;
2164 struct sk_buff *skb;
2165 struct sta_info *sta;
Johannes Bergf30221e2010-11-25 10:02:30 +01002166 struct ieee80211_work *wk;
Johannes Berg9d38d852010-06-09 17:20:33 +02002167 const struct ieee80211_mgmt *mgmt = (void *)buf;
Johannes Berge247bd902011-11-04 11:18:21 +01002168 u32 flags;
Johannes Bergf30221e2010-11-25 10:02:30 +01002169 bool is_offchan = false;
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002170
Johannes Berge247bd902011-11-04 11:18:21 +01002171 if (dont_wait_for_ack)
2172 flags = IEEE80211_TX_CTL_NO_ACK;
2173 else
2174 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
2175 IEEE80211_TX_CTL_REQ_TX_STATUS;
2176
Johannes Berg9d38d852010-06-09 17:20:33 +02002177 /* Check that we are on the requested channel for transmission */
2178 if (chan != local->tmp_channel &&
2179 chan != local->oper_channel)
Johannes Bergf30221e2010-11-25 10:02:30 +01002180 is_offchan = true;
Johannes Berg9d38d852010-06-09 17:20:33 +02002181 if (channel_type_valid &&
2182 (channel_type != local->tmp_channel_type &&
2183 channel_type != local->_oper_channel_type))
Johannes Bergf30221e2010-11-25 10:02:30 +01002184 is_offchan = true;
2185
Johannes Berg21f83582010-12-18 17:20:47 +01002186 if (chan == local->hw_roc_channel) {
2187 /* TODO: check channel type? */
2188 is_offchan = false;
2189 flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
2190 }
2191
Rajkumar Manoharanaad14ce2011-09-25 14:53:31 +05302192 if (no_cck)
2193 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
2194
Johannes Bergf30221e2010-11-25 10:02:30 +01002195 if (is_offchan && !offchan)
Johannes Berg9d38d852010-06-09 17:20:33 +02002196 return -EBUSY;
2197
2198 switch (sdata->vif.type) {
2199 case NL80211_IFTYPE_ADHOC:
Johannes Berg663fcaf2010-09-30 21:06:09 +02002200 case NL80211_IFTYPE_AP:
2201 case NL80211_IFTYPE_AP_VLAN:
2202 case NL80211_IFTYPE_P2P_GO:
Javier Cardonac7108a72010-12-16 17:37:50 -08002203 case NL80211_IFTYPE_MESH_POINT:
Johannes Berg663fcaf2010-09-30 21:06:09 +02002204 if (!ieee80211_is_action(mgmt->frame_control) ||
2205 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
Johannes Berg9d38d852010-06-09 17:20:33 +02002206 break;
2207 rcu_read_lock();
2208 sta = sta_info_get(sdata, mgmt->da);
2209 rcu_read_unlock();
2210 if (!sta)
2211 return -ENOLINK;
2212 break;
2213 case NL80211_IFTYPE_STATION:
Johannes Berg663fcaf2010-09-30 21:06:09 +02002214 case NL80211_IFTYPE_P2P_CLIENT:
Johannes Berg9d38d852010-06-09 17:20:33 +02002215 break;
2216 default:
2217 return -EOPNOTSUPP;
2218 }
2219
2220 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
2221 if (!skb)
2222 return -ENOMEM;
2223 skb_reserve(skb, local->hw.extra_tx_headroom);
2224
2225 memcpy(skb_put(skb, len), buf, len);
2226
2227 IEEE80211_SKB_CB(skb)->flags = flags;
2228
Johannes Berg3a25a8c2012-04-03 16:28:50 +02002229 if (flags & IEEE80211_TX_CTL_TX_OFFCHAN)
2230 IEEE80211_SKB_CB(skb)->hw_queue =
2231 local->hw.offchannel_tx_hw_queue;
2232
Johannes Berg9d38d852010-06-09 17:20:33 +02002233 skb->dev = sdata->dev;
Johannes Berg9d38d852010-06-09 17:20:33 +02002234
2235 *cookie = (unsigned long) skb;
Johannes Bergf30221e2010-11-25 10:02:30 +01002236
Johannes Berg90fc4b32010-12-18 17:20:48 +01002237 if (is_offchan && local->ops->remain_on_channel) {
2238 unsigned int duration;
2239 int ret;
2240
2241 mutex_lock(&local->mtx);
2242 /*
2243 * If the duration is zero, then the driver
2244 * wouldn't actually do anything. Set it to
2245 * 100 for now.
2246 *
2247 * TODO: cancel the off-channel operation
2248 * when we get the SKB's TX status and
2249 * the wait time was zero before.
2250 */
2251 duration = 100;
2252 if (wait)
2253 duration = wait;
2254 ret = ieee80211_remain_on_channel_hw(local, dev, chan,
2255 channel_type,
2256 duration, cookie);
2257 if (ret) {
2258 kfree_skb(skb);
2259 mutex_unlock(&local->mtx);
2260 return ret;
2261 }
2262
2263 local->hw_roc_for_tx = true;
2264 local->hw_roc_duration = wait;
2265
2266 /*
2267 * queue up frame for transmission after
2268 * ieee80211_ready_on_channel call
2269 */
2270
2271 /* modify cookie to prevent API mismatches */
2272 *cookie ^= 2;
2273 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
Johannes Berg3a25a8c2012-04-03 16:28:50 +02002274 IEEE80211_SKB_CB(skb)->hw_queue =
2275 local->hw.offchannel_tx_hw_queue;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002276 local->hw_roc_skb = skb;
Johannes Berg4334ec82011-02-02 16:58:06 +01002277 local->hw_roc_skb_for_status = skb;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002278 mutex_unlock(&local->mtx);
2279
2280 return 0;
2281 }
2282
Johannes Bergf30221e2010-11-25 10:02:30 +01002283 /*
2284 * Can transmit right away if the channel was the
2285 * right one and there's no wait involved... If a
2286 * wait is involved, we might otherwise not be on
2287 * the right channel for long enough!
2288 */
2289 if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) {
2290 ieee80211_tx_skb(sdata, skb);
2291 return 0;
2292 }
2293
2294 wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL);
2295 if (!wk) {
2296 kfree_skb(skb);
2297 return -ENOMEM;
2298 }
2299
2300 wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
2301 wk->chan = chan;
Ben Greear4d51e142011-02-07 13:44:34 -08002302 wk->chan_type = channel_type;
Johannes Bergf30221e2010-11-25 10:02:30 +01002303 wk->sdata = sdata;
2304 wk->done = ieee80211_offchan_tx_done;
2305 wk->offchan_tx.frame = skb;
2306 wk->offchan_tx.wait = wait;
Johannes Berg66e67e42012-01-20 13:55:27 +01002307 wk->data_len = len;
2308 memcpy(wk->data, buf, len);
Johannes Bergf30221e2010-11-25 10:02:30 +01002309
2310 ieee80211_add_work(wk);
Johannes Berg9d38d852010-06-09 17:20:33 +02002311 return 0;
Jouni Malinen026331c2010-02-15 12:53:10 +02002312}
2313
Johannes Bergf30221e2010-11-25 10:02:30 +01002314static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2315 struct net_device *dev,
2316 u64 cookie)
2317{
2318 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2319 struct ieee80211_local *local = sdata->local;
2320 struct ieee80211_work *wk;
2321 int ret = -ENOENT;
2322
2323 mutex_lock(&local->mtx);
Johannes Berg90fc4b32010-12-18 17:20:48 +01002324
2325 if (local->ops->cancel_remain_on_channel) {
2326 cookie ^= 2;
2327 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
2328
2329 if (ret == 0) {
2330 kfree_skb(local->hw_roc_skb);
2331 local->hw_roc_skb = NULL;
Johannes Berg4334ec82011-02-02 16:58:06 +01002332 local->hw_roc_skb_for_status = NULL;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002333 }
2334
2335 mutex_unlock(&local->mtx);
2336
2337 return ret;
2338 }
2339
Johannes Bergf30221e2010-11-25 10:02:30 +01002340 list_for_each_entry(wk, &local->work_list, list) {
2341 if (wk->sdata != sdata)
2342 continue;
2343
2344 if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
2345 continue;
2346
2347 if (cookie != (unsigned long) wk->offchan_tx.frame)
2348 continue;
2349
2350 wk->timeout = jiffies;
2351
2352 ieee80211_queue_work(&local->hw, &local->work_work);
2353 ret = 0;
2354 break;
2355 }
2356 mutex_unlock(&local->mtx);
2357
2358 return ret;
2359}
2360
Johannes Berg7be50862010-10-13 12:06:24 +02002361static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2362 struct net_device *dev,
2363 u16 frame_type, bool reg)
2364{
2365 struct ieee80211_local *local = wiphy_priv(wiphy);
2366
2367 if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
2368 return;
2369
2370 if (reg)
2371 local->probe_req_reg++;
2372 else
2373 local->probe_req_reg--;
2374
2375 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2376}
2377
Bruno Randolf15d96752010-11-10 12:50:56 +09002378static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
2379{
2380 struct ieee80211_local *local = wiphy_priv(wiphy);
2381
2382 if (local->started)
2383 return -EOPNOTSUPP;
2384
2385 return drv_set_antenna(local, tx_ant, rx_ant);
2386}
2387
2388static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
2389{
2390 struct ieee80211_local *local = wiphy_priv(wiphy);
2391
2392 return drv_get_antenna(local, tx_ant, rx_ant);
2393}
2394
John W. Linville38c09152011-03-07 16:19:18 -05002395static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2396{
2397 struct ieee80211_local *local = wiphy_priv(wiphy);
2398
2399 return drv_set_ringparam(local, tx, rx);
2400}
2401
2402static void ieee80211_get_ringparam(struct wiphy *wiphy,
2403 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2404{
2405 struct ieee80211_local *local = wiphy_priv(wiphy);
2406
2407 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2408}
2409
Johannes Bergc68f4b82011-07-05 16:35:41 +02002410static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2411 struct net_device *dev,
2412 struct cfg80211_gtk_rekey_data *data)
2413{
2414 struct ieee80211_local *local = wiphy_priv(wiphy);
2415 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2416
2417 if (!local->ops->set_rekey_data)
2418 return -EOPNOTSUPP;
2419
2420 drv_set_rekey_data(local, sdata, data);
2421
2422 return 0;
2423}
2424
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002425static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
2426{
2427 u8 *pos = (void *)skb_put(skb, 7);
2428
2429 *pos++ = WLAN_EID_EXT_CAPABILITY;
2430 *pos++ = 5; /* len */
2431 *pos++ = 0x0;
2432 *pos++ = 0x0;
2433 *pos++ = 0x0;
2434 *pos++ = 0x0;
2435 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
2436}
2437
2438static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
2439{
2440 struct ieee80211_local *local = sdata->local;
2441 u16 capab;
2442
2443 capab = 0;
2444 if (local->oper_channel->band != IEEE80211_BAND_2GHZ)
2445 return capab;
2446
2447 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
2448 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
2449 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
2450 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
2451
2452 return capab;
2453}
2454
2455static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
2456 u8 *peer, u8 *bssid)
2457{
2458 struct ieee80211_tdls_lnkie *lnkid;
2459
2460 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
2461
2462 lnkid->ie_type = WLAN_EID_LINK_ID;
2463 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
2464
2465 memcpy(lnkid->bssid, bssid, ETH_ALEN);
2466 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
2467 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
2468}
2469
2470static int
2471ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2472 u8 *peer, u8 action_code, u8 dialog_token,
2473 u16 status_code, struct sk_buff *skb)
2474{
2475 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2476 struct ieee80211_tdls_data *tf;
2477
2478 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
2479
2480 memcpy(tf->da, peer, ETH_ALEN);
2481 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
2482 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
2483 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
2484
2485 switch (action_code) {
2486 case WLAN_TDLS_SETUP_REQUEST:
2487 tf->category = WLAN_CATEGORY_TDLS;
2488 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
2489
2490 skb_put(skb, sizeof(tf->u.setup_req));
2491 tf->u.setup_req.dialog_token = dialog_token;
2492 tf->u.setup_req.capability =
2493 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2494
Ashok Nagarajan657c3e02012-04-02 21:21:20 -07002495 ieee80211_add_srates_ie(&sdata->vif, skb, false);
2496 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002497 ieee80211_tdls_add_ext_capab(skb);
2498 break;
2499 case WLAN_TDLS_SETUP_RESPONSE:
2500 tf->category = WLAN_CATEGORY_TDLS;
2501 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
2502
2503 skb_put(skb, sizeof(tf->u.setup_resp));
2504 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
2505 tf->u.setup_resp.dialog_token = dialog_token;
2506 tf->u.setup_resp.capability =
2507 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2508
Ashok Nagarajan657c3e02012-04-02 21:21:20 -07002509 ieee80211_add_srates_ie(&sdata->vif, skb, false);
2510 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002511 ieee80211_tdls_add_ext_capab(skb);
2512 break;
2513 case WLAN_TDLS_SETUP_CONFIRM:
2514 tf->category = WLAN_CATEGORY_TDLS;
2515 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
2516
2517 skb_put(skb, sizeof(tf->u.setup_cfm));
2518 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
2519 tf->u.setup_cfm.dialog_token = dialog_token;
2520 break;
2521 case WLAN_TDLS_TEARDOWN:
2522 tf->category = WLAN_CATEGORY_TDLS;
2523 tf->action_code = WLAN_TDLS_TEARDOWN;
2524
2525 skb_put(skb, sizeof(tf->u.teardown));
2526 tf->u.teardown.reason_code = cpu_to_le16(status_code);
2527 break;
2528 case WLAN_TDLS_DISCOVERY_REQUEST:
2529 tf->category = WLAN_CATEGORY_TDLS;
2530 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
2531
2532 skb_put(skb, sizeof(tf->u.discover_req));
2533 tf->u.discover_req.dialog_token = dialog_token;
2534 break;
2535 default:
2536 return -EINVAL;
2537 }
2538
2539 return 0;
2540}
2541
2542static int
2543ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2544 u8 *peer, u8 action_code, u8 dialog_token,
2545 u16 status_code, struct sk_buff *skb)
2546{
2547 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2548 struct ieee80211_mgmt *mgmt;
2549
2550 mgmt = (void *)skb_put(skb, 24);
2551 memset(mgmt, 0, 24);
2552 memcpy(mgmt->da, peer, ETH_ALEN);
2553 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
2554 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
2555
2556 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2557 IEEE80211_STYPE_ACTION);
2558
2559 switch (action_code) {
2560 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2561 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
2562 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
2563 mgmt->u.action.u.tdls_discover_resp.action_code =
2564 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
2565 mgmt->u.action.u.tdls_discover_resp.dialog_token =
2566 dialog_token;
2567 mgmt->u.action.u.tdls_discover_resp.capability =
2568 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2569
Ashok Nagarajan657c3e02012-04-02 21:21:20 -07002570 ieee80211_add_srates_ie(&sdata->vif, skb, false);
2571 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002572 ieee80211_tdls_add_ext_capab(skb);
2573 break;
2574 default:
2575 return -EINVAL;
2576 }
2577
2578 return 0;
2579}
2580
2581static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2582 u8 *peer, u8 action_code, u8 dialog_token,
2583 u16 status_code, const u8 *extra_ies,
2584 size_t extra_ies_len)
2585{
2586 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2587 struct ieee80211_local *local = sdata->local;
2588 struct ieee80211_tx_info *info;
2589 struct sk_buff *skb = NULL;
2590 bool send_direct;
2591 int ret;
2592
2593 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2594 return -ENOTSUPP;
2595
2596 /* make sure we are in managed mode, and associated */
2597 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
2598 !sdata->u.mgd.associated)
2599 return -EINVAL;
2600
2601#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2602 printk(KERN_DEBUG "TDLS mgmt action %d peer %pM\n", action_code, peer);
2603#endif
2604
2605 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
2606 max(sizeof(struct ieee80211_mgmt),
2607 sizeof(struct ieee80211_tdls_data)) +
2608 50 + /* supported rates */
2609 7 + /* ext capab */
2610 extra_ies_len +
2611 sizeof(struct ieee80211_tdls_lnkie));
2612 if (!skb)
2613 return -ENOMEM;
2614
2615 info = IEEE80211_SKB_CB(skb);
2616 skb_reserve(skb, local->hw.extra_tx_headroom);
2617
2618 switch (action_code) {
2619 case WLAN_TDLS_SETUP_REQUEST:
2620 case WLAN_TDLS_SETUP_RESPONSE:
2621 case WLAN_TDLS_SETUP_CONFIRM:
2622 case WLAN_TDLS_TEARDOWN:
2623 case WLAN_TDLS_DISCOVERY_REQUEST:
2624 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
2625 action_code, dialog_token,
2626 status_code, skb);
2627 send_direct = false;
2628 break;
2629 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2630 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
2631 dialog_token, status_code,
2632 skb);
2633 send_direct = true;
2634 break;
2635 default:
2636 ret = -ENOTSUPP;
2637 break;
2638 }
2639
2640 if (ret < 0)
2641 goto fail;
2642
2643 if (extra_ies_len)
2644 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
2645
2646 /* the TDLS link IE is always added last */
2647 switch (action_code) {
2648 case WLAN_TDLS_SETUP_REQUEST:
2649 case WLAN_TDLS_SETUP_CONFIRM:
2650 case WLAN_TDLS_TEARDOWN:
2651 case WLAN_TDLS_DISCOVERY_REQUEST:
2652 /* we are the initiator */
2653 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
2654 sdata->u.mgd.bssid);
2655 break;
2656 case WLAN_TDLS_SETUP_RESPONSE:
2657 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2658 /* we are the responder */
2659 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
2660 sdata->u.mgd.bssid);
2661 break;
2662 default:
2663 ret = -ENOTSUPP;
2664 goto fail;
2665 }
2666
2667 if (send_direct) {
2668 ieee80211_tx_skb(sdata, skb);
2669 return 0;
2670 }
2671
2672 /*
2673 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
2674 * we should default to AC_VI.
2675 */
2676 switch (action_code) {
2677 case WLAN_TDLS_SETUP_REQUEST:
2678 case WLAN_TDLS_SETUP_RESPONSE:
2679 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
2680 skb->priority = 2;
2681 break;
2682 default:
2683 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
2684 skb->priority = 5;
2685 break;
2686 }
2687
2688 /* disable bottom halves when entering the Tx path */
2689 local_bh_disable();
2690 ret = ieee80211_subif_start_xmit(skb, dev);
2691 local_bh_enable();
2692
2693 return ret;
2694
2695fail:
2696 dev_kfree_skb(skb);
2697 return ret;
2698}
2699
2700static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2701 u8 *peer, enum nl80211_tdls_operation oper)
2702{
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002703 struct sta_info *sta;
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002704 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2705
2706 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2707 return -ENOTSUPP;
2708
2709 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2710 return -EINVAL;
2711
2712#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2713 printk(KERN_DEBUG "TDLS oper %d peer %pM\n", oper, peer);
2714#endif
2715
2716 switch (oper) {
2717 case NL80211_TDLS_ENABLE_LINK:
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002718 rcu_read_lock();
2719 sta = sta_info_get(sdata, peer);
2720 if (!sta) {
2721 rcu_read_unlock();
2722 return -ENOLINK;
2723 }
2724
Johannes Bergc2c98fd2011-09-29 16:04:36 +02002725 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002726 rcu_read_unlock();
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002727 break;
2728 case NL80211_TDLS_DISABLE_LINK:
2729 return sta_info_destroy_addr(sdata, peer);
2730 case NL80211_TDLS_TEARDOWN:
2731 case NL80211_TDLS_SETUP:
2732 case NL80211_TDLS_DISCOVERY_REQ:
2733 /* We don't support in-driver setup/teardown/discovery */
2734 return -ENOTSUPP;
2735 default:
2736 return -ENOTSUPP;
2737 }
2738
2739 return 0;
2740}
2741
Johannes Berg06500732011-11-04 11:18:16 +01002742static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
2743 const u8 *peer, u64 *cookie)
2744{
2745 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2746 struct ieee80211_local *local = sdata->local;
2747 struct ieee80211_qos_hdr *nullfunc;
2748 struct sk_buff *skb;
2749 int size = sizeof(*nullfunc);
2750 __le16 fc;
2751 bool qos;
2752 struct ieee80211_tx_info *info;
2753 struct sta_info *sta;
2754
2755 rcu_read_lock();
2756 sta = sta_info_get(sdata, peer);
Johannes Bergb4487c22011-11-11 20:22:30 +01002757 if (sta) {
Johannes Berg06500732011-11-04 11:18:16 +01002758 qos = test_sta_flag(sta, WLAN_STA_WME);
Johannes Bergb4487c22011-11-11 20:22:30 +01002759 rcu_read_unlock();
2760 } else {
2761 rcu_read_unlock();
Johannes Berg06500732011-11-04 11:18:16 +01002762 return -ENOLINK;
Johannes Bergb4487c22011-11-11 20:22:30 +01002763 }
Johannes Berg06500732011-11-04 11:18:16 +01002764
2765 if (qos) {
2766 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
2767 IEEE80211_STYPE_QOS_NULLFUNC |
2768 IEEE80211_FCTL_FROMDS);
2769 } else {
2770 size -= 2;
2771 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
2772 IEEE80211_STYPE_NULLFUNC |
2773 IEEE80211_FCTL_FROMDS);
2774 }
2775
2776 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
2777 if (!skb)
2778 return -ENOMEM;
2779
2780 skb->dev = dev;
2781
2782 skb_reserve(skb, local->hw.extra_tx_headroom);
2783
2784 nullfunc = (void *) skb_put(skb, size);
2785 nullfunc->frame_control = fc;
2786 nullfunc->duration_id = 0;
2787 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
2788 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
2789 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
2790 nullfunc->seq_ctrl = 0;
2791
2792 info = IEEE80211_SKB_CB(skb);
2793
2794 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
2795 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
2796
2797 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
2798 skb->priority = 7;
2799 if (qos)
2800 nullfunc->qos_ctrl = cpu_to_le16(7);
2801
2802 local_bh_disable();
2803 ieee80211_xmit(sdata, skb);
2804 local_bh_enable();
2805
2806 *cookie = (unsigned long) skb;
2807 return 0;
2808}
2809
Johannes Berge9998822011-11-09 10:30:21 +01002810static struct ieee80211_channel *
Pontus Fuchsd91df0e2012-04-03 16:39:58 +02002811ieee80211_wiphy_get_channel(struct wiphy *wiphy,
2812 enum nl80211_channel_type *type)
Johannes Berge9998822011-11-09 10:30:21 +01002813{
2814 struct ieee80211_local *local = wiphy_priv(wiphy);
2815
Pontus Fuchsd91df0e2012-04-03 16:39:58 +02002816 *type = local->_oper_channel_type;
Johannes Berge9998822011-11-09 10:30:21 +01002817 return local->oper_channel;
2818}
2819
Johannes Berg6d525632012-04-04 15:05:25 +02002820#ifdef CONFIG_PM
2821static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
2822{
2823 drv_set_wakeup(wiphy_priv(wiphy), enabled);
2824}
2825#endif
2826
Jiri Bencf0706e82007-05-05 11:45:53 -07002827struct cfg80211_ops mac80211_config_ops = {
2828 .add_virtual_intf = ieee80211_add_iface,
2829 .del_virtual_intf = ieee80211_del_iface,
Johannes Berg42613db2007-09-28 21:52:27 +02002830 .change_virtual_intf = ieee80211_change_iface,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002831 .add_key = ieee80211_add_key,
2832 .del_key = ieee80211_del_key,
Johannes Berg62da92f2007-12-19 02:03:31 +01002833 .get_key = ieee80211_get_key,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002834 .set_default_key = ieee80211_config_default_key,
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +02002835 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
Johannes Berg88600202012-02-13 15:17:18 +01002836 .start_ap = ieee80211_start_ap,
2837 .change_beacon = ieee80211_change_beacon,
2838 .stop_ap = ieee80211_stop_ap,
Johannes Berg4fd69312007-12-19 02:03:35 +01002839 .add_station = ieee80211_add_station,
2840 .del_station = ieee80211_del_station,
2841 .change_station = ieee80211_change_station,
Johannes Berg7bbdd2d2007-12-19 02:03:37 +01002842 .get_station = ieee80211_get_station,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002843 .dump_station = ieee80211_dump_station,
Holger Schurig12897232010-04-19 10:23:57 +02002844 .dump_survey = ieee80211_dump_survey,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002845#ifdef CONFIG_MAC80211_MESH
2846 .add_mpath = ieee80211_add_mpath,
2847 .del_mpath = ieee80211_del_mpath,
2848 .change_mpath = ieee80211_change_mpath,
2849 .get_mpath = ieee80211_get_mpath,
2850 .dump_mpath = ieee80211_dump_mpath,
Javier Cardona24bdd9f2010-12-16 17:37:48 -08002851 .update_mesh_config = ieee80211_update_mesh_config,
2852 .get_mesh_config = ieee80211_get_mesh_config,
Johannes Berg29cbe682010-12-03 09:20:44 +01002853 .join_mesh = ieee80211_join_mesh,
2854 .leave_mesh = ieee80211_leave_mesh,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002855#endif
Jouni Malinen9f1ba902008-08-07 20:07:01 +03002856 .change_bss = ieee80211_change_bss,
Jouni Malinen31888482008-10-30 16:59:24 +02002857 .set_txq_params = ieee80211_set_txq_params,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02002858 .set_channel = ieee80211_set_channel,
Bob Copeland665af4f2009-01-19 11:20:53 -05002859 .suspend = ieee80211_suspend,
2860 .resume = ieee80211_resume,
Johannes Berg2a519312009-02-10 21:25:55 +01002861 .scan = ieee80211_scan,
Luciano Coelho79f460c2011-05-11 17:09:36 +03002862 .sched_scan_start = ieee80211_sched_scan_start,
2863 .sched_scan_stop = ieee80211_sched_scan_stop,
Jouni Malinen636a5d32009-03-19 13:39:22 +02002864 .auth = ieee80211_auth,
2865 .assoc = ieee80211_assoc,
2866 .deauth = ieee80211_deauth,
2867 .disassoc = ieee80211_disassoc,
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02002868 .join_ibss = ieee80211_join_ibss,
2869 .leave_ibss = ieee80211_leave_ibss,
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002870 .set_wiphy_params = ieee80211_set_wiphy_params,
Johannes Berg7643a2c2009-06-02 13:01:39 +02002871 .set_tx_power = ieee80211_set_tx_power,
2872 .get_tx_power = ieee80211_get_tx_power,
Johannes Bergab737a42009-07-01 21:26:58 +02002873 .set_wds_peer = ieee80211_set_wds_peer,
Johannes Berg1f87f7d2009-06-02 13:01:41 +02002874 .rfkill_poll = ieee80211_rfkill_poll,
Johannes Bergaff89a92009-07-01 21:26:51 +02002875 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
Wey-Yi Guy71063f02011-05-20 09:05:54 -07002876 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
Johannes Bergbc92afd2009-07-01 21:26:57 +02002877 .set_power_mgmt = ieee80211_set_power_mgmt,
Johannes Berg99303802009-07-01 21:26:59 +02002878 .set_bitrate_mask = ieee80211_set_bitrate_mask,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002879 .remain_on_channel = ieee80211_remain_on_channel,
2880 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
Johannes Berg2e161f782010-08-12 15:38:38 +02002881 .mgmt_tx = ieee80211_mgmt_tx,
Johannes Bergf30221e2010-11-25 10:02:30 +01002882 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002883 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
Johannes Berg7be50862010-10-13 12:06:24 +02002884 .mgmt_frame_register = ieee80211_mgmt_frame_register,
Bruno Randolf15d96752010-11-10 12:50:56 +09002885 .set_antenna = ieee80211_set_antenna,
2886 .get_antenna = ieee80211_get_antenna,
John W. Linville38c09152011-03-07 16:19:18 -05002887 .set_ringparam = ieee80211_set_ringparam,
2888 .get_ringparam = ieee80211_get_ringparam,
Johannes Bergc68f4b82011-07-05 16:35:41 +02002889 .set_rekey_data = ieee80211_set_rekey_data,
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002890 .tdls_oper = ieee80211_tdls_oper,
2891 .tdls_mgmt = ieee80211_tdls_mgmt,
Johannes Berg06500732011-11-04 11:18:16 +01002892 .probe_client = ieee80211_probe_client,
Johannes Berge9998822011-11-09 10:30:21 +01002893 .get_channel = ieee80211_wiphy_get_channel,
Simon Wunderlichb53be792011-11-18 14:20:44 +01002894 .set_noack_map = ieee80211_set_noack_map,
Johannes Berg6d525632012-04-04 15:05:25 +02002895#ifdef CONFIG_PM
2896 .set_wakeup = ieee80211_set_wakeup,
2897#endif
Ben Greearb1ab7922012-04-23 12:50:30 -07002898 .get_et_sset_count = ieee80211_get_et_sset_count,
2899 .get_et_stats = ieee80211_get_et_stats,
2900 .get_et_strings = ieee80211_get_et_strings,
Jiri Bencf0706e82007-05-05 11:45:53 -07002901};