blob: 31023ca175755c46621c79645549ad0cd47a6450 [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{
466 if (sset == ETH_SS_STATS)
467 return STA_STATS_LEN;
468
469 return -EOPNOTSUPP;
470}
471
472static void ieee80211_get_et_stats(struct wiphy *wiphy,
473 struct net_device *dev,
474 struct ethtool_stats *stats,
475 u64 *data)
476{
477 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
478 struct sta_info *sta;
479 struct ieee80211_local *local = sdata->local;
480 int i;
481
482 memset(data, 0, sizeof(u64) * STA_STATS_LEN);
483
484#define ADD_STA_STATS(sta) \
485 do { \
486 data[i++] += sta->rx_packets; \
487 data[i++] += sta->rx_bytes; \
488 data[i++] += sta->wep_weak_iv_count; \
489 data[i++] += sta->num_duplicates; \
490 data[i++] += sta->rx_fragments; \
491 data[i++] += sta->rx_dropped; \
492 \
493 data[i++] += sta->tx_packets; \
494 data[i++] += sta->tx_bytes; \
495 data[i++] += sta->tx_fragments; \
496 data[i++] += sta->tx_filtered_count; \
497 data[i++] += sta->tx_retry_failed; \
498 data[i++] += sta->tx_retry_count; \
499 data[i++] += sta->beacon_loss_count; \
500 } while (0)
501
502 /* For Managed stations, find the single station based on BSSID
503 * and use that. For interface types, iterate through all available
504 * stations and add stats for any station that is assigned to this
505 * network device.
506 */
507
508 rcu_read_lock();
509
510 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
511 sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
512 if (sta && !WARN_ON(sta->sdata->dev != dev)) {
513 i = 0;
514 ADD_STA_STATS(sta);
515 BUG_ON(i != STA_STATS_LEN);
516 }
517 } else {
518 list_for_each_entry_rcu(sta, &local->sta_list, list) {
519 /* Make sure this station belongs to the proper dev */
520 if (sta->sdata->dev != dev)
521 continue;
522
523 i = 0;
524 ADD_STA_STATS(sta);
525 BUG_ON(i != STA_STATS_LEN);
526 }
527 }
528
529 rcu_read_unlock();
530}
531
532static void ieee80211_get_et_strings(struct wiphy *wiphy,
533 struct net_device *dev,
534 u32 sset, u8 *data)
535{
536 if (sset == ETH_SS_STATS) {
537 int sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
538 memcpy(data, *ieee80211_gstrings_sta_stats, sz_sta_stats);
539 }
540}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100541
542static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
543 int idx, u8 *mac, struct station_info *sinfo)
544{
Johannes Berg3b53fde82009-11-16 12:00:37 +0100545 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100546 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100547 int ret = -ENOENT;
548
549 rcu_read_lock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100550
Johannes Berg3b53fde82009-11-16 12:00:37 +0100551 sta = sta_info_get_by_idx(sdata, idx);
Johannes Bergd0709a62008-02-25 16:27:46 +0100552 if (sta) {
553 ret = 0;
Johannes Berg17741cd2008-09-11 00:02:02 +0200554 memcpy(mac, sta->sta.addr, ETH_ALEN);
Johannes Bergd0709a62008-02-25 16:27:46 +0100555 sta_set_sinfo(sta, sinfo);
556 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100557
Johannes Bergd0709a62008-02-25 16:27:46 +0100558 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100559
Johannes Bergd0709a62008-02-25 16:27:46 +0100560 return ret;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100561}
562
Holger Schurig12897232010-04-19 10:23:57 +0200563static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
564 int idx, struct survey_info *survey)
565{
566 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
567
Holger Schurig12897232010-04-19 10:23:57 +0200568 return drv_get_survey(local, idx, survey);
569}
570
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100571static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Luis Carlos Cobo2ec600d2008-02-23 15:17:06 +0100572 u8 *mac, struct station_info *sinfo)
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100573{
Johannes Bergabe60632009-11-25 17:46:18 +0100574 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100575 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100576 int ret = -ENOENT;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100577
Johannes Bergd0709a62008-02-25 16:27:46 +0100578 rcu_read_lock();
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100579
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100580 sta = sta_info_get_bss(sdata, mac);
Johannes Bergd0709a62008-02-25 16:27:46 +0100581 if (sta) {
582 ret = 0;
583 sta_set_sinfo(sta, sinfo);
584 }
585
586 rcu_read_unlock();
587
588 return ret;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100589}
590
Arik Nemtsov02945822011-11-10 11:28:57 +0200591static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
Johannes Berg88600202012-02-13 15:17:18 +0100592 const u8 *resp, size_t resp_len)
Arik Nemtsov02945822011-11-10 11:28:57 +0200593{
594 struct sk_buff *new, *old;
595
596 if (!resp || !resp_len)
Johannes Berg88600202012-02-13 15:17:18 +0100597 return 1;
Arik Nemtsov02945822011-11-10 11:28:57 +0200598
Arik Nemtsovf7248282011-11-19 10:51:26 +0200599 old = rtnl_dereference(sdata->u.ap.probe_resp);
Arik Nemtsov02945822011-11-10 11:28:57 +0200600
601 new = dev_alloc_skb(resp_len);
602 if (!new)
603 return -ENOMEM;
604
605 memcpy(skb_put(new, resp_len), resp, resp_len);
606
607 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
Johannes Berg88600202012-02-13 15:17:18 +0100608 if (old) {
609 /* TODO: use call_rcu() */
610 synchronize_rcu();
Arik Nemtsov02945822011-11-10 11:28:57 +0200611 dev_kfree_skb(old);
Johannes Berg88600202012-02-13 15:17:18 +0100612 }
Arik Nemtsov02945822011-11-10 11:28:57 +0200613
614 return 0;
615}
616
Johannes Berg88600202012-02-13 15:17:18 +0100617static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
618 struct cfg80211_beacon_data *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100619{
620 struct beacon_data *new, *old;
621 int new_head_len, new_tail_len;
Johannes Berg88600202012-02-13 15:17:18 +0100622 int size, err;
623 u32 changed = BSS_CHANGED_BEACON;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100624
Johannes Berg40b275b2011-05-13 14:15:49 +0200625 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100626
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100627 /* Need to have a beacon head if we don't have one yet */
628 if (!params->head && !old)
Johannes Berg88600202012-02-13 15:17:18 +0100629 return -EINVAL;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100630
631 /* new or old head? */
632 if (params->head)
633 new_head_len = params->head_len;
634 else
635 new_head_len = old->head_len;
636
637 /* new or old tail? */
638 if (params->tail || !old)
639 /* params->tail_len will be zero for !params->tail */
640 new_tail_len = params->tail_len;
641 else
642 new_tail_len = old->tail_len;
643
644 size = sizeof(*new) + new_head_len + new_tail_len;
645
646 new = kzalloc(size, GFP_KERNEL);
647 if (!new)
648 return -ENOMEM;
649
650 /* start filling the new info now */
651
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100652 /*
653 * pointers go into the block we allocated,
654 * memory is | beacon_data | head | tail |
655 */
656 new->head = ((u8 *) new) + sizeof(*new);
657 new->tail = new->head + new_head_len;
658 new->head_len = new_head_len;
659 new->tail_len = new_tail_len;
660
661 /* copy in head */
662 if (params->head)
663 memcpy(new->head, params->head, new_head_len);
664 else
665 memcpy(new->head, old->head, new_head_len);
666
667 /* copy in optional tail */
668 if (params->tail)
669 memcpy(new->tail, params->tail, new_tail_len);
670 else
671 if (old)
672 memcpy(new->tail, old->tail, new_tail_len);
673
Johannes Berg88600202012-02-13 15:17:18 +0100674 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
675 params->probe_resp_len);
676 if (err < 0)
677 return err;
678 if (err == 0)
679 changed |= BSS_CHANGED_AP_PROBE_RESP;
Johannes Berg19885c42010-02-05 11:45:06 +0100680
Eric Dumazetcf778b02012-01-12 04:41:32 +0000681 rcu_assign_pointer(sdata->u.ap.beacon, new);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100682
Johannes Berg88600202012-02-13 15:17:18 +0100683 if (old)
684 kfree_rcu(old, rcu_head);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100685
Johannes Berg88600202012-02-13 15:17:18 +0100686 return changed;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100687}
688
Johannes Berg88600202012-02-13 15:17:18 +0100689static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
690 struct cfg80211_ap_settings *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100691{
Johannes Berg88600202012-02-13 15:17:18 +0100692 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100693 struct beacon_data *old;
Johannes Berg665c93a2011-11-04 11:18:11 +0100694 struct ieee80211_sub_if_data *vlan;
Johannes Berg88600202012-02-13 15:17:18 +0100695 u32 changed = BSS_CHANGED_BEACON_INT |
696 BSS_CHANGED_BEACON_ENABLED |
697 BSS_CHANGED_BEACON |
698 BSS_CHANGED_SSID;
699 int err;
Johannes Berg14db74b2008-07-29 13:22:52 +0200700
Johannes Berg40b275b2011-05-13 14:15:49 +0200701 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100702 if (old)
703 return -EALREADY;
704
Johannes Berg665c93a2011-11-04 11:18:11 +0100705 /*
706 * Apply control port protocol, this allows us to
707 * not encrypt dynamic WEP control frames.
708 */
709 sdata->control_port_protocol = params->crypto.control_port_ethertype;
710 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
711 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
712 vlan->control_port_protocol =
713 params->crypto.control_port_ethertype;
714 vlan->control_port_no_encrypt =
715 params->crypto.control_port_no_encrypt;
716 }
717
Johannes Berg88600202012-02-13 15:17:18 +0100718 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
719 sdata->vif.bss_conf.dtim_period = params->dtim_period;
720
721 sdata->vif.bss_conf.ssid_len = params->ssid_len;
722 if (params->ssid_len)
723 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
724 params->ssid_len);
725 sdata->vif.bss_conf.hidden_ssid =
726 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
727
728 err = ieee80211_assign_beacon(sdata, &params->beacon);
729 if (err < 0)
730 return err;
731 changed |= err;
732
733 ieee80211_bss_info_change_notify(sdata, changed);
734
Johannes Berg3edaf3e2012-04-03 10:24:00 +0200735 netif_carrier_on(dev);
736 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
737 netif_carrier_on(vlan->dev);
738
Johannes Berg665c93a2011-11-04 11:18:11 +0100739 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100740}
741
Johannes Berg88600202012-02-13 15:17:18 +0100742static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
743 struct cfg80211_beacon_data *params)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100744{
Johannes Berg14db74b2008-07-29 13:22:52 +0200745 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100746 struct beacon_data *old;
Johannes Berg88600202012-02-13 15:17:18 +0100747 int err;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100748
Johannes Berg14db74b2008-07-29 13:22:52 +0200749 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
750
Johannes Berg40b275b2011-05-13 14:15:49 +0200751 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100752 if (!old)
753 return -ENOENT;
754
Johannes Berg88600202012-02-13 15:17:18 +0100755 err = ieee80211_assign_beacon(sdata, params);
756 if (err < 0)
757 return err;
758 ieee80211_bss_info_change_notify(sdata, err);
759 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100760}
761
Johannes Berg88600202012-02-13 15:17:18 +0100762static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100763{
Johannes Berg3edaf3e2012-04-03 10:24:00 +0200764 struct ieee80211_sub_if_data *sdata, *vlan;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100765 struct beacon_data *old;
766
Johannes Berg14db74b2008-07-29 13:22:52 +0200767 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
768
Johannes Berg40b275b2011-05-13 14:15:49 +0200769 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100770 if (!old)
771 return -ENOENT;
772
Johannes Berg3edaf3e2012-04-03 10:24:00 +0200773 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
774 netif_carrier_off(vlan->dev);
775 netif_carrier_off(dev);
776
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +0000777 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
Johannes Berg88600202012-02-13 15:17:18 +0100778
779 kfree_rcu(old, rcu_head);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100780
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200781 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
Johannes Berg88600202012-02-13 15:17:18 +0100782
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200783 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100784}
785
Johannes Berg4fd69312007-12-19 02:03:35 +0100786/* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
787struct iapp_layer2_update {
788 u8 da[ETH_ALEN]; /* broadcast */
789 u8 sa[ETH_ALEN]; /* STA addr */
790 __be16 len; /* 6 */
791 u8 dsap; /* 0 */
792 u8 ssap; /* 0 */
793 u8 control;
794 u8 xid_info[3];
Eric Dumazetbc105022010-06-03 03:21:52 -0700795} __packed;
Johannes Berg4fd69312007-12-19 02:03:35 +0100796
797static void ieee80211_send_layer2_update(struct sta_info *sta)
798{
799 struct iapp_layer2_update *msg;
800 struct sk_buff *skb;
801
802 /* Send Level 2 Update Frame to update forwarding tables in layer 2
803 * bridge devices */
804
805 skb = dev_alloc_skb(sizeof(*msg));
806 if (!skb)
807 return;
808 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
809
810 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
811 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
812
813 memset(msg->da, 0xff, ETH_ALEN);
Johannes Berg17741cd2008-09-11 00:02:02 +0200814 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
Johannes Berg4fd69312007-12-19 02:03:35 +0100815 msg->len = htons(6);
816 msg->dsap = 0;
817 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
818 msg->control = 0xaf; /* XID response lsb.1111F101.
819 * F=0 (no poll command; unsolicited frame) */
820 msg->xid_info[0] = 0x81; /* XID format identifier */
821 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
822 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
823
Johannes Bergd0709a62008-02-25 16:27:46 +0100824 skb->dev = sta->sdata->dev;
825 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
Johannes Berg4fd69312007-12-19 02:03:35 +0100826 memset(skb->cb, 0, sizeof(skb->cb));
John W. Linville06ee1c22010-07-19 11:52:59 -0400827 netif_rx_ni(skb);
Johannes Berg4fd69312007-12-19 02:03:35 +0100828}
829
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100830static int sta_apply_parameters(struct ieee80211_local *local,
831 struct sta_info *sta,
832 struct station_parameters *params)
Johannes Berg4fd69312007-12-19 02:03:35 +0100833{
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100834 int ret = 0;
Johannes Berg4fd69312007-12-19 02:03:35 +0100835 u32 rates;
836 int i, j;
Johannes Berg8318d782008-01-24 19:38:38 +0100837 struct ieee80211_supported_band *sband;
Johannes Bergd0709a62008-02-25 16:27:46 +0100838 struct ieee80211_sub_if_data *sdata = sta->sdata;
Johannes Bergeccb8e82009-05-11 21:57:56 +0300839 u32 mask, set;
Johannes Berg4fd69312007-12-19 02:03:35 +0100840
Johannes Bergae5eb022008-10-14 16:58:37 +0200841 sband = local->hw.wiphy->bands[local->oper_channel->band];
842
Johannes Bergeccb8e82009-05-11 21:57:56 +0300843 mask = params->sta_flags_mask;
844 set = params->sta_flags_set;
Johannes Berg73651ee2008-02-25 16:27:47 +0100845
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100846 /*
847 * In mesh mode, we can clear AUTHENTICATED flag but must
848 * also make ASSOCIATED follow appropriately for the driver
849 * API. See also below, after AUTHORIZED changes.
850 */
851 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
852 /* cfg80211 should not allow this in non-mesh modes */
853 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
854 return -EINVAL;
855
856 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
857 !test_sta_flag(sta, WLAN_STA_AUTH)) {
Johannes Berg83d5cc02012-01-12 09:31:10 +0100858 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100859 if (ret)
860 return ret;
Johannes Berg83d5cc02012-01-12 09:31:10 +0100861 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100862 if (ret)
863 return ret;
864 }
865 }
866
Johannes Bergeccb8e82009-05-11 21:57:56 +0300867 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300868 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Johannes Berg83d5cc02012-01-12 09:31:10 +0100869 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
Johannes Berg543d1b92012-01-13 14:17:59 +0100870 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
Johannes Berg83d5cc02012-01-12 09:31:10 +0100871 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100872 if (ret)
873 return ret;
Johannes Berg4fd69312007-12-19 02:03:35 +0100874 }
875
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100876 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
877 /* cfg80211 should not allow this in non-mesh modes */
878 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
879 return -EINVAL;
880
881 if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
882 test_sta_flag(sta, WLAN_STA_AUTH)) {
Johannes Berg83d5cc02012-01-12 09:31:10 +0100883 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100884 if (ret)
885 return ret;
Johannes Berg83d5cc02012-01-12 09:31:10 +0100886 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100887 if (ret)
888 return ret;
889 }
890 }
891
892
Johannes Bergeccb8e82009-05-11 21:57:56 +0300893 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300894 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200895 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
896 else
897 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300898 }
899
900 if (mask & BIT(NL80211_STA_FLAG_WME)) {
Arik Nemtsov39df6002011-06-27 23:58:45 +0300901 if (set & BIT(NL80211_STA_FLAG_WME)) {
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200902 set_sta_flag(sta, WLAN_STA_WME);
Arik Nemtsov39df6002011-06-27 23:58:45 +0300903 sta->sta.wme = true;
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200904 } else {
905 clear_sta_flag(sta, WLAN_STA_WME);
906 sta->sta.wme = false;
Arik Nemtsov39df6002011-06-27 23:58:45 +0300907 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300908 }
909
910 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300911 if (set & BIT(NL80211_STA_FLAG_MFP))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200912 set_sta_flag(sta, WLAN_STA_MFP);
913 else
914 clear_sta_flag(sta, WLAN_STA_MFP);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300915 }
Javier Cardonab39c48f2011-04-07 15:08:30 -0700916
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300917 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300918 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200919 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
920 else
921 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300922 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300923
Johannes Berg3b9ce802011-09-27 20:56:12 +0200924 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
925 sta->sta.uapsd_queues = params->uapsd_queues;
926 sta->sta.max_sp = params->max_sp;
927 }
Eliad Peller9533b4a2011-08-23 14:37:47 +0300928
Johannes Berg73651ee2008-02-25 16:27:47 +0100929 /*
Johannes Berg51b50fb2009-05-24 16:42:30 +0200930 * cfg80211 validates this (1-2007) and allows setting the AID
931 * only when creating a new station entry
932 */
933 if (params->aid)
934 sta->sta.aid = params->aid;
935
936 /*
Johannes Berg73651ee2008-02-25 16:27:47 +0100937 * FIXME: updating the following information is racy when this
938 * function is called from ieee80211_change_station().
939 * However, all this information should be static so
940 * maybe we should just reject attemps to change it.
941 */
942
Johannes Berg4fd69312007-12-19 02:03:35 +0100943 if (params->listen_interval >= 0)
944 sta->listen_interval = params->listen_interval;
945
946 if (params->supported_rates) {
947 rates = 0;
Johannes Berg8318d782008-01-24 19:38:38 +0100948
Johannes Berg4fd69312007-12-19 02:03:35 +0100949 for (i = 0; i < params->supported_rates_len; i++) {
950 int rate = (params->supported_rates[i] & 0x7f) * 5;
Johannes Berg8318d782008-01-24 19:38:38 +0100951 for (j = 0; j < sband->n_bitrates; j++) {
952 if (sband->bitrates[j].bitrate == rate)
Johannes Berg4fd69312007-12-19 02:03:35 +0100953 rates |= BIT(j);
954 }
955 }
Johannes Berg323ce792008-09-11 02:45:11 +0200956 sta->sta.supp_rates[local->oper_channel->band] = rates;
Johannes Berg4fd69312007-12-19 02:03:35 +0100957 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100958
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200959 if (params->ht_capa)
Ben Greearef96a8422011-11-18 11:32:00 -0800960 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
Johannes Bergae5eb022008-10-14 16:58:37 +0200961 params->ht_capa,
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200962 &sta->sta.ht_cap);
Jouni Malinen36aedc92008-08-25 11:58:58 +0300963
Javier Cardona9c3990a2011-05-03 16:57:11 -0700964 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400965#ifdef CONFIG_MAC80211_MESH
Javier Cardona9c3990a2011-05-03 16:57:11 -0700966 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
967 switch (params->plink_state) {
Javier Cardona57cf8042011-05-13 10:45:43 -0700968 case NL80211_PLINK_LISTEN:
969 case NL80211_PLINK_ESTAB:
970 case NL80211_PLINK_BLOCKED:
Javier Cardona9c3990a2011-05-03 16:57:11 -0700971 sta->plink_state = params->plink_state;
972 break;
973 default:
974 /* nothing */
975 break;
976 }
977 else
978 switch (params->plink_action) {
979 case PLINK_ACTION_OPEN:
980 mesh_plink_open(sta);
981 break;
982 case PLINK_ACTION_BLOCK:
983 mesh_plink_block(sta);
984 break;
985 }
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400986#endif
Johannes Berg902acc72008-02-23 15:17:19 +0100987 }
Johannes Bergd9a7ddb2011-12-14 12:35:30 +0100988
989 return 0;
Johannes Berg4fd69312007-12-19 02:03:35 +0100990}
991
992static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
993 u8 *mac, struct station_parameters *params)
994{
Johannes Berg14db74b2008-07-29 13:22:52 +0200995 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +0100996 struct sta_info *sta;
997 struct ieee80211_sub_if_data *sdata;
Johannes Berg73651ee2008-02-25 16:27:47 +0100998 int err;
Jouni Malinenb8d476c2008-12-12 17:08:31 +0200999 int layer2_update;
Johannes Berg4fd69312007-12-19 02:03:35 +01001000
Johannes Berg4fd69312007-12-19 02:03:35 +01001001 if (params->vlan) {
1002 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1003
Johannes Berg05c914f2008-09-11 00:01:58 +02001004 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1005 sdata->vif.type != NL80211_IFTYPE_AP)
Johannes Berg4fd69312007-12-19 02:03:35 +01001006 return -EINVAL;
1007 } else
1008 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1009
Johannes Berg47846c92009-11-25 17:46:19 +01001010 if (compare_ether_addr(mac, sdata->vif.addr) == 0)
Johannes Berg03e44972008-02-27 09:56:40 +01001011 return -EINVAL;
1012
1013 if (is_multicast_ether_addr(mac))
1014 return -EINVAL;
1015
1016 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +01001017 if (!sta)
1018 return -ENOMEM;
Johannes Berg4fd69312007-12-19 02:03:35 +01001019
Johannes Berg83d5cc02012-01-12 09:31:10 +01001020 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1021 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
Johannes Berg4fd69312007-12-19 02:03:35 +01001022
Johannes Bergd9a7ddb2011-12-14 12:35:30 +01001023 err = sta_apply_parameters(local, sta, params);
1024 if (err) {
1025 sta_info_free(local, sta);
1026 return err;
1027 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001028
Arik Nemtsovd64cf632011-11-07 23:24:39 +02001029 /*
1030 * for TDLS, rate control should be initialized only when supported
1031 * rates are known.
1032 */
1033 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER))
1034 rate_control_rate_init(sta);
Johannes Berg4fd69312007-12-19 02:03:35 +01001035
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001036 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1037 sdata->vif.type == NL80211_IFTYPE_AP;
1038
Johannes Berg34e89502010-02-03 13:59:58 +01001039 err = sta_info_insert_rcu(sta);
Johannes Berg73651ee2008-02-25 16:27:47 +01001040 if (err) {
Johannes Berg73651ee2008-02-25 16:27:47 +01001041 rcu_read_unlock();
1042 return err;
1043 }
1044
Jouni Malinenb8d476c2008-12-12 17:08:31 +02001045 if (layer2_update)
Johannes Berg73651ee2008-02-25 16:27:47 +01001046 ieee80211_send_layer2_update(sta);
1047
1048 rcu_read_unlock();
1049
Johannes Berg4fd69312007-12-19 02:03:35 +01001050 return 0;
1051}
1052
1053static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1054 u8 *mac)
1055{
Johannes Berg14db74b2008-07-29 13:22:52 +02001056 struct ieee80211_local *local = wiphy_priv(wiphy);
1057 struct ieee80211_sub_if_data *sdata;
Johannes Berg4fd69312007-12-19 02:03:35 +01001058
Johannes Berg14db74b2008-07-29 13:22:52 +02001059 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1060
Johannes Berg34e89502010-02-03 13:59:58 +01001061 if (mac)
1062 return sta_info_destroy_addr_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001063
Johannes Berg34e89502010-02-03 13:59:58 +01001064 sta_info_flush(local, sdata);
Johannes Berg4fd69312007-12-19 02:03:35 +01001065 return 0;
1066}
1067
1068static int ieee80211_change_station(struct wiphy *wiphy,
1069 struct net_device *dev,
1070 u8 *mac,
1071 struct station_parameters *params)
1072{
Johannes Bergabe60632009-11-25 17:46:18 +01001073 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg14db74b2008-07-29 13:22:52 +02001074 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +01001075 struct sta_info *sta;
1076 struct ieee80211_sub_if_data *vlansdata;
Eliad Peller35b88622011-12-29 14:41:39 +02001077 int err;
Johannes Berg4fd69312007-12-19 02:03:35 +01001078
Johannes Berg87be1e12011-12-14 12:20:29 +01001079 mutex_lock(&local->sta_mtx);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001080
Felix Fietkau0e5ded52010-01-08 18:10:58 +01001081 sta = sta_info_get_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001082 if (!sta) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001083 mutex_unlock(&local->sta_mtx);
Johannes Berg4fd69312007-12-19 02:03:35 +01001084 return -ENOENT;
Johannes Berg98dd6a52008-04-10 15:36:09 +02001085 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001086
Johannes Bergbdd90d52011-12-14 12:20:27 +01001087 /* in station mode, supported rates are only valid with TDLS */
1088 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1089 params->supported_rates &&
1090 !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001091 mutex_unlock(&local->sta_mtx);
Johannes Bergbdd90d52011-12-14 12:20:27 +01001092 return -EINVAL;
1093 }
1094
Johannes Bergd0709a62008-02-25 16:27:46 +01001095 if (params->vlan && params->vlan != sta->sdata->dev) {
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001096 bool prev_4addr = false;
1097 bool new_4addr = false;
1098
Johannes Berg4fd69312007-12-19 02:03:35 +01001099 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1100
Johannes Berg05c914f2008-09-11 00:01:58 +02001101 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1102 vlansdata->vif.type != NL80211_IFTYPE_AP) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001103 mutex_unlock(&local->sta_mtx);
Johannes Berg4fd69312007-12-19 02:03:35 +01001104 return -EINVAL;
Johannes Berg98dd6a52008-04-10 15:36:09 +02001105 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001106
Johannes Berg9bc383d2009-11-19 11:55:19 +01001107 if (params->vlan->ieee80211_ptr->use_4addr) {
Johannes Berg33054432009-11-20 10:09:14 +01001108 if (vlansdata->u.vlan.sta) {
Johannes Berg87be1e12011-12-14 12:20:29 +01001109 mutex_unlock(&local->sta_mtx);
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001110 return -EBUSY;
Johannes Berg33054432009-11-20 10:09:14 +01001111 }
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001112
Eric Dumazetcf778b02012-01-12 04:41:32 +00001113 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001114 new_4addr = true;
1115 }
1116
1117 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1118 sta->sdata->u.vlan.sta) {
1119 rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL);
1120 prev_4addr = true;
Felix Fietkauf14543ee2009-11-10 20:10:05 +01001121 }
1122
Johannes Berg14db74b2008-07-29 13:22:52 +02001123 sta->sdata = vlansdata;
Felix Fietkau7e3ed022012-04-23 19:49:03 +02001124
1125 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
1126 prev_4addr != new_4addr) {
1127 if (new_4addr)
1128 atomic_dec(&sta->sdata->bss->num_mcast_sta);
1129 else
1130 atomic_inc(&sta->sdata->bss->num_mcast_sta);
1131 }
1132
Johannes Berg4fd69312007-12-19 02:03:35 +01001133 ieee80211_send_layer2_update(sta);
1134 }
1135
Eliad Peller35b88622011-12-29 14:41:39 +02001136 err = sta_apply_parameters(local, sta, params);
1137 if (err) {
1138 mutex_unlock(&local->sta_mtx);
1139 return err;
1140 }
Johannes Berg4fd69312007-12-19 02:03:35 +01001141
Arik Nemtsovd64cf632011-11-07 23:24:39 +02001142 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates)
1143 rate_control_rate_init(sta);
1144
Johannes Berg87be1e12011-12-14 12:20:29 +01001145 mutex_unlock(&local->sta_mtx);
Johannes Berg98dd6a52008-04-10 15:36:09 +02001146
Jason Young808118c2011-03-10 16:43:19 -08001147 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1148 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))
1149 ieee80211_recalc_ps(local, -1);
1150
Johannes Berg4fd69312007-12-19 02:03:35 +01001151 return 0;
1152}
1153
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001154#ifdef CONFIG_MAC80211_MESH
1155static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1156 u8 *dst, u8 *next_hop)
1157{
Johannes Berg14db74b2008-07-29 13:22:52 +02001158 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001159 struct mesh_path *mpath;
1160 struct sta_info *sta;
1161 int err;
1162
Johannes Berg14db74b2008-07-29 13:22:52 +02001163 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1164
Johannes Bergd0709a62008-02-25 16:27:46 +01001165 rcu_read_lock();
Johannes Bergabe60632009-11-25 17:46:18 +01001166 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +01001167 if (!sta) {
1168 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001169 return -ENOENT;
Johannes Bergd0709a62008-02-25 16:27:46 +01001170 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001171
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001172 err = mesh_path_add(dst, sdata);
Johannes Bergd0709a62008-02-25 16:27:46 +01001173 if (err) {
1174 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001175 return err;
Johannes Bergd0709a62008-02-25 16:27:46 +01001176 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001177
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001178 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001179 if (!mpath) {
1180 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001181 return -ENXIO;
1182 }
1183 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +01001184
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001185 rcu_read_unlock();
1186 return 0;
1187}
1188
1189static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1190 u8 *dst)
1191{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001192 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001193
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001194 if (dst)
1195 return mesh_path_del(dst, sdata);
1196
Javier Cardonaece1a2e2011-08-29 13:23:04 -07001197 mesh_path_flush_by_iface(sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001198 return 0;
1199}
1200
1201static int ieee80211_change_mpath(struct wiphy *wiphy,
1202 struct net_device *dev,
1203 u8 *dst, u8 *next_hop)
1204{
Johannes Berg14db74b2008-07-29 13:22:52 +02001205 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001206 struct mesh_path *mpath;
1207 struct sta_info *sta;
1208
Johannes Berg14db74b2008-07-29 13:22:52 +02001209 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1210
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001211 rcu_read_lock();
Johannes Bergd0709a62008-02-25 16:27:46 +01001212
Johannes Bergabe60632009-11-25 17:46:18 +01001213 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +01001214 if (!sta) {
1215 rcu_read_unlock();
1216 return -ENOENT;
1217 }
1218
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001219 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001220 if (!mpath) {
1221 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001222 return -ENOENT;
1223 }
1224
1225 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +01001226
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001227 rcu_read_unlock();
1228 return 0;
1229}
1230
1231static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1232 struct mpath_info *pinfo)
1233{
Johannes Berga3836e02011-05-12 15:11:37 +02001234 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1235
1236 if (next_hop_sta)
1237 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001238 else
1239 memset(next_hop, 0, ETH_ALEN);
1240
Johannes Bergf5ea9122009-08-07 16:17:38 +02001241 pinfo->generation = mesh_paths_generation;
1242
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001243 pinfo->filled = MPATH_INFO_FRAME_QLEN |
Rui Paulod19b3bf2009-11-09 23:46:55 +00001244 MPATH_INFO_SN |
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001245 MPATH_INFO_METRIC |
1246 MPATH_INFO_EXPTIME |
1247 MPATH_INFO_DISCOVERY_TIMEOUT |
1248 MPATH_INFO_DISCOVERY_RETRIES |
1249 MPATH_INFO_FLAGS;
1250
1251 pinfo->frame_qlen = mpath->frame_queue.qlen;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001252 pinfo->sn = mpath->sn;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001253 pinfo->metric = mpath->metric;
1254 if (time_before(jiffies, mpath->exp_time))
1255 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1256 pinfo->discovery_timeout =
1257 jiffies_to_msecs(mpath->discovery_timeout);
1258 pinfo->discovery_retries = mpath->discovery_retries;
1259 pinfo->flags = 0;
1260 if (mpath->flags & MESH_PATH_ACTIVE)
1261 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1262 if (mpath->flags & MESH_PATH_RESOLVING)
1263 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001264 if (mpath->flags & MESH_PATH_SN_VALID)
1265 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001266 if (mpath->flags & MESH_PATH_FIXED)
1267 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1268 if (mpath->flags & MESH_PATH_RESOLVING)
1269 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1270
1271 pinfo->flags = mpath->flags;
1272}
1273
1274static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1275 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1276
1277{
Johannes Berg14db74b2008-07-29 13:22:52 +02001278 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001279 struct mesh_path *mpath;
1280
Johannes Berg14db74b2008-07-29 13:22:52 +02001281 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1282
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001283 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001284 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001285 if (!mpath) {
1286 rcu_read_unlock();
1287 return -ENOENT;
1288 }
1289 memcpy(dst, mpath->dst, ETH_ALEN);
1290 mpath_set_pinfo(mpath, next_hop, pinfo);
1291 rcu_read_unlock();
1292 return 0;
1293}
1294
1295static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1296 int idx, u8 *dst, u8 *next_hop,
1297 struct mpath_info *pinfo)
1298{
Johannes Berg14db74b2008-07-29 13:22:52 +02001299 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001300 struct mesh_path *mpath;
1301
Johannes Berg14db74b2008-07-29 13:22:52 +02001302 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1303
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001304 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001305 mpath = mesh_path_lookup_by_idx(idx, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001306 if (!mpath) {
1307 rcu_read_unlock();
1308 return -ENOENT;
1309 }
1310 memcpy(dst, mpath->dst, ETH_ALEN);
1311 mpath_set_pinfo(mpath, next_hop, pinfo);
1312 rcu_read_unlock();
1313 return 0;
1314}
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001315
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001316static int ieee80211_get_mesh_config(struct wiphy *wiphy,
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001317 struct net_device *dev,
1318 struct mesh_config *conf)
1319{
1320 struct ieee80211_sub_if_data *sdata;
1321 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1322
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001323 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1324 return 0;
1325}
1326
1327static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1328{
1329 return (mask >> (parm-1)) & 0x1;
1330}
1331
Javier Cardonac80d5452010-12-16 17:37:49 -08001332static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1333 const struct mesh_setup *setup)
1334{
1335 u8 *new_ie;
1336 const u8 *old_ie;
Chun-Yeow Yeoh4bb62342011-11-24 17:15:20 -08001337 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
1338 struct ieee80211_sub_if_data, u.mesh);
Javier Cardonac80d5452010-12-16 17:37:49 -08001339
Javier Cardona581a8b02011-04-07 15:08:27 -07001340 /* allocate information elements */
Javier Cardonac80d5452010-12-16 17:37:49 -08001341 new_ie = NULL;
Javier Cardona581a8b02011-04-07 15:08:27 -07001342 old_ie = ifmsh->ie;
Javier Cardonac80d5452010-12-16 17:37:49 -08001343
Javier Cardona581a8b02011-04-07 15:08:27 -07001344 if (setup->ie_len) {
1345 new_ie = kmemdup(setup->ie, setup->ie_len,
Javier Cardonac80d5452010-12-16 17:37:49 -08001346 GFP_KERNEL);
1347 if (!new_ie)
1348 return -ENOMEM;
1349 }
Javier Cardona581a8b02011-04-07 15:08:27 -07001350 ifmsh->ie_len = setup->ie_len;
1351 ifmsh->ie = new_ie;
1352 kfree(old_ie);
Javier Cardonac80d5452010-12-16 17:37:49 -08001353
1354 /* now copy the rest of the setup parameters */
1355 ifmsh->mesh_id_len = setup->mesh_id_len;
1356 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
Javier Cardonad299a1f2012-03-31 11:31:33 -07001357 ifmsh->mesh_sp_id = setup->sync_method;
Javier Cardonac80d5452010-12-16 17:37:49 -08001358 ifmsh->mesh_pp_id = setup->path_sel_proto;
1359 ifmsh->mesh_pm_id = setup->path_metric;
Javier Cardonab130e5c2011-05-03 16:57:07 -07001360 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1361 if (setup->is_authenticated)
1362 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1363 if (setup->is_secure)
1364 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
Javier Cardonac80d5452010-12-16 17:37:49 -08001365
Chun-Yeow Yeoh4bb62342011-11-24 17:15:20 -08001366 /* mcast rate setting in Mesh Node */
1367 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
1368 sizeof(setup->mcast_rate));
1369
Javier Cardonac80d5452010-12-16 17:37:49 -08001370 return 0;
1371}
1372
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001373static int ieee80211_update_mesh_config(struct wiphy *wiphy,
Johannes Berg29cbe682010-12-03 09:20:44 +01001374 struct net_device *dev, u32 mask,
1375 const struct mesh_config *nconf)
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001376{
1377 struct mesh_config *conf;
1378 struct ieee80211_sub_if_data *sdata;
Rui Paulo63c57232009-11-09 23:46:57 +00001379 struct ieee80211_if_mesh *ifmsh;
1380
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001381 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Rui Paulo63c57232009-11-09 23:46:57 +00001382 ifmsh = &sdata->u.mesh;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001383
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001384 /* Set the config options which we are interested in setting */
1385 conf = &(sdata->u.mesh.mshcfg);
1386 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1387 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1388 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1389 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1390 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1391 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1392 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1393 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1394 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1395 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1396 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1397 conf->dot11MeshTTL = nconf->dot11MeshTTL;
Javier Cardona45904f22010-12-03 09:20:40 +01001398 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1399 conf->dot11MeshTTL = nconf->element_ttl;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001400 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
1401 conf->auto_open_plinks = nconf->auto_open_plinks;
Javier Cardonad299a1f2012-03-31 11:31:33 -07001402 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
1403 conf->dot11MeshNbrOffsetMaxNeighbor =
1404 nconf->dot11MeshNbrOffsetMaxNeighbor;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001405 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1406 conf->dot11MeshHWMPmaxPREQretries =
1407 nconf->dot11MeshHWMPmaxPREQretries;
1408 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1409 conf->path_refresh_time = nconf->path_refresh_time;
1410 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1411 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1412 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1413 conf->dot11MeshHWMPactivePathTimeout =
1414 nconf->dot11MeshHWMPactivePathTimeout;
1415 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1416 conf->dot11MeshHWMPpreqMinInterval =
1417 nconf->dot11MeshHWMPpreqMinInterval;
Thomas Pedersendca7e942011-11-24 17:15:24 -08001418 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
1419 conf->dot11MeshHWMPperrMinInterval =
1420 nconf->dot11MeshHWMPperrMinInterval;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001421 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1422 mask))
1423 conf->dot11MeshHWMPnetDiameterTraversalTime =
1424 nconf->dot11MeshHWMPnetDiameterTraversalTime;
Rui Paulo63c57232009-11-09 23:46:57 +00001425 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1426 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1427 ieee80211_mesh_root_setup(ifmsh);
1428 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001429 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
Thomas Pedersenc61336612011-08-25 10:36:14 -07001430 /* our current gate announcement implementation rides on root
1431 * announcements, so require this ifmsh to also be a root node
1432 * */
1433 if (nconf->dot11MeshGateAnnouncementProtocol &&
1434 !conf->dot11MeshHWMPRootMode) {
1435 conf->dot11MeshHWMPRootMode = 1;
1436 ieee80211_mesh_root_setup(ifmsh);
1437 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001438 conf->dot11MeshGateAnnouncementProtocol =
1439 nconf->dot11MeshGateAnnouncementProtocol;
1440 }
Javier Cardona0507e152011-08-09 16:45:10 -07001441 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) {
1442 conf->dot11MeshHWMPRannInterval =
1443 nconf->dot11MeshHWMPRannInterval;
1444 }
Chun-Yeow Yeoh94f90652012-01-21 01:02:16 +08001445 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1446 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
Ashok Nagarajan55335132012-02-28 17:04:08 -08001447 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
1448 /* our RSSI threshold implementation is supported only for
1449 * devices that report signal in dBm.
1450 */
1451 if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM))
1452 return -ENOTSUPP;
1453 conf->rssi_threshold = nconf->rssi_threshold;
1454 }
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001455 return 0;
1456}
1457
Johannes Berg29cbe682010-12-03 09:20:44 +01001458static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1459 const struct mesh_config *conf,
1460 const struct mesh_setup *setup)
1461{
1462 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1463 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
Javier Cardonac80d5452010-12-16 17:37:49 -08001464 int err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001465
Javier Cardonac80d5452010-12-16 17:37:49 -08001466 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1467 err = copy_mesh_setup(ifmsh, setup);
1468 if (err)
1469 return err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001470 ieee80211_start_mesh(sdata);
1471
1472 return 0;
1473}
1474
1475static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1476{
1477 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1478
1479 ieee80211_stop_mesh(sdata);
1480
1481 return 0;
1482}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001483#endif
1484
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001485static int ieee80211_change_bss(struct wiphy *wiphy,
1486 struct net_device *dev,
1487 struct bss_parameters *params)
1488{
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001489 struct ieee80211_sub_if_data *sdata;
1490 u32 changed = 0;
1491
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001492 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1493
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001494 if (params->use_cts_prot >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001495 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001496 changed |= BSS_CHANGED_ERP_CTS_PROT;
1497 }
1498 if (params->use_short_preamble >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001499 sdata->vif.bss_conf.use_short_preamble =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001500 params->use_short_preamble;
1501 changed |= BSS_CHANGED_ERP_PREAMBLE;
1502 }
Felix Fietkau43d35342010-01-15 03:00:48 +01001503
1504 if (!sdata->vif.bss_conf.use_short_slot &&
1505 sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) {
1506 sdata->vif.bss_conf.use_short_slot = true;
1507 changed |= BSS_CHANGED_ERP_SLOT;
1508 }
1509
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001510 if (params->use_short_slot_time >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001511 sdata->vif.bss_conf.use_short_slot =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001512 params->use_short_slot_time;
1513 changed |= BSS_CHANGED_ERP_SLOT;
1514 }
1515
Jouni Malinen90c97a02008-10-30 16:59:22 +02001516 if (params->basic_rates) {
1517 int i, j;
1518 u32 rates = 0;
1519 struct ieee80211_local *local = wiphy_priv(wiphy);
1520 struct ieee80211_supported_band *sband =
1521 wiphy->bands[local->oper_channel->band];
1522
1523 for (i = 0; i < params->basic_rates_len; i++) {
1524 int rate = (params->basic_rates[i] & 0x7f) * 5;
1525 for (j = 0; j < sband->n_bitrates; j++) {
1526 if (sband->bitrates[j].bitrate == rate)
1527 rates |= BIT(j);
1528 }
1529 }
1530 sdata->vif.bss_conf.basic_rates = rates;
1531 changed |= BSS_CHANGED_BASIC_RATES;
1532 }
1533
Felix Fietkau7b7b5e52010-04-27 01:23:36 +02001534 if (params->ap_isolate >= 0) {
1535 if (params->ap_isolate)
1536 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1537 else
1538 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1539 }
1540
Helmut Schaa80d7e402010-11-19 12:40:26 +01001541 if (params->ht_opmode >= 0) {
1542 sdata->vif.bss_conf.ht_operation_mode =
1543 (u16) params->ht_opmode;
1544 changed |= BSS_CHANGED_HT;
1545 }
1546
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001547 ieee80211_bss_info_change_notify(sdata, changed);
1548
1549 return 0;
1550}
1551
Jouni Malinen31888482008-10-30 16:59:24 +02001552static int ieee80211_set_txq_params(struct wiphy *wiphy,
Eliad Pellerf70f01c2011-09-25 20:06:53 +03001553 struct net_device *dev,
Jouni Malinen31888482008-10-30 16:59:24 +02001554 struct ieee80211_txq_params *params)
1555{
1556 struct ieee80211_local *local = wiphy_priv(wiphy);
Eliad Pellerf6f3def2011-09-25 20:06:54 +03001557 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen31888482008-10-30 16:59:24 +02001558 struct ieee80211_tx_queue_params p;
1559
1560 if (!local->ops->conf_tx)
1561 return -EOPNOTSUPP;
1562
Johannes Berg54bcbc62012-03-28 11:04:25 +02001563 if (local->hw.queues < IEEE80211_NUM_ACS)
1564 return -EOPNOTSUPP;
1565
Jouni Malinen31888482008-10-30 16:59:24 +02001566 memset(&p, 0, sizeof(p));
1567 p.aifs = params->aifs;
1568 p.cw_max = params->cwmax;
1569 p.cw_min = params->cwmin;
1570 p.txop = params->txop;
Kalle Valoab133152010-01-12 10:42:31 +02001571
1572 /*
1573 * Setting tx queue params disables u-apsd because it's only
1574 * called in master mode.
1575 */
1576 p.uapsd = false;
1577
Johannes Berga3304b02012-03-28 11:04:24 +02001578 sdata->tx_conf[params->ac] = p;
1579 if (drv_conf_tx(local, sdata, params->ac, &p)) {
Joe Perches0fb9a9e2010-08-20 16:25:38 -07001580 wiphy_debug(local->hw.wiphy,
Johannes Berga3304b02012-03-28 11:04:24 +02001581 "failed to set TX queue parameters for AC %d\n",
1582 params->ac);
Jouni Malinen31888482008-10-30 16:59:24 +02001583 return -EINVAL;
1584 }
1585
1586 return 0;
1587}
1588
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001589static int ieee80211_set_channel(struct wiphy *wiphy,
Johannes Bergf444de02010-05-05 15:25:02 +02001590 struct net_device *netdev,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001591 struct ieee80211_channel *chan,
Sujith094d05d2008-12-12 11:57:43 +05301592 enum nl80211_channel_type channel_type)
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001593{
1594 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg0aaffa92010-05-05 15:28:27 +02001595 struct ieee80211_sub_if_data *sdata = NULL;
Ben Greeareeabee72011-01-28 10:20:47 -08001596 struct ieee80211_channel *old_oper;
1597 enum nl80211_channel_type old_oper_type;
1598 enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001599
1600 if (netdev)
1601 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001602
Johannes Bergf444de02010-05-05 15:25:02 +02001603 switch (ieee80211_get_channel_mode(local, NULL)) {
1604 case CHAN_MODE_HOPPING:
1605 return -EBUSY;
1606 case CHAN_MODE_FIXED:
Johannes Berg0aaffa92010-05-05 15:28:27 +02001607 if (local->oper_channel != chan)
1608 return -EBUSY;
1609 if (!sdata && local->_oper_channel_type == channel_type)
Johannes Bergf444de02010-05-05 15:25:02 +02001610 return 0;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001611 break;
Johannes Bergf444de02010-05-05 15:25:02 +02001612 case CHAN_MODE_UNDEFINED:
1613 break;
1614 }
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001615
Ben Greeareeabee72011-01-28 10:20:47 -08001616 if (sdata)
1617 old_vif_oper_type = sdata->vif.bss_conf.channel_type;
1618 old_oper_type = local->_oper_channel_type;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001619
Johannes Berg0aaffa92010-05-05 15:28:27 +02001620 if (!ieee80211_set_channel_type(local, sdata, channel_type))
1621 return -EBUSY;
1622
Ben Greeareeabee72011-01-28 10:20:47 -08001623 old_oper = local->oper_channel;
1624 local->oper_channel = chan;
1625
1626 /* Update driver if changes were actually made. */
1627 if ((old_oper != local->oper_channel) ||
1628 (old_oper_type != local->_oper_channel_type))
1629 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1630
Johannes Bergef5af742011-10-18 13:39:14 +02001631 if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR &&
Ben Greeareeabee72011-01-28 10:20:47 -08001632 old_vif_oper_type != sdata->vif.bss_conf.channel_type)
Johannes Berg0aaffa92010-05-05 15:28:27 +02001633 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1634
1635 return 0;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001636}
1637
Bob Copeland665af4f2009-01-19 11:20:53 -05001638#ifdef CONFIG_PM
Johannes Bergff1b6e62011-05-04 15:37:28 +02001639static int ieee80211_suspend(struct wiphy *wiphy,
1640 struct cfg80211_wowlan *wowlan)
Bob Copeland665af4f2009-01-19 11:20:53 -05001641{
Johannes Bergeecc4802011-05-04 15:37:29 +02001642 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
Bob Copeland665af4f2009-01-19 11:20:53 -05001643}
1644
1645static int ieee80211_resume(struct wiphy *wiphy)
1646{
1647 return __ieee80211_resume(wiphy_priv(wiphy));
1648}
1649#else
1650#define ieee80211_suspend NULL
1651#define ieee80211_resume NULL
1652#endif
1653
Johannes Berg2a519312009-02-10 21:25:55 +01001654static int ieee80211_scan(struct wiphy *wiphy,
1655 struct net_device *dev,
1656 struct cfg80211_scan_request *req)
1657{
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001658 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg2a519312009-02-10 21:25:55 +01001659
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001660 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
1661 case NL80211_IFTYPE_STATION:
1662 case NL80211_IFTYPE_ADHOC:
1663 case NL80211_IFTYPE_MESH_POINT:
1664 case NL80211_IFTYPE_P2P_CLIENT:
1665 break;
1666 case NL80211_IFTYPE_P2P_GO:
1667 if (sdata->local->ops->hw_scan)
1668 break;
Johannes Berge9d77322011-02-01 15:35:36 +01001669 /*
1670 * FIXME: implement NoA while scanning in software,
1671 * for now fall through to allow scanning only when
1672 * beaconing hasn't been configured yet
1673 */
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001674 case NL80211_IFTYPE_AP:
1675 if (sdata->u.ap.beacon)
1676 return -EOPNOTSUPP;
1677 break;
1678 default:
1679 return -EOPNOTSUPP;
1680 }
Johannes Berg2a519312009-02-10 21:25:55 +01001681
1682 return ieee80211_request_scan(sdata, req);
1683}
1684
Luciano Coelho79f460c2011-05-11 17:09:36 +03001685static int
1686ieee80211_sched_scan_start(struct wiphy *wiphy,
1687 struct net_device *dev,
1688 struct cfg80211_sched_scan_request *req)
1689{
1690 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1691
1692 if (!sdata->local->ops->sched_scan_start)
1693 return -EOPNOTSUPP;
1694
1695 return ieee80211_request_sched_scan_start(sdata, req);
1696}
1697
1698static int
Luciano Coelho85a99942011-05-12 16:28:29 +03001699ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
Luciano Coelho79f460c2011-05-11 17:09:36 +03001700{
1701 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1702
1703 if (!sdata->local->ops->sched_scan_stop)
1704 return -EOPNOTSUPP;
1705
Luciano Coelho85a99942011-05-12 16:28:29 +03001706 return ieee80211_request_sched_scan_stop(sdata);
Luciano Coelho79f460c2011-05-11 17:09:36 +03001707}
1708
Jouni Malinen636a5d32009-03-19 13:39:22 +02001709static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1710 struct cfg80211_auth_request *req)
1711{
Johannes Berg77fdaa12009-07-07 03:45:17 +02001712 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001713}
1714
1715static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1716 struct cfg80211_assoc_request *req)
1717{
Johannes Bergf444de02010-05-05 15:25:02 +02001718 struct ieee80211_local *local = wiphy_priv(wiphy);
1719 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1720
1721 switch (ieee80211_get_channel_mode(local, sdata)) {
1722 case CHAN_MODE_HOPPING:
1723 return -EBUSY;
1724 case CHAN_MODE_FIXED:
1725 if (local->oper_channel == req->bss->channel)
1726 break;
1727 return -EBUSY;
1728 case CHAN_MODE_UNDEFINED:
1729 break;
1730 }
1731
Johannes Berg77fdaa12009-07-07 03:45:17 +02001732 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001733}
1734
1735static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001736 struct cfg80211_deauth_request *req)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001737{
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001738 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001739}
1740
1741static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001742 struct cfg80211_disassoc_request *req)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001743{
Johannes Berg63c9c5e2012-02-24 13:50:51 +01001744 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001745}
1746
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001747static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1748 struct cfg80211_ibss_params *params)
1749{
Johannes Bergf444de02010-05-05 15:25:02 +02001750 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001751 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1752
Johannes Bergf444de02010-05-05 15:25:02 +02001753 switch (ieee80211_get_channel_mode(local, sdata)) {
1754 case CHAN_MODE_HOPPING:
1755 return -EBUSY;
1756 case CHAN_MODE_FIXED:
1757 if (!params->channel_fixed)
1758 return -EBUSY;
1759 if (local->oper_channel == params->channel)
1760 break;
1761 return -EBUSY;
1762 case CHAN_MODE_UNDEFINED:
1763 break;
1764 }
1765
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001766 return ieee80211_ibss_join(sdata, params);
1767}
1768
1769static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1770{
1771 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1772
1773 return ieee80211_ibss_leave(sdata);
1774}
1775
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001776static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1777{
1778 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg24487982009-04-23 18:52:52 +02001779 int err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001780
Arik Nemtsovf23a4782010-11-08 11:51:06 +02001781 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1782 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
1783
1784 if (err)
1785 return err;
1786 }
1787
Lukáš Turek310bc672009-12-21 22:50:48 +01001788 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
1789 err = drv_set_coverage_class(local, wiphy->coverage_class);
1790
1791 if (err)
1792 return err;
1793 }
1794
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001795 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
Johannes Berg24487982009-04-23 18:52:52 +02001796 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001797
Johannes Berg24487982009-04-23 18:52:52 +02001798 if (err)
1799 return err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001800 }
1801
1802 if (changed & WIPHY_PARAM_RETRY_SHORT)
1803 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
1804 if (changed & WIPHY_PARAM_RETRY_LONG)
1805 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
1806 if (changed &
1807 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
1808 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
1809
1810 return 0;
1811}
1812
Johannes Berg7643a2c2009-06-02 13:01:39 +02001813static int ieee80211_set_tx_power(struct wiphy *wiphy,
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001814 enum nl80211_tx_power_setting type, int mbm)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001815{
1816 struct ieee80211_local *local = wiphy_priv(wiphy);
1817 struct ieee80211_channel *chan = local->hw.conf.channel;
1818 u32 changes = 0;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001819
1820 switch (type) {
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001821 case NL80211_TX_POWER_AUTOMATIC:
Johannes Berg7643a2c2009-06-02 13:01:39 +02001822 local->user_power_level = -1;
1823 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001824 case NL80211_TX_POWER_LIMITED:
1825 if (mbm < 0 || (mbm % 100))
1826 return -EOPNOTSUPP;
1827 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001828 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001829 case NL80211_TX_POWER_FIXED:
1830 if (mbm < 0 || (mbm % 100))
1831 return -EOPNOTSUPP;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001832 /* TODO: move to cfg80211 when it knows the channel */
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001833 if (MBM_TO_DBM(mbm) > chan->max_power)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001834 return -EINVAL;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001835 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001836 break;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001837 }
1838
1839 ieee80211_hw_config(local, changes);
1840
1841 return 0;
1842}
1843
1844static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1845{
1846 struct ieee80211_local *local = wiphy_priv(wiphy);
1847
1848 *dbm = local->hw.conf.power_level;
1849
Johannes Berg7643a2c2009-06-02 13:01:39 +02001850 return 0;
1851}
1852
Johannes Bergab737a42009-07-01 21:26:58 +02001853static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg388ac772010-10-07 13:11:09 +02001854 const u8 *addr)
Johannes Bergab737a42009-07-01 21:26:58 +02001855{
1856 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1857
1858 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
1859
1860 return 0;
1861}
1862
Johannes Berg1f87f7d2009-06-02 13:01:41 +02001863static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1864{
1865 struct ieee80211_local *local = wiphy_priv(wiphy);
1866
1867 drv_rfkill_poll(local);
1868}
1869
Johannes Bergaff89a92009-07-01 21:26:51 +02001870#ifdef CONFIG_NL80211_TESTMODE
Johannes Berg99783e22009-07-07 03:54:43 +02001871static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
Johannes Bergaff89a92009-07-01 21:26:51 +02001872{
1873 struct ieee80211_local *local = wiphy_priv(wiphy);
1874
1875 if (!local->ops->testmode_cmd)
1876 return -EOPNOTSUPP;
1877
1878 return local->ops->testmode_cmd(&local->hw, data, len);
1879}
Wey-Yi Guy71063f02011-05-20 09:05:54 -07001880
1881static int ieee80211_testmode_dump(struct wiphy *wiphy,
1882 struct sk_buff *skb,
1883 struct netlink_callback *cb,
1884 void *data, int len)
1885{
1886 struct ieee80211_local *local = wiphy_priv(wiphy);
1887
1888 if (!local->ops->testmode_dump)
1889 return -EOPNOTSUPP;
1890
1891 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
1892}
Johannes Bergaff89a92009-07-01 21:26:51 +02001893#endif
1894
Johannes Berg0f782312009-12-01 13:37:02 +01001895int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1896 enum ieee80211_smps_mode smps_mode)
1897{
1898 const u8 *ap;
1899 enum ieee80211_smps_mode old_req;
1900 int err;
1901
Johannes Berg243e6df2011-04-19 20:44:04 +02001902 lockdep_assert_held(&sdata->u.mgd.mtx);
1903
Johannes Berg0f782312009-12-01 13:37:02 +01001904 old_req = sdata->u.mgd.req_smps;
1905 sdata->u.mgd.req_smps = smps_mode;
1906
1907 if (old_req == smps_mode &&
1908 smps_mode != IEEE80211_SMPS_AUTOMATIC)
1909 return 0;
1910
1911 /*
1912 * If not associated, or current association is not an HT
1913 * association, there's no need to send an action frame.
1914 */
1915 if (!sdata->u.mgd.associated ||
Johannes Berg0aaffa92010-05-05 15:28:27 +02001916 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
Johannes Berg0f782312009-12-01 13:37:02 +01001917 mutex_lock(&sdata->local->iflist_mtx);
Johannes Berg025e6be2010-10-05 10:41:47 +02001918 ieee80211_recalc_smps(sdata->local);
Johannes Berg0f782312009-12-01 13:37:02 +01001919 mutex_unlock(&sdata->local->iflist_mtx);
1920 return 0;
1921 }
1922
Johannes Berg0c1ad2c2009-12-23 13:15:39 +01001923 ap = sdata->u.mgd.associated->bssid;
Johannes Berg0f782312009-12-01 13:37:02 +01001924
1925 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
1926 if (sdata->u.mgd.powersave)
1927 smps_mode = IEEE80211_SMPS_DYNAMIC;
1928 else
1929 smps_mode = IEEE80211_SMPS_OFF;
1930 }
1931
1932 /* send SM PS frame to AP */
1933 err = ieee80211_send_smps_action(sdata, smps_mode,
1934 ap, ap);
1935 if (err)
1936 sdata->u.mgd.req_smps = old_req;
1937
1938 return err;
1939}
1940
Johannes Bergbc92afd2009-07-01 21:26:57 +02001941static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
1942 bool enabled, int timeout)
1943{
1944 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1945 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Bergbc92afd2009-07-01 21:26:57 +02001946
Benoit Papillaulte5de30c2010-01-15 12:21:37 +01001947 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1948 return -EOPNOTSUPP;
1949
Johannes Bergbc92afd2009-07-01 21:26:57 +02001950 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
1951 return -EOPNOTSUPP;
1952
1953 if (enabled == sdata->u.mgd.powersave &&
Juuso Oikarinenff616382010-06-09 09:51:52 +03001954 timeout == local->dynamic_ps_forced_timeout)
Johannes Bergbc92afd2009-07-01 21:26:57 +02001955 return 0;
1956
1957 sdata->u.mgd.powersave = enabled;
Juuso Oikarinenff616382010-06-09 09:51:52 +03001958 local->dynamic_ps_forced_timeout = timeout;
Johannes Bergbc92afd2009-07-01 21:26:57 +02001959
Johannes Berg0f782312009-12-01 13:37:02 +01001960 /* no change, but if automatic follow powersave */
1961 mutex_lock(&sdata->u.mgd.mtx);
1962 __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
1963 mutex_unlock(&sdata->u.mgd.mtx);
1964
Johannes Bergbc92afd2009-07-01 21:26:57 +02001965 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
1966 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
1967
1968 ieee80211_recalc_ps(local, -1);
1969
1970 return 0;
1971}
1972
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001973static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
1974 struct net_device *dev,
1975 s32 rssi_thold, u32 rssi_hyst)
1976{
1977 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001978 struct ieee80211_vif *vif = &sdata->vif;
1979 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1980
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001981 if (rssi_thold == bss_conf->cqm_rssi_thold &&
1982 rssi_hyst == bss_conf->cqm_rssi_hyst)
1983 return 0;
1984
1985 bss_conf->cqm_rssi_thold = rssi_thold;
1986 bss_conf->cqm_rssi_hyst = rssi_hyst;
1987
1988 /* tell the driver upon association, unless already associated */
Johannes Bergea086352012-01-19 09:29:58 +01001989 if (sdata->u.mgd.associated &&
1990 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001991 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
1992
1993 return 0;
1994}
1995
Johannes Berg99303802009-07-01 21:26:59 +02001996static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
1997 struct net_device *dev,
1998 const u8 *addr,
1999 const struct cfg80211_bitrate_mask *mask)
2000{
2001 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2002 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05302003 int i, ret;
Johannes Berg99303802009-07-01 21:26:59 +02002004
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05302005 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
2006 ret = drv_set_bitrate_mask(local, sdata, mask);
2007 if (ret)
2008 return ret;
2009 }
Johannes Berg99303802009-07-01 21:26:59 +02002010
Simon Wunderlich19468412012-01-28 17:25:33 +01002011 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
Jouni Malinen37eb0b12010-01-06 13:09:08 +02002012 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
Simon Wunderlich19468412012-01-28 17:25:33 +01002013 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
2014 sizeof(mask->control[i].mcs));
2015 }
Johannes Berg99303802009-07-01 21:26:59 +02002016
Jouni Malinen37eb0b12010-01-06 13:09:08 +02002017 return 0;
Johannes Berg99303802009-07-01 21:26:59 +02002018}
2019
Johannes Berg21f83582010-12-18 17:20:47 +01002020static int ieee80211_remain_on_channel_hw(struct ieee80211_local *local,
2021 struct net_device *dev,
2022 struct ieee80211_channel *chan,
2023 enum nl80211_channel_type chantype,
2024 unsigned int duration, u64 *cookie)
2025{
2026 int ret;
2027 u32 random_cookie;
2028
2029 lockdep_assert_held(&local->mtx);
2030
2031 if (local->hw_roc_cookie)
2032 return -EBUSY;
2033 /* must be nonzero */
2034 random_cookie = random32() | 1;
2035
2036 *cookie = random_cookie;
2037 local->hw_roc_dev = dev;
2038 local->hw_roc_cookie = random_cookie;
2039 local->hw_roc_channel = chan;
2040 local->hw_roc_channel_type = chantype;
2041 local->hw_roc_duration = duration;
2042 ret = drv_remain_on_channel(local, chan, chantype, duration);
2043 if (ret) {
2044 local->hw_roc_channel = NULL;
2045 local->hw_roc_cookie = 0;
2046 }
2047
2048 return ret;
2049}
2050
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002051static int ieee80211_remain_on_channel(struct wiphy *wiphy,
2052 struct net_device *dev,
2053 struct ieee80211_channel *chan,
2054 enum nl80211_channel_type channel_type,
2055 unsigned int duration,
2056 u64 *cookie)
2057{
2058 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01002059 struct ieee80211_local *local = sdata->local;
2060
2061 if (local->ops->remain_on_channel) {
2062 int ret;
2063
2064 mutex_lock(&local->mtx);
2065 ret = ieee80211_remain_on_channel_hw(local, dev,
2066 chan, channel_type,
2067 duration, cookie);
Johannes Berg90fc4b32010-12-18 17:20:48 +01002068 local->hw_roc_for_tx = false;
Johannes Berg21f83582010-12-18 17:20:47 +01002069 mutex_unlock(&local->mtx);
2070
2071 return ret;
2072 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002073
2074 return ieee80211_wk_remain_on_channel(sdata, chan, channel_type,
2075 duration, cookie);
2076}
2077
Johannes Berg21f83582010-12-18 17:20:47 +01002078static int ieee80211_cancel_remain_on_channel_hw(struct ieee80211_local *local,
2079 u64 cookie)
2080{
2081 int ret;
2082
2083 lockdep_assert_held(&local->mtx);
2084
2085 if (local->hw_roc_cookie != cookie)
2086 return -ENOENT;
2087
2088 ret = drv_cancel_remain_on_channel(local);
2089 if (ret)
2090 return ret;
2091
2092 local->hw_roc_cookie = 0;
2093 local->hw_roc_channel = NULL;
2094
2095 ieee80211_recalc_idle(local);
2096
2097 return 0;
2098}
2099
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002100static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
2101 struct net_device *dev,
2102 u64 cookie)
2103{
2104 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01002105 struct ieee80211_local *local = sdata->local;
2106
2107 if (local->ops->cancel_remain_on_channel) {
2108 int ret;
2109
2110 mutex_lock(&local->mtx);
2111 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
2112 mutex_unlock(&local->mtx);
2113
2114 return ret;
2115 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002116
2117 return ieee80211_wk_cancel_remain_on_channel(sdata, cookie);
2118}
2119
Johannes Bergf30221e2010-11-25 10:02:30 +01002120static enum work_done_result
2121ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb)
2122{
2123 /*
2124 * Use the data embedded in the work struct for reporting
2125 * here so if the driver mangled the SKB before dropping
2126 * it (which is the only way we really should get here)
2127 * then we don't report mangled data.
2128 *
2129 * If there was no wait time, then by the time we get here
2130 * the driver will likely not have reported the status yet,
2131 * so in that case userspace will have to deal with it.
2132 */
2133
Johannes Berg28a1bcd2011-10-04 18:27:10 +02002134 if (wk->offchan_tx.wait && !wk->offchan_tx.status)
Johannes Bergf30221e2010-11-25 10:02:30 +01002135 cfg80211_mgmt_tx_status(wk->sdata->dev,
2136 (unsigned long) wk->offchan_tx.frame,
Johannes Berg66e67e42012-01-20 13:55:27 +01002137 wk->data, wk->data_len, false, GFP_KERNEL);
Johannes Bergf30221e2010-11-25 10:02:30 +01002138
2139 return WORK_DONE_DESTROY;
2140}
2141
Johannes Berg2e161f782010-08-12 15:38:38 +02002142static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002143 struct ieee80211_channel *chan, bool offchan,
Johannes Berg2e161f782010-08-12 15:38:38 +02002144 enum nl80211_channel_type channel_type,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002145 bool channel_type_valid, unsigned int wait,
Rajkumar Manoharane9f935e2011-09-25 14:53:30 +05302146 const u8 *buf, size_t len, bool no_cck,
Johannes Berge247bd902011-11-04 11:18:21 +01002147 bool dont_wait_for_ack, u64 *cookie)
Jouni Malinen026331c2010-02-15 12:53:10 +02002148{
Johannes Berg9d38d852010-06-09 17:20:33 +02002149 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2150 struct ieee80211_local *local = sdata->local;
2151 struct sk_buff *skb;
2152 struct sta_info *sta;
Johannes Bergf30221e2010-11-25 10:02:30 +01002153 struct ieee80211_work *wk;
Johannes Berg9d38d852010-06-09 17:20:33 +02002154 const struct ieee80211_mgmt *mgmt = (void *)buf;
Johannes Berge247bd902011-11-04 11:18:21 +01002155 u32 flags;
Johannes Bergf30221e2010-11-25 10:02:30 +01002156 bool is_offchan = false;
Johannes Bergf7ca38d2010-11-25 10:02:29 +01002157
Johannes Berge247bd902011-11-04 11:18:21 +01002158 if (dont_wait_for_ack)
2159 flags = IEEE80211_TX_CTL_NO_ACK;
2160 else
2161 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
2162 IEEE80211_TX_CTL_REQ_TX_STATUS;
2163
Johannes Berg9d38d852010-06-09 17:20:33 +02002164 /* Check that we are on the requested channel for transmission */
2165 if (chan != local->tmp_channel &&
2166 chan != local->oper_channel)
Johannes Bergf30221e2010-11-25 10:02:30 +01002167 is_offchan = true;
Johannes Berg9d38d852010-06-09 17:20:33 +02002168 if (channel_type_valid &&
2169 (channel_type != local->tmp_channel_type &&
2170 channel_type != local->_oper_channel_type))
Johannes Bergf30221e2010-11-25 10:02:30 +01002171 is_offchan = true;
2172
Johannes Berg21f83582010-12-18 17:20:47 +01002173 if (chan == local->hw_roc_channel) {
2174 /* TODO: check channel type? */
2175 is_offchan = false;
2176 flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
2177 }
2178
Rajkumar Manoharanaad14ce2011-09-25 14:53:31 +05302179 if (no_cck)
2180 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
2181
Johannes Bergf30221e2010-11-25 10:02:30 +01002182 if (is_offchan && !offchan)
Johannes Berg9d38d852010-06-09 17:20:33 +02002183 return -EBUSY;
2184
2185 switch (sdata->vif.type) {
2186 case NL80211_IFTYPE_ADHOC:
Johannes Berg663fcaf2010-09-30 21:06:09 +02002187 case NL80211_IFTYPE_AP:
2188 case NL80211_IFTYPE_AP_VLAN:
2189 case NL80211_IFTYPE_P2P_GO:
Javier Cardonac7108a72010-12-16 17:37:50 -08002190 case NL80211_IFTYPE_MESH_POINT:
Johannes Berg663fcaf2010-09-30 21:06:09 +02002191 if (!ieee80211_is_action(mgmt->frame_control) ||
2192 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
Johannes Berg9d38d852010-06-09 17:20:33 +02002193 break;
2194 rcu_read_lock();
2195 sta = sta_info_get(sdata, mgmt->da);
2196 rcu_read_unlock();
2197 if (!sta)
2198 return -ENOLINK;
2199 break;
2200 case NL80211_IFTYPE_STATION:
Johannes Berg663fcaf2010-09-30 21:06:09 +02002201 case NL80211_IFTYPE_P2P_CLIENT:
Johannes Berg9d38d852010-06-09 17:20:33 +02002202 break;
2203 default:
2204 return -EOPNOTSUPP;
2205 }
2206
2207 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
2208 if (!skb)
2209 return -ENOMEM;
2210 skb_reserve(skb, local->hw.extra_tx_headroom);
2211
2212 memcpy(skb_put(skb, len), buf, len);
2213
2214 IEEE80211_SKB_CB(skb)->flags = flags;
2215
Johannes Berg3a25a8c2012-04-03 16:28:50 +02002216 if (flags & IEEE80211_TX_CTL_TX_OFFCHAN)
2217 IEEE80211_SKB_CB(skb)->hw_queue =
2218 local->hw.offchannel_tx_hw_queue;
2219
Johannes Berg9d38d852010-06-09 17:20:33 +02002220 skb->dev = sdata->dev;
Johannes Berg9d38d852010-06-09 17:20:33 +02002221
2222 *cookie = (unsigned long) skb;
Johannes Bergf30221e2010-11-25 10:02:30 +01002223
Johannes Berg90fc4b32010-12-18 17:20:48 +01002224 if (is_offchan && local->ops->remain_on_channel) {
2225 unsigned int duration;
2226 int ret;
2227
2228 mutex_lock(&local->mtx);
2229 /*
2230 * If the duration is zero, then the driver
2231 * wouldn't actually do anything. Set it to
2232 * 100 for now.
2233 *
2234 * TODO: cancel the off-channel operation
2235 * when we get the SKB's TX status and
2236 * the wait time was zero before.
2237 */
2238 duration = 100;
2239 if (wait)
2240 duration = wait;
2241 ret = ieee80211_remain_on_channel_hw(local, dev, chan,
2242 channel_type,
2243 duration, cookie);
2244 if (ret) {
2245 kfree_skb(skb);
2246 mutex_unlock(&local->mtx);
2247 return ret;
2248 }
2249
2250 local->hw_roc_for_tx = true;
2251 local->hw_roc_duration = wait;
2252
2253 /*
2254 * queue up frame for transmission after
2255 * ieee80211_ready_on_channel call
2256 */
2257
2258 /* modify cookie to prevent API mismatches */
2259 *cookie ^= 2;
2260 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
Johannes Berg3a25a8c2012-04-03 16:28:50 +02002261 IEEE80211_SKB_CB(skb)->hw_queue =
2262 local->hw.offchannel_tx_hw_queue;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002263 local->hw_roc_skb = skb;
Johannes Berg4334ec82011-02-02 16:58:06 +01002264 local->hw_roc_skb_for_status = skb;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002265 mutex_unlock(&local->mtx);
2266
2267 return 0;
2268 }
2269
Johannes Bergf30221e2010-11-25 10:02:30 +01002270 /*
2271 * Can transmit right away if the channel was the
2272 * right one and there's no wait involved... If a
2273 * wait is involved, we might otherwise not be on
2274 * the right channel for long enough!
2275 */
2276 if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) {
2277 ieee80211_tx_skb(sdata, skb);
2278 return 0;
2279 }
2280
2281 wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL);
2282 if (!wk) {
2283 kfree_skb(skb);
2284 return -ENOMEM;
2285 }
2286
2287 wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
2288 wk->chan = chan;
Ben Greear4d51e142011-02-07 13:44:34 -08002289 wk->chan_type = channel_type;
Johannes Bergf30221e2010-11-25 10:02:30 +01002290 wk->sdata = sdata;
2291 wk->done = ieee80211_offchan_tx_done;
2292 wk->offchan_tx.frame = skb;
2293 wk->offchan_tx.wait = wait;
Johannes Berg66e67e42012-01-20 13:55:27 +01002294 wk->data_len = len;
2295 memcpy(wk->data, buf, len);
Johannes Bergf30221e2010-11-25 10:02:30 +01002296
2297 ieee80211_add_work(wk);
Johannes Berg9d38d852010-06-09 17:20:33 +02002298 return 0;
Jouni Malinen026331c2010-02-15 12:53:10 +02002299}
2300
Johannes Bergf30221e2010-11-25 10:02:30 +01002301static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2302 struct net_device *dev,
2303 u64 cookie)
2304{
2305 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2306 struct ieee80211_local *local = sdata->local;
2307 struct ieee80211_work *wk;
2308 int ret = -ENOENT;
2309
2310 mutex_lock(&local->mtx);
Johannes Berg90fc4b32010-12-18 17:20:48 +01002311
2312 if (local->ops->cancel_remain_on_channel) {
2313 cookie ^= 2;
2314 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
2315
2316 if (ret == 0) {
2317 kfree_skb(local->hw_roc_skb);
2318 local->hw_roc_skb = NULL;
Johannes Berg4334ec82011-02-02 16:58:06 +01002319 local->hw_roc_skb_for_status = NULL;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002320 }
2321
2322 mutex_unlock(&local->mtx);
2323
2324 return ret;
2325 }
2326
Johannes Bergf30221e2010-11-25 10:02:30 +01002327 list_for_each_entry(wk, &local->work_list, list) {
2328 if (wk->sdata != sdata)
2329 continue;
2330
2331 if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
2332 continue;
2333
2334 if (cookie != (unsigned long) wk->offchan_tx.frame)
2335 continue;
2336
2337 wk->timeout = jiffies;
2338
2339 ieee80211_queue_work(&local->hw, &local->work_work);
2340 ret = 0;
2341 break;
2342 }
2343 mutex_unlock(&local->mtx);
2344
2345 return ret;
2346}
2347
Johannes Berg7be50862010-10-13 12:06:24 +02002348static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2349 struct net_device *dev,
2350 u16 frame_type, bool reg)
2351{
2352 struct ieee80211_local *local = wiphy_priv(wiphy);
2353
2354 if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
2355 return;
2356
2357 if (reg)
2358 local->probe_req_reg++;
2359 else
2360 local->probe_req_reg--;
2361
2362 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2363}
2364
Bruno Randolf15d96752010-11-10 12:50:56 +09002365static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
2366{
2367 struct ieee80211_local *local = wiphy_priv(wiphy);
2368
2369 if (local->started)
2370 return -EOPNOTSUPP;
2371
2372 return drv_set_antenna(local, tx_ant, rx_ant);
2373}
2374
2375static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
2376{
2377 struct ieee80211_local *local = wiphy_priv(wiphy);
2378
2379 return drv_get_antenna(local, tx_ant, rx_ant);
2380}
2381
John W. Linville38c09152011-03-07 16:19:18 -05002382static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2383{
2384 struct ieee80211_local *local = wiphy_priv(wiphy);
2385
2386 return drv_set_ringparam(local, tx, rx);
2387}
2388
2389static void ieee80211_get_ringparam(struct wiphy *wiphy,
2390 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2391{
2392 struct ieee80211_local *local = wiphy_priv(wiphy);
2393
2394 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2395}
2396
Johannes Bergc68f4b82011-07-05 16:35:41 +02002397static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2398 struct net_device *dev,
2399 struct cfg80211_gtk_rekey_data *data)
2400{
2401 struct ieee80211_local *local = wiphy_priv(wiphy);
2402 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2403
2404 if (!local->ops->set_rekey_data)
2405 return -EOPNOTSUPP;
2406
2407 drv_set_rekey_data(local, sdata, data);
2408
2409 return 0;
2410}
2411
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002412static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
2413{
2414 u8 *pos = (void *)skb_put(skb, 7);
2415
2416 *pos++ = WLAN_EID_EXT_CAPABILITY;
2417 *pos++ = 5; /* len */
2418 *pos++ = 0x0;
2419 *pos++ = 0x0;
2420 *pos++ = 0x0;
2421 *pos++ = 0x0;
2422 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
2423}
2424
2425static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
2426{
2427 struct ieee80211_local *local = sdata->local;
2428 u16 capab;
2429
2430 capab = 0;
2431 if (local->oper_channel->band != IEEE80211_BAND_2GHZ)
2432 return capab;
2433
2434 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
2435 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
2436 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
2437 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
2438
2439 return capab;
2440}
2441
2442static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
2443 u8 *peer, u8 *bssid)
2444{
2445 struct ieee80211_tdls_lnkie *lnkid;
2446
2447 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
2448
2449 lnkid->ie_type = WLAN_EID_LINK_ID;
2450 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
2451
2452 memcpy(lnkid->bssid, bssid, ETH_ALEN);
2453 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
2454 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
2455}
2456
2457static int
2458ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2459 u8 *peer, u8 action_code, u8 dialog_token,
2460 u16 status_code, struct sk_buff *skb)
2461{
2462 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2463 struct ieee80211_tdls_data *tf;
2464
2465 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
2466
2467 memcpy(tf->da, peer, ETH_ALEN);
2468 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
2469 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
2470 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
2471
2472 switch (action_code) {
2473 case WLAN_TDLS_SETUP_REQUEST:
2474 tf->category = WLAN_CATEGORY_TDLS;
2475 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
2476
2477 skb_put(skb, sizeof(tf->u.setup_req));
2478 tf->u.setup_req.dialog_token = dialog_token;
2479 tf->u.setup_req.capability =
2480 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2481
Ashok Nagarajan657c3e02012-04-02 21:21:20 -07002482 ieee80211_add_srates_ie(&sdata->vif, skb, false);
2483 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002484 ieee80211_tdls_add_ext_capab(skb);
2485 break;
2486 case WLAN_TDLS_SETUP_RESPONSE:
2487 tf->category = WLAN_CATEGORY_TDLS;
2488 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
2489
2490 skb_put(skb, sizeof(tf->u.setup_resp));
2491 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
2492 tf->u.setup_resp.dialog_token = dialog_token;
2493 tf->u.setup_resp.capability =
2494 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2495
Ashok Nagarajan657c3e02012-04-02 21:21:20 -07002496 ieee80211_add_srates_ie(&sdata->vif, skb, false);
2497 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002498 ieee80211_tdls_add_ext_capab(skb);
2499 break;
2500 case WLAN_TDLS_SETUP_CONFIRM:
2501 tf->category = WLAN_CATEGORY_TDLS;
2502 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
2503
2504 skb_put(skb, sizeof(tf->u.setup_cfm));
2505 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
2506 tf->u.setup_cfm.dialog_token = dialog_token;
2507 break;
2508 case WLAN_TDLS_TEARDOWN:
2509 tf->category = WLAN_CATEGORY_TDLS;
2510 tf->action_code = WLAN_TDLS_TEARDOWN;
2511
2512 skb_put(skb, sizeof(tf->u.teardown));
2513 tf->u.teardown.reason_code = cpu_to_le16(status_code);
2514 break;
2515 case WLAN_TDLS_DISCOVERY_REQUEST:
2516 tf->category = WLAN_CATEGORY_TDLS;
2517 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
2518
2519 skb_put(skb, sizeof(tf->u.discover_req));
2520 tf->u.discover_req.dialog_token = dialog_token;
2521 break;
2522 default:
2523 return -EINVAL;
2524 }
2525
2526 return 0;
2527}
2528
2529static int
2530ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2531 u8 *peer, u8 action_code, u8 dialog_token,
2532 u16 status_code, struct sk_buff *skb)
2533{
2534 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2535 struct ieee80211_mgmt *mgmt;
2536
2537 mgmt = (void *)skb_put(skb, 24);
2538 memset(mgmt, 0, 24);
2539 memcpy(mgmt->da, peer, ETH_ALEN);
2540 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
2541 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
2542
2543 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2544 IEEE80211_STYPE_ACTION);
2545
2546 switch (action_code) {
2547 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2548 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
2549 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
2550 mgmt->u.action.u.tdls_discover_resp.action_code =
2551 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
2552 mgmt->u.action.u.tdls_discover_resp.dialog_token =
2553 dialog_token;
2554 mgmt->u.action.u.tdls_discover_resp.capability =
2555 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2556
Ashok Nagarajan657c3e02012-04-02 21:21:20 -07002557 ieee80211_add_srates_ie(&sdata->vif, skb, false);
2558 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002559 ieee80211_tdls_add_ext_capab(skb);
2560 break;
2561 default:
2562 return -EINVAL;
2563 }
2564
2565 return 0;
2566}
2567
2568static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2569 u8 *peer, u8 action_code, u8 dialog_token,
2570 u16 status_code, const u8 *extra_ies,
2571 size_t extra_ies_len)
2572{
2573 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2574 struct ieee80211_local *local = sdata->local;
2575 struct ieee80211_tx_info *info;
2576 struct sk_buff *skb = NULL;
2577 bool send_direct;
2578 int ret;
2579
2580 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2581 return -ENOTSUPP;
2582
2583 /* make sure we are in managed mode, and associated */
2584 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
2585 !sdata->u.mgd.associated)
2586 return -EINVAL;
2587
2588#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2589 printk(KERN_DEBUG "TDLS mgmt action %d peer %pM\n", action_code, peer);
2590#endif
2591
2592 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
2593 max(sizeof(struct ieee80211_mgmt),
2594 sizeof(struct ieee80211_tdls_data)) +
2595 50 + /* supported rates */
2596 7 + /* ext capab */
2597 extra_ies_len +
2598 sizeof(struct ieee80211_tdls_lnkie));
2599 if (!skb)
2600 return -ENOMEM;
2601
2602 info = IEEE80211_SKB_CB(skb);
2603 skb_reserve(skb, local->hw.extra_tx_headroom);
2604
2605 switch (action_code) {
2606 case WLAN_TDLS_SETUP_REQUEST:
2607 case WLAN_TDLS_SETUP_RESPONSE:
2608 case WLAN_TDLS_SETUP_CONFIRM:
2609 case WLAN_TDLS_TEARDOWN:
2610 case WLAN_TDLS_DISCOVERY_REQUEST:
2611 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
2612 action_code, dialog_token,
2613 status_code, skb);
2614 send_direct = false;
2615 break;
2616 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2617 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
2618 dialog_token, status_code,
2619 skb);
2620 send_direct = true;
2621 break;
2622 default:
2623 ret = -ENOTSUPP;
2624 break;
2625 }
2626
2627 if (ret < 0)
2628 goto fail;
2629
2630 if (extra_ies_len)
2631 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
2632
2633 /* the TDLS link IE is always added last */
2634 switch (action_code) {
2635 case WLAN_TDLS_SETUP_REQUEST:
2636 case WLAN_TDLS_SETUP_CONFIRM:
2637 case WLAN_TDLS_TEARDOWN:
2638 case WLAN_TDLS_DISCOVERY_REQUEST:
2639 /* we are the initiator */
2640 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
2641 sdata->u.mgd.bssid);
2642 break;
2643 case WLAN_TDLS_SETUP_RESPONSE:
2644 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2645 /* we are the responder */
2646 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
2647 sdata->u.mgd.bssid);
2648 break;
2649 default:
2650 ret = -ENOTSUPP;
2651 goto fail;
2652 }
2653
2654 if (send_direct) {
2655 ieee80211_tx_skb(sdata, skb);
2656 return 0;
2657 }
2658
2659 /*
2660 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
2661 * we should default to AC_VI.
2662 */
2663 switch (action_code) {
2664 case WLAN_TDLS_SETUP_REQUEST:
2665 case WLAN_TDLS_SETUP_RESPONSE:
2666 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
2667 skb->priority = 2;
2668 break;
2669 default:
2670 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
2671 skb->priority = 5;
2672 break;
2673 }
2674
2675 /* disable bottom halves when entering the Tx path */
2676 local_bh_disable();
2677 ret = ieee80211_subif_start_xmit(skb, dev);
2678 local_bh_enable();
2679
2680 return ret;
2681
2682fail:
2683 dev_kfree_skb(skb);
2684 return ret;
2685}
2686
2687static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2688 u8 *peer, enum nl80211_tdls_operation oper)
2689{
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002690 struct sta_info *sta;
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002691 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2692
2693 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2694 return -ENOTSUPP;
2695
2696 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2697 return -EINVAL;
2698
2699#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2700 printk(KERN_DEBUG "TDLS oper %d peer %pM\n", oper, peer);
2701#endif
2702
2703 switch (oper) {
2704 case NL80211_TDLS_ENABLE_LINK:
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002705 rcu_read_lock();
2706 sta = sta_info_get(sdata, peer);
2707 if (!sta) {
2708 rcu_read_unlock();
2709 return -ENOLINK;
2710 }
2711
Johannes Bergc2c98fd2011-09-29 16:04:36 +02002712 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002713 rcu_read_unlock();
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002714 break;
2715 case NL80211_TDLS_DISABLE_LINK:
2716 return sta_info_destroy_addr(sdata, peer);
2717 case NL80211_TDLS_TEARDOWN:
2718 case NL80211_TDLS_SETUP:
2719 case NL80211_TDLS_DISCOVERY_REQ:
2720 /* We don't support in-driver setup/teardown/discovery */
2721 return -ENOTSUPP;
2722 default:
2723 return -ENOTSUPP;
2724 }
2725
2726 return 0;
2727}
2728
Johannes Berg06500732011-11-04 11:18:16 +01002729static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
2730 const u8 *peer, u64 *cookie)
2731{
2732 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2733 struct ieee80211_local *local = sdata->local;
2734 struct ieee80211_qos_hdr *nullfunc;
2735 struct sk_buff *skb;
2736 int size = sizeof(*nullfunc);
2737 __le16 fc;
2738 bool qos;
2739 struct ieee80211_tx_info *info;
2740 struct sta_info *sta;
2741
2742 rcu_read_lock();
2743 sta = sta_info_get(sdata, peer);
Johannes Bergb4487c22011-11-11 20:22:30 +01002744 if (sta) {
Johannes Berg06500732011-11-04 11:18:16 +01002745 qos = test_sta_flag(sta, WLAN_STA_WME);
Johannes Bergb4487c22011-11-11 20:22:30 +01002746 rcu_read_unlock();
2747 } else {
2748 rcu_read_unlock();
Johannes Berg06500732011-11-04 11:18:16 +01002749 return -ENOLINK;
Johannes Bergb4487c22011-11-11 20:22:30 +01002750 }
Johannes Berg06500732011-11-04 11:18:16 +01002751
2752 if (qos) {
2753 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
2754 IEEE80211_STYPE_QOS_NULLFUNC |
2755 IEEE80211_FCTL_FROMDS);
2756 } else {
2757 size -= 2;
2758 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
2759 IEEE80211_STYPE_NULLFUNC |
2760 IEEE80211_FCTL_FROMDS);
2761 }
2762
2763 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
2764 if (!skb)
2765 return -ENOMEM;
2766
2767 skb->dev = dev;
2768
2769 skb_reserve(skb, local->hw.extra_tx_headroom);
2770
2771 nullfunc = (void *) skb_put(skb, size);
2772 nullfunc->frame_control = fc;
2773 nullfunc->duration_id = 0;
2774 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
2775 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
2776 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
2777 nullfunc->seq_ctrl = 0;
2778
2779 info = IEEE80211_SKB_CB(skb);
2780
2781 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
2782 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
2783
2784 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
2785 skb->priority = 7;
2786 if (qos)
2787 nullfunc->qos_ctrl = cpu_to_le16(7);
2788
2789 local_bh_disable();
2790 ieee80211_xmit(sdata, skb);
2791 local_bh_enable();
2792
2793 *cookie = (unsigned long) skb;
2794 return 0;
2795}
2796
Johannes Berge9998822011-11-09 10:30:21 +01002797static struct ieee80211_channel *
Pontus Fuchsd91df0e2012-04-03 16:39:58 +02002798ieee80211_wiphy_get_channel(struct wiphy *wiphy,
2799 enum nl80211_channel_type *type)
Johannes Berge9998822011-11-09 10:30:21 +01002800{
2801 struct ieee80211_local *local = wiphy_priv(wiphy);
2802
Pontus Fuchsd91df0e2012-04-03 16:39:58 +02002803 *type = local->_oper_channel_type;
Johannes Berge9998822011-11-09 10:30:21 +01002804 return local->oper_channel;
2805}
2806
Johannes Berg6d525632012-04-04 15:05:25 +02002807#ifdef CONFIG_PM
2808static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
2809{
2810 drv_set_wakeup(wiphy_priv(wiphy), enabled);
2811}
2812#endif
2813
Jiri Bencf0706e82007-05-05 11:45:53 -07002814struct cfg80211_ops mac80211_config_ops = {
2815 .add_virtual_intf = ieee80211_add_iface,
2816 .del_virtual_intf = ieee80211_del_iface,
Johannes Berg42613db2007-09-28 21:52:27 +02002817 .change_virtual_intf = ieee80211_change_iface,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002818 .add_key = ieee80211_add_key,
2819 .del_key = ieee80211_del_key,
Johannes Berg62da92f2007-12-19 02:03:31 +01002820 .get_key = ieee80211_get_key,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002821 .set_default_key = ieee80211_config_default_key,
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +02002822 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
Johannes Berg88600202012-02-13 15:17:18 +01002823 .start_ap = ieee80211_start_ap,
2824 .change_beacon = ieee80211_change_beacon,
2825 .stop_ap = ieee80211_stop_ap,
Johannes Berg4fd69312007-12-19 02:03:35 +01002826 .add_station = ieee80211_add_station,
2827 .del_station = ieee80211_del_station,
2828 .change_station = ieee80211_change_station,
Johannes Berg7bbdd2d2007-12-19 02:03:37 +01002829 .get_station = ieee80211_get_station,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002830 .dump_station = ieee80211_dump_station,
Holger Schurig12897232010-04-19 10:23:57 +02002831 .dump_survey = ieee80211_dump_survey,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002832#ifdef CONFIG_MAC80211_MESH
2833 .add_mpath = ieee80211_add_mpath,
2834 .del_mpath = ieee80211_del_mpath,
2835 .change_mpath = ieee80211_change_mpath,
2836 .get_mpath = ieee80211_get_mpath,
2837 .dump_mpath = ieee80211_dump_mpath,
Javier Cardona24bdd9f2010-12-16 17:37:48 -08002838 .update_mesh_config = ieee80211_update_mesh_config,
2839 .get_mesh_config = ieee80211_get_mesh_config,
Johannes Berg29cbe682010-12-03 09:20:44 +01002840 .join_mesh = ieee80211_join_mesh,
2841 .leave_mesh = ieee80211_leave_mesh,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002842#endif
Jouni Malinen9f1ba902008-08-07 20:07:01 +03002843 .change_bss = ieee80211_change_bss,
Jouni Malinen31888482008-10-30 16:59:24 +02002844 .set_txq_params = ieee80211_set_txq_params,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02002845 .set_channel = ieee80211_set_channel,
Bob Copeland665af4f2009-01-19 11:20:53 -05002846 .suspend = ieee80211_suspend,
2847 .resume = ieee80211_resume,
Johannes Berg2a519312009-02-10 21:25:55 +01002848 .scan = ieee80211_scan,
Luciano Coelho79f460c2011-05-11 17:09:36 +03002849 .sched_scan_start = ieee80211_sched_scan_start,
2850 .sched_scan_stop = ieee80211_sched_scan_stop,
Jouni Malinen636a5d32009-03-19 13:39:22 +02002851 .auth = ieee80211_auth,
2852 .assoc = ieee80211_assoc,
2853 .deauth = ieee80211_deauth,
2854 .disassoc = ieee80211_disassoc,
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02002855 .join_ibss = ieee80211_join_ibss,
2856 .leave_ibss = ieee80211_leave_ibss,
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002857 .set_wiphy_params = ieee80211_set_wiphy_params,
Johannes Berg7643a2c2009-06-02 13:01:39 +02002858 .set_tx_power = ieee80211_set_tx_power,
2859 .get_tx_power = ieee80211_get_tx_power,
Johannes Bergab737a42009-07-01 21:26:58 +02002860 .set_wds_peer = ieee80211_set_wds_peer,
Johannes Berg1f87f7d2009-06-02 13:01:41 +02002861 .rfkill_poll = ieee80211_rfkill_poll,
Johannes Bergaff89a92009-07-01 21:26:51 +02002862 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
Wey-Yi Guy71063f02011-05-20 09:05:54 -07002863 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
Johannes Bergbc92afd2009-07-01 21:26:57 +02002864 .set_power_mgmt = ieee80211_set_power_mgmt,
Johannes Berg99303802009-07-01 21:26:59 +02002865 .set_bitrate_mask = ieee80211_set_bitrate_mask,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002866 .remain_on_channel = ieee80211_remain_on_channel,
2867 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
Johannes Berg2e161f782010-08-12 15:38:38 +02002868 .mgmt_tx = ieee80211_mgmt_tx,
Johannes Bergf30221e2010-11-25 10:02:30 +01002869 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002870 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
Johannes Berg7be50862010-10-13 12:06:24 +02002871 .mgmt_frame_register = ieee80211_mgmt_frame_register,
Bruno Randolf15d96752010-11-10 12:50:56 +09002872 .set_antenna = ieee80211_set_antenna,
2873 .get_antenna = ieee80211_get_antenna,
John W. Linville38c09152011-03-07 16:19:18 -05002874 .set_ringparam = ieee80211_set_ringparam,
2875 .get_ringparam = ieee80211_get_ringparam,
Johannes Bergc68f4b82011-07-05 16:35:41 +02002876 .set_rekey_data = ieee80211_set_rekey_data,
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002877 .tdls_oper = ieee80211_tdls_oper,
2878 .tdls_mgmt = ieee80211_tdls_mgmt,
Johannes Berg06500732011-11-04 11:18:16 +01002879 .probe_client = ieee80211_probe_client,
Johannes Berge9998822011-11-09 10:30:21 +01002880 .get_channel = ieee80211_wiphy_get_channel,
Simon Wunderlichb53be792011-11-18 14:20:44 +01002881 .set_noack_map = ieee80211_set_noack_map,
Johannes Berg6d525632012-04-04 15:05:25 +02002882#ifdef CONFIG_PM
2883 .set_wakeup = ieee80211_set_wakeup,
2884#endif
Ben Greearb1ab7922012-04-23 12:50:30 -07002885 .get_et_sset_count = ieee80211_get_et_sset_count,
2886 .get_et_stats = ieee80211_get_et_stats,
2887 .get_et_strings = ieee80211_get_et_strings,
Jiri Bencf0706e82007-05-05 11:45:53 -07002888};