blob: 1309bb9c97be197c90b2b2f454487cb592d2d3a2 [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 Berg9607e6b2009-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)
66 rcu_assign_pointer(sdata->u.vlan.sta, NULL);
67 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
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100105static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200106 u8 key_idx, bool pairwise, const u8 *mac_addr,
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100107 struct key_params *params)
108{
Johannes Berg26a58452010-08-27 12:35:55 +0200109 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100110 struct sta_info *sta = NULL;
Johannes Bergdb4d1162008-02-25 16:27:45 +0100111 struct ieee80211_key *key;
Johannes Berg3b967662008-04-08 17:56:52 +0200112 int err;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100113
Johannes Berg26a58452010-08-27 12:35:55 +0200114 if (!ieee80211_sdata_running(sdata))
Johannes Bergad0e2b52010-06-01 10:19:19 +0200115 return -ENETDOWN;
116
Johannes Berg97359d12010-08-10 09:46:38 +0200117 /* reject WEP and TKIP keys if WEP failed to initialize */
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100118 switch (params->cipher) {
119 case WLAN_CIPHER_SUITE_WEP40:
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100120 case WLAN_CIPHER_SUITE_TKIP:
Johannes Berg97359d12010-08-10 09:46:38 +0200121 case WLAN_CIPHER_SUITE_WEP104:
122 if (IS_ERR(sdata->local->wep_tx_tfm))
123 return -EINVAL;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200124 break;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100125 default:
Johannes Berg97359d12010-08-10 09:46:38 +0200126 break;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100127 }
128
Johannes Berg97359d12010-08-10 09:46:38 +0200129 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
130 params->key, params->seq_len, params->seq);
Ben Hutchings1ac62ba2010-08-01 17:37:03 +0100131 if (IS_ERR(key))
132 return PTR_ERR(key);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100133
Johannes Berge31b8212010-10-05 19:39:30 +0200134 if (pairwise)
135 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
136
Johannes Bergad0e2b52010-06-01 10:19:19 +0200137 mutex_lock(&sdata->local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200138
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100139 if (mac_addr) {
Thomas Pedersenff973af2011-05-03 16:57:12 -0700140 if (ieee80211_vif_is_mesh(&sdata->vif))
141 sta = sta_info_get(sdata, mac_addr);
142 else
143 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100144 if (!sta) {
Jouni Malinen32162a42010-07-26 15:52:03 -0700145 ieee80211_key_free(sdata->local, key);
Johannes Berg3b967662008-04-08 17:56:52 +0200146 err = -ENOENT;
147 goto out_unlock;
Johannes Bergdb4d1162008-02-25 16:27:45 +0100148 }
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100149 }
150
Johannes Berg3ffc2a92010-08-27 14:26:52 +0300151 err = ieee80211_key_link(key, sdata, sta);
152 if (err)
153 ieee80211_key_free(sdata->local, key);
Johannes Bergdb4d1162008-02-25 16:27:45 +0100154
Johannes Berg3b967662008-04-08 17:56:52 +0200155 out_unlock:
Johannes Bergad0e2b52010-06-01 10:19:19 +0200156 mutex_unlock(&sdata->local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200157
158 return err;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100159}
160
161static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200162 u8 key_idx, bool pairwise, const u8 *mac_addr)
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100163{
Johannes Berg5c0c3642011-05-12 14:31:49 +0200164 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
165 struct ieee80211_local *local = sdata->local;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100166 struct sta_info *sta;
Johannes Berg5c0c3642011-05-12 14:31:49 +0200167 struct ieee80211_key *key = NULL;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100168 int ret;
169
Johannes Berg5c0c3642011-05-12 14:31:49 +0200170 mutex_lock(&local->sta_mtx);
171 mutex_lock(&local->key_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200172
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100173 if (mac_addr) {
Johannes Berg3b967662008-04-08 17:56:52 +0200174 ret = -ENOENT;
175
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100176 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100177 if (!sta)
Johannes Berg3b967662008-04-08 17:56:52 +0200178 goto out_unlock;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100179
Johannes Berg5c0c3642011-05-12 14:31:49 +0200180 if (pairwise)
Johannes Berg40b275b2011-05-13 14:15:49 +0200181 key = key_mtx_dereference(local, sta->ptk);
Johannes Berg5c0c3642011-05-12 14:31:49 +0200182 else
Johannes Berg40b275b2011-05-13 14:15:49 +0200183 key = key_mtx_dereference(local, sta->gtk[key_idx]);
Johannes Berg5c0c3642011-05-12 14:31:49 +0200184 } else
Johannes Berg40b275b2011-05-13 14:15:49 +0200185 key = key_mtx_dereference(local, sdata->keys[key_idx]);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100186
Johannes Berg5c0c3642011-05-12 14:31:49 +0200187 if (!key) {
Johannes Berg3b967662008-04-08 17:56:52 +0200188 ret = -ENOENT;
189 goto out_unlock;
190 }
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100191
Johannes Berg5c0c3642011-05-12 14:31:49 +0200192 __ieee80211_key_free(key);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100193
Johannes Berg3b967662008-04-08 17:56:52 +0200194 ret = 0;
195 out_unlock:
Johannes Berg5c0c3642011-05-12 14:31:49 +0200196 mutex_unlock(&local->key_mtx);
197 mutex_unlock(&local->sta_mtx);
Johannes Berg3b967662008-04-08 17:56:52 +0200198
199 return ret;
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100200}
201
Johannes Berg62da92f2007-12-19 02:03:31 +0100202static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
Johannes Berge31b8212010-10-05 19:39:30 +0200203 u8 key_idx, bool pairwise, const u8 *mac_addr,
204 void *cookie,
Johannes Berg62da92f2007-12-19 02:03:31 +0100205 void (*callback)(void *cookie,
206 struct key_params *params))
207{
Johannes Berg14db74b2008-07-29 13:22:52 +0200208 struct ieee80211_sub_if_data *sdata;
Johannes Berg62da92f2007-12-19 02:03:31 +0100209 struct sta_info *sta = NULL;
210 u8 seq[6] = {0};
211 struct key_params params;
Johannes Berge31b8212010-10-05 19:39:30 +0200212 struct ieee80211_key *key = NULL;
Johannes Bergaba83a0b2011-07-06 21:59:39 +0200213 u64 pn64;
Johannes Berg62da92f2007-12-19 02:03:31 +0100214 u32 iv32;
215 u16 iv16;
216 int err = -ENOENT;
217
Johannes Berg14db74b2008-07-29 13:22:52 +0200218 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
219
Johannes Berg3b967662008-04-08 17:56:52 +0200220 rcu_read_lock();
221
Johannes Berg62da92f2007-12-19 02:03:31 +0100222 if (mac_addr) {
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100223 sta = sta_info_get_bss(sdata, mac_addr);
Johannes Berg62da92f2007-12-19 02:03:31 +0100224 if (!sta)
225 goto out;
226
Johannes Berge31b8212010-10-05 19:39:30 +0200227 if (pairwise)
Johannes Berga3836e02011-05-12 15:11:37 +0200228 key = rcu_dereference(sta->ptk);
Johannes Berge31b8212010-10-05 19:39:30 +0200229 else if (key_idx < NUM_DEFAULT_KEYS)
Johannes Berga3836e02011-05-12 15:11:37 +0200230 key = rcu_dereference(sta->gtk[key_idx]);
Johannes Berg62da92f2007-12-19 02:03:31 +0100231 } else
Johannes Berga3836e02011-05-12 15:11:37 +0200232 key = rcu_dereference(sdata->keys[key_idx]);
Johannes Berg62da92f2007-12-19 02:03:31 +0100233
234 if (!key)
235 goto out;
236
237 memset(&params, 0, sizeof(params));
238
Johannes Berg97359d12010-08-10 09:46:38 +0200239 params.cipher = key->conf.cipher;
Johannes Berg62da92f2007-12-19 02:03:31 +0100240
Johannes Berg97359d12010-08-10 09:46:38 +0200241 switch (key->conf.cipher) {
242 case WLAN_CIPHER_SUITE_TKIP:
Harvey Harrisonb0f76b32008-05-14 16:26:19 -0700243 iv32 = key->u.tkip.tx.iv32;
244 iv16 = key->u.tkip.tx.iv16;
Johannes Berg62da92f2007-12-19 02:03:31 +0100245
Johannes Berg24487982009-04-23 18:52:52 +0200246 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
247 drv_get_tkip_seq(sdata->local,
248 key->conf.hw_key_idx,
249 &iv32, &iv16);
Johannes Berg62da92f2007-12-19 02:03:31 +0100250
251 seq[0] = iv16 & 0xff;
252 seq[1] = (iv16 >> 8) & 0xff;
253 seq[2] = iv32 & 0xff;
254 seq[3] = (iv32 >> 8) & 0xff;
255 seq[4] = (iv32 >> 16) & 0xff;
256 seq[5] = (iv32 >> 24) & 0xff;
257 params.seq = seq;
258 params.seq_len = 6;
259 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200260 case WLAN_CIPHER_SUITE_CCMP:
Johannes Bergaba83a0b2011-07-06 21:59:39 +0200261 pn64 = atomic64_read(&key->u.ccmp.tx_pn);
262 seq[0] = pn64;
263 seq[1] = pn64 >> 8;
264 seq[2] = pn64 >> 16;
265 seq[3] = pn64 >> 24;
266 seq[4] = pn64 >> 32;
267 seq[5] = pn64 >> 40;
Johannes Berg62da92f2007-12-19 02:03:31 +0100268 params.seq = seq;
269 params.seq_len = 6;
270 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200271 case WLAN_CIPHER_SUITE_AES_CMAC:
Johannes Berg75396ae2011-07-06 22:00:35 +0200272 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
273 seq[0] = pn64;
274 seq[1] = pn64 >> 8;
275 seq[2] = pn64 >> 16;
276 seq[3] = pn64 >> 24;
277 seq[4] = pn64 >> 32;
278 seq[5] = pn64 >> 40;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200279 params.seq = seq;
280 params.seq_len = 6;
281 break;
Johannes Berg62da92f2007-12-19 02:03:31 +0100282 }
283
284 params.key = key->conf.key;
285 params.key_len = key->conf.keylen;
286
287 callback(cookie, &params);
288 err = 0;
289
290 out:
Johannes Berg3b967662008-04-08 17:56:52 +0200291 rcu_read_unlock();
Johannes Berg62da92f2007-12-19 02:03:31 +0100292 return err;
293}
294
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100295static int ieee80211_config_default_key(struct wiphy *wiphy,
296 struct net_device *dev,
Johannes Bergdbd2fd62010-12-09 19:58:59 +0100297 u8 key_idx, bool uni,
298 bool multi)
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100299{
Johannes Bergad0e2b52010-06-01 10:19:19 +0200300 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100301
Johannes Bergf7e01042010-12-09 19:49:02 +0100302 ieee80211_set_default_key(sdata, key_idx, uni, multi);
Johannes Berge8cbb4c2007-12-19 02:03:30 +0100303
304 return 0;
305}
306
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200307static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
308 struct net_device *dev,
309 u8 key_idx)
310{
Johannes Berg66c52422010-07-22 13:58:51 +0200311 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200312
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200313 ieee80211_set_default_mgmt_key(sdata, key_idx);
314
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200315 return 0;
316}
317
Felix Fietkau3af63342011-02-27 22:08:01 +0100318static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
319{
320 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
321 struct ieee80211_supported_band *sband;
322 sband = sta->local->hw.wiphy->bands[
323 sta->local->hw.conf.channel->band];
324 rate->legacy = sband->bitrates[idx].bitrate;
325 } else
326 rate->mcs = idx;
327}
328
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100329static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
330{
Johannes Bergd0709a62008-02-25 16:27:46 +0100331 struct ieee80211_sub_if_data *sdata = sta->sdata;
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530332 struct timespec uptime;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100333
Johannes Bergf5ea9122009-08-07 16:17:38 +0200334 sinfo->generation = sdata->local->sta_generation;
335
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100336 sinfo->filled = STATION_INFO_INACTIVE_TIME |
337 STATION_INFO_RX_BYTES |
Henning Rogge420e7fa2008-12-11 22:04:19 +0100338 STATION_INFO_TX_BYTES |
Jouni Malinen98c8a60a2009-02-17 13:24:57 +0200339 STATION_INFO_RX_PACKETS |
340 STATION_INFO_TX_PACKETS |
Bruno Randolfb206b4e2010-10-06 18:34:12 +0900341 STATION_INFO_TX_RETRIES |
342 STATION_INFO_TX_FAILED |
Ben Greear5a5c7312010-10-07 16:39:20 -0700343 STATION_INFO_TX_BITRATE |
Felix Fietkau3af63342011-02-27 22:08:01 +0100344 STATION_INFO_RX_BITRATE |
Paul Stewartf4263c92011-03-31 09:25:41 -0700345 STATION_INFO_RX_DROP_MISC |
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530346 STATION_INFO_BSS_PARAM |
347 STATION_INFO_CONNECTED_TIME;
348
349 do_posix_clock_monotonic_gettime(&uptime);
350 sinfo->connected_time = uptime.tv_sec - sta->last_connected;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100351
352 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
353 sinfo->rx_bytes = sta->rx_bytes;
354 sinfo->tx_bytes = sta->tx_bytes;
Jouni Malinen98c8a60a2009-02-17 13:24:57 +0200355 sinfo->rx_packets = sta->rx_packets;
356 sinfo->tx_packets = sta->tx_packets;
Bruno Randolfb206b4e2010-10-06 18:34:12 +0900357 sinfo->tx_retries = sta->tx_retry_count;
358 sinfo->tx_failed = sta->tx_retry_failed;
Ben Greear5a5c7312010-10-07 16:39:20 -0700359 sinfo->rx_dropped_misc = sta->rx_dropped;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100360
John W. Linville19deffb2009-12-08 17:10:13 -0500361 if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
362 (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
Bruno Randolf541a45a2010-12-02 19:12:43 +0900363 sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
Henning Rogge420e7fa2008-12-11 22:04:19 +0100364 sinfo->signal = (s8)sta->last_signal;
Bruno Randolf541a45a2010-12-02 19:12:43 +0900365 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100366 }
367
368 sinfo->txrate.flags = 0;
369 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
370 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
371 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
372 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
373 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
374 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
Felix Fietkau3af63342011-02-27 22:08:01 +0100375 rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100376
Felix Fietkau3af63342011-02-27 22:08:01 +0100377 sinfo->rxrate.flags = 0;
378 if (sta->last_rx_rate_flag & RX_FLAG_HT)
379 sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
380 if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
381 sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
382 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
383 sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
384 rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100385
Johannes Berg902acc72008-02-23 15:17:19 +0100386 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100387#ifdef CONFIG_MAC80211_MESH
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100388 sinfo->filled |= STATION_INFO_LLID |
389 STATION_INFO_PLID |
390 STATION_INFO_PLINK_STATE;
391
392 sinfo->llid = le16_to_cpu(sta->llid);
393 sinfo->plid = le16_to_cpu(sta->plid);
394 sinfo->plink_state = sta->plink_state;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100395#endif
Johannes Berg902acc72008-02-23 15:17:19 +0100396 }
Paul Stewartf4263c92011-03-31 09:25:41 -0700397
398 sinfo->bss_param.flags = 0;
399 if (sdata->vif.bss_conf.use_cts_prot)
400 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
401 if (sdata->vif.bss_conf.use_short_preamble)
402 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
403 if (sdata->vif.bss_conf.use_short_slot)
404 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
405 sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
406 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100407}
408
409
410static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
411 int idx, u8 *mac, struct station_info *sinfo)
412{
Johannes Berg3b53fde82009-11-16 12:00:37 +0100413 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100414 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100415 int ret = -ENOENT;
416
417 rcu_read_lock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100418
Johannes Berg3b53fde82009-11-16 12:00:37 +0100419 sta = sta_info_get_by_idx(sdata, idx);
Johannes Bergd0709a62008-02-25 16:27:46 +0100420 if (sta) {
421 ret = 0;
Johannes Berg17741cd2008-09-11 00:02:02 +0200422 memcpy(mac, sta->sta.addr, ETH_ALEN);
Johannes Bergd0709a62008-02-25 16:27:46 +0100423 sta_set_sinfo(sta, sinfo);
424 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100425
Johannes Bergd0709a62008-02-25 16:27:46 +0100426 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100427
Johannes Bergd0709a62008-02-25 16:27:46 +0100428 return ret;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100429}
430
Holger Schurig12897232010-04-19 10:23:57 +0200431static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
432 int idx, struct survey_info *survey)
433{
434 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
435
Holger Schurig12897232010-04-19 10:23:57 +0200436 return drv_get_survey(local, idx, survey);
437}
438
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100439static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Luis Carlos Cobo2ec600d2008-02-23 15:17:06 +0100440 u8 *mac, struct station_info *sinfo)
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100441{
Johannes Bergabe60632009-11-25 17:46:18 +0100442 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100443 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100444 int ret = -ENOENT;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100445
Johannes Bergd0709a62008-02-25 16:27:46 +0100446 rcu_read_lock();
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100447
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100448 sta = sta_info_get_bss(sdata, mac);
Johannes Bergd0709a62008-02-25 16:27:46 +0100449 if (sta) {
450 ret = 0;
451 sta_set_sinfo(sta, sinfo);
452 }
453
454 rcu_read_unlock();
455
456 return ret;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100457}
458
Arik Nemtsov78274932011-09-04 11:11:32 +0300459static void ieee80211_config_ap_ssid(struct ieee80211_sub_if_data *sdata,
460 struct beacon_parameters *params)
461{
462 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
463
464 bss_conf->ssid_len = params->ssid_len;
465
466 if (params->ssid_len)
467 memcpy(bss_conf->ssid, params->ssid, params->ssid_len);
468
469 bss_conf->hidden_ssid =
470 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
471}
472
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100473/*
474 * This handles both adding a beacon and setting new beacon info
475 */
476static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
477 struct beacon_parameters *params)
478{
479 struct beacon_data *new, *old;
480 int new_head_len, new_tail_len;
481 int size;
482 int err = -EINVAL;
483
Johannes Berg40b275b2011-05-13 14:15:49 +0200484 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100485
486 /* head must not be zero-length */
487 if (params->head && !params->head_len)
488 return -EINVAL;
489
490 /*
491 * This is a kludge. beacon interval should really be part
492 * of the beacon information.
493 */
Johannes Berg57c4d7b2009-04-23 16:10:04 +0200494 if (params->interval &&
495 (sdata->vif.bss_conf.beacon_int != params->interval)) {
496 sdata->vif.bss_conf.beacon_int = params->interval;
497 ieee80211_bss_info_change_notify(sdata,
498 BSS_CHANGED_BEACON_INT);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100499 }
500
501 /* Need to have a beacon head if we don't have one yet */
502 if (!params->head && !old)
503 return err;
504
505 /* sorry, no way to start beaconing without dtim period */
506 if (!params->dtim_period && !old)
507 return err;
508
509 /* new or old head? */
510 if (params->head)
511 new_head_len = params->head_len;
512 else
513 new_head_len = old->head_len;
514
515 /* new or old tail? */
516 if (params->tail || !old)
517 /* params->tail_len will be zero for !params->tail */
518 new_tail_len = params->tail_len;
519 else
520 new_tail_len = old->tail_len;
521
522 size = sizeof(*new) + new_head_len + new_tail_len;
523
524 new = kzalloc(size, GFP_KERNEL);
525 if (!new)
526 return -ENOMEM;
527
528 /* start filling the new info now */
529
530 /* new or old dtim period? */
531 if (params->dtim_period)
532 new->dtim_period = params->dtim_period;
533 else
534 new->dtim_period = old->dtim_period;
535
536 /*
537 * pointers go into the block we allocated,
538 * memory is | beacon_data | head | tail |
539 */
540 new->head = ((u8 *) new) + sizeof(*new);
541 new->tail = new->head + new_head_len;
542 new->head_len = new_head_len;
543 new->tail_len = new_tail_len;
544
545 /* copy in head */
546 if (params->head)
547 memcpy(new->head, params->head, new_head_len);
548 else
549 memcpy(new->head, old->head, new_head_len);
550
551 /* copy in optional tail */
552 if (params->tail)
553 memcpy(new->tail, params->tail, new_tail_len);
554 else
555 if (old)
556 memcpy(new->tail, old->tail, new_tail_len);
557
Johannes Berg19885c42010-02-05 11:45:06 +0100558 sdata->vif.bss_conf.dtim_period = new->dtim_period;
559
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100560 rcu_assign_pointer(sdata->u.ap.beacon, new);
561
562 synchronize_rcu();
563
564 kfree(old);
565
Arik Nemtsov78274932011-09-04 11:11:32 +0300566 ieee80211_config_ap_ssid(sdata, params);
567
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200568 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
Arik Nemtsov78274932011-09-04 11:11:32 +0300569 BSS_CHANGED_BEACON |
570 BSS_CHANGED_SSID);
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200571 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100572}
573
574static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
575 struct beacon_parameters *params)
576{
Johannes Berg14db74b2008-07-29 13:22:52 +0200577 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100578 struct beacon_data *old;
579
Johannes Berg14db74b2008-07-29 13:22:52 +0200580 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
581
Johannes Berg40b275b2011-05-13 14:15:49 +0200582 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100583 if (old)
584 return -EALREADY;
585
586 return ieee80211_config_beacon(sdata, params);
587}
588
589static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
590 struct beacon_parameters *params)
591{
Johannes Berg14db74b2008-07-29 13:22:52 +0200592 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100593 struct beacon_data *old;
594
Johannes Berg14db74b2008-07-29 13:22:52 +0200595 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
596
Johannes Berg40b275b2011-05-13 14:15:49 +0200597 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100598 if (!old)
599 return -ENOENT;
600
601 return ieee80211_config_beacon(sdata, params);
602}
603
604static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
605{
Johannes Berg14db74b2008-07-29 13:22:52 +0200606 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100607 struct beacon_data *old;
608
Johannes Berg14db74b2008-07-29 13:22:52 +0200609 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
610
Johannes Berg40b275b2011-05-13 14:15:49 +0200611 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100612 if (!old)
613 return -ENOENT;
614
615 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
616 synchronize_rcu();
617 kfree(old);
618
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200619 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
620 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100621}
622
Johannes Berg4fd69312007-12-19 02:03:35 +0100623/* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
624struct iapp_layer2_update {
625 u8 da[ETH_ALEN]; /* broadcast */
626 u8 sa[ETH_ALEN]; /* STA addr */
627 __be16 len; /* 6 */
628 u8 dsap; /* 0 */
629 u8 ssap; /* 0 */
630 u8 control;
631 u8 xid_info[3];
Eric Dumazetbc105022010-06-03 03:21:52 -0700632} __packed;
Johannes Berg4fd69312007-12-19 02:03:35 +0100633
634static void ieee80211_send_layer2_update(struct sta_info *sta)
635{
636 struct iapp_layer2_update *msg;
637 struct sk_buff *skb;
638
639 /* Send Level 2 Update Frame to update forwarding tables in layer 2
640 * bridge devices */
641
642 skb = dev_alloc_skb(sizeof(*msg));
643 if (!skb)
644 return;
645 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
646
647 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
648 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
649
650 memset(msg->da, 0xff, ETH_ALEN);
Johannes Berg17741cd2008-09-11 00:02:02 +0200651 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
Johannes Berg4fd69312007-12-19 02:03:35 +0100652 msg->len = htons(6);
653 msg->dsap = 0;
654 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
655 msg->control = 0xaf; /* XID response lsb.1111F101.
656 * F=0 (no poll command; unsolicited frame) */
657 msg->xid_info[0] = 0x81; /* XID format identifier */
658 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
659 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
660
Johannes Bergd0709a62008-02-25 16:27:46 +0100661 skb->dev = sta->sdata->dev;
662 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
Johannes Berg4fd69312007-12-19 02:03:35 +0100663 memset(skb->cb, 0, sizeof(skb->cb));
John W. Linville06ee1c22010-07-19 11:52:59 -0400664 netif_rx_ni(skb);
Johannes Berg4fd69312007-12-19 02:03:35 +0100665}
666
667static void sta_apply_parameters(struct ieee80211_local *local,
668 struct sta_info *sta,
669 struct station_parameters *params)
670{
671 u32 rates;
672 int i, j;
Johannes Berg8318d782008-01-24 19:38:38 +0100673 struct ieee80211_supported_band *sband;
Johannes Bergd0709a62008-02-25 16:27:46 +0100674 struct ieee80211_sub_if_data *sdata = sta->sdata;
Johannes Bergeccb8e82009-05-11 21:57:56 +0300675 u32 mask, set;
Johannes Berg4fd69312007-12-19 02:03:35 +0100676
Johannes Bergae5eb022008-10-14 16:58:37 +0200677 sband = local->hw.wiphy->bands[local->oper_channel->band];
678
Johannes Bergeccb8e82009-05-11 21:57:56 +0300679 mask = params->sta_flags_mask;
680 set = params->sta_flags_set;
Johannes Berg73651ee2008-02-25 16:27:47 +0100681
Johannes Bergeccb8e82009-05-11 21:57:56 +0300682 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300683 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200684 set_sta_flag(sta, WLAN_STA_AUTHORIZED);
685 else
686 clear_sta_flag(sta, WLAN_STA_AUTHORIZED);
Johannes Berg4fd69312007-12-19 02:03:35 +0100687 }
688
Johannes Bergeccb8e82009-05-11 21:57:56 +0300689 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300690 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200691 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
692 else
693 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300694 }
695
696 if (mask & BIT(NL80211_STA_FLAG_WME)) {
Arik Nemtsov39df6002011-06-27 23:58:45 +0300697 if (set & BIT(NL80211_STA_FLAG_WME)) {
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200698 set_sta_flag(sta, WLAN_STA_WME);
Arik Nemtsov39df6002011-06-27 23:58:45 +0300699 sta->sta.wme = true;
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200700 } else {
701 clear_sta_flag(sta, WLAN_STA_WME);
702 sta->sta.wme = false;
Arik Nemtsov39df6002011-06-27 23:58:45 +0300703 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300704 }
705
706 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300707 if (set & BIT(NL80211_STA_FLAG_MFP))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200708 set_sta_flag(sta, WLAN_STA_MFP);
709 else
710 clear_sta_flag(sta, WLAN_STA_MFP);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300711 }
Javier Cardonab39c48f2011-04-07 15:08:30 -0700712
713 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
Javier Cardonab39c48f2011-04-07 15:08:30 -0700714 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200715 set_sta_flag(sta, WLAN_STA_AUTH);
716 else
717 clear_sta_flag(sta, WLAN_STA_AUTH);
Javier Cardonab39c48f2011-04-07 15:08:30 -0700718 }
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300719
720 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300721 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200722 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
723 else
724 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300725 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300726
Johannes Berg3b9ce802011-09-27 20:56:12 +0200727 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
728 sta->sta.uapsd_queues = params->uapsd_queues;
729 sta->sta.max_sp = params->max_sp;
730 }
Eliad Peller9533b4a2011-08-23 14:37:47 +0300731
Johannes Berg73651ee2008-02-25 16:27:47 +0100732 /*
Johannes Berg51b50fb2009-05-24 16:42:30 +0200733 * cfg80211 validates this (1-2007) and allows setting the AID
734 * only when creating a new station entry
735 */
736 if (params->aid)
737 sta->sta.aid = params->aid;
738
739 /*
Johannes Berg73651ee2008-02-25 16:27:47 +0100740 * FIXME: updating the following information is racy when this
741 * function is called from ieee80211_change_station().
742 * However, all this information should be static so
743 * maybe we should just reject attemps to change it.
744 */
745
Johannes Berg4fd69312007-12-19 02:03:35 +0100746 if (params->listen_interval >= 0)
747 sta->listen_interval = params->listen_interval;
748
749 if (params->supported_rates) {
750 rates = 0;
Johannes Berg8318d782008-01-24 19:38:38 +0100751
Johannes Berg4fd69312007-12-19 02:03:35 +0100752 for (i = 0; i < params->supported_rates_len; i++) {
753 int rate = (params->supported_rates[i] & 0x7f) * 5;
Johannes Berg8318d782008-01-24 19:38:38 +0100754 for (j = 0; j < sband->n_bitrates; j++) {
755 if (sband->bitrates[j].bitrate == rate)
Johannes Berg4fd69312007-12-19 02:03:35 +0100756 rates |= BIT(j);
757 }
758 }
Johannes Berg323ce792008-09-11 02:45:11 +0200759 sta->sta.supp_rates[local->oper_channel->band] = rates;
Johannes Berg4fd69312007-12-19 02:03:35 +0100760 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100761
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200762 if (params->ht_capa)
Johannes Bergae5eb022008-10-14 16:58:37 +0200763 ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
764 params->ht_capa,
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200765 &sta->sta.ht_cap);
Jouni Malinen36aedc902008-08-25 11:58:58 +0300766
Javier Cardona9c3990a2011-05-03 16:57:11 -0700767 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400768#ifdef CONFIG_MAC80211_MESH
Javier Cardona9c3990a2011-05-03 16:57:11 -0700769 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
770 switch (params->plink_state) {
Javier Cardona57cf8042011-05-13 10:45:43 -0700771 case NL80211_PLINK_LISTEN:
772 case NL80211_PLINK_ESTAB:
773 case NL80211_PLINK_BLOCKED:
Javier Cardona9c3990a2011-05-03 16:57:11 -0700774 sta->plink_state = params->plink_state;
775 break;
776 default:
777 /* nothing */
778 break;
779 }
780 else
781 switch (params->plink_action) {
782 case PLINK_ACTION_OPEN:
783 mesh_plink_open(sta);
784 break;
785 case PLINK_ACTION_BLOCK:
786 mesh_plink_block(sta);
787 break;
788 }
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400789#endif
Johannes Berg902acc72008-02-23 15:17:19 +0100790 }
Johannes Berg4fd69312007-12-19 02:03:35 +0100791}
792
793static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
794 u8 *mac, struct station_parameters *params)
795{
Johannes Berg14db74b2008-07-29 13:22:52 +0200796 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +0100797 struct sta_info *sta;
798 struct ieee80211_sub_if_data *sdata;
Johannes Berg73651ee2008-02-25 16:27:47 +0100799 int err;
Jouni Malinenb8d476c2008-12-12 17:08:31 +0200800 int layer2_update;
Johannes Berg4fd69312007-12-19 02:03:35 +0100801
Johannes Berg4fd69312007-12-19 02:03:35 +0100802 if (params->vlan) {
803 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
804
Johannes Berg05c914f2008-09-11 00:01:58 +0200805 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
806 sdata->vif.type != NL80211_IFTYPE_AP)
Johannes Berg4fd69312007-12-19 02:03:35 +0100807 return -EINVAL;
808 } else
809 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
810
Johannes Berg47846c92009-11-25 17:46:19 +0100811 if (compare_ether_addr(mac, sdata->vif.addr) == 0)
Johannes Berg03e44972008-02-27 09:56:40 +0100812 return -EINVAL;
813
814 if (is_multicast_ether_addr(mac))
815 return -EINVAL;
816
817 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +0100818 if (!sta)
819 return -ENOMEM;
Johannes Berg4fd69312007-12-19 02:03:35 +0100820
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200821 set_sta_flag(sta, WLAN_STA_AUTH);
822 set_sta_flag(sta, WLAN_STA_ASSOC);
Johannes Berg4fd69312007-12-19 02:03:35 +0100823
824 sta_apply_parameters(local, sta, params);
825
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300826 /* Only TDLS-supporting stations can add TDLS peers */
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200827 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300828 !((wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) &&
829 sdata->vif.type == NL80211_IFTYPE_STATION))
830 return -ENOTSUPP;
831
Johannes Berg4b7679a2008-09-18 18:14:18 +0200832 rate_control_rate_init(sta);
Johannes Berg4fd69312007-12-19 02:03:35 +0100833
Jouni Malinenb8d476c2008-12-12 17:08:31 +0200834 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
835 sdata->vif.type == NL80211_IFTYPE_AP;
836
Johannes Berg34e89502010-02-03 13:59:58 +0100837 err = sta_info_insert_rcu(sta);
Johannes Berg73651ee2008-02-25 16:27:47 +0100838 if (err) {
Johannes Berg73651ee2008-02-25 16:27:47 +0100839 rcu_read_unlock();
840 return err;
841 }
842
Jouni Malinenb8d476c2008-12-12 17:08:31 +0200843 if (layer2_update)
Johannes Berg73651ee2008-02-25 16:27:47 +0100844 ieee80211_send_layer2_update(sta);
845
846 rcu_read_unlock();
847
Johannes Berg4fd69312007-12-19 02:03:35 +0100848 return 0;
849}
850
851static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
852 u8 *mac)
853{
Johannes Berg14db74b2008-07-29 13:22:52 +0200854 struct ieee80211_local *local = wiphy_priv(wiphy);
855 struct ieee80211_sub_if_data *sdata;
Johannes Berg4fd69312007-12-19 02:03:35 +0100856
Johannes Berg14db74b2008-07-29 13:22:52 +0200857 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
858
Johannes Berg34e89502010-02-03 13:59:58 +0100859 if (mac)
860 return sta_info_destroy_addr_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +0200861
Johannes Berg34e89502010-02-03 13:59:58 +0100862 sta_info_flush(local, sdata);
Johannes Berg4fd69312007-12-19 02:03:35 +0100863 return 0;
864}
865
866static int ieee80211_change_station(struct wiphy *wiphy,
867 struct net_device *dev,
868 u8 *mac,
869 struct station_parameters *params)
870{
Johannes Bergabe60632009-11-25 17:46:18 +0100871 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg14db74b2008-07-29 13:22:52 +0200872 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +0100873 struct sta_info *sta;
874 struct ieee80211_sub_if_data *vlansdata;
875
Johannes Berg98dd6a52008-04-10 15:36:09 +0200876 rcu_read_lock();
877
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100878 sta = sta_info_get_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +0200879 if (!sta) {
880 rcu_read_unlock();
Johannes Berg4fd69312007-12-19 02:03:35 +0100881 return -ENOENT;
Johannes Berg98dd6a52008-04-10 15:36:09 +0200882 }
Johannes Berg4fd69312007-12-19 02:03:35 +0100883
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300884 /* The TDLS bit cannot be toggled after the STA was added */
885 if ((params->sta_flags_mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) &&
886 !!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) !=
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200887 !!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300888 rcu_read_unlock();
889 return -EINVAL;
890 }
891
Johannes Bergd0709a62008-02-25 16:27:46 +0100892 if (params->vlan && params->vlan != sta->sdata->dev) {
Johannes Berg4fd69312007-12-19 02:03:35 +0100893 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
894
Johannes Berg05c914f2008-09-11 00:01:58 +0200895 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
896 vlansdata->vif.type != NL80211_IFTYPE_AP) {
Johannes Berg98dd6a52008-04-10 15:36:09 +0200897 rcu_read_unlock();
Johannes Berg4fd69312007-12-19 02:03:35 +0100898 return -EINVAL;
Johannes Berg98dd6a52008-04-10 15:36:09 +0200899 }
Johannes Berg4fd69312007-12-19 02:03:35 +0100900
Johannes Berg9bc383d2009-11-19 11:55:19 +0100901 if (params->vlan->ieee80211_ptr->use_4addr) {
Johannes Berg33054432009-11-20 10:09:14 +0100902 if (vlansdata->u.vlan.sta) {
903 rcu_read_unlock();
Felix Fietkauf14543ee2009-11-10 20:10:05 +0100904 return -EBUSY;
Johannes Berg33054432009-11-20 10:09:14 +0100905 }
Felix Fietkauf14543ee2009-11-10 20:10:05 +0100906
907 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
908 }
909
Johannes Berg14db74b2008-07-29 13:22:52 +0200910 sta->sdata = vlansdata;
Johannes Berg4fd69312007-12-19 02:03:35 +0100911 ieee80211_send_layer2_update(sta);
912 }
913
914 sta_apply_parameters(local, sta, params);
915
Johannes Berg98dd6a52008-04-10 15:36:09 +0200916 rcu_read_unlock();
917
Jason Young808118c2011-03-10 16:43:19 -0800918 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
919 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))
920 ieee80211_recalc_ps(local, -1);
921
Johannes Berg4fd69312007-12-19 02:03:35 +0100922 return 0;
923}
924
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100925#ifdef CONFIG_MAC80211_MESH
926static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
927 u8 *dst, u8 *next_hop)
928{
Johannes Berg14db74b2008-07-29 13:22:52 +0200929 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100930 struct mesh_path *mpath;
931 struct sta_info *sta;
932 int err;
933
Johannes Berg14db74b2008-07-29 13:22:52 +0200934 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
935
Johannes Bergd0709a62008-02-25 16:27:46 +0100936 rcu_read_lock();
Johannes Bergabe60632009-11-25 17:46:18 +0100937 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +0100938 if (!sta) {
939 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100940 return -ENOENT;
Johannes Bergd0709a62008-02-25 16:27:46 +0100941 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100942
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200943 err = mesh_path_add(dst, sdata);
Johannes Bergd0709a62008-02-25 16:27:46 +0100944 if (err) {
945 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100946 return err;
Johannes Bergd0709a62008-02-25 16:27:46 +0100947 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100948
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200949 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100950 if (!mpath) {
951 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100952 return -ENXIO;
953 }
954 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +0100955
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100956 rcu_read_unlock();
957 return 0;
958}
959
960static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
961 u8 *dst)
962{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200963 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100964
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200965 if (dst)
966 return mesh_path_del(dst, sdata);
967
Javier Cardonaece1a2e2011-08-29 13:23:04 -0700968 mesh_path_flush_by_iface(sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100969 return 0;
970}
971
972static int ieee80211_change_mpath(struct wiphy *wiphy,
973 struct net_device *dev,
974 u8 *dst, u8 *next_hop)
975{
Johannes Berg14db74b2008-07-29 13:22:52 +0200976 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100977 struct mesh_path *mpath;
978 struct sta_info *sta;
979
Johannes Berg14db74b2008-07-29 13:22:52 +0200980 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
981
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100982 rcu_read_lock();
Johannes Bergd0709a62008-02-25 16:27:46 +0100983
Johannes Bergabe60632009-11-25 17:46:18 +0100984 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +0100985 if (!sta) {
986 rcu_read_unlock();
987 return -ENOENT;
988 }
989
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200990 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100991 if (!mpath) {
992 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100993 return -ENOENT;
994 }
995
996 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +0100997
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100998 rcu_read_unlock();
999 return 0;
1000}
1001
1002static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1003 struct mpath_info *pinfo)
1004{
Johannes Berga3836e02011-05-12 15:11:37 +02001005 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1006
1007 if (next_hop_sta)
1008 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001009 else
1010 memset(next_hop, 0, ETH_ALEN);
1011
Johannes Bergf5ea9122009-08-07 16:17:38 +02001012 pinfo->generation = mesh_paths_generation;
1013
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001014 pinfo->filled = MPATH_INFO_FRAME_QLEN |
Rui Paulod19b3bf2009-11-09 23:46:55 +00001015 MPATH_INFO_SN |
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001016 MPATH_INFO_METRIC |
1017 MPATH_INFO_EXPTIME |
1018 MPATH_INFO_DISCOVERY_TIMEOUT |
1019 MPATH_INFO_DISCOVERY_RETRIES |
1020 MPATH_INFO_FLAGS;
1021
1022 pinfo->frame_qlen = mpath->frame_queue.qlen;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001023 pinfo->sn = mpath->sn;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001024 pinfo->metric = mpath->metric;
1025 if (time_before(jiffies, mpath->exp_time))
1026 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1027 pinfo->discovery_timeout =
1028 jiffies_to_msecs(mpath->discovery_timeout);
1029 pinfo->discovery_retries = mpath->discovery_retries;
1030 pinfo->flags = 0;
1031 if (mpath->flags & MESH_PATH_ACTIVE)
1032 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1033 if (mpath->flags & MESH_PATH_RESOLVING)
1034 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001035 if (mpath->flags & MESH_PATH_SN_VALID)
1036 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001037 if (mpath->flags & MESH_PATH_FIXED)
1038 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1039 if (mpath->flags & MESH_PATH_RESOLVING)
1040 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1041
1042 pinfo->flags = mpath->flags;
1043}
1044
1045static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1046 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1047
1048{
Johannes Berg14db74b2008-07-29 13:22:52 +02001049 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001050 struct mesh_path *mpath;
1051
Johannes Berg14db74b2008-07-29 13:22:52 +02001052 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1053
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001054 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001055 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001056 if (!mpath) {
1057 rcu_read_unlock();
1058 return -ENOENT;
1059 }
1060 memcpy(dst, mpath->dst, ETH_ALEN);
1061 mpath_set_pinfo(mpath, next_hop, pinfo);
1062 rcu_read_unlock();
1063 return 0;
1064}
1065
1066static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1067 int idx, u8 *dst, u8 *next_hop,
1068 struct mpath_info *pinfo)
1069{
Johannes Berg14db74b2008-07-29 13:22:52 +02001070 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001071 struct mesh_path *mpath;
1072
Johannes Berg14db74b2008-07-29 13:22:52 +02001073 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1074
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001075 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001076 mpath = mesh_path_lookup_by_idx(idx, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001077 if (!mpath) {
1078 rcu_read_unlock();
1079 return -ENOENT;
1080 }
1081 memcpy(dst, mpath->dst, ETH_ALEN);
1082 mpath_set_pinfo(mpath, next_hop, pinfo);
1083 rcu_read_unlock();
1084 return 0;
1085}
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001086
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001087static int ieee80211_get_mesh_config(struct wiphy *wiphy,
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001088 struct net_device *dev,
1089 struct mesh_config *conf)
1090{
1091 struct ieee80211_sub_if_data *sdata;
1092 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1093
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001094 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1095 return 0;
1096}
1097
1098static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1099{
1100 return (mask >> (parm-1)) & 0x1;
1101}
1102
Javier Cardonac80d5452010-12-16 17:37:49 -08001103static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1104 const struct mesh_setup *setup)
1105{
1106 u8 *new_ie;
1107 const u8 *old_ie;
1108
Javier Cardona581a8b02011-04-07 15:08:27 -07001109 /* allocate information elements */
Javier Cardonac80d5452010-12-16 17:37:49 -08001110 new_ie = NULL;
Javier Cardona581a8b02011-04-07 15:08:27 -07001111 old_ie = ifmsh->ie;
Javier Cardonac80d5452010-12-16 17:37:49 -08001112
Javier Cardona581a8b02011-04-07 15:08:27 -07001113 if (setup->ie_len) {
1114 new_ie = kmemdup(setup->ie, setup->ie_len,
Javier Cardonac80d5452010-12-16 17:37:49 -08001115 GFP_KERNEL);
1116 if (!new_ie)
1117 return -ENOMEM;
1118 }
Javier Cardona581a8b02011-04-07 15:08:27 -07001119 ifmsh->ie_len = setup->ie_len;
1120 ifmsh->ie = new_ie;
1121 kfree(old_ie);
Javier Cardonac80d5452010-12-16 17:37:49 -08001122
1123 /* now copy the rest of the setup parameters */
1124 ifmsh->mesh_id_len = setup->mesh_id_len;
1125 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
1126 ifmsh->mesh_pp_id = setup->path_sel_proto;
1127 ifmsh->mesh_pm_id = setup->path_metric;
Javier Cardonab130e5c2011-05-03 16:57:07 -07001128 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1129 if (setup->is_authenticated)
1130 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1131 if (setup->is_secure)
1132 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
Javier Cardonac80d5452010-12-16 17:37:49 -08001133
1134 return 0;
1135}
1136
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001137static int ieee80211_update_mesh_config(struct wiphy *wiphy,
Johannes Berg29cbe682010-12-03 09:20:44 +01001138 struct net_device *dev, u32 mask,
1139 const struct mesh_config *nconf)
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001140{
1141 struct mesh_config *conf;
1142 struct ieee80211_sub_if_data *sdata;
Rui Paulo63c57232009-11-09 23:46:57 +00001143 struct ieee80211_if_mesh *ifmsh;
1144
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001145 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Rui Paulo63c57232009-11-09 23:46:57 +00001146 ifmsh = &sdata->u.mesh;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001147
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001148 /* Set the config options which we are interested in setting */
1149 conf = &(sdata->u.mesh.mshcfg);
1150 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1151 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1152 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1153 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1154 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1155 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1156 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1157 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1158 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1159 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1160 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1161 conf->dot11MeshTTL = nconf->dot11MeshTTL;
Javier Cardona45904f22010-12-03 09:20:40 +01001162 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1163 conf->dot11MeshTTL = nconf->element_ttl;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001164 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
1165 conf->auto_open_plinks = nconf->auto_open_plinks;
1166 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1167 conf->dot11MeshHWMPmaxPREQretries =
1168 nconf->dot11MeshHWMPmaxPREQretries;
1169 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1170 conf->path_refresh_time = nconf->path_refresh_time;
1171 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1172 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1173 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1174 conf->dot11MeshHWMPactivePathTimeout =
1175 nconf->dot11MeshHWMPactivePathTimeout;
1176 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1177 conf->dot11MeshHWMPpreqMinInterval =
1178 nconf->dot11MeshHWMPpreqMinInterval;
1179 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1180 mask))
1181 conf->dot11MeshHWMPnetDiameterTraversalTime =
1182 nconf->dot11MeshHWMPnetDiameterTraversalTime;
Rui Paulo63c57232009-11-09 23:46:57 +00001183 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1184 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1185 ieee80211_mesh_root_setup(ifmsh);
1186 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001187 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
Thomas Pedersenc61336612011-08-25 10:36:14 -07001188 /* our current gate announcement implementation rides on root
1189 * announcements, so require this ifmsh to also be a root node
1190 * */
1191 if (nconf->dot11MeshGateAnnouncementProtocol &&
1192 !conf->dot11MeshHWMPRootMode) {
1193 conf->dot11MeshHWMPRootMode = 1;
1194 ieee80211_mesh_root_setup(ifmsh);
1195 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001196 conf->dot11MeshGateAnnouncementProtocol =
1197 nconf->dot11MeshGateAnnouncementProtocol;
1198 }
Javier Cardona0507e152011-08-09 16:45:10 -07001199 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) {
1200 conf->dot11MeshHWMPRannInterval =
1201 nconf->dot11MeshHWMPRannInterval;
1202 }
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001203 return 0;
1204}
1205
Johannes Berg29cbe682010-12-03 09:20:44 +01001206static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1207 const struct mesh_config *conf,
1208 const struct mesh_setup *setup)
1209{
1210 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1211 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
Javier Cardonac80d5452010-12-16 17:37:49 -08001212 int err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001213
Javier Cardonac80d5452010-12-16 17:37:49 -08001214 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1215 err = copy_mesh_setup(ifmsh, setup);
1216 if (err)
1217 return err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001218 ieee80211_start_mesh(sdata);
1219
1220 return 0;
1221}
1222
1223static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1224{
1225 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1226
1227 ieee80211_stop_mesh(sdata);
1228
1229 return 0;
1230}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001231#endif
1232
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001233static int ieee80211_change_bss(struct wiphy *wiphy,
1234 struct net_device *dev,
1235 struct bss_parameters *params)
1236{
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001237 struct ieee80211_sub_if_data *sdata;
1238 u32 changed = 0;
1239
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001240 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1241
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001242 if (params->use_cts_prot >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001243 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001244 changed |= BSS_CHANGED_ERP_CTS_PROT;
1245 }
1246 if (params->use_short_preamble >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001247 sdata->vif.bss_conf.use_short_preamble =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001248 params->use_short_preamble;
1249 changed |= BSS_CHANGED_ERP_PREAMBLE;
1250 }
Felix Fietkau43d35342010-01-15 03:00:48 +01001251
1252 if (!sdata->vif.bss_conf.use_short_slot &&
1253 sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) {
1254 sdata->vif.bss_conf.use_short_slot = true;
1255 changed |= BSS_CHANGED_ERP_SLOT;
1256 }
1257
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001258 if (params->use_short_slot_time >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001259 sdata->vif.bss_conf.use_short_slot =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001260 params->use_short_slot_time;
1261 changed |= BSS_CHANGED_ERP_SLOT;
1262 }
1263
Jouni Malinen90c97a02008-10-30 16:59:22 +02001264 if (params->basic_rates) {
1265 int i, j;
1266 u32 rates = 0;
1267 struct ieee80211_local *local = wiphy_priv(wiphy);
1268 struct ieee80211_supported_band *sband =
1269 wiphy->bands[local->oper_channel->band];
1270
1271 for (i = 0; i < params->basic_rates_len; i++) {
1272 int rate = (params->basic_rates[i] & 0x7f) * 5;
1273 for (j = 0; j < sband->n_bitrates; j++) {
1274 if (sband->bitrates[j].bitrate == rate)
1275 rates |= BIT(j);
1276 }
1277 }
1278 sdata->vif.bss_conf.basic_rates = rates;
1279 changed |= BSS_CHANGED_BASIC_RATES;
1280 }
1281
Felix Fietkau7b7b5e52010-04-27 01:23:36 +02001282 if (params->ap_isolate >= 0) {
1283 if (params->ap_isolate)
1284 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1285 else
1286 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1287 }
1288
Helmut Schaa80d7e402010-11-19 12:40:26 +01001289 if (params->ht_opmode >= 0) {
1290 sdata->vif.bss_conf.ht_operation_mode =
1291 (u16) params->ht_opmode;
1292 changed |= BSS_CHANGED_HT;
1293 }
1294
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001295 ieee80211_bss_info_change_notify(sdata, changed);
1296
1297 return 0;
1298}
1299
Jouni Malinen31888482008-10-30 16:59:24 +02001300static int ieee80211_set_txq_params(struct wiphy *wiphy,
Eliad Pellerf70f01c2011-09-25 20:06:53 +03001301 struct net_device *dev,
Jouni Malinen31888482008-10-30 16:59:24 +02001302 struct ieee80211_txq_params *params)
1303{
1304 struct ieee80211_local *local = wiphy_priv(wiphy);
Eliad Pellerf6f3def2011-09-25 20:06:54 +03001305 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen31888482008-10-30 16:59:24 +02001306 struct ieee80211_tx_queue_params p;
1307
1308 if (!local->ops->conf_tx)
1309 return -EOPNOTSUPP;
1310
1311 memset(&p, 0, sizeof(p));
1312 p.aifs = params->aifs;
1313 p.cw_max = params->cwmax;
1314 p.cw_min = params->cwmin;
1315 p.txop = params->txop;
Kalle Valoab133152010-01-12 10:42:31 +02001316
1317 /*
1318 * Setting tx queue params disables u-apsd because it's only
1319 * called in master mode.
1320 */
1321 p.uapsd = false;
1322
Eliad Peller2683d652011-07-14 20:29:42 +03001323 if (params->queue >= local->hw.queues)
1324 return -EINVAL;
1325
Eliad Pellerf6f3def2011-09-25 20:06:54 +03001326 sdata->tx_conf[params->queue] = p;
1327 if (drv_conf_tx(local, sdata, params->queue, &p)) {
Joe Perches0fb9a9e2010-08-20 16:25:38 -07001328 wiphy_debug(local->hw.wiphy,
1329 "failed to set TX queue parameters for queue %d\n",
1330 params->queue);
Jouni Malinen31888482008-10-30 16:59:24 +02001331 return -EINVAL;
1332 }
1333
1334 return 0;
1335}
1336
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001337static int ieee80211_set_channel(struct wiphy *wiphy,
Johannes Bergf444de02010-05-05 15:25:02 +02001338 struct net_device *netdev,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001339 struct ieee80211_channel *chan,
Sujith094d05d2008-12-12 11:57:43 +05301340 enum nl80211_channel_type channel_type)
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001341{
1342 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg0aaffa92010-05-05 15:28:27 +02001343 struct ieee80211_sub_if_data *sdata = NULL;
Ben Greeareeabee72011-01-28 10:20:47 -08001344 struct ieee80211_channel *old_oper;
1345 enum nl80211_channel_type old_oper_type;
1346 enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001347
1348 if (netdev)
1349 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001350
Johannes Bergf444de02010-05-05 15:25:02 +02001351 switch (ieee80211_get_channel_mode(local, NULL)) {
1352 case CHAN_MODE_HOPPING:
1353 return -EBUSY;
1354 case CHAN_MODE_FIXED:
Johannes Berg0aaffa92010-05-05 15:28:27 +02001355 if (local->oper_channel != chan)
1356 return -EBUSY;
1357 if (!sdata && local->_oper_channel_type == channel_type)
Johannes Bergf444de02010-05-05 15:25:02 +02001358 return 0;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001359 break;
Johannes Bergf444de02010-05-05 15:25:02 +02001360 case CHAN_MODE_UNDEFINED:
1361 break;
1362 }
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001363
Ben Greeareeabee72011-01-28 10:20:47 -08001364 if (sdata)
1365 old_vif_oper_type = sdata->vif.bss_conf.channel_type;
1366 old_oper_type = local->_oper_channel_type;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001367
Johannes Berg0aaffa92010-05-05 15:28:27 +02001368 if (!ieee80211_set_channel_type(local, sdata, channel_type))
1369 return -EBUSY;
1370
Ben Greeareeabee72011-01-28 10:20:47 -08001371 old_oper = local->oper_channel;
1372 local->oper_channel = chan;
1373
1374 /* Update driver if changes were actually made. */
1375 if ((old_oper != local->oper_channel) ||
1376 (old_oper_type != local->_oper_channel_type))
1377 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1378
1379 if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) &&
1380 old_vif_oper_type != sdata->vif.bss_conf.channel_type)
Johannes Berg0aaffa92010-05-05 15:28:27 +02001381 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1382
1383 return 0;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001384}
1385
Bob Copeland665af4f2009-01-19 11:20:53 -05001386#ifdef CONFIG_PM
Johannes Bergff1b6e62011-05-04 15:37:28 +02001387static int ieee80211_suspend(struct wiphy *wiphy,
1388 struct cfg80211_wowlan *wowlan)
Bob Copeland665af4f2009-01-19 11:20:53 -05001389{
Johannes Bergeecc4802011-05-04 15:37:29 +02001390 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
Bob Copeland665af4f2009-01-19 11:20:53 -05001391}
1392
1393static int ieee80211_resume(struct wiphy *wiphy)
1394{
1395 return __ieee80211_resume(wiphy_priv(wiphy));
1396}
1397#else
1398#define ieee80211_suspend NULL
1399#define ieee80211_resume NULL
1400#endif
1401
Johannes Berg2a519312009-02-10 21:25:55 +01001402static int ieee80211_scan(struct wiphy *wiphy,
1403 struct net_device *dev,
1404 struct cfg80211_scan_request *req)
1405{
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001406 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg2a519312009-02-10 21:25:55 +01001407
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001408 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
1409 case NL80211_IFTYPE_STATION:
1410 case NL80211_IFTYPE_ADHOC:
1411 case NL80211_IFTYPE_MESH_POINT:
1412 case NL80211_IFTYPE_P2P_CLIENT:
1413 break;
1414 case NL80211_IFTYPE_P2P_GO:
1415 if (sdata->local->ops->hw_scan)
1416 break;
Johannes Berge9d77322011-02-01 15:35:36 +01001417 /*
1418 * FIXME: implement NoA while scanning in software,
1419 * for now fall through to allow scanning only when
1420 * beaconing hasn't been configured yet
1421 */
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001422 case NL80211_IFTYPE_AP:
1423 if (sdata->u.ap.beacon)
1424 return -EOPNOTSUPP;
1425 break;
1426 default:
1427 return -EOPNOTSUPP;
1428 }
Johannes Berg2a519312009-02-10 21:25:55 +01001429
1430 return ieee80211_request_scan(sdata, req);
1431}
1432
Luciano Coelho79f460c2011-05-11 17:09:36 +03001433static int
1434ieee80211_sched_scan_start(struct wiphy *wiphy,
1435 struct net_device *dev,
1436 struct cfg80211_sched_scan_request *req)
1437{
1438 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1439
1440 if (!sdata->local->ops->sched_scan_start)
1441 return -EOPNOTSUPP;
1442
1443 return ieee80211_request_sched_scan_start(sdata, req);
1444}
1445
1446static int
Luciano Coelho85a99942011-05-12 16:28:29 +03001447ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
Luciano Coelho79f460c2011-05-11 17:09:36 +03001448{
1449 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1450
1451 if (!sdata->local->ops->sched_scan_stop)
1452 return -EOPNOTSUPP;
1453
Luciano Coelho85a99942011-05-12 16:28:29 +03001454 return ieee80211_request_sched_scan_stop(sdata);
Luciano Coelho79f460c2011-05-11 17:09:36 +03001455}
1456
Jouni Malinen636a5d32009-03-19 13:39:22 +02001457static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1458 struct cfg80211_auth_request *req)
1459{
Johannes Berg77fdaa12009-07-07 03:45:17 +02001460 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001461}
1462
1463static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1464 struct cfg80211_assoc_request *req)
1465{
Johannes Bergf444de02010-05-05 15:25:02 +02001466 struct ieee80211_local *local = wiphy_priv(wiphy);
1467 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1468
1469 switch (ieee80211_get_channel_mode(local, sdata)) {
1470 case CHAN_MODE_HOPPING:
1471 return -EBUSY;
1472 case CHAN_MODE_FIXED:
1473 if (local->oper_channel == req->bss->channel)
1474 break;
1475 return -EBUSY;
1476 case CHAN_MODE_UNDEFINED:
1477 break;
1478 }
1479
Johannes Berg77fdaa12009-07-07 03:45:17 +02001480 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001481}
1482
1483static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg667503dd2009-07-07 03:56:11 +02001484 struct cfg80211_deauth_request *req,
1485 void *cookie)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001486{
Johannes Berg667503dd2009-07-07 03:56:11 +02001487 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev),
1488 req, cookie);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001489}
1490
1491static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg667503dd2009-07-07 03:56:11 +02001492 struct cfg80211_disassoc_request *req,
1493 void *cookie)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001494{
Johannes Berg667503dd2009-07-07 03:56:11 +02001495 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev),
1496 req, cookie);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001497}
1498
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001499static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1500 struct cfg80211_ibss_params *params)
1501{
Johannes Bergf444de02010-05-05 15:25:02 +02001502 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001503 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1504
Johannes Bergf444de02010-05-05 15:25:02 +02001505 switch (ieee80211_get_channel_mode(local, sdata)) {
1506 case CHAN_MODE_HOPPING:
1507 return -EBUSY;
1508 case CHAN_MODE_FIXED:
1509 if (!params->channel_fixed)
1510 return -EBUSY;
1511 if (local->oper_channel == params->channel)
1512 break;
1513 return -EBUSY;
1514 case CHAN_MODE_UNDEFINED:
1515 break;
1516 }
1517
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001518 return ieee80211_ibss_join(sdata, params);
1519}
1520
1521static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1522{
1523 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1524
1525 return ieee80211_ibss_leave(sdata);
1526}
1527
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001528static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1529{
1530 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg24487982009-04-23 18:52:52 +02001531 int err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001532
Arik Nemtsovf23a4782010-11-08 11:51:06 +02001533 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1534 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
1535
1536 if (err)
1537 return err;
1538 }
1539
Lukáš Turek310bc672009-12-21 22:50:48 +01001540 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
1541 err = drv_set_coverage_class(local, wiphy->coverage_class);
1542
1543 if (err)
1544 return err;
1545 }
1546
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001547 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
Johannes Berg24487982009-04-23 18:52:52 +02001548 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001549
Johannes Berg24487982009-04-23 18:52:52 +02001550 if (err)
1551 return err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001552 }
1553
1554 if (changed & WIPHY_PARAM_RETRY_SHORT)
1555 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
1556 if (changed & WIPHY_PARAM_RETRY_LONG)
1557 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
1558 if (changed &
1559 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
1560 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
1561
1562 return 0;
1563}
1564
Johannes Berg7643a2c2009-06-02 13:01:39 +02001565static int ieee80211_set_tx_power(struct wiphy *wiphy,
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001566 enum nl80211_tx_power_setting type, int mbm)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001567{
1568 struct ieee80211_local *local = wiphy_priv(wiphy);
1569 struct ieee80211_channel *chan = local->hw.conf.channel;
1570 u32 changes = 0;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001571
1572 switch (type) {
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001573 case NL80211_TX_POWER_AUTOMATIC:
Johannes Berg7643a2c2009-06-02 13:01:39 +02001574 local->user_power_level = -1;
1575 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001576 case NL80211_TX_POWER_LIMITED:
1577 if (mbm < 0 || (mbm % 100))
1578 return -EOPNOTSUPP;
1579 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001580 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001581 case NL80211_TX_POWER_FIXED:
1582 if (mbm < 0 || (mbm % 100))
1583 return -EOPNOTSUPP;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001584 /* TODO: move to cfg80211 when it knows the channel */
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001585 if (MBM_TO_DBM(mbm) > chan->max_power)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001586 return -EINVAL;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001587 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001588 break;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001589 }
1590
1591 ieee80211_hw_config(local, changes);
1592
1593 return 0;
1594}
1595
1596static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1597{
1598 struct ieee80211_local *local = wiphy_priv(wiphy);
1599
1600 *dbm = local->hw.conf.power_level;
1601
Johannes Berg7643a2c2009-06-02 13:01:39 +02001602 return 0;
1603}
1604
Johannes Bergab737a42009-07-01 21:26:58 +02001605static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg388ac772010-10-07 13:11:09 +02001606 const u8 *addr)
Johannes Bergab737a42009-07-01 21:26:58 +02001607{
1608 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1609
1610 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
1611
1612 return 0;
1613}
1614
Johannes Berg1f87f7d2009-06-02 13:01:41 +02001615static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1616{
1617 struct ieee80211_local *local = wiphy_priv(wiphy);
1618
1619 drv_rfkill_poll(local);
1620}
1621
Johannes Bergaff89a92009-07-01 21:26:51 +02001622#ifdef CONFIG_NL80211_TESTMODE
Johannes Berg99783e22009-07-07 03:54:43 +02001623static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
Johannes Bergaff89a92009-07-01 21:26:51 +02001624{
1625 struct ieee80211_local *local = wiphy_priv(wiphy);
1626
1627 if (!local->ops->testmode_cmd)
1628 return -EOPNOTSUPP;
1629
1630 return local->ops->testmode_cmd(&local->hw, data, len);
1631}
Wey-Yi Guy71063f02011-05-20 09:05:54 -07001632
1633static int ieee80211_testmode_dump(struct wiphy *wiphy,
1634 struct sk_buff *skb,
1635 struct netlink_callback *cb,
1636 void *data, int len)
1637{
1638 struct ieee80211_local *local = wiphy_priv(wiphy);
1639
1640 if (!local->ops->testmode_dump)
1641 return -EOPNOTSUPP;
1642
1643 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
1644}
Johannes Bergaff89a92009-07-01 21:26:51 +02001645#endif
1646
Johannes Berg0f782312009-12-01 13:37:02 +01001647int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1648 enum ieee80211_smps_mode smps_mode)
1649{
1650 const u8 *ap;
1651 enum ieee80211_smps_mode old_req;
1652 int err;
1653
Johannes Berg243e6df2011-04-19 20:44:04 +02001654 lockdep_assert_held(&sdata->u.mgd.mtx);
1655
Johannes Berg0f782312009-12-01 13:37:02 +01001656 old_req = sdata->u.mgd.req_smps;
1657 sdata->u.mgd.req_smps = smps_mode;
1658
1659 if (old_req == smps_mode &&
1660 smps_mode != IEEE80211_SMPS_AUTOMATIC)
1661 return 0;
1662
1663 /*
1664 * If not associated, or current association is not an HT
1665 * association, there's no need to send an action frame.
1666 */
1667 if (!sdata->u.mgd.associated ||
Johannes Berg0aaffa92010-05-05 15:28:27 +02001668 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
Johannes Berg0f782312009-12-01 13:37:02 +01001669 mutex_lock(&sdata->local->iflist_mtx);
Johannes Berg025e6be2010-10-05 10:41:47 +02001670 ieee80211_recalc_smps(sdata->local);
Johannes Berg0f782312009-12-01 13:37:02 +01001671 mutex_unlock(&sdata->local->iflist_mtx);
1672 return 0;
1673 }
1674
Johannes Berg0c1ad2c2009-12-23 13:15:39 +01001675 ap = sdata->u.mgd.associated->bssid;
Johannes Berg0f782312009-12-01 13:37:02 +01001676
1677 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
1678 if (sdata->u.mgd.powersave)
1679 smps_mode = IEEE80211_SMPS_DYNAMIC;
1680 else
1681 smps_mode = IEEE80211_SMPS_OFF;
1682 }
1683
1684 /* send SM PS frame to AP */
1685 err = ieee80211_send_smps_action(sdata, smps_mode,
1686 ap, ap);
1687 if (err)
1688 sdata->u.mgd.req_smps = old_req;
1689
1690 return err;
1691}
1692
Johannes Bergbc92afd2009-07-01 21:26:57 +02001693static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
1694 bool enabled, int timeout)
1695{
1696 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1697 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Bergbc92afd2009-07-01 21:26:57 +02001698
Benoit Papillaulte5de30c2010-01-15 12:21:37 +01001699 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1700 return -EOPNOTSUPP;
1701
Johannes Bergbc92afd2009-07-01 21:26:57 +02001702 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
1703 return -EOPNOTSUPP;
1704
1705 if (enabled == sdata->u.mgd.powersave &&
Juuso Oikarinenff616382010-06-09 09:51:52 +03001706 timeout == local->dynamic_ps_forced_timeout)
Johannes Bergbc92afd2009-07-01 21:26:57 +02001707 return 0;
1708
1709 sdata->u.mgd.powersave = enabled;
Juuso Oikarinenff616382010-06-09 09:51:52 +03001710 local->dynamic_ps_forced_timeout = timeout;
Johannes Bergbc92afd2009-07-01 21:26:57 +02001711
Johannes Berg0f782312009-12-01 13:37:02 +01001712 /* no change, but if automatic follow powersave */
1713 mutex_lock(&sdata->u.mgd.mtx);
1714 __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
1715 mutex_unlock(&sdata->u.mgd.mtx);
1716
Johannes Bergbc92afd2009-07-01 21:26:57 +02001717 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
1718 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
1719
1720 ieee80211_recalc_ps(local, -1);
1721
1722 return 0;
1723}
1724
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001725static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
1726 struct net_device *dev,
1727 s32 rssi_thold, u32 rssi_hyst)
1728{
1729 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1730 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1731 struct ieee80211_vif *vif = &sdata->vif;
1732 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1733
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001734 if (rssi_thold == bss_conf->cqm_rssi_thold &&
1735 rssi_hyst == bss_conf->cqm_rssi_hyst)
1736 return 0;
1737
1738 bss_conf->cqm_rssi_thold = rssi_thold;
1739 bss_conf->cqm_rssi_hyst = rssi_hyst;
1740
Jouni Malinen17e4ec12010-03-29 23:28:30 -07001741 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) {
1742 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1743 return -EOPNOTSUPP;
1744 return 0;
1745 }
1746
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001747 /* tell the driver upon association, unless already associated */
1748 if (sdata->u.mgd.associated)
1749 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
1750
1751 return 0;
1752}
1753
Johannes Berg99303802009-07-01 21:26:59 +02001754static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
1755 struct net_device *dev,
1756 const u8 *addr,
1757 const struct cfg80211_bitrate_mask *mask)
1758{
1759 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1760 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05301761 int i, ret;
Johannes Berg99303802009-07-01 21:26:59 +02001762
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05301763 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
1764 ret = drv_set_bitrate_mask(local, sdata, mask);
1765 if (ret)
1766 return ret;
1767 }
Johannes Berg99303802009-07-01 21:26:59 +02001768
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001769 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
1770 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
Johannes Berg99303802009-07-01 21:26:59 +02001771
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001772 return 0;
Johannes Berg99303802009-07-01 21:26:59 +02001773}
1774
Johannes Berg21f83582010-12-18 17:20:47 +01001775static int ieee80211_remain_on_channel_hw(struct ieee80211_local *local,
1776 struct net_device *dev,
1777 struct ieee80211_channel *chan,
1778 enum nl80211_channel_type chantype,
1779 unsigned int duration, u64 *cookie)
1780{
1781 int ret;
1782 u32 random_cookie;
1783
1784 lockdep_assert_held(&local->mtx);
1785
1786 if (local->hw_roc_cookie)
1787 return -EBUSY;
1788 /* must be nonzero */
1789 random_cookie = random32() | 1;
1790
1791 *cookie = random_cookie;
1792 local->hw_roc_dev = dev;
1793 local->hw_roc_cookie = random_cookie;
1794 local->hw_roc_channel = chan;
1795 local->hw_roc_channel_type = chantype;
1796 local->hw_roc_duration = duration;
1797 ret = drv_remain_on_channel(local, chan, chantype, duration);
1798 if (ret) {
1799 local->hw_roc_channel = NULL;
1800 local->hw_roc_cookie = 0;
1801 }
1802
1803 return ret;
1804}
1805
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001806static int ieee80211_remain_on_channel(struct wiphy *wiphy,
1807 struct net_device *dev,
1808 struct ieee80211_channel *chan,
1809 enum nl80211_channel_type channel_type,
1810 unsigned int duration,
1811 u64 *cookie)
1812{
1813 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01001814 struct ieee80211_local *local = sdata->local;
1815
1816 if (local->ops->remain_on_channel) {
1817 int ret;
1818
1819 mutex_lock(&local->mtx);
1820 ret = ieee80211_remain_on_channel_hw(local, dev,
1821 chan, channel_type,
1822 duration, cookie);
Johannes Berg90fc4b32010-12-18 17:20:48 +01001823 local->hw_roc_for_tx = false;
Johannes Berg21f83582010-12-18 17:20:47 +01001824 mutex_unlock(&local->mtx);
1825
1826 return ret;
1827 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001828
1829 return ieee80211_wk_remain_on_channel(sdata, chan, channel_type,
1830 duration, cookie);
1831}
1832
Johannes Berg21f83582010-12-18 17:20:47 +01001833static int ieee80211_cancel_remain_on_channel_hw(struct ieee80211_local *local,
1834 u64 cookie)
1835{
1836 int ret;
1837
1838 lockdep_assert_held(&local->mtx);
1839
1840 if (local->hw_roc_cookie != cookie)
1841 return -ENOENT;
1842
1843 ret = drv_cancel_remain_on_channel(local);
1844 if (ret)
1845 return ret;
1846
1847 local->hw_roc_cookie = 0;
1848 local->hw_roc_channel = NULL;
1849
1850 ieee80211_recalc_idle(local);
1851
1852 return 0;
1853}
1854
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001855static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
1856 struct net_device *dev,
1857 u64 cookie)
1858{
1859 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01001860 struct ieee80211_local *local = sdata->local;
1861
1862 if (local->ops->cancel_remain_on_channel) {
1863 int ret;
1864
1865 mutex_lock(&local->mtx);
1866 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
1867 mutex_unlock(&local->mtx);
1868
1869 return ret;
1870 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001871
1872 return ieee80211_wk_cancel_remain_on_channel(sdata, cookie);
1873}
1874
Johannes Bergf30221e2010-11-25 10:02:30 +01001875static enum work_done_result
1876ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb)
1877{
1878 /*
1879 * Use the data embedded in the work struct for reporting
1880 * here so if the driver mangled the SKB before dropping
1881 * it (which is the only way we really should get here)
1882 * then we don't report mangled data.
1883 *
1884 * If there was no wait time, then by the time we get here
1885 * the driver will likely not have reported the status yet,
1886 * so in that case userspace will have to deal with it.
1887 */
1888
1889 if (wk->offchan_tx.wait && wk->offchan_tx.frame)
1890 cfg80211_mgmt_tx_status(wk->sdata->dev,
1891 (unsigned long) wk->offchan_tx.frame,
1892 wk->ie, wk->ie_len, false, GFP_KERNEL);
1893
1894 return WORK_DONE_DESTROY;
1895}
1896
Johannes Berg2e161f72010-08-12 15:38:38 +02001897static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01001898 struct ieee80211_channel *chan, bool offchan,
Johannes Berg2e161f72010-08-12 15:38:38 +02001899 enum nl80211_channel_type channel_type,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01001900 bool channel_type_valid, unsigned int wait,
Rajkumar Manoharane9f935e2011-09-25 14:53:30 +05301901 const u8 *buf, size_t len, bool no_cck,
1902 u64 *cookie)
Jouni Malinen026331c2010-02-15 12:53:10 +02001903{
Johannes Berg9d38d852010-06-09 17:20:33 +02001904 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1905 struct ieee80211_local *local = sdata->local;
1906 struct sk_buff *skb;
1907 struct sta_info *sta;
Johannes Bergf30221e2010-11-25 10:02:30 +01001908 struct ieee80211_work *wk;
Johannes Berg9d38d852010-06-09 17:20:33 +02001909 const struct ieee80211_mgmt *mgmt = (void *)buf;
1910 u32 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
1911 IEEE80211_TX_CTL_REQ_TX_STATUS;
Johannes Bergf30221e2010-11-25 10:02:30 +01001912 bool is_offchan = false;
Johannes Bergf7ca38d2010-11-25 10:02:29 +01001913
Johannes Berg9d38d852010-06-09 17:20:33 +02001914 /* Check that we are on the requested channel for transmission */
1915 if (chan != local->tmp_channel &&
1916 chan != local->oper_channel)
Johannes Bergf30221e2010-11-25 10:02:30 +01001917 is_offchan = true;
Johannes Berg9d38d852010-06-09 17:20:33 +02001918 if (channel_type_valid &&
1919 (channel_type != local->tmp_channel_type &&
1920 channel_type != local->_oper_channel_type))
Johannes Bergf30221e2010-11-25 10:02:30 +01001921 is_offchan = true;
1922
Johannes Berg21f83582010-12-18 17:20:47 +01001923 if (chan == local->hw_roc_channel) {
1924 /* TODO: check channel type? */
1925 is_offchan = false;
1926 flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
1927 }
1928
Rajkumar Manoharanaad14ce2011-09-25 14:53:31 +05301929 if (no_cck)
1930 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
1931
Johannes Bergf30221e2010-11-25 10:02:30 +01001932 if (is_offchan && !offchan)
Johannes Berg9d38d852010-06-09 17:20:33 +02001933 return -EBUSY;
1934
1935 switch (sdata->vif.type) {
1936 case NL80211_IFTYPE_ADHOC:
Johannes Berg663fcaf2010-09-30 21:06:09 +02001937 case NL80211_IFTYPE_AP:
1938 case NL80211_IFTYPE_AP_VLAN:
1939 case NL80211_IFTYPE_P2P_GO:
Javier Cardonac7108a72010-12-16 17:37:50 -08001940 case NL80211_IFTYPE_MESH_POINT:
Johannes Berg663fcaf2010-09-30 21:06:09 +02001941 if (!ieee80211_is_action(mgmt->frame_control) ||
1942 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
Johannes Berg9d38d852010-06-09 17:20:33 +02001943 break;
1944 rcu_read_lock();
1945 sta = sta_info_get(sdata, mgmt->da);
1946 rcu_read_unlock();
1947 if (!sta)
1948 return -ENOLINK;
1949 break;
1950 case NL80211_IFTYPE_STATION:
Johannes Berg663fcaf2010-09-30 21:06:09 +02001951 case NL80211_IFTYPE_P2P_CLIENT:
Johannes Berg9d38d852010-06-09 17:20:33 +02001952 break;
1953 default:
1954 return -EOPNOTSUPP;
1955 }
1956
1957 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
1958 if (!skb)
1959 return -ENOMEM;
1960 skb_reserve(skb, local->hw.extra_tx_headroom);
1961
1962 memcpy(skb_put(skb, len), buf, len);
1963
1964 IEEE80211_SKB_CB(skb)->flags = flags;
1965
1966 skb->dev = sdata->dev;
Johannes Berg9d38d852010-06-09 17:20:33 +02001967
1968 *cookie = (unsigned long) skb;
Johannes Bergf30221e2010-11-25 10:02:30 +01001969
Johannes Berg90fc4b32010-12-18 17:20:48 +01001970 if (is_offchan && local->ops->remain_on_channel) {
1971 unsigned int duration;
1972 int ret;
1973
1974 mutex_lock(&local->mtx);
1975 /*
1976 * If the duration is zero, then the driver
1977 * wouldn't actually do anything. Set it to
1978 * 100 for now.
1979 *
1980 * TODO: cancel the off-channel operation
1981 * when we get the SKB's TX status and
1982 * the wait time was zero before.
1983 */
1984 duration = 100;
1985 if (wait)
1986 duration = wait;
1987 ret = ieee80211_remain_on_channel_hw(local, dev, chan,
1988 channel_type,
1989 duration, cookie);
1990 if (ret) {
1991 kfree_skb(skb);
1992 mutex_unlock(&local->mtx);
1993 return ret;
1994 }
1995
1996 local->hw_roc_for_tx = true;
1997 local->hw_roc_duration = wait;
1998
1999 /*
2000 * queue up frame for transmission after
2001 * ieee80211_ready_on_channel call
2002 */
2003
2004 /* modify cookie to prevent API mismatches */
2005 *cookie ^= 2;
2006 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
2007 local->hw_roc_skb = skb;
Johannes Berg4334ec82011-02-02 16:58:06 +01002008 local->hw_roc_skb_for_status = skb;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002009 mutex_unlock(&local->mtx);
2010
2011 return 0;
2012 }
2013
Johannes Bergf30221e2010-11-25 10:02:30 +01002014 /*
2015 * Can transmit right away if the channel was the
2016 * right one and there's no wait involved... If a
2017 * wait is involved, we might otherwise not be on
2018 * the right channel for long enough!
2019 */
2020 if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) {
2021 ieee80211_tx_skb(sdata, skb);
2022 return 0;
2023 }
2024
2025 wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL);
2026 if (!wk) {
2027 kfree_skb(skb);
2028 return -ENOMEM;
2029 }
2030
2031 wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
2032 wk->chan = chan;
Ben Greear4d51e142011-02-07 13:44:34 -08002033 wk->chan_type = channel_type;
Johannes Bergf30221e2010-11-25 10:02:30 +01002034 wk->sdata = sdata;
2035 wk->done = ieee80211_offchan_tx_done;
2036 wk->offchan_tx.frame = skb;
2037 wk->offchan_tx.wait = wait;
2038 wk->ie_len = len;
2039 memcpy(wk->ie, buf, len);
2040
2041 ieee80211_add_work(wk);
Johannes Berg9d38d852010-06-09 17:20:33 +02002042 return 0;
Jouni Malinen026331c2010-02-15 12:53:10 +02002043}
2044
Johannes Bergf30221e2010-11-25 10:02:30 +01002045static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2046 struct net_device *dev,
2047 u64 cookie)
2048{
2049 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2050 struct ieee80211_local *local = sdata->local;
2051 struct ieee80211_work *wk;
2052 int ret = -ENOENT;
2053
2054 mutex_lock(&local->mtx);
Johannes Berg90fc4b32010-12-18 17:20:48 +01002055
2056 if (local->ops->cancel_remain_on_channel) {
2057 cookie ^= 2;
2058 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
2059
2060 if (ret == 0) {
2061 kfree_skb(local->hw_roc_skb);
2062 local->hw_roc_skb = NULL;
Johannes Berg4334ec82011-02-02 16:58:06 +01002063 local->hw_roc_skb_for_status = NULL;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002064 }
2065
2066 mutex_unlock(&local->mtx);
2067
2068 return ret;
2069 }
2070
Johannes Bergf30221e2010-11-25 10:02:30 +01002071 list_for_each_entry(wk, &local->work_list, list) {
2072 if (wk->sdata != sdata)
2073 continue;
2074
2075 if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
2076 continue;
2077
2078 if (cookie != (unsigned long) wk->offchan_tx.frame)
2079 continue;
2080
2081 wk->timeout = jiffies;
2082
2083 ieee80211_queue_work(&local->hw, &local->work_work);
2084 ret = 0;
2085 break;
2086 }
2087 mutex_unlock(&local->mtx);
2088
2089 return ret;
2090}
2091
Johannes Berg7be50862010-10-13 12:06:24 +02002092static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2093 struct net_device *dev,
2094 u16 frame_type, bool reg)
2095{
2096 struct ieee80211_local *local = wiphy_priv(wiphy);
2097
2098 if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
2099 return;
2100
2101 if (reg)
2102 local->probe_req_reg++;
2103 else
2104 local->probe_req_reg--;
2105
2106 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2107}
2108
Bruno Randolf15d96752010-11-10 12:50:56 +09002109static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
2110{
2111 struct ieee80211_local *local = wiphy_priv(wiphy);
2112
2113 if (local->started)
2114 return -EOPNOTSUPP;
2115
2116 return drv_set_antenna(local, tx_ant, rx_ant);
2117}
2118
2119static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
2120{
2121 struct ieee80211_local *local = wiphy_priv(wiphy);
2122
2123 return drv_get_antenna(local, tx_ant, rx_ant);
2124}
2125
John W. Linville38c09152011-03-07 16:19:18 -05002126static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2127{
2128 struct ieee80211_local *local = wiphy_priv(wiphy);
2129
2130 return drv_set_ringparam(local, tx, rx);
2131}
2132
2133static void ieee80211_get_ringparam(struct wiphy *wiphy,
2134 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2135{
2136 struct ieee80211_local *local = wiphy_priv(wiphy);
2137
2138 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2139}
2140
Johannes Bergc68f4b82011-07-05 16:35:41 +02002141static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2142 struct net_device *dev,
2143 struct cfg80211_gtk_rekey_data *data)
2144{
2145 struct ieee80211_local *local = wiphy_priv(wiphy);
2146 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2147
2148 if (!local->ops->set_rekey_data)
2149 return -EOPNOTSUPP;
2150
2151 drv_set_rekey_data(local, sdata, data);
2152
2153 return 0;
2154}
2155
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002156static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
2157{
2158 u8 *pos = (void *)skb_put(skb, 7);
2159
2160 *pos++ = WLAN_EID_EXT_CAPABILITY;
2161 *pos++ = 5; /* len */
2162 *pos++ = 0x0;
2163 *pos++ = 0x0;
2164 *pos++ = 0x0;
2165 *pos++ = 0x0;
2166 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
2167}
2168
2169static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
2170{
2171 struct ieee80211_local *local = sdata->local;
2172 u16 capab;
2173
2174 capab = 0;
2175 if (local->oper_channel->band != IEEE80211_BAND_2GHZ)
2176 return capab;
2177
2178 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
2179 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
2180 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
2181 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
2182
2183 return capab;
2184}
2185
2186static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
2187 u8 *peer, u8 *bssid)
2188{
2189 struct ieee80211_tdls_lnkie *lnkid;
2190
2191 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
2192
2193 lnkid->ie_type = WLAN_EID_LINK_ID;
2194 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
2195
2196 memcpy(lnkid->bssid, bssid, ETH_ALEN);
2197 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
2198 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
2199}
2200
2201static int
2202ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2203 u8 *peer, u8 action_code, u8 dialog_token,
2204 u16 status_code, struct sk_buff *skb)
2205{
2206 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2207 struct ieee80211_tdls_data *tf;
2208
2209 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
2210
2211 memcpy(tf->da, peer, ETH_ALEN);
2212 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
2213 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
2214 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
2215
2216 switch (action_code) {
2217 case WLAN_TDLS_SETUP_REQUEST:
2218 tf->category = WLAN_CATEGORY_TDLS;
2219 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
2220
2221 skb_put(skb, sizeof(tf->u.setup_req));
2222 tf->u.setup_req.dialog_token = dialog_token;
2223 tf->u.setup_req.capability =
2224 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2225
2226 ieee80211_add_srates_ie(&sdata->vif, skb);
2227 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2228 ieee80211_tdls_add_ext_capab(skb);
2229 break;
2230 case WLAN_TDLS_SETUP_RESPONSE:
2231 tf->category = WLAN_CATEGORY_TDLS;
2232 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
2233
2234 skb_put(skb, sizeof(tf->u.setup_resp));
2235 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
2236 tf->u.setup_resp.dialog_token = dialog_token;
2237 tf->u.setup_resp.capability =
2238 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2239
2240 ieee80211_add_srates_ie(&sdata->vif, skb);
2241 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2242 ieee80211_tdls_add_ext_capab(skb);
2243 break;
2244 case WLAN_TDLS_SETUP_CONFIRM:
2245 tf->category = WLAN_CATEGORY_TDLS;
2246 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
2247
2248 skb_put(skb, sizeof(tf->u.setup_cfm));
2249 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
2250 tf->u.setup_cfm.dialog_token = dialog_token;
2251 break;
2252 case WLAN_TDLS_TEARDOWN:
2253 tf->category = WLAN_CATEGORY_TDLS;
2254 tf->action_code = WLAN_TDLS_TEARDOWN;
2255
2256 skb_put(skb, sizeof(tf->u.teardown));
2257 tf->u.teardown.reason_code = cpu_to_le16(status_code);
2258 break;
2259 case WLAN_TDLS_DISCOVERY_REQUEST:
2260 tf->category = WLAN_CATEGORY_TDLS;
2261 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
2262
2263 skb_put(skb, sizeof(tf->u.discover_req));
2264 tf->u.discover_req.dialog_token = dialog_token;
2265 break;
2266 default:
2267 return -EINVAL;
2268 }
2269
2270 return 0;
2271}
2272
2273static int
2274ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2275 u8 *peer, u8 action_code, u8 dialog_token,
2276 u16 status_code, struct sk_buff *skb)
2277{
2278 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2279 struct ieee80211_mgmt *mgmt;
2280
2281 mgmt = (void *)skb_put(skb, 24);
2282 memset(mgmt, 0, 24);
2283 memcpy(mgmt->da, peer, ETH_ALEN);
2284 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
2285 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
2286
2287 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2288 IEEE80211_STYPE_ACTION);
2289
2290 switch (action_code) {
2291 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2292 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
2293 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
2294 mgmt->u.action.u.tdls_discover_resp.action_code =
2295 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
2296 mgmt->u.action.u.tdls_discover_resp.dialog_token =
2297 dialog_token;
2298 mgmt->u.action.u.tdls_discover_resp.capability =
2299 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2300
2301 ieee80211_add_srates_ie(&sdata->vif, skb);
2302 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2303 ieee80211_tdls_add_ext_capab(skb);
2304 break;
2305 default:
2306 return -EINVAL;
2307 }
2308
2309 return 0;
2310}
2311
2312static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2313 u8 *peer, u8 action_code, u8 dialog_token,
2314 u16 status_code, const u8 *extra_ies,
2315 size_t extra_ies_len)
2316{
2317 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2318 struct ieee80211_local *local = sdata->local;
2319 struct ieee80211_tx_info *info;
2320 struct sk_buff *skb = NULL;
2321 bool send_direct;
2322 int ret;
2323
2324 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2325 return -ENOTSUPP;
2326
2327 /* make sure we are in managed mode, and associated */
2328 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
2329 !sdata->u.mgd.associated)
2330 return -EINVAL;
2331
2332#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2333 printk(KERN_DEBUG "TDLS mgmt action %d peer %pM\n", action_code, peer);
2334#endif
2335
2336 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
2337 max(sizeof(struct ieee80211_mgmt),
2338 sizeof(struct ieee80211_tdls_data)) +
2339 50 + /* supported rates */
2340 7 + /* ext capab */
2341 extra_ies_len +
2342 sizeof(struct ieee80211_tdls_lnkie));
2343 if (!skb)
2344 return -ENOMEM;
2345
2346 info = IEEE80211_SKB_CB(skb);
2347 skb_reserve(skb, local->hw.extra_tx_headroom);
2348
2349 switch (action_code) {
2350 case WLAN_TDLS_SETUP_REQUEST:
2351 case WLAN_TDLS_SETUP_RESPONSE:
2352 case WLAN_TDLS_SETUP_CONFIRM:
2353 case WLAN_TDLS_TEARDOWN:
2354 case WLAN_TDLS_DISCOVERY_REQUEST:
2355 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
2356 action_code, dialog_token,
2357 status_code, skb);
2358 send_direct = false;
2359 break;
2360 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2361 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
2362 dialog_token, status_code,
2363 skb);
2364 send_direct = true;
2365 break;
2366 default:
2367 ret = -ENOTSUPP;
2368 break;
2369 }
2370
2371 if (ret < 0)
2372 goto fail;
2373
2374 if (extra_ies_len)
2375 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
2376
2377 /* the TDLS link IE is always added last */
2378 switch (action_code) {
2379 case WLAN_TDLS_SETUP_REQUEST:
2380 case WLAN_TDLS_SETUP_CONFIRM:
2381 case WLAN_TDLS_TEARDOWN:
2382 case WLAN_TDLS_DISCOVERY_REQUEST:
2383 /* we are the initiator */
2384 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
2385 sdata->u.mgd.bssid);
2386 break;
2387 case WLAN_TDLS_SETUP_RESPONSE:
2388 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2389 /* we are the responder */
2390 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
2391 sdata->u.mgd.bssid);
2392 break;
2393 default:
2394 ret = -ENOTSUPP;
2395 goto fail;
2396 }
2397
2398 if (send_direct) {
2399 ieee80211_tx_skb(sdata, skb);
2400 return 0;
2401 }
2402
2403 /*
2404 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
2405 * we should default to AC_VI.
2406 */
2407 switch (action_code) {
2408 case WLAN_TDLS_SETUP_REQUEST:
2409 case WLAN_TDLS_SETUP_RESPONSE:
2410 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
2411 skb->priority = 2;
2412 break;
2413 default:
2414 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
2415 skb->priority = 5;
2416 break;
2417 }
2418
2419 /* disable bottom halves when entering the Tx path */
2420 local_bh_disable();
2421 ret = ieee80211_subif_start_xmit(skb, dev);
2422 local_bh_enable();
2423
2424 return ret;
2425
2426fail:
2427 dev_kfree_skb(skb);
2428 return ret;
2429}
2430
2431static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2432 u8 *peer, enum nl80211_tdls_operation oper)
2433{
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002434 struct sta_info *sta;
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002435 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2436
2437 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2438 return -ENOTSUPP;
2439
2440 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2441 return -EINVAL;
2442
2443#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2444 printk(KERN_DEBUG "TDLS oper %d peer %pM\n", oper, peer);
2445#endif
2446
2447 switch (oper) {
2448 case NL80211_TDLS_ENABLE_LINK:
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002449 rcu_read_lock();
2450 sta = sta_info_get(sdata, peer);
2451 if (!sta) {
2452 rcu_read_unlock();
2453 return -ENOLINK;
2454 }
2455
Johannes Bergc2c98fd2011-09-29 16:04:36 +02002456 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002457 rcu_read_unlock();
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002458 break;
2459 case NL80211_TDLS_DISABLE_LINK:
2460 return sta_info_destroy_addr(sdata, peer);
2461 case NL80211_TDLS_TEARDOWN:
2462 case NL80211_TDLS_SETUP:
2463 case NL80211_TDLS_DISCOVERY_REQ:
2464 /* We don't support in-driver setup/teardown/discovery */
2465 return -ENOTSUPP;
2466 default:
2467 return -ENOTSUPP;
2468 }
2469
2470 return 0;
2471}
2472
Jiri Bencf0706e82007-05-05 11:45:53 -07002473struct cfg80211_ops mac80211_config_ops = {
2474 .add_virtual_intf = ieee80211_add_iface,
2475 .del_virtual_intf = ieee80211_del_iface,
Johannes Berg42613db2007-09-28 21:52:27 +02002476 .change_virtual_intf = ieee80211_change_iface,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002477 .add_key = ieee80211_add_key,
2478 .del_key = ieee80211_del_key,
Johannes Berg62da92f2007-12-19 02:03:31 +01002479 .get_key = ieee80211_get_key,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002480 .set_default_key = ieee80211_config_default_key,
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +02002481 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
Johannes Berg5dfdaf52007-12-19 02:03:33 +01002482 .add_beacon = ieee80211_add_beacon,
2483 .set_beacon = ieee80211_set_beacon,
2484 .del_beacon = ieee80211_del_beacon,
Johannes Berg4fd69312007-12-19 02:03:35 +01002485 .add_station = ieee80211_add_station,
2486 .del_station = ieee80211_del_station,
2487 .change_station = ieee80211_change_station,
Johannes Berg7bbdd2d2007-12-19 02:03:37 +01002488 .get_station = ieee80211_get_station,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002489 .dump_station = ieee80211_dump_station,
Holger Schurig12897232010-04-19 10:23:57 +02002490 .dump_survey = ieee80211_dump_survey,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002491#ifdef CONFIG_MAC80211_MESH
2492 .add_mpath = ieee80211_add_mpath,
2493 .del_mpath = ieee80211_del_mpath,
2494 .change_mpath = ieee80211_change_mpath,
2495 .get_mpath = ieee80211_get_mpath,
2496 .dump_mpath = ieee80211_dump_mpath,
Javier Cardona24bdd9f2010-12-16 17:37:48 -08002497 .update_mesh_config = ieee80211_update_mesh_config,
2498 .get_mesh_config = ieee80211_get_mesh_config,
Johannes Berg29cbe682010-12-03 09:20:44 +01002499 .join_mesh = ieee80211_join_mesh,
2500 .leave_mesh = ieee80211_leave_mesh,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002501#endif
Jouni Malinen9f1ba902008-08-07 20:07:01 +03002502 .change_bss = ieee80211_change_bss,
Jouni Malinen31888482008-10-30 16:59:24 +02002503 .set_txq_params = ieee80211_set_txq_params,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02002504 .set_channel = ieee80211_set_channel,
Bob Copeland665af4f2009-01-19 11:20:53 -05002505 .suspend = ieee80211_suspend,
2506 .resume = ieee80211_resume,
Johannes Berg2a519312009-02-10 21:25:55 +01002507 .scan = ieee80211_scan,
Luciano Coelho79f460c2011-05-11 17:09:36 +03002508 .sched_scan_start = ieee80211_sched_scan_start,
2509 .sched_scan_stop = ieee80211_sched_scan_stop,
Jouni Malinen636a5d32009-03-19 13:39:22 +02002510 .auth = ieee80211_auth,
2511 .assoc = ieee80211_assoc,
2512 .deauth = ieee80211_deauth,
2513 .disassoc = ieee80211_disassoc,
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02002514 .join_ibss = ieee80211_join_ibss,
2515 .leave_ibss = ieee80211_leave_ibss,
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002516 .set_wiphy_params = ieee80211_set_wiphy_params,
Johannes Berg7643a2c2009-06-02 13:01:39 +02002517 .set_tx_power = ieee80211_set_tx_power,
2518 .get_tx_power = ieee80211_get_tx_power,
Johannes Bergab737a42009-07-01 21:26:58 +02002519 .set_wds_peer = ieee80211_set_wds_peer,
Johannes Berg1f87f7d2009-06-02 13:01:41 +02002520 .rfkill_poll = ieee80211_rfkill_poll,
Johannes Bergaff89a92009-07-01 21:26:51 +02002521 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
Wey-Yi Guy71063f02011-05-20 09:05:54 -07002522 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
Johannes Bergbc92afd2009-07-01 21:26:57 +02002523 .set_power_mgmt = ieee80211_set_power_mgmt,
Johannes Berg99303802009-07-01 21:26:59 +02002524 .set_bitrate_mask = ieee80211_set_bitrate_mask,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002525 .remain_on_channel = ieee80211_remain_on_channel,
2526 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
Johannes Berg2e161f72010-08-12 15:38:38 +02002527 .mgmt_tx = ieee80211_mgmt_tx,
Johannes Bergf30221e2010-11-25 10:02:30 +01002528 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002529 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
Johannes Berg7be50862010-10-13 12:06:24 +02002530 .mgmt_frame_register = ieee80211_mgmt_frame_register,
Bruno Randolf15d96752010-11-10 12:50:56 +09002531 .set_antenna = ieee80211_set_antenna,
2532 .get_antenna = ieee80211_get_antenna,
John W. Linville38c09152011-03-07 16:19:18 -05002533 .set_ringparam = ieee80211_set_ringparam,
2534 .get_ringparam = ieee80211_get_ringparam,
Johannes Bergc68f4b82011-07-05 16:35:41 +02002535 .set_rekey_data = ieee80211_set_rekey_data,
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002536 .tdls_oper = ieee80211_tdls_oper,
2537 .tdls_mgmt = ieee80211_tdls_mgmt,
Jiri Bencf0706e82007-05-05 11:45:53 -07002538};