blob: 1f1056172ef1f4e04c7f2e260cb6ce96464ad2e7 [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)
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +000066 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
Johannes Berg9bc383d2009-11-19 11:55:19 +010067 else if (type == NL80211_IFTYPE_STATION &&
68 params && params->use_4addr >= 0)
69 sdata->u.mgd.use_4addr = params->use_4addr;
70
Christian Lamparter85416a42010-10-02 13:17:07 +020071 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
72 struct ieee80211_local *local = sdata->local;
73
74 if (ieee80211_sdata_running(sdata)) {
75 /*
76 * Prohibit MONITOR_FLAG_COOK_FRAMES to be
77 * changed while the interface is up.
78 * Else we would need to add a lot of cruft
79 * to update everything:
80 * cooked_mntrs, monitor and all fif_* counters
81 * reconfigure hardware
82 */
83 if ((*flags & MONITOR_FLAG_COOK_FRAMES) !=
84 (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
85 return -EBUSY;
86
87 ieee80211_adjust_monitor_flags(sdata, -1);
88 sdata->u.mntr_flags = *flags;
89 ieee80211_adjust_monitor_flags(sdata, 1);
90
91 ieee80211_configure_filter(local);
92 } else {
93 /*
94 * Because the interface is down, ieee80211_do_stop
95 * and ieee80211_do_open take care of "everything"
96 * mentioned in the comment above.
97 */
98 sdata->u.mntr_flags = *flags;
99 }
100 }
Felix Fietkauf7917af2010-04-27 00:26:34 +0200101
Johannes Berg42613db2007-09-28 21:52:27 +0200102 return 0;
103}
104
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 |
Helmut Schaa7a724762011-10-13 16:30:40 +0200347 STATION_INFO_CONNECTED_TIME |
348 STATION_INFO_STA_FLAGS;
Mohammed Shafi Shajakhanebe27c92011-04-08 21:24:24 +0530349
350 do_posix_clock_monotonic_gettime(&uptime);
351 sinfo->connected_time = uptime.tv_sec - sta->last_connected;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100352
353 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
354 sinfo->rx_bytes = sta->rx_bytes;
355 sinfo->tx_bytes = sta->tx_bytes;
Jouni Malinen98c8a60a2009-02-17 13:24:57 +0200356 sinfo->rx_packets = sta->rx_packets;
357 sinfo->tx_packets = sta->tx_packets;
Bruno Randolfb206b4e2010-10-06 18:34:12 +0900358 sinfo->tx_retries = sta->tx_retry_count;
359 sinfo->tx_failed = sta->tx_retry_failed;
Ben Greear5a5c7312010-10-07 16:39:20 -0700360 sinfo->rx_dropped_misc = sta->rx_dropped;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100361
John W. Linville19deffb2009-12-08 17:10:13 -0500362 if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
363 (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
Bruno Randolf541a45a2010-12-02 19:12:43 +0900364 sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
Henning Rogge420e7fa2008-12-11 22:04:19 +0100365 sinfo->signal = (s8)sta->last_signal;
Bruno Randolf541a45a2010-12-02 19:12:43 +0900366 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100367 }
368
369 sinfo->txrate.flags = 0;
370 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
371 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
372 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
373 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
374 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
375 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
Felix Fietkau3af63342011-02-27 22:08:01 +0100376 rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100377
Felix Fietkau3af63342011-02-27 22:08:01 +0100378 sinfo->rxrate.flags = 0;
379 if (sta->last_rx_rate_flag & RX_FLAG_HT)
380 sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
381 if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
382 sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
383 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
384 sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
385 rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
Henning Rogge420e7fa2008-12-11 22:04:19 +0100386
Johannes Berg902acc72008-02-23 15:17:19 +0100387 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100388#ifdef CONFIG_MAC80211_MESH
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100389 sinfo->filled |= STATION_INFO_LLID |
390 STATION_INFO_PLID |
391 STATION_INFO_PLINK_STATE;
392
393 sinfo->llid = le16_to_cpu(sta->llid);
394 sinfo->plid = le16_to_cpu(sta->plid);
395 sinfo->plink_state = sta->plink_state;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100396#endif
Johannes Berg902acc72008-02-23 15:17:19 +0100397 }
Paul Stewartf4263c92011-03-31 09:25:41 -0700398
399 sinfo->bss_param.flags = 0;
400 if (sdata->vif.bss_conf.use_cts_prot)
401 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
402 if (sdata->vif.bss_conf.use_short_preamble)
403 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
404 if (sdata->vif.bss_conf.use_short_slot)
405 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
406 sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
407 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
Helmut Schaa7a724762011-10-13 16:30:40 +0200408
409 sinfo->sta_flags.set = 0;
410 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
411 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
412 BIT(NL80211_STA_FLAG_WME) |
413 BIT(NL80211_STA_FLAG_MFP) |
414 BIT(NL80211_STA_FLAG_AUTHENTICATED);
415 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
416 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
417 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
418 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
419 if (test_sta_flag(sta, WLAN_STA_WME))
420 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
421 if (test_sta_flag(sta, WLAN_STA_MFP))
422 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
423 if (test_sta_flag(sta, WLAN_STA_AUTH))
424 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100425}
426
427
428static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
429 int idx, u8 *mac, struct station_info *sinfo)
430{
Johannes Berg3b53fde82009-11-16 12:00:37 +0100431 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100432 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100433 int ret = -ENOENT;
434
435 rcu_read_lock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100436
Johannes Berg3b53fde82009-11-16 12:00:37 +0100437 sta = sta_info_get_by_idx(sdata, idx);
Johannes Bergd0709a62008-02-25 16:27:46 +0100438 if (sta) {
439 ret = 0;
Johannes Berg17741cd2008-09-11 00:02:02 +0200440 memcpy(mac, sta->sta.addr, ETH_ALEN);
Johannes Bergd0709a62008-02-25 16:27:46 +0100441 sta_set_sinfo(sta, sinfo);
442 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100443
Johannes Bergd0709a62008-02-25 16:27:46 +0100444 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100445
Johannes Bergd0709a62008-02-25 16:27:46 +0100446 return ret;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100447}
448
Holger Schurig12897232010-04-19 10:23:57 +0200449static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
450 int idx, struct survey_info *survey)
451{
452 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
453
Holger Schurig12897232010-04-19 10:23:57 +0200454 return drv_get_survey(local, idx, survey);
455}
456
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100457static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Luis Carlos Cobo2ec600d2008-02-23 15:17:06 +0100458 u8 *mac, struct station_info *sinfo)
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100459{
Johannes Bergabe60632009-11-25 17:46:18 +0100460 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100461 struct sta_info *sta;
Johannes Bergd0709a62008-02-25 16:27:46 +0100462 int ret = -ENOENT;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100463
Johannes Bergd0709a62008-02-25 16:27:46 +0100464 rcu_read_lock();
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100465
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100466 sta = sta_info_get_bss(sdata, mac);
Johannes Bergd0709a62008-02-25 16:27:46 +0100467 if (sta) {
468 ret = 0;
469 sta_set_sinfo(sta, sinfo);
470 }
471
472 rcu_read_unlock();
473
474 return ret;
Johannes Berg7bbdd2d2007-12-19 02:03:37 +0100475}
476
Arik Nemtsov78274932011-09-04 11:11:32 +0300477static void ieee80211_config_ap_ssid(struct ieee80211_sub_if_data *sdata,
478 struct beacon_parameters *params)
479{
480 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
481
482 bss_conf->ssid_len = params->ssid_len;
483
484 if (params->ssid_len)
485 memcpy(bss_conf->ssid, params->ssid, params->ssid_len);
486
487 bss_conf->hidden_ssid =
488 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
489}
490
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100491/*
492 * This handles both adding a beacon and setting new beacon info
493 */
494static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
495 struct beacon_parameters *params)
496{
497 struct beacon_data *new, *old;
498 int new_head_len, new_tail_len;
499 int size;
500 int err = -EINVAL;
501
Johannes Berg40b275b2011-05-13 14:15:49 +0200502 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100503
504 /* head must not be zero-length */
505 if (params->head && !params->head_len)
506 return -EINVAL;
507
508 /*
509 * This is a kludge. beacon interval should really be part
510 * of the beacon information.
511 */
Johannes Berg57c4d7b2009-04-23 16:10:04 +0200512 if (params->interval &&
513 (sdata->vif.bss_conf.beacon_int != params->interval)) {
514 sdata->vif.bss_conf.beacon_int = params->interval;
515 ieee80211_bss_info_change_notify(sdata,
516 BSS_CHANGED_BEACON_INT);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100517 }
518
519 /* Need to have a beacon head if we don't have one yet */
520 if (!params->head && !old)
521 return err;
522
523 /* sorry, no way to start beaconing without dtim period */
524 if (!params->dtim_period && !old)
525 return err;
526
527 /* new or old head? */
528 if (params->head)
529 new_head_len = params->head_len;
530 else
531 new_head_len = old->head_len;
532
533 /* new or old tail? */
534 if (params->tail || !old)
535 /* params->tail_len will be zero for !params->tail */
536 new_tail_len = params->tail_len;
537 else
538 new_tail_len = old->tail_len;
539
540 size = sizeof(*new) + new_head_len + new_tail_len;
541
542 new = kzalloc(size, GFP_KERNEL);
543 if (!new)
544 return -ENOMEM;
545
546 /* start filling the new info now */
547
548 /* new or old dtim period? */
549 if (params->dtim_period)
550 new->dtim_period = params->dtim_period;
551 else
552 new->dtim_period = old->dtim_period;
553
554 /*
555 * pointers go into the block we allocated,
556 * memory is | beacon_data | head | tail |
557 */
558 new->head = ((u8 *) new) + sizeof(*new);
559 new->tail = new->head + new_head_len;
560 new->head_len = new_head_len;
561 new->tail_len = new_tail_len;
562
563 /* copy in head */
564 if (params->head)
565 memcpy(new->head, params->head, new_head_len);
566 else
567 memcpy(new->head, old->head, new_head_len);
568
569 /* copy in optional tail */
570 if (params->tail)
571 memcpy(new->tail, params->tail, new_tail_len);
572 else
573 if (old)
574 memcpy(new->tail, old->tail, new_tail_len);
575
Johannes Berg19885c42010-02-05 11:45:06 +0100576 sdata->vif.bss_conf.dtim_period = new->dtim_period;
577
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +0000578 RCU_INIT_POINTER(sdata->u.ap.beacon, new);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100579
580 synchronize_rcu();
581
582 kfree(old);
583
Arik Nemtsov78274932011-09-04 11:11:32 +0300584 ieee80211_config_ap_ssid(sdata, params);
585
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200586 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
Arik Nemtsov78274932011-09-04 11:11:32 +0300587 BSS_CHANGED_BEACON |
588 BSS_CHANGED_SSID);
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200589 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100590}
591
592static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
593 struct beacon_parameters *params)
594{
Johannes Berg14db74b2008-07-29 13:22:52 +0200595 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100596 struct beacon_data *old;
Johannes Berg665c93a2011-11-04 11:18:11 +0100597 struct ieee80211_sub_if_data *vlan;
598 int ret;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100599
Johannes Berg14db74b2008-07-29 13:22:52 +0200600 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
601
Johannes Berg40b275b2011-05-13 14:15:49 +0200602 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100603 if (old)
604 return -EALREADY;
605
Johannes Berg665c93a2011-11-04 11:18:11 +0100606 ret = ieee80211_config_beacon(sdata, params);
607 if (ret)
608 return ret;
609
610 /*
611 * Apply control port protocol, this allows us to
612 * not encrypt dynamic WEP control frames.
613 */
614 sdata->control_port_protocol = params->crypto.control_port_ethertype;
615 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
616 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
617 vlan->control_port_protocol =
618 params->crypto.control_port_ethertype;
619 vlan->control_port_no_encrypt =
620 params->crypto.control_port_no_encrypt;
621 }
622
623 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100624}
625
626static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
627 struct beacon_parameters *params)
628{
Johannes Berg14db74b2008-07-29 13:22:52 +0200629 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100630 struct beacon_data *old;
631
Johannes Berg14db74b2008-07-29 13:22:52 +0200632 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
633
Johannes Berg40b275b2011-05-13 14:15:49 +0200634 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100635 if (!old)
636 return -ENOENT;
637
638 return ieee80211_config_beacon(sdata, params);
639}
640
641static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
642{
Johannes Berg14db74b2008-07-29 13:22:52 +0200643 struct ieee80211_sub_if_data *sdata;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100644 struct beacon_data *old;
645
Johannes Berg14db74b2008-07-29 13:22:52 +0200646 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
647
Johannes Berg40b275b2011-05-13 14:15:49 +0200648 old = rtnl_dereference(sdata->u.ap.beacon);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100649 if (!old)
650 return -ENOENT;
651
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +0000652 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100653 synchronize_rcu();
654 kfree(old);
655
Johannes Berg2d0ddec2009-04-23 16:13:26 +0200656 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
657 return 0;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100658}
659
Johannes Berg4fd69312007-12-19 02:03:35 +0100660/* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
661struct iapp_layer2_update {
662 u8 da[ETH_ALEN]; /* broadcast */
663 u8 sa[ETH_ALEN]; /* STA addr */
664 __be16 len; /* 6 */
665 u8 dsap; /* 0 */
666 u8 ssap; /* 0 */
667 u8 control;
668 u8 xid_info[3];
Eric Dumazetbc105022010-06-03 03:21:52 -0700669} __packed;
Johannes Berg4fd69312007-12-19 02:03:35 +0100670
671static void ieee80211_send_layer2_update(struct sta_info *sta)
672{
673 struct iapp_layer2_update *msg;
674 struct sk_buff *skb;
675
676 /* Send Level 2 Update Frame to update forwarding tables in layer 2
677 * bridge devices */
678
679 skb = dev_alloc_skb(sizeof(*msg));
680 if (!skb)
681 return;
682 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
683
684 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
685 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
686
687 memset(msg->da, 0xff, ETH_ALEN);
Johannes Berg17741cd2008-09-11 00:02:02 +0200688 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
Johannes Berg4fd69312007-12-19 02:03:35 +0100689 msg->len = htons(6);
690 msg->dsap = 0;
691 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
692 msg->control = 0xaf; /* XID response lsb.1111F101.
693 * F=0 (no poll command; unsolicited frame) */
694 msg->xid_info[0] = 0x81; /* XID format identifier */
695 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
696 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
697
Johannes Bergd0709a62008-02-25 16:27:46 +0100698 skb->dev = sta->sdata->dev;
699 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
Johannes Berg4fd69312007-12-19 02:03:35 +0100700 memset(skb->cb, 0, sizeof(skb->cb));
John W. Linville06ee1c22010-07-19 11:52:59 -0400701 netif_rx_ni(skb);
Johannes Berg4fd69312007-12-19 02:03:35 +0100702}
703
704static void sta_apply_parameters(struct ieee80211_local *local,
705 struct sta_info *sta,
706 struct station_parameters *params)
707{
708 u32 rates;
709 int i, j;
Johannes Berg8318d782008-01-24 19:38:38 +0100710 struct ieee80211_supported_band *sband;
Johannes Bergd0709a62008-02-25 16:27:46 +0100711 struct ieee80211_sub_if_data *sdata = sta->sdata;
Johannes Bergeccb8e82009-05-11 21:57:56 +0300712 u32 mask, set;
Johannes Berg4fd69312007-12-19 02:03:35 +0100713
Johannes Bergae5eb022008-10-14 16:58:37 +0200714 sband = local->hw.wiphy->bands[local->oper_channel->band];
715
Johannes Bergeccb8e82009-05-11 21:57:56 +0300716 mask = params->sta_flags_mask;
717 set = params->sta_flags_set;
Johannes Berg73651ee2008-02-25 16:27:47 +0100718
Johannes Bergeccb8e82009-05-11 21:57:56 +0300719 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300720 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200721 set_sta_flag(sta, WLAN_STA_AUTHORIZED);
722 else
723 clear_sta_flag(sta, WLAN_STA_AUTHORIZED);
Johannes Berg4fd69312007-12-19 02:03:35 +0100724 }
725
Johannes Bergeccb8e82009-05-11 21:57:56 +0300726 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300727 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200728 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
729 else
730 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300731 }
732
733 if (mask & BIT(NL80211_STA_FLAG_WME)) {
Arik Nemtsov39df6002011-06-27 23:58:45 +0300734 if (set & BIT(NL80211_STA_FLAG_WME)) {
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200735 set_sta_flag(sta, WLAN_STA_WME);
Arik Nemtsov39df6002011-06-27 23:58:45 +0300736 sta->sta.wme = true;
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200737 } else {
738 clear_sta_flag(sta, WLAN_STA_WME);
739 sta->sta.wme = false;
Arik Nemtsov39df6002011-06-27 23:58:45 +0300740 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300741 }
742
743 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
Johannes Bergeccb8e82009-05-11 21:57:56 +0300744 if (set & BIT(NL80211_STA_FLAG_MFP))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200745 set_sta_flag(sta, WLAN_STA_MFP);
746 else
747 clear_sta_flag(sta, WLAN_STA_MFP);
Johannes Bergeccb8e82009-05-11 21:57:56 +0300748 }
Javier Cardonab39c48f2011-04-07 15:08:30 -0700749
750 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
Javier Cardonab39c48f2011-04-07 15:08:30 -0700751 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200752 set_sta_flag(sta, WLAN_STA_AUTH);
753 else
754 clear_sta_flag(sta, WLAN_STA_AUTH);
Javier Cardonab39c48f2011-04-07 15:08:30 -0700755 }
Johannes Bergeccb8e82009-05-11 21:57:56 +0300756
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300757 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300758 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200759 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
760 else
761 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300762 }
Johannes Berg73651ee2008-02-25 16:27:47 +0100763
Johannes Berg3b9ce802011-09-27 20:56:12 +0200764 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
765 sta->sta.uapsd_queues = params->uapsd_queues;
766 sta->sta.max_sp = params->max_sp;
767 }
Eliad Peller9533b4a2011-08-23 14:37:47 +0300768
Johannes Berg73651ee2008-02-25 16:27:47 +0100769 /*
Johannes Berg51b50fb2009-05-24 16:42:30 +0200770 * cfg80211 validates this (1-2007) and allows setting the AID
771 * only when creating a new station entry
772 */
773 if (params->aid)
774 sta->sta.aid = params->aid;
775
776 /*
Johannes Berg73651ee2008-02-25 16:27:47 +0100777 * FIXME: updating the following information is racy when this
778 * function is called from ieee80211_change_station().
779 * However, all this information should be static so
780 * maybe we should just reject attemps to change it.
781 */
782
Johannes Berg4fd69312007-12-19 02:03:35 +0100783 if (params->listen_interval >= 0)
784 sta->listen_interval = params->listen_interval;
785
786 if (params->supported_rates) {
787 rates = 0;
Johannes Berg8318d782008-01-24 19:38:38 +0100788
Johannes Berg4fd69312007-12-19 02:03:35 +0100789 for (i = 0; i < params->supported_rates_len; i++) {
790 int rate = (params->supported_rates[i] & 0x7f) * 5;
Johannes Berg8318d782008-01-24 19:38:38 +0100791 for (j = 0; j < sband->n_bitrates; j++) {
792 if (sband->bitrates[j].bitrate == rate)
Johannes Berg4fd69312007-12-19 02:03:35 +0100793 rates |= BIT(j);
794 }
795 }
Johannes Berg323ce792008-09-11 02:45:11 +0200796 sta->sta.supp_rates[local->oper_channel->band] = rates;
Johannes Berg4fd69312007-12-19 02:03:35 +0100797 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100798
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200799 if (params->ht_capa)
Johannes Bergae5eb022008-10-14 16:58:37 +0200800 ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
801 params->ht_capa,
Johannes Bergd9fe60d2008-10-09 12:13:49 +0200802 &sta->sta.ht_cap);
Jouni Malinen36aedc902008-08-25 11:58:58 +0300803
Javier Cardona9c3990a2011-05-03 16:57:11 -0700804 if (ieee80211_vif_is_mesh(&sdata->vif)) {
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400805#ifdef CONFIG_MAC80211_MESH
Javier Cardona9c3990a2011-05-03 16:57:11 -0700806 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
807 switch (params->plink_state) {
Javier Cardona57cf8042011-05-13 10:45:43 -0700808 case NL80211_PLINK_LISTEN:
809 case NL80211_PLINK_ESTAB:
810 case NL80211_PLINK_BLOCKED:
Javier Cardona9c3990a2011-05-03 16:57:11 -0700811 sta->plink_state = params->plink_state;
812 break;
813 default:
814 /* nothing */
815 break;
816 }
817 else
818 switch (params->plink_action) {
819 case PLINK_ACTION_OPEN:
820 mesh_plink_open(sta);
821 break;
822 case PLINK_ACTION_BLOCK:
823 mesh_plink_block(sta);
824 break;
825 }
Yogesh Ashok Powar4daf50f2011-05-12 09:32:17 -0400826#endif
Johannes Berg902acc72008-02-23 15:17:19 +0100827 }
Johannes Berg4fd69312007-12-19 02:03:35 +0100828}
829
830static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
831 u8 *mac, struct station_parameters *params)
832{
Johannes Berg14db74b2008-07-29 13:22:52 +0200833 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +0100834 struct sta_info *sta;
835 struct ieee80211_sub_if_data *sdata;
Johannes Berg73651ee2008-02-25 16:27:47 +0100836 int err;
Jouni Malinenb8d476c2008-12-12 17:08:31 +0200837 int layer2_update;
Johannes Berg4fd69312007-12-19 02:03:35 +0100838
Johannes Berg4fd69312007-12-19 02:03:35 +0100839 if (params->vlan) {
840 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
841
Johannes Berg05c914f2008-09-11 00:01:58 +0200842 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
843 sdata->vif.type != NL80211_IFTYPE_AP)
Johannes Berg4fd69312007-12-19 02:03:35 +0100844 return -EINVAL;
845 } else
846 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
847
Johannes Berg47846c92009-11-25 17:46:19 +0100848 if (compare_ether_addr(mac, sdata->vif.addr) == 0)
Johannes Berg03e44972008-02-27 09:56:40 +0100849 return -EINVAL;
850
851 if (is_multicast_ether_addr(mac))
852 return -EINVAL;
853
Jouni Malinene3a4cc22011-10-23 22:36:04 +0300854 /* Only TDLS-supporting stations can add TDLS peers */
855 if ((params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) &&
856 !((wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) &&
857 sdata->vif.type == NL80211_IFTYPE_STATION))
858 return -ENOTSUPP;
859
Johannes Berg03e44972008-02-27 09:56:40 +0100860 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +0100861 if (!sta)
862 return -ENOMEM;
Johannes Berg4fd69312007-12-19 02:03:35 +0100863
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200864 set_sta_flag(sta, WLAN_STA_AUTH);
865 set_sta_flag(sta, WLAN_STA_ASSOC);
Johannes Berg4fd69312007-12-19 02:03:35 +0100866
867 sta_apply_parameters(local, sta, params);
868
Johannes Berg4b7679a2008-09-18 18:14:18 +0200869 rate_control_rate_init(sta);
Johannes Berg4fd69312007-12-19 02:03:35 +0100870
Jouni Malinenb8d476c2008-12-12 17:08:31 +0200871 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
872 sdata->vif.type == NL80211_IFTYPE_AP;
873
Johannes Berg34e89502010-02-03 13:59:58 +0100874 err = sta_info_insert_rcu(sta);
Johannes Berg73651ee2008-02-25 16:27:47 +0100875 if (err) {
Johannes Berg73651ee2008-02-25 16:27:47 +0100876 rcu_read_unlock();
877 return err;
878 }
879
Jouni Malinenb8d476c2008-12-12 17:08:31 +0200880 if (layer2_update)
Johannes Berg73651ee2008-02-25 16:27:47 +0100881 ieee80211_send_layer2_update(sta);
882
883 rcu_read_unlock();
884
Johannes Berg4fd69312007-12-19 02:03:35 +0100885 return 0;
886}
887
888static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
889 u8 *mac)
890{
Johannes Berg14db74b2008-07-29 13:22:52 +0200891 struct ieee80211_local *local = wiphy_priv(wiphy);
892 struct ieee80211_sub_if_data *sdata;
Johannes Berg4fd69312007-12-19 02:03:35 +0100893
Johannes Berg14db74b2008-07-29 13:22:52 +0200894 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
895
Johannes Berg34e89502010-02-03 13:59:58 +0100896 if (mac)
897 return sta_info_destroy_addr_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +0200898
Johannes Berg34e89502010-02-03 13:59:58 +0100899 sta_info_flush(local, sdata);
Johannes Berg4fd69312007-12-19 02:03:35 +0100900 return 0;
901}
902
903static int ieee80211_change_station(struct wiphy *wiphy,
904 struct net_device *dev,
905 u8 *mac,
906 struct station_parameters *params)
907{
Johannes Bergabe60632009-11-25 17:46:18 +0100908 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg14db74b2008-07-29 13:22:52 +0200909 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg4fd69312007-12-19 02:03:35 +0100910 struct sta_info *sta;
911 struct ieee80211_sub_if_data *vlansdata;
912
Johannes Berg98dd6a52008-04-10 15:36:09 +0200913 rcu_read_lock();
914
Felix Fietkau0e5ded52010-01-08 18:10:58 +0100915 sta = sta_info_get_bss(sdata, mac);
Johannes Berg98dd6a52008-04-10 15:36:09 +0200916 if (!sta) {
917 rcu_read_unlock();
Johannes Berg4fd69312007-12-19 02:03:35 +0100918 return -ENOENT;
Johannes Berg98dd6a52008-04-10 15:36:09 +0200919 }
Johannes Berg4fd69312007-12-19 02:03:35 +0100920
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300921 /* The TDLS bit cannot be toggled after the STA was added */
922 if ((params->sta_flags_mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) &&
923 !!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) !=
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200924 !!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
Arik Nemtsov07ba55d2011-09-28 14:12:53 +0300925 rcu_read_unlock();
926 return -EINVAL;
927 }
928
Johannes Bergd0709a62008-02-25 16:27:46 +0100929 if (params->vlan && params->vlan != sta->sdata->dev) {
Johannes Berg4fd69312007-12-19 02:03:35 +0100930 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
931
Johannes Berg05c914f2008-09-11 00:01:58 +0200932 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
933 vlansdata->vif.type != NL80211_IFTYPE_AP) {
Johannes Berg98dd6a52008-04-10 15:36:09 +0200934 rcu_read_unlock();
Johannes Berg4fd69312007-12-19 02:03:35 +0100935 return -EINVAL;
Johannes Berg98dd6a52008-04-10 15:36:09 +0200936 }
Johannes Berg4fd69312007-12-19 02:03:35 +0100937
Johannes Berg9bc383d2009-11-19 11:55:19 +0100938 if (params->vlan->ieee80211_ptr->use_4addr) {
Johannes Berg33054432009-11-20 10:09:14 +0100939 if (vlansdata->u.vlan.sta) {
940 rcu_read_unlock();
Felix Fietkauf14543ee2009-11-10 20:10:05 +0100941 return -EBUSY;
Johannes Berg33054432009-11-20 10:09:14 +0100942 }
Felix Fietkauf14543ee2009-11-10 20:10:05 +0100943
Stephen Hemmingera9b3cd72011-08-01 16:19:00 +0000944 RCU_INIT_POINTER(vlansdata->u.vlan.sta, sta);
Felix Fietkauf14543ee2009-11-10 20:10:05 +0100945 }
946
Johannes Berg14db74b2008-07-29 13:22:52 +0200947 sta->sdata = vlansdata;
Johannes Berg4fd69312007-12-19 02:03:35 +0100948 ieee80211_send_layer2_update(sta);
949 }
950
951 sta_apply_parameters(local, sta, params);
952
Johannes Berg98dd6a52008-04-10 15:36:09 +0200953 rcu_read_unlock();
954
Jason Young808118c2011-03-10 16:43:19 -0800955 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
956 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))
957 ieee80211_recalc_ps(local, -1);
958
Johannes Berg4fd69312007-12-19 02:03:35 +0100959 return 0;
960}
961
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100962#ifdef CONFIG_MAC80211_MESH
963static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
964 u8 *dst, u8 *next_hop)
965{
Johannes Berg14db74b2008-07-29 13:22:52 +0200966 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100967 struct mesh_path *mpath;
968 struct sta_info *sta;
969 int err;
970
Johannes Berg14db74b2008-07-29 13:22:52 +0200971 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
972
Johannes Bergd0709a62008-02-25 16:27:46 +0100973 rcu_read_lock();
Johannes Bergabe60632009-11-25 17:46:18 +0100974 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +0100975 if (!sta) {
976 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100977 return -ENOENT;
Johannes Bergd0709a62008-02-25 16:27:46 +0100978 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100979
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200980 err = mesh_path_add(dst, sdata);
Johannes Bergd0709a62008-02-25 16:27:46 +0100981 if (err) {
982 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100983 return err;
Johannes Bergd0709a62008-02-25 16:27:46 +0100984 }
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100985
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200986 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100987 if (!mpath) {
988 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100989 return -ENXIO;
990 }
991 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +0100992
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +0100993 rcu_read_unlock();
994 return 0;
995}
996
997static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
998 u8 *dst)
999{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001000 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001001
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001002 if (dst)
1003 return mesh_path_del(dst, sdata);
1004
Javier Cardonaece1a2e2011-08-29 13:23:04 -07001005 mesh_path_flush_by_iface(sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001006 return 0;
1007}
1008
1009static int ieee80211_change_mpath(struct wiphy *wiphy,
1010 struct net_device *dev,
1011 u8 *dst, u8 *next_hop)
1012{
Johannes Berg14db74b2008-07-29 13:22:52 +02001013 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001014 struct mesh_path *mpath;
1015 struct sta_info *sta;
1016
Johannes Berg14db74b2008-07-29 13:22:52 +02001017 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1018
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001019 rcu_read_lock();
Johannes Bergd0709a62008-02-25 16:27:46 +01001020
Johannes Bergabe60632009-11-25 17:46:18 +01001021 sta = sta_info_get(sdata, next_hop);
Johannes Bergd0709a62008-02-25 16:27:46 +01001022 if (!sta) {
1023 rcu_read_unlock();
1024 return -ENOENT;
1025 }
1026
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001027 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001028 if (!mpath) {
1029 rcu_read_unlock();
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001030 return -ENOENT;
1031 }
1032
1033 mesh_path_fix_nexthop(mpath, sta);
Johannes Bergd0709a62008-02-25 16:27:46 +01001034
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001035 rcu_read_unlock();
1036 return 0;
1037}
1038
1039static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1040 struct mpath_info *pinfo)
1041{
Johannes Berga3836e02011-05-12 15:11:37 +02001042 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1043
1044 if (next_hop_sta)
1045 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001046 else
1047 memset(next_hop, 0, ETH_ALEN);
1048
Johannes Bergf5ea9122009-08-07 16:17:38 +02001049 pinfo->generation = mesh_paths_generation;
1050
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001051 pinfo->filled = MPATH_INFO_FRAME_QLEN |
Rui Paulod19b3bf2009-11-09 23:46:55 +00001052 MPATH_INFO_SN |
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001053 MPATH_INFO_METRIC |
1054 MPATH_INFO_EXPTIME |
1055 MPATH_INFO_DISCOVERY_TIMEOUT |
1056 MPATH_INFO_DISCOVERY_RETRIES |
1057 MPATH_INFO_FLAGS;
1058
1059 pinfo->frame_qlen = mpath->frame_queue.qlen;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001060 pinfo->sn = mpath->sn;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001061 pinfo->metric = mpath->metric;
1062 if (time_before(jiffies, mpath->exp_time))
1063 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1064 pinfo->discovery_timeout =
1065 jiffies_to_msecs(mpath->discovery_timeout);
1066 pinfo->discovery_retries = mpath->discovery_retries;
1067 pinfo->flags = 0;
1068 if (mpath->flags & MESH_PATH_ACTIVE)
1069 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1070 if (mpath->flags & MESH_PATH_RESOLVING)
1071 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
Rui Paulod19b3bf2009-11-09 23:46:55 +00001072 if (mpath->flags & MESH_PATH_SN_VALID)
1073 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001074 if (mpath->flags & MESH_PATH_FIXED)
1075 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1076 if (mpath->flags & MESH_PATH_RESOLVING)
1077 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1078
1079 pinfo->flags = mpath->flags;
1080}
1081
1082static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1083 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1084
1085{
Johannes Berg14db74b2008-07-29 13:22:52 +02001086 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001087 struct mesh_path *mpath;
1088
Johannes Berg14db74b2008-07-29 13:22:52 +02001089 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1090
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001091 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001092 mpath = mesh_path_lookup(dst, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001093 if (!mpath) {
1094 rcu_read_unlock();
1095 return -ENOENT;
1096 }
1097 memcpy(dst, mpath->dst, ETH_ALEN);
1098 mpath_set_pinfo(mpath, next_hop, pinfo);
1099 rcu_read_unlock();
1100 return 0;
1101}
1102
1103static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1104 int idx, u8 *dst, u8 *next_hop,
1105 struct mpath_info *pinfo)
1106{
Johannes Berg14db74b2008-07-29 13:22:52 +02001107 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001108 struct mesh_path *mpath;
1109
Johannes Berg14db74b2008-07-29 13:22:52 +02001110 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1111
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001112 rcu_read_lock();
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +12001113 mpath = mesh_path_lookup_by_idx(idx, sdata);
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001114 if (!mpath) {
1115 rcu_read_unlock();
1116 return -ENOENT;
1117 }
1118 memcpy(dst, mpath->dst, ETH_ALEN);
1119 mpath_set_pinfo(mpath, next_hop, pinfo);
1120 rcu_read_unlock();
1121 return 0;
1122}
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001123
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001124static int ieee80211_get_mesh_config(struct wiphy *wiphy,
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001125 struct net_device *dev,
1126 struct mesh_config *conf)
1127{
1128 struct ieee80211_sub_if_data *sdata;
1129 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1130
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001131 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1132 return 0;
1133}
1134
1135static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1136{
1137 return (mask >> (parm-1)) & 0x1;
1138}
1139
Javier Cardonac80d5452010-12-16 17:37:49 -08001140static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1141 const struct mesh_setup *setup)
1142{
1143 u8 *new_ie;
1144 const u8 *old_ie;
1145
Javier Cardona581a8b02011-04-07 15:08:27 -07001146 /* allocate information elements */
Javier Cardonac80d5452010-12-16 17:37:49 -08001147 new_ie = NULL;
Javier Cardona581a8b02011-04-07 15:08:27 -07001148 old_ie = ifmsh->ie;
Javier Cardonac80d5452010-12-16 17:37:49 -08001149
Javier Cardona581a8b02011-04-07 15:08:27 -07001150 if (setup->ie_len) {
1151 new_ie = kmemdup(setup->ie, setup->ie_len,
Javier Cardonac80d5452010-12-16 17:37:49 -08001152 GFP_KERNEL);
1153 if (!new_ie)
1154 return -ENOMEM;
1155 }
Javier Cardona581a8b02011-04-07 15:08:27 -07001156 ifmsh->ie_len = setup->ie_len;
1157 ifmsh->ie = new_ie;
1158 kfree(old_ie);
Javier Cardonac80d5452010-12-16 17:37:49 -08001159
1160 /* now copy the rest of the setup parameters */
1161 ifmsh->mesh_id_len = setup->mesh_id_len;
1162 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
1163 ifmsh->mesh_pp_id = setup->path_sel_proto;
1164 ifmsh->mesh_pm_id = setup->path_metric;
Javier Cardonab130e5c2011-05-03 16:57:07 -07001165 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1166 if (setup->is_authenticated)
1167 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1168 if (setup->is_secure)
1169 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
Javier Cardonac80d5452010-12-16 17:37:49 -08001170
1171 return 0;
1172}
1173
Javier Cardona24bdd9f2010-12-16 17:37:48 -08001174static int ieee80211_update_mesh_config(struct wiphy *wiphy,
Johannes Berg29cbe682010-12-03 09:20:44 +01001175 struct net_device *dev, u32 mask,
1176 const struct mesh_config *nconf)
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001177{
1178 struct mesh_config *conf;
1179 struct ieee80211_sub_if_data *sdata;
Rui Paulo63c57232009-11-09 23:46:57 +00001180 struct ieee80211_if_mesh *ifmsh;
1181
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001182 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Rui Paulo63c57232009-11-09 23:46:57 +00001183 ifmsh = &sdata->u.mesh;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001184
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001185 /* Set the config options which we are interested in setting */
1186 conf = &(sdata->u.mesh.mshcfg);
1187 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1188 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1189 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1190 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1191 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1192 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1193 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1194 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1195 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1196 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1197 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1198 conf->dot11MeshTTL = nconf->dot11MeshTTL;
Javier Cardona45904f22010-12-03 09:20:40 +01001199 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1200 conf->dot11MeshTTL = nconf->element_ttl;
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001201 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
1202 conf->auto_open_plinks = nconf->auto_open_plinks;
1203 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1204 conf->dot11MeshHWMPmaxPREQretries =
1205 nconf->dot11MeshHWMPmaxPREQretries;
1206 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1207 conf->path_refresh_time = nconf->path_refresh_time;
1208 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1209 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1210 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1211 conf->dot11MeshHWMPactivePathTimeout =
1212 nconf->dot11MeshHWMPactivePathTimeout;
1213 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1214 conf->dot11MeshHWMPpreqMinInterval =
1215 nconf->dot11MeshHWMPpreqMinInterval;
1216 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1217 mask))
1218 conf->dot11MeshHWMPnetDiameterTraversalTime =
1219 nconf->dot11MeshHWMPnetDiameterTraversalTime;
Rui Paulo63c57232009-11-09 23:46:57 +00001220 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1221 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1222 ieee80211_mesh_root_setup(ifmsh);
1223 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001224 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
Thomas Pedersenc61336612011-08-25 10:36:14 -07001225 /* our current gate announcement implementation rides on root
1226 * announcements, so require this ifmsh to also be a root node
1227 * */
1228 if (nconf->dot11MeshGateAnnouncementProtocol &&
1229 !conf->dot11MeshHWMPRootMode) {
1230 conf->dot11MeshHWMPRootMode = 1;
1231 ieee80211_mesh_root_setup(ifmsh);
1232 }
Javier Cardona16dd7262011-08-09 16:45:11 -07001233 conf->dot11MeshGateAnnouncementProtocol =
1234 nconf->dot11MeshGateAnnouncementProtocol;
1235 }
Javier Cardona0507e152011-08-09 16:45:10 -07001236 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) {
1237 conf->dot11MeshHWMPRannInterval =
1238 nconf->dot11MeshHWMPRannInterval;
1239 }
colin@cozybit.com93da9cc2008-10-21 12:03:48 -07001240 return 0;
1241}
1242
Johannes Berg29cbe682010-12-03 09:20:44 +01001243static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1244 const struct mesh_config *conf,
1245 const struct mesh_setup *setup)
1246{
1247 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1248 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
Javier Cardonac80d5452010-12-16 17:37:49 -08001249 int err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001250
Javier Cardonac80d5452010-12-16 17:37:49 -08001251 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1252 err = copy_mesh_setup(ifmsh, setup);
1253 if (err)
1254 return err;
Johannes Berg29cbe682010-12-03 09:20:44 +01001255 ieee80211_start_mesh(sdata);
1256
1257 return 0;
1258}
1259
1260static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1261{
1262 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1263
1264 ieee80211_stop_mesh(sdata);
1265
1266 return 0;
1267}
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01001268#endif
1269
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001270static int ieee80211_change_bss(struct wiphy *wiphy,
1271 struct net_device *dev,
1272 struct bss_parameters *params)
1273{
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001274 struct ieee80211_sub_if_data *sdata;
1275 u32 changed = 0;
1276
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001277 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1278
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001279 if (params->use_cts_prot >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001280 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001281 changed |= BSS_CHANGED_ERP_CTS_PROT;
1282 }
1283 if (params->use_short_preamble >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001284 sdata->vif.bss_conf.use_short_preamble =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001285 params->use_short_preamble;
1286 changed |= BSS_CHANGED_ERP_PREAMBLE;
1287 }
Felix Fietkau43d35342010-01-15 03:00:48 +01001288
1289 if (!sdata->vif.bss_conf.use_short_slot &&
1290 sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) {
1291 sdata->vif.bss_conf.use_short_slot = true;
1292 changed |= BSS_CHANGED_ERP_SLOT;
1293 }
1294
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001295 if (params->use_short_slot_time >= 0) {
Johannes Bergbda39332008-10-11 01:51:51 +02001296 sdata->vif.bss_conf.use_short_slot =
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001297 params->use_short_slot_time;
1298 changed |= BSS_CHANGED_ERP_SLOT;
1299 }
1300
Jouni Malinen90c97a02008-10-30 16:59:22 +02001301 if (params->basic_rates) {
1302 int i, j;
1303 u32 rates = 0;
1304 struct ieee80211_local *local = wiphy_priv(wiphy);
1305 struct ieee80211_supported_band *sband =
1306 wiphy->bands[local->oper_channel->band];
1307
1308 for (i = 0; i < params->basic_rates_len; i++) {
1309 int rate = (params->basic_rates[i] & 0x7f) * 5;
1310 for (j = 0; j < sband->n_bitrates; j++) {
1311 if (sband->bitrates[j].bitrate == rate)
1312 rates |= BIT(j);
1313 }
1314 }
1315 sdata->vif.bss_conf.basic_rates = rates;
1316 changed |= BSS_CHANGED_BASIC_RATES;
1317 }
1318
Felix Fietkau7b7b5e52010-04-27 01:23:36 +02001319 if (params->ap_isolate >= 0) {
1320 if (params->ap_isolate)
1321 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1322 else
1323 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1324 }
1325
Helmut Schaa80d7e402010-11-19 12:40:26 +01001326 if (params->ht_opmode >= 0) {
1327 sdata->vif.bss_conf.ht_operation_mode =
1328 (u16) params->ht_opmode;
1329 changed |= BSS_CHANGED_HT;
1330 }
1331
Jouni Malinen9f1ba902008-08-07 20:07:01 +03001332 ieee80211_bss_info_change_notify(sdata, changed);
1333
1334 return 0;
1335}
1336
Jouni Malinen31888482008-10-30 16:59:24 +02001337static int ieee80211_set_txq_params(struct wiphy *wiphy,
Eliad Pellerf70f01c2011-09-25 20:06:53 +03001338 struct net_device *dev,
Jouni Malinen31888482008-10-30 16:59:24 +02001339 struct ieee80211_txq_params *params)
1340{
1341 struct ieee80211_local *local = wiphy_priv(wiphy);
Eliad Pellerf6f3def2011-09-25 20:06:54 +03001342 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Jouni Malinen31888482008-10-30 16:59:24 +02001343 struct ieee80211_tx_queue_params p;
1344
1345 if (!local->ops->conf_tx)
1346 return -EOPNOTSUPP;
1347
1348 memset(&p, 0, sizeof(p));
1349 p.aifs = params->aifs;
1350 p.cw_max = params->cwmax;
1351 p.cw_min = params->cwmin;
1352 p.txop = params->txop;
Kalle Valoab133152010-01-12 10:42:31 +02001353
1354 /*
1355 * Setting tx queue params disables u-apsd because it's only
1356 * called in master mode.
1357 */
1358 p.uapsd = false;
1359
Eliad Peller2683d652011-07-14 20:29:42 +03001360 if (params->queue >= local->hw.queues)
1361 return -EINVAL;
1362
Eliad Pellerf6f3def2011-09-25 20:06:54 +03001363 sdata->tx_conf[params->queue] = p;
1364 if (drv_conf_tx(local, sdata, params->queue, &p)) {
Joe Perches0fb9a9e2010-08-20 16:25:38 -07001365 wiphy_debug(local->hw.wiphy,
1366 "failed to set TX queue parameters for queue %d\n",
1367 params->queue);
Jouni Malinen31888482008-10-30 16:59:24 +02001368 return -EINVAL;
1369 }
1370
1371 return 0;
1372}
1373
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001374static int ieee80211_set_channel(struct wiphy *wiphy,
Johannes Bergf444de02010-05-05 15:25:02 +02001375 struct net_device *netdev,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001376 struct ieee80211_channel *chan,
Sujith094d05d2008-12-12 11:57:43 +05301377 enum nl80211_channel_type channel_type)
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001378{
1379 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg0aaffa92010-05-05 15:28:27 +02001380 struct ieee80211_sub_if_data *sdata = NULL;
Ben Greeareeabee72011-01-28 10:20:47 -08001381 struct ieee80211_channel *old_oper;
1382 enum nl80211_channel_type old_oper_type;
1383 enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001384
1385 if (netdev)
1386 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001387
Johannes Bergf444de02010-05-05 15:25:02 +02001388 switch (ieee80211_get_channel_mode(local, NULL)) {
1389 case CHAN_MODE_HOPPING:
1390 return -EBUSY;
1391 case CHAN_MODE_FIXED:
Johannes Berg0aaffa92010-05-05 15:28:27 +02001392 if (local->oper_channel != chan)
1393 return -EBUSY;
1394 if (!sdata && local->_oper_channel_type == channel_type)
Johannes Bergf444de02010-05-05 15:25:02 +02001395 return 0;
Johannes Berg0aaffa92010-05-05 15:28:27 +02001396 break;
Johannes Bergf444de02010-05-05 15:25:02 +02001397 case CHAN_MODE_UNDEFINED:
1398 break;
1399 }
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001400
Ben Greeareeabee72011-01-28 10:20:47 -08001401 if (sdata)
1402 old_vif_oper_type = sdata->vif.bss_conf.channel_type;
1403 old_oper_type = local->_oper_channel_type;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001404
Johannes Berg0aaffa92010-05-05 15:28:27 +02001405 if (!ieee80211_set_channel_type(local, sdata, channel_type))
1406 return -EBUSY;
1407
Ben Greeareeabee72011-01-28 10:20:47 -08001408 old_oper = local->oper_channel;
1409 local->oper_channel = chan;
1410
1411 /* Update driver if changes were actually made. */
1412 if ((old_oper != local->oper_channel) ||
1413 (old_oper_type != local->_oper_channel_type))
1414 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1415
Johannes Bergef5af742011-10-18 13:39:14 +02001416 if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR &&
Ben Greeareeabee72011-01-28 10:20:47 -08001417 old_vif_oper_type != sdata->vif.bss_conf.channel_type)
Johannes Berg0aaffa92010-05-05 15:28:27 +02001418 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1419
1420 return 0;
Jouni Malinen72bdcf32008-11-26 16:15:24 +02001421}
1422
Bob Copeland665af4f2009-01-19 11:20:53 -05001423#ifdef CONFIG_PM
Johannes Bergff1b6e62011-05-04 15:37:28 +02001424static int ieee80211_suspend(struct wiphy *wiphy,
1425 struct cfg80211_wowlan *wowlan)
Bob Copeland665af4f2009-01-19 11:20:53 -05001426{
Johannes Bergeecc4802011-05-04 15:37:29 +02001427 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
Bob Copeland665af4f2009-01-19 11:20:53 -05001428}
1429
1430static int ieee80211_resume(struct wiphy *wiphy)
1431{
1432 return __ieee80211_resume(wiphy_priv(wiphy));
1433}
1434#else
1435#define ieee80211_suspend NULL
1436#define ieee80211_resume NULL
1437#endif
1438
Johannes Berg2a519312009-02-10 21:25:55 +01001439static int ieee80211_scan(struct wiphy *wiphy,
1440 struct net_device *dev,
1441 struct cfg80211_scan_request *req)
1442{
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001443 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg2a519312009-02-10 21:25:55 +01001444
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001445 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
1446 case NL80211_IFTYPE_STATION:
1447 case NL80211_IFTYPE_ADHOC:
1448 case NL80211_IFTYPE_MESH_POINT:
1449 case NL80211_IFTYPE_P2P_CLIENT:
1450 break;
1451 case NL80211_IFTYPE_P2P_GO:
1452 if (sdata->local->ops->hw_scan)
1453 break;
Johannes Berge9d77322011-02-01 15:35:36 +01001454 /*
1455 * FIXME: implement NoA while scanning in software,
1456 * for now fall through to allow scanning only when
1457 * beaconing hasn't been configured yet
1458 */
Johannes Berg2ca27bc2010-09-16 14:58:23 +02001459 case NL80211_IFTYPE_AP:
1460 if (sdata->u.ap.beacon)
1461 return -EOPNOTSUPP;
1462 break;
1463 default:
1464 return -EOPNOTSUPP;
1465 }
Johannes Berg2a519312009-02-10 21:25:55 +01001466
1467 return ieee80211_request_scan(sdata, req);
1468}
1469
Luciano Coelho79f460c2011-05-11 17:09:36 +03001470static int
1471ieee80211_sched_scan_start(struct wiphy *wiphy,
1472 struct net_device *dev,
1473 struct cfg80211_sched_scan_request *req)
1474{
1475 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1476
1477 if (!sdata->local->ops->sched_scan_start)
1478 return -EOPNOTSUPP;
1479
1480 return ieee80211_request_sched_scan_start(sdata, req);
1481}
1482
1483static int
Luciano Coelho85a99942011-05-12 16:28:29 +03001484ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
Luciano Coelho79f460c2011-05-11 17:09:36 +03001485{
1486 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1487
1488 if (!sdata->local->ops->sched_scan_stop)
1489 return -EOPNOTSUPP;
1490
Luciano Coelho85a99942011-05-12 16:28:29 +03001491 return ieee80211_request_sched_scan_stop(sdata);
Luciano Coelho79f460c2011-05-11 17:09:36 +03001492}
1493
Jouni Malinen636a5d32009-03-19 13:39:22 +02001494static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1495 struct cfg80211_auth_request *req)
1496{
Johannes Berg77fdaa12009-07-07 03:45:17 +02001497 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001498}
1499
1500static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1501 struct cfg80211_assoc_request *req)
1502{
Johannes Bergf444de02010-05-05 15:25:02 +02001503 struct ieee80211_local *local = wiphy_priv(wiphy);
1504 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1505
1506 switch (ieee80211_get_channel_mode(local, sdata)) {
1507 case CHAN_MODE_HOPPING:
1508 return -EBUSY;
1509 case CHAN_MODE_FIXED:
1510 if (local->oper_channel == req->bss->channel)
1511 break;
1512 return -EBUSY;
1513 case CHAN_MODE_UNDEFINED:
1514 break;
1515 }
1516
Johannes Berg77fdaa12009-07-07 03:45:17 +02001517 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001518}
1519
1520static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg667503dd2009-07-07 03:56:11 +02001521 struct cfg80211_deauth_request *req,
1522 void *cookie)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001523{
Johannes Berg667503dd2009-07-07 03:56:11 +02001524 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev),
1525 req, cookie);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001526}
1527
1528static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg667503dd2009-07-07 03:56:11 +02001529 struct cfg80211_disassoc_request *req,
1530 void *cookie)
Jouni Malinen636a5d32009-03-19 13:39:22 +02001531{
Johannes Berg667503dd2009-07-07 03:56:11 +02001532 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev),
1533 req, cookie);
Jouni Malinen636a5d32009-03-19 13:39:22 +02001534}
1535
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001536static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1537 struct cfg80211_ibss_params *params)
1538{
Johannes Bergf444de02010-05-05 15:25:02 +02001539 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001540 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1541
Johannes Bergf444de02010-05-05 15:25:02 +02001542 switch (ieee80211_get_channel_mode(local, sdata)) {
1543 case CHAN_MODE_HOPPING:
1544 return -EBUSY;
1545 case CHAN_MODE_FIXED:
1546 if (!params->channel_fixed)
1547 return -EBUSY;
1548 if (local->oper_channel == params->channel)
1549 break;
1550 return -EBUSY;
1551 case CHAN_MODE_UNDEFINED:
1552 break;
1553 }
1554
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02001555 return ieee80211_ibss_join(sdata, params);
1556}
1557
1558static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1559{
1560 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1561
1562 return ieee80211_ibss_leave(sdata);
1563}
1564
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001565static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1566{
1567 struct ieee80211_local *local = wiphy_priv(wiphy);
Johannes Berg24487982009-04-23 18:52:52 +02001568 int err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001569
Arik Nemtsovf23a4782010-11-08 11:51:06 +02001570 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1571 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
1572
1573 if (err)
1574 return err;
1575 }
1576
Lukáš Turek310bc672009-12-21 22:50:48 +01001577 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
1578 err = drv_set_coverage_class(local, wiphy->coverage_class);
1579
1580 if (err)
1581 return err;
1582 }
1583
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001584 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
Johannes Berg24487982009-04-23 18:52:52 +02001585 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001586
Johannes Berg24487982009-04-23 18:52:52 +02001587 if (err)
1588 return err;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02001589 }
1590
1591 if (changed & WIPHY_PARAM_RETRY_SHORT)
1592 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
1593 if (changed & WIPHY_PARAM_RETRY_LONG)
1594 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
1595 if (changed &
1596 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
1597 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
1598
1599 return 0;
1600}
1601
Johannes Berg7643a2c2009-06-02 13:01:39 +02001602static int ieee80211_set_tx_power(struct wiphy *wiphy,
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001603 enum nl80211_tx_power_setting type, int mbm)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001604{
1605 struct ieee80211_local *local = wiphy_priv(wiphy);
1606 struct ieee80211_channel *chan = local->hw.conf.channel;
1607 u32 changes = 0;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001608
1609 switch (type) {
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001610 case NL80211_TX_POWER_AUTOMATIC:
Johannes Berg7643a2c2009-06-02 13:01:39 +02001611 local->user_power_level = -1;
1612 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001613 case NL80211_TX_POWER_LIMITED:
1614 if (mbm < 0 || (mbm % 100))
1615 return -EOPNOTSUPP;
1616 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001617 break;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001618 case NL80211_TX_POWER_FIXED:
1619 if (mbm < 0 || (mbm % 100))
1620 return -EOPNOTSUPP;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001621 /* TODO: move to cfg80211 when it knows the channel */
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001622 if (MBM_TO_DBM(mbm) > chan->max_power)
Johannes Berg7643a2c2009-06-02 13:01:39 +02001623 return -EINVAL;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +03001624 local->user_power_level = MBM_TO_DBM(mbm);
Johannes Berg7643a2c2009-06-02 13:01:39 +02001625 break;
Johannes Berg7643a2c2009-06-02 13:01:39 +02001626 }
1627
1628 ieee80211_hw_config(local, changes);
1629
1630 return 0;
1631}
1632
1633static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1634{
1635 struct ieee80211_local *local = wiphy_priv(wiphy);
1636
1637 *dbm = local->hw.conf.power_level;
1638
Johannes Berg7643a2c2009-06-02 13:01:39 +02001639 return 0;
1640}
1641
Johannes Bergab737a42009-07-01 21:26:58 +02001642static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
Johannes Berg388ac772010-10-07 13:11:09 +02001643 const u8 *addr)
Johannes Bergab737a42009-07-01 21:26:58 +02001644{
1645 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1646
1647 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
1648
1649 return 0;
1650}
1651
Johannes Berg1f87f7d2009-06-02 13:01:41 +02001652static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1653{
1654 struct ieee80211_local *local = wiphy_priv(wiphy);
1655
1656 drv_rfkill_poll(local);
1657}
1658
Johannes Bergaff89a92009-07-01 21:26:51 +02001659#ifdef CONFIG_NL80211_TESTMODE
Johannes Berg99783e22009-07-07 03:54:43 +02001660static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
Johannes Bergaff89a92009-07-01 21:26:51 +02001661{
1662 struct ieee80211_local *local = wiphy_priv(wiphy);
1663
1664 if (!local->ops->testmode_cmd)
1665 return -EOPNOTSUPP;
1666
1667 return local->ops->testmode_cmd(&local->hw, data, len);
1668}
Wey-Yi Guy71063f02011-05-20 09:05:54 -07001669
1670static int ieee80211_testmode_dump(struct wiphy *wiphy,
1671 struct sk_buff *skb,
1672 struct netlink_callback *cb,
1673 void *data, int len)
1674{
1675 struct ieee80211_local *local = wiphy_priv(wiphy);
1676
1677 if (!local->ops->testmode_dump)
1678 return -EOPNOTSUPP;
1679
1680 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
1681}
Johannes Bergaff89a92009-07-01 21:26:51 +02001682#endif
1683
Johannes Berg0f782312009-12-01 13:37:02 +01001684int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1685 enum ieee80211_smps_mode smps_mode)
1686{
1687 const u8 *ap;
1688 enum ieee80211_smps_mode old_req;
1689 int err;
1690
Johannes Berg243e6df2011-04-19 20:44:04 +02001691 lockdep_assert_held(&sdata->u.mgd.mtx);
1692
Johannes Berg0f782312009-12-01 13:37:02 +01001693 old_req = sdata->u.mgd.req_smps;
1694 sdata->u.mgd.req_smps = smps_mode;
1695
1696 if (old_req == smps_mode &&
1697 smps_mode != IEEE80211_SMPS_AUTOMATIC)
1698 return 0;
1699
1700 /*
1701 * If not associated, or current association is not an HT
1702 * association, there's no need to send an action frame.
1703 */
1704 if (!sdata->u.mgd.associated ||
Johannes Berg0aaffa92010-05-05 15:28:27 +02001705 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
Johannes Berg0f782312009-12-01 13:37:02 +01001706 mutex_lock(&sdata->local->iflist_mtx);
Johannes Berg025e6be2010-10-05 10:41:47 +02001707 ieee80211_recalc_smps(sdata->local);
Johannes Berg0f782312009-12-01 13:37:02 +01001708 mutex_unlock(&sdata->local->iflist_mtx);
1709 return 0;
1710 }
1711
Johannes Berg0c1ad2c2009-12-23 13:15:39 +01001712 ap = sdata->u.mgd.associated->bssid;
Johannes Berg0f782312009-12-01 13:37:02 +01001713
1714 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
1715 if (sdata->u.mgd.powersave)
1716 smps_mode = IEEE80211_SMPS_DYNAMIC;
1717 else
1718 smps_mode = IEEE80211_SMPS_OFF;
1719 }
1720
1721 /* send SM PS frame to AP */
1722 err = ieee80211_send_smps_action(sdata, smps_mode,
1723 ap, ap);
1724 if (err)
1725 sdata->u.mgd.req_smps = old_req;
1726
1727 return err;
1728}
1729
Johannes Bergbc92afd2009-07-01 21:26:57 +02001730static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
1731 bool enabled, int timeout)
1732{
1733 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1734 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Bergbc92afd2009-07-01 21:26:57 +02001735
Benoit Papillaulte5de30c2010-01-15 12:21:37 +01001736 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1737 return -EOPNOTSUPP;
1738
Johannes Bergbc92afd2009-07-01 21:26:57 +02001739 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
1740 return -EOPNOTSUPP;
1741
1742 if (enabled == sdata->u.mgd.powersave &&
Juuso Oikarinenff616382010-06-09 09:51:52 +03001743 timeout == local->dynamic_ps_forced_timeout)
Johannes Bergbc92afd2009-07-01 21:26:57 +02001744 return 0;
1745
1746 sdata->u.mgd.powersave = enabled;
Juuso Oikarinenff616382010-06-09 09:51:52 +03001747 local->dynamic_ps_forced_timeout = timeout;
Johannes Bergbc92afd2009-07-01 21:26:57 +02001748
Johannes Berg0f782312009-12-01 13:37:02 +01001749 /* no change, but if automatic follow powersave */
1750 mutex_lock(&sdata->u.mgd.mtx);
1751 __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
1752 mutex_unlock(&sdata->u.mgd.mtx);
1753
Johannes Bergbc92afd2009-07-01 21:26:57 +02001754 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
1755 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
1756
1757 ieee80211_recalc_ps(local, -1);
1758
1759 return 0;
1760}
1761
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001762static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
1763 struct net_device *dev,
1764 s32 rssi_thold, u32 rssi_hyst)
1765{
1766 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1767 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1768 struct ieee80211_vif *vif = &sdata->vif;
1769 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1770
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001771 if (rssi_thold == bss_conf->cqm_rssi_thold &&
1772 rssi_hyst == bss_conf->cqm_rssi_hyst)
1773 return 0;
1774
1775 bss_conf->cqm_rssi_thold = rssi_thold;
1776 bss_conf->cqm_rssi_hyst = rssi_hyst;
1777
Jouni Malinen17e4ec12010-03-29 23:28:30 -07001778 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) {
1779 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1780 return -EOPNOTSUPP;
1781 return 0;
1782 }
1783
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02001784 /* tell the driver upon association, unless already associated */
1785 if (sdata->u.mgd.associated)
1786 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
1787
1788 return 0;
1789}
1790
Johannes Berg99303802009-07-01 21:26:59 +02001791static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
1792 struct net_device *dev,
1793 const u8 *addr,
1794 const struct cfg80211_bitrate_mask *mask)
1795{
1796 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1797 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05301798 int i, ret;
Johannes Berg99303802009-07-01 21:26:59 +02001799
Sujith Manoharanbdbfd6b2011-04-27 16:56:51 +05301800 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
1801 ret = drv_set_bitrate_mask(local, sdata, mask);
1802 if (ret)
1803 return ret;
1804 }
Johannes Berg99303802009-07-01 21:26:59 +02001805
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001806 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
1807 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
Johannes Berg99303802009-07-01 21:26:59 +02001808
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001809 return 0;
Johannes Berg99303802009-07-01 21:26:59 +02001810}
1811
Johannes Berg21f83582010-12-18 17:20:47 +01001812static int ieee80211_remain_on_channel_hw(struct ieee80211_local *local,
1813 struct net_device *dev,
1814 struct ieee80211_channel *chan,
1815 enum nl80211_channel_type chantype,
1816 unsigned int duration, u64 *cookie)
1817{
1818 int ret;
1819 u32 random_cookie;
1820
1821 lockdep_assert_held(&local->mtx);
1822
1823 if (local->hw_roc_cookie)
1824 return -EBUSY;
1825 /* must be nonzero */
1826 random_cookie = random32() | 1;
1827
1828 *cookie = random_cookie;
1829 local->hw_roc_dev = dev;
1830 local->hw_roc_cookie = random_cookie;
1831 local->hw_roc_channel = chan;
1832 local->hw_roc_channel_type = chantype;
1833 local->hw_roc_duration = duration;
1834 ret = drv_remain_on_channel(local, chan, chantype, duration);
1835 if (ret) {
1836 local->hw_roc_channel = NULL;
1837 local->hw_roc_cookie = 0;
1838 }
1839
1840 return ret;
1841}
1842
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001843static int ieee80211_remain_on_channel(struct wiphy *wiphy,
1844 struct net_device *dev,
1845 struct ieee80211_channel *chan,
1846 enum nl80211_channel_type channel_type,
1847 unsigned int duration,
1848 u64 *cookie)
1849{
1850 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01001851 struct ieee80211_local *local = sdata->local;
1852
1853 if (local->ops->remain_on_channel) {
1854 int ret;
1855
1856 mutex_lock(&local->mtx);
1857 ret = ieee80211_remain_on_channel_hw(local, dev,
1858 chan, channel_type,
1859 duration, cookie);
Johannes Berg90fc4b32010-12-18 17:20:48 +01001860 local->hw_roc_for_tx = false;
Johannes Berg21f83582010-12-18 17:20:47 +01001861 mutex_unlock(&local->mtx);
1862
1863 return ret;
1864 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001865
1866 return ieee80211_wk_remain_on_channel(sdata, chan, channel_type,
1867 duration, cookie);
1868}
1869
Johannes Berg21f83582010-12-18 17:20:47 +01001870static int ieee80211_cancel_remain_on_channel_hw(struct ieee80211_local *local,
1871 u64 cookie)
1872{
1873 int ret;
1874
1875 lockdep_assert_held(&local->mtx);
1876
1877 if (local->hw_roc_cookie != cookie)
1878 return -ENOENT;
1879
1880 ret = drv_cancel_remain_on_channel(local);
1881 if (ret)
1882 return ret;
1883
1884 local->hw_roc_cookie = 0;
1885 local->hw_roc_channel = NULL;
1886
1887 ieee80211_recalc_idle(local);
1888
1889 return 0;
1890}
1891
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001892static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
1893 struct net_device *dev,
1894 u64 cookie)
1895{
1896 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg21f83582010-12-18 17:20:47 +01001897 struct ieee80211_local *local = sdata->local;
1898
1899 if (local->ops->cancel_remain_on_channel) {
1900 int ret;
1901
1902 mutex_lock(&local->mtx);
1903 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
1904 mutex_unlock(&local->mtx);
1905
1906 return ret;
1907 }
Johannes Bergb8bc4b02009-12-23 13:15:42 +01001908
1909 return ieee80211_wk_cancel_remain_on_channel(sdata, cookie);
1910}
1911
Johannes Bergf30221e2010-11-25 10:02:30 +01001912static enum work_done_result
1913ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb)
1914{
1915 /*
1916 * Use the data embedded in the work struct for reporting
1917 * here so if the driver mangled the SKB before dropping
1918 * it (which is the only way we really should get here)
1919 * then we don't report mangled data.
1920 *
1921 * If there was no wait time, then by the time we get here
1922 * the driver will likely not have reported the status yet,
1923 * so in that case userspace will have to deal with it.
1924 */
1925
Johannes Berg28a1bcd2011-10-04 18:27:10 +02001926 if (wk->offchan_tx.wait && !wk->offchan_tx.status)
Johannes Bergf30221e2010-11-25 10:02:30 +01001927 cfg80211_mgmt_tx_status(wk->sdata->dev,
1928 (unsigned long) wk->offchan_tx.frame,
1929 wk->ie, wk->ie_len, false, GFP_KERNEL);
1930
1931 return WORK_DONE_DESTROY;
1932}
1933
Johannes Berg2e161f72010-08-12 15:38:38 +02001934static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01001935 struct ieee80211_channel *chan, bool offchan,
Johannes Berg2e161f72010-08-12 15:38:38 +02001936 enum nl80211_channel_type channel_type,
Johannes Bergf7ca38d2010-11-25 10:02:29 +01001937 bool channel_type_valid, unsigned int wait,
Rajkumar Manoharane9f935e2011-09-25 14:53:30 +05301938 const u8 *buf, size_t len, bool no_cck,
1939 u64 *cookie)
Jouni Malinen026331c2010-02-15 12:53:10 +02001940{
Johannes Berg9d38d852010-06-09 17:20:33 +02001941 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1942 struct ieee80211_local *local = sdata->local;
1943 struct sk_buff *skb;
1944 struct sta_info *sta;
Johannes Bergf30221e2010-11-25 10:02:30 +01001945 struct ieee80211_work *wk;
Johannes Berg9d38d852010-06-09 17:20:33 +02001946 const struct ieee80211_mgmt *mgmt = (void *)buf;
1947 u32 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
1948 IEEE80211_TX_CTL_REQ_TX_STATUS;
Johannes Bergf30221e2010-11-25 10:02:30 +01001949 bool is_offchan = false;
Johannes Bergf7ca38d2010-11-25 10:02:29 +01001950
Johannes Berg9d38d852010-06-09 17:20:33 +02001951 /* Check that we are on the requested channel for transmission */
1952 if (chan != local->tmp_channel &&
1953 chan != local->oper_channel)
Johannes Bergf30221e2010-11-25 10:02:30 +01001954 is_offchan = true;
Johannes Berg9d38d852010-06-09 17:20:33 +02001955 if (channel_type_valid &&
1956 (channel_type != local->tmp_channel_type &&
1957 channel_type != local->_oper_channel_type))
Johannes Bergf30221e2010-11-25 10:02:30 +01001958 is_offchan = true;
1959
Johannes Berg21f83582010-12-18 17:20:47 +01001960 if (chan == local->hw_roc_channel) {
1961 /* TODO: check channel type? */
1962 is_offchan = false;
1963 flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
1964 }
1965
Rajkumar Manoharanaad14ce2011-09-25 14:53:31 +05301966 if (no_cck)
1967 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
1968
Johannes Bergf30221e2010-11-25 10:02:30 +01001969 if (is_offchan && !offchan)
Johannes Berg9d38d852010-06-09 17:20:33 +02001970 return -EBUSY;
1971
1972 switch (sdata->vif.type) {
1973 case NL80211_IFTYPE_ADHOC:
Johannes Berg663fcaf2010-09-30 21:06:09 +02001974 case NL80211_IFTYPE_AP:
1975 case NL80211_IFTYPE_AP_VLAN:
1976 case NL80211_IFTYPE_P2P_GO:
Javier Cardonac7108a72010-12-16 17:37:50 -08001977 case NL80211_IFTYPE_MESH_POINT:
Johannes Berg663fcaf2010-09-30 21:06:09 +02001978 if (!ieee80211_is_action(mgmt->frame_control) ||
1979 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
Johannes Berg9d38d852010-06-09 17:20:33 +02001980 break;
1981 rcu_read_lock();
1982 sta = sta_info_get(sdata, mgmt->da);
1983 rcu_read_unlock();
1984 if (!sta)
1985 return -ENOLINK;
1986 break;
1987 case NL80211_IFTYPE_STATION:
Johannes Berg663fcaf2010-09-30 21:06:09 +02001988 case NL80211_IFTYPE_P2P_CLIENT:
Johannes Berg9d38d852010-06-09 17:20:33 +02001989 break;
1990 default:
1991 return -EOPNOTSUPP;
1992 }
1993
1994 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
1995 if (!skb)
1996 return -ENOMEM;
1997 skb_reserve(skb, local->hw.extra_tx_headroom);
1998
1999 memcpy(skb_put(skb, len), buf, len);
2000
2001 IEEE80211_SKB_CB(skb)->flags = flags;
2002
2003 skb->dev = sdata->dev;
Johannes Berg9d38d852010-06-09 17:20:33 +02002004
2005 *cookie = (unsigned long) skb;
Johannes Bergf30221e2010-11-25 10:02:30 +01002006
Johannes Berg90fc4b32010-12-18 17:20:48 +01002007 if (is_offchan && local->ops->remain_on_channel) {
2008 unsigned int duration;
2009 int ret;
2010
2011 mutex_lock(&local->mtx);
2012 /*
2013 * If the duration is zero, then the driver
2014 * wouldn't actually do anything. Set it to
2015 * 100 for now.
2016 *
2017 * TODO: cancel the off-channel operation
2018 * when we get the SKB's TX status and
2019 * the wait time was zero before.
2020 */
2021 duration = 100;
2022 if (wait)
2023 duration = wait;
2024 ret = ieee80211_remain_on_channel_hw(local, dev, chan,
2025 channel_type,
2026 duration, cookie);
2027 if (ret) {
2028 kfree_skb(skb);
2029 mutex_unlock(&local->mtx);
2030 return ret;
2031 }
2032
2033 local->hw_roc_for_tx = true;
2034 local->hw_roc_duration = wait;
2035
2036 /*
2037 * queue up frame for transmission after
2038 * ieee80211_ready_on_channel call
2039 */
2040
2041 /* modify cookie to prevent API mismatches */
2042 *cookie ^= 2;
2043 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
2044 local->hw_roc_skb = skb;
Johannes Berg4334ec82011-02-02 16:58:06 +01002045 local->hw_roc_skb_for_status = skb;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002046 mutex_unlock(&local->mtx);
2047
2048 return 0;
2049 }
2050
Johannes Bergf30221e2010-11-25 10:02:30 +01002051 /*
2052 * Can transmit right away if the channel was the
2053 * right one and there's no wait involved... If a
2054 * wait is involved, we might otherwise not be on
2055 * the right channel for long enough!
2056 */
2057 if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) {
2058 ieee80211_tx_skb(sdata, skb);
2059 return 0;
2060 }
2061
2062 wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL);
2063 if (!wk) {
2064 kfree_skb(skb);
2065 return -ENOMEM;
2066 }
2067
2068 wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
2069 wk->chan = chan;
Ben Greear4d51e142011-02-07 13:44:34 -08002070 wk->chan_type = channel_type;
Johannes Bergf30221e2010-11-25 10:02:30 +01002071 wk->sdata = sdata;
2072 wk->done = ieee80211_offchan_tx_done;
2073 wk->offchan_tx.frame = skb;
2074 wk->offchan_tx.wait = wait;
2075 wk->ie_len = len;
2076 memcpy(wk->ie, buf, len);
2077
2078 ieee80211_add_work(wk);
Johannes Berg9d38d852010-06-09 17:20:33 +02002079 return 0;
Jouni Malinen026331c2010-02-15 12:53:10 +02002080}
2081
Johannes Bergf30221e2010-11-25 10:02:30 +01002082static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2083 struct net_device *dev,
2084 u64 cookie)
2085{
2086 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2087 struct ieee80211_local *local = sdata->local;
2088 struct ieee80211_work *wk;
2089 int ret = -ENOENT;
2090
2091 mutex_lock(&local->mtx);
Johannes Berg90fc4b32010-12-18 17:20:48 +01002092
2093 if (local->ops->cancel_remain_on_channel) {
2094 cookie ^= 2;
2095 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
2096
2097 if (ret == 0) {
2098 kfree_skb(local->hw_roc_skb);
2099 local->hw_roc_skb = NULL;
Johannes Berg4334ec82011-02-02 16:58:06 +01002100 local->hw_roc_skb_for_status = NULL;
Johannes Berg90fc4b32010-12-18 17:20:48 +01002101 }
2102
2103 mutex_unlock(&local->mtx);
2104
2105 return ret;
2106 }
2107
Johannes Bergf30221e2010-11-25 10:02:30 +01002108 list_for_each_entry(wk, &local->work_list, list) {
2109 if (wk->sdata != sdata)
2110 continue;
2111
2112 if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
2113 continue;
2114
2115 if (cookie != (unsigned long) wk->offchan_tx.frame)
2116 continue;
2117
2118 wk->timeout = jiffies;
2119
2120 ieee80211_queue_work(&local->hw, &local->work_work);
2121 ret = 0;
2122 break;
2123 }
2124 mutex_unlock(&local->mtx);
2125
2126 return ret;
2127}
2128
Johannes Berg7be50862010-10-13 12:06:24 +02002129static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2130 struct net_device *dev,
2131 u16 frame_type, bool reg)
2132{
2133 struct ieee80211_local *local = wiphy_priv(wiphy);
2134
2135 if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
2136 return;
2137
2138 if (reg)
2139 local->probe_req_reg++;
2140 else
2141 local->probe_req_reg--;
2142
2143 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2144}
2145
Bruno Randolf15d96752010-11-10 12:50:56 +09002146static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
2147{
2148 struct ieee80211_local *local = wiphy_priv(wiphy);
2149
2150 if (local->started)
2151 return -EOPNOTSUPP;
2152
2153 return drv_set_antenna(local, tx_ant, rx_ant);
2154}
2155
2156static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
2157{
2158 struct ieee80211_local *local = wiphy_priv(wiphy);
2159
2160 return drv_get_antenna(local, tx_ant, rx_ant);
2161}
2162
John W. Linville38c09152011-03-07 16:19:18 -05002163static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2164{
2165 struct ieee80211_local *local = wiphy_priv(wiphy);
2166
2167 return drv_set_ringparam(local, tx, rx);
2168}
2169
2170static void ieee80211_get_ringparam(struct wiphy *wiphy,
2171 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2172{
2173 struct ieee80211_local *local = wiphy_priv(wiphy);
2174
2175 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2176}
2177
Johannes Bergc68f4b82011-07-05 16:35:41 +02002178static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2179 struct net_device *dev,
2180 struct cfg80211_gtk_rekey_data *data)
2181{
2182 struct ieee80211_local *local = wiphy_priv(wiphy);
2183 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2184
2185 if (!local->ops->set_rekey_data)
2186 return -EOPNOTSUPP;
2187
2188 drv_set_rekey_data(local, sdata, data);
2189
2190 return 0;
2191}
2192
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002193static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
2194{
2195 u8 *pos = (void *)skb_put(skb, 7);
2196
2197 *pos++ = WLAN_EID_EXT_CAPABILITY;
2198 *pos++ = 5; /* len */
2199 *pos++ = 0x0;
2200 *pos++ = 0x0;
2201 *pos++ = 0x0;
2202 *pos++ = 0x0;
2203 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
2204}
2205
2206static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
2207{
2208 struct ieee80211_local *local = sdata->local;
2209 u16 capab;
2210
2211 capab = 0;
2212 if (local->oper_channel->band != IEEE80211_BAND_2GHZ)
2213 return capab;
2214
2215 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
2216 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
2217 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
2218 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
2219
2220 return capab;
2221}
2222
2223static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
2224 u8 *peer, u8 *bssid)
2225{
2226 struct ieee80211_tdls_lnkie *lnkid;
2227
2228 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
2229
2230 lnkid->ie_type = WLAN_EID_LINK_ID;
2231 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
2232
2233 memcpy(lnkid->bssid, bssid, ETH_ALEN);
2234 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
2235 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
2236}
2237
2238static int
2239ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2240 u8 *peer, u8 action_code, u8 dialog_token,
2241 u16 status_code, struct sk_buff *skb)
2242{
2243 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2244 struct ieee80211_tdls_data *tf;
2245
2246 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
2247
2248 memcpy(tf->da, peer, ETH_ALEN);
2249 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
2250 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
2251 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
2252
2253 switch (action_code) {
2254 case WLAN_TDLS_SETUP_REQUEST:
2255 tf->category = WLAN_CATEGORY_TDLS;
2256 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
2257
2258 skb_put(skb, sizeof(tf->u.setup_req));
2259 tf->u.setup_req.dialog_token = dialog_token;
2260 tf->u.setup_req.capability =
2261 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2262
2263 ieee80211_add_srates_ie(&sdata->vif, skb);
2264 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2265 ieee80211_tdls_add_ext_capab(skb);
2266 break;
2267 case WLAN_TDLS_SETUP_RESPONSE:
2268 tf->category = WLAN_CATEGORY_TDLS;
2269 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
2270
2271 skb_put(skb, sizeof(tf->u.setup_resp));
2272 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
2273 tf->u.setup_resp.dialog_token = dialog_token;
2274 tf->u.setup_resp.capability =
2275 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2276
2277 ieee80211_add_srates_ie(&sdata->vif, skb);
2278 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2279 ieee80211_tdls_add_ext_capab(skb);
2280 break;
2281 case WLAN_TDLS_SETUP_CONFIRM:
2282 tf->category = WLAN_CATEGORY_TDLS;
2283 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
2284
2285 skb_put(skb, sizeof(tf->u.setup_cfm));
2286 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
2287 tf->u.setup_cfm.dialog_token = dialog_token;
2288 break;
2289 case WLAN_TDLS_TEARDOWN:
2290 tf->category = WLAN_CATEGORY_TDLS;
2291 tf->action_code = WLAN_TDLS_TEARDOWN;
2292
2293 skb_put(skb, sizeof(tf->u.teardown));
2294 tf->u.teardown.reason_code = cpu_to_le16(status_code);
2295 break;
2296 case WLAN_TDLS_DISCOVERY_REQUEST:
2297 tf->category = WLAN_CATEGORY_TDLS;
2298 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
2299
2300 skb_put(skb, sizeof(tf->u.discover_req));
2301 tf->u.discover_req.dialog_token = dialog_token;
2302 break;
2303 default:
2304 return -EINVAL;
2305 }
2306
2307 return 0;
2308}
2309
2310static int
2311ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2312 u8 *peer, u8 action_code, u8 dialog_token,
2313 u16 status_code, struct sk_buff *skb)
2314{
2315 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2316 struct ieee80211_mgmt *mgmt;
2317
2318 mgmt = (void *)skb_put(skb, 24);
2319 memset(mgmt, 0, 24);
2320 memcpy(mgmt->da, peer, ETH_ALEN);
2321 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
2322 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
2323
2324 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2325 IEEE80211_STYPE_ACTION);
2326
2327 switch (action_code) {
2328 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2329 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
2330 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
2331 mgmt->u.action.u.tdls_discover_resp.action_code =
2332 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
2333 mgmt->u.action.u.tdls_discover_resp.dialog_token =
2334 dialog_token;
2335 mgmt->u.action.u.tdls_discover_resp.capability =
2336 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2337
2338 ieee80211_add_srates_ie(&sdata->vif, skb);
2339 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2340 ieee80211_tdls_add_ext_capab(skb);
2341 break;
2342 default:
2343 return -EINVAL;
2344 }
2345
2346 return 0;
2347}
2348
2349static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2350 u8 *peer, u8 action_code, u8 dialog_token,
2351 u16 status_code, const u8 *extra_ies,
2352 size_t extra_ies_len)
2353{
2354 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2355 struct ieee80211_local *local = sdata->local;
2356 struct ieee80211_tx_info *info;
2357 struct sk_buff *skb = NULL;
2358 bool send_direct;
2359 int ret;
2360
2361 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2362 return -ENOTSUPP;
2363
2364 /* make sure we are in managed mode, and associated */
2365 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
2366 !sdata->u.mgd.associated)
2367 return -EINVAL;
2368
2369#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2370 printk(KERN_DEBUG "TDLS mgmt action %d peer %pM\n", action_code, peer);
2371#endif
2372
2373 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
2374 max(sizeof(struct ieee80211_mgmt),
2375 sizeof(struct ieee80211_tdls_data)) +
2376 50 + /* supported rates */
2377 7 + /* ext capab */
2378 extra_ies_len +
2379 sizeof(struct ieee80211_tdls_lnkie));
2380 if (!skb)
2381 return -ENOMEM;
2382
2383 info = IEEE80211_SKB_CB(skb);
2384 skb_reserve(skb, local->hw.extra_tx_headroom);
2385
2386 switch (action_code) {
2387 case WLAN_TDLS_SETUP_REQUEST:
2388 case WLAN_TDLS_SETUP_RESPONSE:
2389 case WLAN_TDLS_SETUP_CONFIRM:
2390 case WLAN_TDLS_TEARDOWN:
2391 case WLAN_TDLS_DISCOVERY_REQUEST:
2392 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
2393 action_code, dialog_token,
2394 status_code, skb);
2395 send_direct = false;
2396 break;
2397 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2398 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
2399 dialog_token, status_code,
2400 skb);
2401 send_direct = true;
2402 break;
2403 default:
2404 ret = -ENOTSUPP;
2405 break;
2406 }
2407
2408 if (ret < 0)
2409 goto fail;
2410
2411 if (extra_ies_len)
2412 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
2413
2414 /* the TDLS link IE is always added last */
2415 switch (action_code) {
2416 case WLAN_TDLS_SETUP_REQUEST:
2417 case WLAN_TDLS_SETUP_CONFIRM:
2418 case WLAN_TDLS_TEARDOWN:
2419 case WLAN_TDLS_DISCOVERY_REQUEST:
2420 /* we are the initiator */
2421 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
2422 sdata->u.mgd.bssid);
2423 break;
2424 case WLAN_TDLS_SETUP_RESPONSE:
2425 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2426 /* we are the responder */
2427 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
2428 sdata->u.mgd.bssid);
2429 break;
2430 default:
2431 ret = -ENOTSUPP;
2432 goto fail;
2433 }
2434
2435 if (send_direct) {
2436 ieee80211_tx_skb(sdata, skb);
2437 return 0;
2438 }
2439
2440 /*
2441 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
2442 * we should default to AC_VI.
2443 */
2444 switch (action_code) {
2445 case WLAN_TDLS_SETUP_REQUEST:
2446 case WLAN_TDLS_SETUP_RESPONSE:
2447 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
2448 skb->priority = 2;
2449 break;
2450 default:
2451 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
2452 skb->priority = 5;
2453 break;
2454 }
2455
2456 /* disable bottom halves when entering the Tx path */
2457 local_bh_disable();
2458 ret = ieee80211_subif_start_xmit(skb, dev);
2459 local_bh_enable();
2460
2461 return ret;
2462
2463fail:
2464 dev_kfree_skb(skb);
2465 return ret;
2466}
2467
2468static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2469 u8 *peer, enum nl80211_tdls_operation oper)
2470{
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002471 struct sta_info *sta;
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002472 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2473
2474 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2475 return -ENOTSUPP;
2476
2477 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2478 return -EINVAL;
2479
2480#ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2481 printk(KERN_DEBUG "TDLS oper %d peer %pM\n", oper, peer);
2482#endif
2483
2484 switch (oper) {
2485 case NL80211_TDLS_ENABLE_LINK:
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002486 rcu_read_lock();
2487 sta = sta_info_get(sdata, peer);
2488 if (!sta) {
2489 rcu_read_unlock();
2490 return -ENOLINK;
2491 }
2492
Johannes Bergc2c98fd2011-09-29 16:04:36 +02002493 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
Arik Nemtsov941c93c2011-09-28 14:12:54 +03002494 rcu_read_unlock();
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002495 break;
2496 case NL80211_TDLS_DISABLE_LINK:
2497 return sta_info_destroy_addr(sdata, peer);
2498 case NL80211_TDLS_TEARDOWN:
2499 case NL80211_TDLS_SETUP:
2500 case NL80211_TDLS_DISCOVERY_REQ:
2501 /* We don't support in-driver setup/teardown/discovery */
2502 return -ENOTSUPP;
2503 default:
2504 return -ENOTSUPP;
2505 }
2506
2507 return 0;
2508}
2509
Jiri Bencf0706e82007-05-05 11:45:53 -07002510struct cfg80211_ops mac80211_config_ops = {
2511 .add_virtual_intf = ieee80211_add_iface,
2512 .del_virtual_intf = ieee80211_del_iface,
Johannes Berg42613db2007-09-28 21:52:27 +02002513 .change_virtual_intf = ieee80211_change_iface,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002514 .add_key = ieee80211_add_key,
2515 .del_key = ieee80211_del_key,
Johannes Berg62da92f2007-12-19 02:03:31 +01002516 .get_key = ieee80211_get_key,
Johannes Berge8cbb4c2007-12-19 02:03:30 +01002517 .set_default_key = ieee80211_config_default_key,
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +02002518 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
Johannes Berg5dfdaf52007-12-19 02:03:33 +01002519 .add_beacon = ieee80211_add_beacon,
2520 .set_beacon = ieee80211_set_beacon,
2521 .del_beacon = ieee80211_del_beacon,
Johannes Berg4fd69312007-12-19 02:03:35 +01002522 .add_station = ieee80211_add_station,
2523 .del_station = ieee80211_del_station,
2524 .change_station = ieee80211_change_station,
Johannes Berg7bbdd2d2007-12-19 02:03:37 +01002525 .get_station = ieee80211_get_station,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002526 .dump_station = ieee80211_dump_station,
Holger Schurig12897232010-04-19 10:23:57 +02002527 .dump_survey = ieee80211_dump_survey,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002528#ifdef CONFIG_MAC80211_MESH
2529 .add_mpath = ieee80211_add_mpath,
2530 .del_mpath = ieee80211_del_mpath,
2531 .change_mpath = ieee80211_change_mpath,
2532 .get_mpath = ieee80211_get_mpath,
2533 .dump_mpath = ieee80211_dump_mpath,
Javier Cardona24bdd9f2010-12-16 17:37:48 -08002534 .update_mesh_config = ieee80211_update_mesh_config,
2535 .get_mesh_config = ieee80211_get_mesh_config,
Johannes Berg29cbe682010-12-03 09:20:44 +01002536 .join_mesh = ieee80211_join_mesh,
2537 .leave_mesh = ieee80211_leave_mesh,
Luis Carlos Coboc5dd9c22008-02-23 15:17:17 +01002538#endif
Jouni Malinen9f1ba902008-08-07 20:07:01 +03002539 .change_bss = ieee80211_change_bss,
Jouni Malinen31888482008-10-30 16:59:24 +02002540 .set_txq_params = ieee80211_set_txq_params,
Jouni Malinen72bdcf32008-11-26 16:15:24 +02002541 .set_channel = ieee80211_set_channel,
Bob Copeland665af4f2009-01-19 11:20:53 -05002542 .suspend = ieee80211_suspend,
2543 .resume = ieee80211_resume,
Johannes Berg2a519312009-02-10 21:25:55 +01002544 .scan = ieee80211_scan,
Luciano Coelho79f460c2011-05-11 17:09:36 +03002545 .sched_scan_start = ieee80211_sched_scan_start,
2546 .sched_scan_stop = ieee80211_sched_scan_stop,
Jouni Malinen636a5d32009-03-19 13:39:22 +02002547 .auth = ieee80211_auth,
2548 .assoc = ieee80211_assoc,
2549 .deauth = ieee80211_deauth,
2550 .disassoc = ieee80211_disassoc,
Johannes Bergaf8cdcd2009-04-19 21:25:43 +02002551 .join_ibss = ieee80211_join_ibss,
2552 .leave_ibss = ieee80211_leave_ibss,
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +02002553 .set_wiphy_params = ieee80211_set_wiphy_params,
Johannes Berg7643a2c2009-06-02 13:01:39 +02002554 .set_tx_power = ieee80211_set_tx_power,
2555 .get_tx_power = ieee80211_get_tx_power,
Johannes Bergab737a42009-07-01 21:26:58 +02002556 .set_wds_peer = ieee80211_set_wds_peer,
Johannes Berg1f87f7d2009-06-02 13:01:41 +02002557 .rfkill_poll = ieee80211_rfkill_poll,
Johannes Bergaff89a92009-07-01 21:26:51 +02002558 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
Wey-Yi Guy71063f02011-05-20 09:05:54 -07002559 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
Johannes Bergbc92afd2009-07-01 21:26:57 +02002560 .set_power_mgmt = ieee80211_set_power_mgmt,
Johannes Berg99303802009-07-01 21:26:59 +02002561 .set_bitrate_mask = ieee80211_set_bitrate_mask,
Johannes Bergb8bc4b02009-12-23 13:15:42 +01002562 .remain_on_channel = ieee80211_remain_on_channel,
2563 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
Johannes Berg2e161f72010-08-12 15:38:38 +02002564 .mgmt_tx = ieee80211_mgmt_tx,
Johannes Bergf30221e2010-11-25 10:02:30 +01002565 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
Juuso Oikarinena97c13c2010-03-23 09:02:34 +02002566 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
Johannes Berg7be50862010-10-13 12:06:24 +02002567 .mgmt_frame_register = ieee80211_mgmt_frame_register,
Bruno Randolf15d96752010-11-10 12:50:56 +09002568 .set_antenna = ieee80211_set_antenna,
2569 .get_antenna = ieee80211_get_antenna,
John W. Linville38c09152011-03-07 16:19:18 -05002570 .set_ringparam = ieee80211_set_ringparam,
2571 .get_ringparam = ieee80211_get_ringparam,
Johannes Bergc68f4b82011-07-05 16:35:41 +02002572 .set_rekey_data = ieee80211_set_rekey_data,
Arik Nemtsovdfe018b2011-09-28 14:12:52 +03002573 .tdls_oper = ieee80211_tdls_oper,
2574 .tdls_mgmt = ieee80211_tdls_mgmt,
Jiri Bencf0706e82007-05-05 11:45:53 -07002575};