Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * mac80211 configuration hooks for cfg80211 |
| 3 | * |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 4 | * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 5 | * |
| 6 | * This file is GPLv2 as found in COPYING. |
| 7 | */ |
| 8 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 9 | #include <linux/ieee80211.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 10 | #include <linux/nl80211.h> |
| 11 | #include <linux/rtnetlink.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 13 | #include <net/net_namespace.h> |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 14 | #include <linux/rcupdate.h> |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 15 | #include <linux/if_ether.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 16 | #include <net/cfg80211.h> |
| 17 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 18 | #include "driver-ops.h" |
Michael Wu | e0eb685 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 19 | #include "cfg.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 20 | #include "rate.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 21 | #include "mesh.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 22 | |
Johannes Berg | f9e10ce | 2010-12-03 09:20:42 +0100 | [diff] [blame] | 23 | static 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 Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 27 | { |
| 28 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 29 | struct net_device *dev; |
| 30 | struct ieee80211_sub_if_data *sdata; |
| 31 | int err; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 32 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 33 | err = ieee80211_if_add(local, name, &dev, type, params); |
Johannes Berg | f9e10ce | 2010-12-03 09:20:42 +0100 | [diff] [blame] | 34 | if (err) |
| 35 | return ERR_PTR(err); |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 36 | |
Johannes Berg | f9e10ce | 2010-12-03 09:20:42 +0100 | [diff] [blame] | 37 | 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 Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Johannes Berg | 463d018 | 2009-07-14 00:33:35 +0200 | [diff] [blame] | 45 | static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 46 | { |
Johannes Berg | 463d018 | 2009-07-14 00:33:35 +0200 | [diff] [blame] | 47 | ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 48 | |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 49 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Johannes Berg | e36d56b | 2009-06-09 21:04:43 +0200 | [diff] [blame] | 52 | static int ieee80211_change_iface(struct wiphy *wiphy, |
| 53 | struct net_device *dev, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 54 | enum nl80211_iftype type, u32 *flags, |
| 55 | struct vif_params *params) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 56 | { |
Johannes Berg | 9607e6b66 | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 57 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 58 | int ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 59 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 60 | ret = ieee80211_if_change_type(sdata, type); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 61 | if (ret) |
| 62 | return ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 63 | |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 64 | if (type == NL80211_IFTYPE_AP_VLAN && |
| 65 | params && params->use_4addr == 0) |
| 66 | rcu_assign_pointer(sdata->u.vlan.sta, NULL); |
| 67 | else if (type == NL80211_IFTYPE_STATION && |
| 68 | params && params->use_4addr >= 0) |
| 69 | sdata->u.mgd.use_4addr = params->use_4addr; |
| 70 | |
Christian Lamparter | 85416a4 | 2010-10-02 13:17:07 +0200 | [diff] [blame] | 71 | 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 Fietkau | f7917af | 2010-04-27 00:26:34 +0200 | [diff] [blame] | 101 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 102 | return 0; |
| 103 | } |
| 104 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 105 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 106 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 107 | struct key_params *params) |
| 108 | { |
Johannes Berg | 26a5845 | 2010-08-27 12:35:55 +0200 | [diff] [blame] | 109 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 110 | struct sta_info *sta = NULL; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 111 | struct ieee80211_key *key; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 112 | int err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 113 | |
Johannes Berg | 26a5845 | 2010-08-27 12:35:55 +0200 | [diff] [blame] | 114 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 115 | return -ENETDOWN; |
| 116 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 117 | /* reject WEP and TKIP keys if WEP failed to initialize */ |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 118 | switch (params->cipher) { |
| 119 | case WLAN_CIPHER_SUITE_WEP40: |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 120 | case WLAN_CIPHER_SUITE_TKIP: |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 121 | case WLAN_CIPHER_SUITE_WEP104: |
| 122 | if (IS_ERR(sdata->local->wep_tx_tfm)) |
| 123 | return -EINVAL; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 124 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 125 | default: |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 126 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 127 | } |
| 128 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 129 | key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, |
| 130 | params->key, params->seq_len, params->seq); |
Ben Hutchings | 1ac62ba | 2010-08-01 17:37:03 +0100 | [diff] [blame] | 131 | if (IS_ERR(key)) |
| 132 | return PTR_ERR(key); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 133 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 134 | if (pairwise) |
| 135 | key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE; |
| 136 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 137 | mutex_lock(&sdata->local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 138 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 139 | if (mac_addr) { |
Thomas Pedersen | ff973af | 2011-05-03 16:57:12 -0700 | [diff] [blame] | 140 | 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 Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 144 | if (!sta) { |
Jouni Malinen | 32162a4 | 2010-07-26 15:52:03 -0700 | [diff] [blame] | 145 | ieee80211_key_free(sdata->local, key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 146 | err = -ENOENT; |
| 147 | goto out_unlock; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 148 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 149 | } |
| 150 | |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 151 | err = ieee80211_key_link(key, sdata, sta); |
| 152 | if (err) |
| 153 | ieee80211_key_free(sdata->local, key); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 154 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 155 | out_unlock: |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 156 | mutex_unlock(&sdata->local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 157 | |
| 158 | return err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 162 | u8 key_idx, bool pairwise, const u8 *mac_addr) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 163 | { |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 164 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 165 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 166 | struct sta_info *sta; |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 167 | struct ieee80211_key *key = NULL; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 168 | int ret; |
| 169 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 170 | mutex_lock(&local->sta_mtx); |
| 171 | mutex_lock(&local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 172 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 173 | if (mac_addr) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 174 | ret = -ENOENT; |
| 175 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 176 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 177 | if (!sta) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 178 | goto out_unlock; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 179 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 180 | if (pairwise) |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 181 | key = key_mtx_dereference(local, sta->ptk); |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 182 | else |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 183 | key = key_mtx_dereference(local, sta->gtk[key_idx]); |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 184 | } else |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 185 | key = key_mtx_dereference(local, sdata->keys[key_idx]); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 186 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 187 | if (!key) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 188 | ret = -ENOENT; |
| 189 | goto out_unlock; |
| 190 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 191 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 192 | __ieee80211_key_free(key); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 193 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 194 | ret = 0; |
| 195 | out_unlock: |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 196 | mutex_unlock(&local->key_mtx); |
| 197 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 198 | |
| 199 | return ret; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 200 | } |
| 201 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 202 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 203 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
| 204 | void *cookie, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 205 | void (*callback)(void *cookie, |
| 206 | struct key_params *params)) |
| 207 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 208 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 209 | struct sta_info *sta = NULL; |
| 210 | u8 seq[6] = {0}; |
| 211 | struct key_params params; |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 212 | struct ieee80211_key *key = NULL; |
Johannes Berg | aba83a0b | 2011-07-06 21:59:39 +0200 | [diff] [blame] | 213 | u64 pn64; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 214 | u32 iv32; |
| 215 | u16 iv16; |
| 216 | int err = -ENOENT; |
| 217 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 218 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 219 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 220 | rcu_read_lock(); |
| 221 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 222 | if (mac_addr) { |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 223 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 224 | if (!sta) |
| 225 | goto out; |
| 226 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 227 | if (pairwise) |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 228 | key = rcu_dereference(sta->ptk); |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 229 | else if (key_idx < NUM_DEFAULT_KEYS) |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 230 | key = rcu_dereference(sta->gtk[key_idx]); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 231 | } else |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 232 | key = rcu_dereference(sdata->keys[key_idx]); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 233 | |
| 234 | if (!key) |
| 235 | goto out; |
| 236 | |
| 237 | memset(¶ms, 0, sizeof(params)); |
| 238 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 239 | params.cipher = key->conf.cipher; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 240 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 241 | switch (key->conf.cipher) { |
| 242 | case WLAN_CIPHER_SUITE_TKIP: |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 243 | iv32 = key->u.tkip.tx.iv32; |
| 244 | iv16 = key->u.tkip.tx.iv16; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 245 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 246 | 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 Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 250 | |
| 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 Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 260 | case WLAN_CIPHER_SUITE_CCMP: |
Johannes Berg | aba83a0b | 2011-07-06 21:59:39 +0200 | [diff] [blame] | 261 | 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 Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 268 | params.seq = seq; |
| 269 | params.seq_len = 6; |
| 270 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 271 | case WLAN_CIPHER_SUITE_AES_CMAC: |
Johannes Berg | 75396ae | 2011-07-06 22:00:35 +0200 | [diff] [blame] | 272 | 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 Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 279 | params.seq = seq; |
| 280 | params.seq_len = 6; |
| 281 | break; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | params.key = key->conf.key; |
| 285 | params.key_len = key->conf.keylen; |
| 286 | |
| 287 | callback(cookie, ¶ms); |
| 288 | err = 0; |
| 289 | |
| 290 | out: |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 291 | rcu_read_unlock(); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 292 | return err; |
| 293 | } |
| 294 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 295 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
| 296 | struct net_device *dev, |
Johannes Berg | dbd2fd6 | 2010-12-09 19:58:59 +0100 | [diff] [blame] | 297 | u8 key_idx, bool uni, |
| 298 | bool multi) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 299 | { |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 300 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 301 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 302 | ieee80211_set_default_key(sdata, key_idx, uni, multi); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 303 | |
| 304 | return 0; |
| 305 | } |
| 306 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 307 | static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, |
| 308 | struct net_device *dev, |
| 309 | u8 key_idx) |
| 310 | { |
Johannes Berg | 66c5242 | 2010-07-22 13:58:51 +0200 | [diff] [blame] | 311 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 312 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 313 | ieee80211_set_default_mgmt_key(sdata, key_idx); |
| 314 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 315 | return 0; |
| 316 | } |
| 317 | |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 318 | static 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 Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 329 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
| 330 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 331 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 332 | struct timespec uptime; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 333 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 334 | sinfo->generation = sdata->local->sta_generation; |
| 335 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 336 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
| 337 | STATION_INFO_RX_BYTES | |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 338 | STATION_INFO_TX_BYTES | |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 339 | STATION_INFO_RX_PACKETS | |
| 340 | STATION_INFO_TX_PACKETS | |
Bruno Randolf | b206b4ef | 2010-10-06 18:34:12 +0900 | [diff] [blame] | 341 | STATION_INFO_TX_RETRIES | |
| 342 | STATION_INFO_TX_FAILED | |
Ben Greear | 5a5c731 | 2010-10-07 16:39:20 -0700 | [diff] [blame] | 343 | STATION_INFO_TX_BITRATE | |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 344 | STATION_INFO_RX_BITRATE | |
Paul Stewart | f4263c9 | 2011-03-31 09:25:41 -0700 | [diff] [blame] | 345 | STATION_INFO_RX_DROP_MISC | |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 346 | STATION_INFO_BSS_PARAM | |
| 347 | STATION_INFO_CONNECTED_TIME; |
| 348 | |
| 349 | do_posix_clock_monotonic_gettime(&uptime); |
| 350 | sinfo->connected_time = uptime.tv_sec - sta->last_connected; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 351 | |
| 352 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
| 353 | sinfo->rx_bytes = sta->rx_bytes; |
| 354 | sinfo->tx_bytes = sta->tx_bytes; |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 355 | sinfo->rx_packets = sta->rx_packets; |
| 356 | sinfo->tx_packets = sta->tx_packets; |
Bruno Randolf | b206b4ef | 2010-10-06 18:34:12 +0900 | [diff] [blame] | 357 | sinfo->tx_retries = sta->tx_retry_count; |
| 358 | sinfo->tx_failed = sta->tx_retry_failed; |
Ben Greear | 5a5c731 | 2010-10-07 16:39:20 -0700 | [diff] [blame] | 359 | sinfo->rx_dropped_misc = sta->rx_dropped; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 360 | |
John W. Linville | 19deffb | 2009-12-08 17:10:13 -0500 | [diff] [blame] | 361 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
| 362 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 363 | sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG; |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 364 | sinfo->signal = (s8)sta->last_signal; |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 365 | sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | sinfo->txrate.flags = 0; |
| 369 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS) |
| 370 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 371 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
| 372 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 373 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI) |
| 374 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 375 | rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 376 | |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 377 | sinfo->rxrate.flags = 0; |
| 378 | if (sta->last_rx_rate_flag & RX_FLAG_HT) |
| 379 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS; |
| 380 | if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) |
| 381 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 382 | if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) |
| 383 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 384 | rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 385 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 386 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 387 | #ifdef CONFIG_MAC80211_MESH |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 388 | sinfo->filled |= STATION_INFO_LLID | |
| 389 | STATION_INFO_PLID | |
| 390 | STATION_INFO_PLINK_STATE; |
| 391 | |
| 392 | sinfo->llid = le16_to_cpu(sta->llid); |
| 393 | sinfo->plid = le16_to_cpu(sta->plid); |
| 394 | sinfo->plink_state = sta->plink_state; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 395 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 396 | } |
Paul Stewart | f4263c9 | 2011-03-31 09:25:41 -0700 | [diff] [blame] | 397 | |
| 398 | sinfo->bss_param.flags = 0; |
| 399 | if (sdata->vif.bss_conf.use_cts_prot) |
| 400 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; |
| 401 | if (sdata->vif.bss_conf.use_short_preamble) |
| 402 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; |
| 403 | if (sdata->vif.bss_conf.use_short_slot) |
| 404 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; |
| 405 | sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period; |
| 406 | sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | |
| 410 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 411 | int idx, u8 *mac, struct station_info *sinfo) |
| 412 | { |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 413 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 414 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 415 | int ret = -ENOENT; |
| 416 | |
| 417 | rcu_read_lock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 418 | |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 419 | sta = sta_info_get_by_idx(sdata, idx); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 420 | if (sta) { |
| 421 | ret = 0; |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 422 | memcpy(mac, sta->sta.addr, ETH_ALEN); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 423 | sta_set_sinfo(sta, sinfo); |
| 424 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 425 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 426 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 427 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 428 | return ret; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 429 | } |
| 430 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 431 | static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, |
| 432 | int idx, struct survey_info *survey) |
| 433 | { |
| 434 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 435 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 436 | return drv_get_survey(local, idx, survey); |
| 437 | } |
| 438 | |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 439 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 440 | u8 *mac, struct station_info *sinfo) |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 441 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 442 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 443 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 444 | int ret = -ENOENT; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 445 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 446 | rcu_read_lock(); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 447 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 448 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 449 | if (sta) { |
| 450 | ret = 0; |
| 451 | sta_set_sinfo(sta, sinfo); |
| 452 | } |
| 453 | |
| 454 | rcu_read_unlock(); |
| 455 | |
| 456 | return ret; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 457 | } |
| 458 | |
Arik Nemtsov | 7827493 | 2011-09-04 11:11:32 +0300 | [diff] [blame] | 459 | static void ieee80211_config_ap_ssid(struct ieee80211_sub_if_data *sdata, |
| 460 | struct beacon_parameters *params) |
| 461 | { |
| 462 | struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; |
| 463 | |
| 464 | bss_conf->ssid_len = params->ssid_len; |
| 465 | |
| 466 | if (params->ssid_len) |
| 467 | memcpy(bss_conf->ssid, params->ssid, params->ssid_len); |
| 468 | |
| 469 | bss_conf->hidden_ssid = |
| 470 | (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); |
| 471 | } |
| 472 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 473 | /* |
| 474 | * This handles both adding a beacon and setting new beacon info |
| 475 | */ |
| 476 | static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, |
| 477 | struct beacon_parameters *params) |
| 478 | { |
| 479 | struct beacon_data *new, *old; |
| 480 | int new_head_len, new_tail_len; |
| 481 | int size; |
| 482 | int err = -EINVAL; |
| 483 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 484 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 485 | |
| 486 | /* head must not be zero-length */ |
| 487 | if (params->head && !params->head_len) |
| 488 | return -EINVAL; |
| 489 | |
| 490 | /* |
| 491 | * This is a kludge. beacon interval should really be part |
| 492 | * of the beacon information. |
| 493 | */ |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 494 | if (params->interval && |
| 495 | (sdata->vif.bss_conf.beacon_int != params->interval)) { |
| 496 | sdata->vif.bss_conf.beacon_int = params->interval; |
| 497 | ieee80211_bss_info_change_notify(sdata, |
| 498 | BSS_CHANGED_BEACON_INT); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | /* Need to have a beacon head if we don't have one yet */ |
| 502 | if (!params->head && !old) |
| 503 | return err; |
| 504 | |
| 505 | /* sorry, no way to start beaconing without dtim period */ |
| 506 | if (!params->dtim_period && !old) |
| 507 | return err; |
| 508 | |
| 509 | /* new or old head? */ |
| 510 | if (params->head) |
| 511 | new_head_len = params->head_len; |
| 512 | else |
| 513 | new_head_len = old->head_len; |
| 514 | |
| 515 | /* new or old tail? */ |
| 516 | if (params->tail || !old) |
| 517 | /* params->tail_len will be zero for !params->tail */ |
| 518 | new_tail_len = params->tail_len; |
| 519 | else |
| 520 | new_tail_len = old->tail_len; |
| 521 | |
| 522 | size = sizeof(*new) + new_head_len + new_tail_len; |
| 523 | |
| 524 | new = kzalloc(size, GFP_KERNEL); |
| 525 | if (!new) |
| 526 | return -ENOMEM; |
| 527 | |
| 528 | /* start filling the new info now */ |
| 529 | |
| 530 | /* new or old dtim period? */ |
| 531 | if (params->dtim_period) |
| 532 | new->dtim_period = params->dtim_period; |
| 533 | else |
| 534 | new->dtim_period = old->dtim_period; |
| 535 | |
| 536 | /* |
| 537 | * pointers go into the block we allocated, |
| 538 | * memory is | beacon_data | head | tail | |
| 539 | */ |
| 540 | new->head = ((u8 *) new) + sizeof(*new); |
| 541 | new->tail = new->head + new_head_len; |
| 542 | new->head_len = new_head_len; |
| 543 | new->tail_len = new_tail_len; |
| 544 | |
| 545 | /* copy in head */ |
| 546 | if (params->head) |
| 547 | memcpy(new->head, params->head, new_head_len); |
| 548 | else |
| 549 | memcpy(new->head, old->head, new_head_len); |
| 550 | |
| 551 | /* copy in optional tail */ |
| 552 | if (params->tail) |
| 553 | memcpy(new->tail, params->tail, new_tail_len); |
| 554 | else |
| 555 | if (old) |
| 556 | memcpy(new->tail, old->tail, new_tail_len); |
| 557 | |
Johannes Berg | 19885c4 | 2010-02-05 11:45:06 +0100 | [diff] [blame] | 558 | sdata->vif.bss_conf.dtim_period = new->dtim_period; |
| 559 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 560 | rcu_assign_pointer(sdata->u.ap.beacon, new); |
| 561 | |
| 562 | synchronize_rcu(); |
| 563 | |
| 564 | kfree(old); |
| 565 | |
Arik Nemtsov | 7827493 | 2011-09-04 11:11:32 +0300 | [diff] [blame] | 566 | ieee80211_config_ap_ssid(sdata, params); |
| 567 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 568 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | |
Arik Nemtsov | 7827493 | 2011-09-04 11:11:32 +0300 | [diff] [blame] | 569 | BSS_CHANGED_BEACON | |
| 570 | BSS_CHANGED_SSID); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 571 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 575 | struct beacon_parameters *params) |
| 576 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 577 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 578 | struct beacon_data *old; |
| 579 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 580 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 581 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 582 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 583 | if (old) |
| 584 | return -EALREADY; |
| 585 | |
| 586 | return ieee80211_config_beacon(sdata, params); |
| 587 | } |
| 588 | |
| 589 | static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 590 | struct beacon_parameters *params) |
| 591 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 592 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 593 | struct beacon_data *old; |
| 594 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 595 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 596 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 597 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 598 | if (!old) |
| 599 | return -ENOENT; |
| 600 | |
| 601 | return ieee80211_config_beacon(sdata, params); |
| 602 | } |
| 603 | |
| 604 | static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) |
| 605 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 606 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 607 | struct beacon_data *old; |
| 608 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 609 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 610 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 611 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 612 | if (!old) |
| 613 | return -ENOENT; |
| 614 | |
| 615 | rcu_assign_pointer(sdata->u.ap.beacon, NULL); |
| 616 | synchronize_rcu(); |
| 617 | kfree(old); |
| 618 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 619 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
| 620 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 621 | } |
| 622 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 623 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
| 624 | struct iapp_layer2_update { |
| 625 | u8 da[ETH_ALEN]; /* broadcast */ |
| 626 | u8 sa[ETH_ALEN]; /* STA addr */ |
| 627 | __be16 len; /* 6 */ |
| 628 | u8 dsap; /* 0 */ |
| 629 | u8 ssap; /* 0 */ |
| 630 | u8 control; |
| 631 | u8 xid_info[3]; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 632 | } __packed; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 633 | |
| 634 | static void ieee80211_send_layer2_update(struct sta_info *sta) |
| 635 | { |
| 636 | struct iapp_layer2_update *msg; |
| 637 | struct sk_buff *skb; |
| 638 | |
| 639 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 |
| 640 | * bridge devices */ |
| 641 | |
| 642 | skb = dev_alloc_skb(sizeof(*msg)); |
| 643 | if (!skb) |
| 644 | return; |
| 645 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); |
| 646 | |
| 647 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) |
| 648 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ |
| 649 | |
| 650 | memset(msg->da, 0xff, ETH_ALEN); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 651 | memcpy(msg->sa, sta->sta.addr, ETH_ALEN); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 652 | msg->len = htons(6); |
| 653 | msg->dsap = 0; |
| 654 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ |
| 655 | msg->control = 0xaf; /* XID response lsb.1111F101. |
| 656 | * F=0 (no poll command; unsolicited frame) */ |
| 657 | msg->xid_info[0] = 0x81; /* XID format identifier */ |
| 658 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ |
| 659 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ |
| 660 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 661 | skb->dev = sta->sdata->dev; |
| 662 | skb->protocol = eth_type_trans(skb, sta->sdata->dev); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 663 | memset(skb->cb, 0, sizeof(skb->cb)); |
John W. Linville | 06ee1c2 | 2010-07-19 11:52:59 -0400 | [diff] [blame] | 664 | netif_rx_ni(skb); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | static void sta_apply_parameters(struct ieee80211_local *local, |
| 668 | struct sta_info *sta, |
| 669 | struct station_parameters *params) |
| 670 | { |
Johannes Berg | f5521b1 | 2010-09-14 22:06:53 +0200 | [diff] [blame] | 671 | unsigned long flags; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 672 | u32 rates; |
| 673 | int i, j; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 674 | struct ieee80211_supported_band *sband; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 675 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 676 | u32 mask, set; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 677 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 678 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
| 679 | |
Johannes Berg | f5521b1 | 2010-09-14 22:06:53 +0200 | [diff] [blame] | 680 | spin_lock_irqsave(&sta->flaglock, flags); |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 681 | mask = params->sta_flags_mask; |
| 682 | set = params->sta_flags_set; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 683 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 684 | if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 685 | sta->flags &= ~WLAN_STA_AUTHORIZED; |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 686 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 687 | sta->flags |= WLAN_STA_AUTHORIZED; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 688 | } |
| 689 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 690 | if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { |
| 691 | sta->flags &= ~WLAN_STA_SHORT_PREAMBLE; |
| 692 | if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) |
| 693 | sta->flags |= WLAN_STA_SHORT_PREAMBLE; |
| 694 | } |
| 695 | |
| 696 | if (mask & BIT(NL80211_STA_FLAG_WME)) { |
| 697 | sta->flags &= ~WLAN_STA_WME; |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 698 | sta->sta.wme = false; |
| 699 | if (set & BIT(NL80211_STA_FLAG_WME)) { |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 700 | sta->flags |= WLAN_STA_WME; |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 701 | sta->sta.wme = true; |
| 702 | } |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | if (mask & BIT(NL80211_STA_FLAG_MFP)) { |
| 706 | sta->flags &= ~WLAN_STA_MFP; |
| 707 | if (set & BIT(NL80211_STA_FLAG_MFP)) |
| 708 | sta->flags |= WLAN_STA_MFP; |
| 709 | } |
Javier Cardona | b39c48f | 2011-04-07 15:08:30 -0700 | [diff] [blame] | 710 | |
| 711 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) { |
| 712 | sta->flags &= ~WLAN_STA_AUTH; |
| 713 | if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) |
| 714 | sta->flags |= WLAN_STA_AUTH; |
| 715 | } |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame^] | 716 | |
| 717 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 718 | sta->flags &= ~WLAN_STA_TDLS_PEER; |
| 719 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) |
| 720 | sta->flags |= WLAN_STA_TDLS_PEER; |
| 721 | } |
Johannes Berg | f5521b1 | 2010-09-14 22:06:53 +0200 | [diff] [blame] | 722 | spin_unlock_irqrestore(&sta->flaglock, flags); |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 723 | |
Johannes Berg | 3b9ce80 | 2011-09-27 20:56:12 +0200 | [diff] [blame] | 724 | if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) { |
| 725 | sta->sta.uapsd_queues = params->uapsd_queues; |
| 726 | sta->sta.max_sp = params->max_sp; |
| 727 | } |
Eliad Peller | 9533b4a | 2011-08-23 14:37:47 +0300 | [diff] [blame] | 728 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 729 | /* |
Johannes Berg | 51b50fb | 2009-05-24 16:42:30 +0200 | [diff] [blame] | 730 | * cfg80211 validates this (1-2007) and allows setting the AID |
| 731 | * only when creating a new station entry |
| 732 | */ |
| 733 | if (params->aid) |
| 734 | sta->sta.aid = params->aid; |
| 735 | |
| 736 | /* |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 737 | * FIXME: updating the following information is racy when this |
| 738 | * function is called from ieee80211_change_station(). |
| 739 | * However, all this information should be static so |
| 740 | * maybe we should just reject attemps to change it. |
| 741 | */ |
| 742 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 743 | if (params->listen_interval >= 0) |
| 744 | sta->listen_interval = params->listen_interval; |
| 745 | |
| 746 | if (params->supported_rates) { |
| 747 | rates = 0; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 748 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 749 | for (i = 0; i < params->supported_rates_len; i++) { |
| 750 | int rate = (params->supported_rates[i] & 0x7f) * 5; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 751 | for (j = 0; j < sband->n_bitrates; j++) { |
| 752 | if (sband->bitrates[j].bitrate == rate) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 753 | rates |= BIT(j); |
| 754 | } |
| 755 | } |
Johannes Berg | 323ce79 | 2008-09-11 02:45:11 +0200 | [diff] [blame] | 756 | sta->sta.supp_rates[local->oper_channel->band] = rates; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 757 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 758 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 759 | if (params->ht_capa) |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 760 | ieee80211_ht_cap_ie_to_sta_ht_cap(sband, |
| 761 | params->ht_capa, |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 762 | &sta->sta.ht_cap); |
Jouni Malinen | 36aedc9 | 2008-08-25 11:58:58 +0300 | [diff] [blame] | 763 | |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 764 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Yogesh Ashok Powar | 4daf50f | 2011-05-12 09:32:17 -0400 | [diff] [blame] | 765 | #ifdef CONFIG_MAC80211_MESH |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 766 | if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) |
| 767 | switch (params->plink_state) { |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 768 | case NL80211_PLINK_LISTEN: |
| 769 | case NL80211_PLINK_ESTAB: |
| 770 | case NL80211_PLINK_BLOCKED: |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 771 | sta->plink_state = params->plink_state; |
| 772 | break; |
| 773 | default: |
| 774 | /* nothing */ |
| 775 | break; |
| 776 | } |
| 777 | else |
| 778 | switch (params->plink_action) { |
| 779 | case PLINK_ACTION_OPEN: |
| 780 | mesh_plink_open(sta); |
| 781 | break; |
| 782 | case PLINK_ACTION_BLOCK: |
| 783 | mesh_plink_block(sta); |
| 784 | break; |
| 785 | } |
Yogesh Ashok Powar | 4daf50f | 2011-05-12 09:32:17 -0400 | [diff] [blame] | 786 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 787 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
| 791 | u8 *mac, struct station_parameters *params) |
| 792 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 793 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 794 | struct sta_info *sta; |
| 795 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 796 | int err; |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 797 | int layer2_update; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 798 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 799 | if (params->vlan) { |
| 800 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 801 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 802 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 803 | sdata->vif.type != NL80211_IFTYPE_AP) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 804 | return -EINVAL; |
| 805 | } else |
| 806 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 807 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 808 | if (compare_ether_addr(mac, sdata->vif.addr) == 0) |
Johannes Berg | 03e4497 | 2008-02-27 09:56:40 +0100 | [diff] [blame] | 809 | return -EINVAL; |
| 810 | |
| 811 | if (is_multicast_ether_addr(mac)) |
| 812 | return -EINVAL; |
| 813 | |
| 814 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 815 | if (!sta) |
| 816 | return -ENOMEM; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 817 | |
| 818 | sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC; |
| 819 | |
| 820 | sta_apply_parameters(local, sta, params); |
| 821 | |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame^] | 822 | /* Only TDLS-supporting stations can add TDLS peers */ |
| 823 | if ((sta->flags & WLAN_STA_TDLS_PEER) && |
| 824 | !((wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) && |
| 825 | sdata->vif.type == NL80211_IFTYPE_STATION)) |
| 826 | return -ENOTSUPP; |
| 827 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 828 | rate_control_rate_init(sta); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 829 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 830 | layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
| 831 | sdata->vif.type == NL80211_IFTYPE_AP; |
| 832 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 833 | err = sta_info_insert_rcu(sta); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 834 | if (err) { |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 835 | rcu_read_unlock(); |
| 836 | return err; |
| 837 | } |
| 838 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 839 | if (layer2_update) |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 840 | ieee80211_send_layer2_update(sta); |
| 841 | |
| 842 | rcu_read_unlock(); |
| 843 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 844 | return 0; |
| 845 | } |
| 846 | |
| 847 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 848 | u8 *mac) |
| 849 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 850 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 851 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 852 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 853 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 854 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 855 | if (mac) |
| 856 | return sta_info_destroy_addr_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 857 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 858 | sta_info_flush(local, sdata); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 859 | return 0; |
| 860 | } |
| 861 | |
| 862 | static int ieee80211_change_station(struct wiphy *wiphy, |
| 863 | struct net_device *dev, |
| 864 | u8 *mac, |
| 865 | struct station_parameters *params) |
| 866 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 867 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 868 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 869 | struct sta_info *sta; |
| 870 | struct ieee80211_sub_if_data *vlansdata; |
| 871 | |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 872 | rcu_read_lock(); |
| 873 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 874 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 875 | if (!sta) { |
| 876 | rcu_read_unlock(); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 877 | return -ENOENT; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 878 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 879 | |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame^] | 880 | /* The TDLS bit cannot be toggled after the STA was added */ |
| 881 | if ((params->sta_flags_mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) && |
| 882 | !!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) != |
| 883 | !!test_sta_flags(sta, WLAN_STA_TDLS_PEER)) { |
| 884 | rcu_read_unlock(); |
| 885 | return -EINVAL; |
| 886 | } |
| 887 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 888 | if (params->vlan && params->vlan != sta->sdata->dev) { |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 889 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 890 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 891 | if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 892 | vlansdata->vif.type != NL80211_IFTYPE_AP) { |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 893 | rcu_read_unlock(); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 894 | return -EINVAL; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 895 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 896 | |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 897 | if (params->vlan->ieee80211_ptr->use_4addr) { |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 898 | if (vlansdata->u.vlan.sta) { |
| 899 | rcu_read_unlock(); |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 900 | return -EBUSY; |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 901 | } |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 902 | |
| 903 | rcu_assign_pointer(vlansdata->u.vlan.sta, sta); |
| 904 | } |
| 905 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 906 | sta->sdata = vlansdata; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 907 | ieee80211_send_layer2_update(sta); |
| 908 | } |
| 909 | |
| 910 | sta_apply_parameters(local, sta, params); |
| 911 | |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 912 | rcu_read_unlock(); |
| 913 | |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 914 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
| 915 | params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
| 916 | ieee80211_recalc_ps(local, -1); |
| 917 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 918 | return 0; |
| 919 | } |
| 920 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 921 | #ifdef CONFIG_MAC80211_MESH |
| 922 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 923 | u8 *dst, u8 *next_hop) |
| 924 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 925 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 926 | struct mesh_path *mpath; |
| 927 | struct sta_info *sta; |
| 928 | int err; |
| 929 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 930 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 931 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 932 | rcu_read_lock(); |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 933 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 934 | if (!sta) { |
| 935 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 936 | return -ENOENT; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 937 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 938 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 939 | err = mesh_path_add(dst, sdata); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 940 | if (err) { |
| 941 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 942 | return err; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 943 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 944 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 945 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 946 | if (!mpath) { |
| 947 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 948 | return -ENXIO; |
| 949 | } |
| 950 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 951 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 952 | rcu_read_unlock(); |
| 953 | return 0; |
| 954 | } |
| 955 | |
| 956 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 957 | u8 *dst) |
| 958 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 959 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 960 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 961 | if (dst) |
| 962 | return mesh_path_del(dst, sdata); |
| 963 | |
Javier Cardona | ece1a2e | 2011-08-29 13:23:04 -0700 | [diff] [blame] | 964 | mesh_path_flush_by_iface(sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | static int ieee80211_change_mpath(struct wiphy *wiphy, |
| 969 | struct net_device *dev, |
| 970 | u8 *dst, u8 *next_hop) |
| 971 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 972 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 973 | struct mesh_path *mpath; |
| 974 | struct sta_info *sta; |
| 975 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 976 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 977 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 978 | rcu_read_lock(); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 979 | |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 980 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 981 | if (!sta) { |
| 982 | rcu_read_unlock(); |
| 983 | return -ENOENT; |
| 984 | } |
| 985 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 986 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 987 | if (!mpath) { |
| 988 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 989 | return -ENOENT; |
| 990 | } |
| 991 | |
| 992 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 993 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 994 | rcu_read_unlock(); |
| 995 | return 0; |
| 996 | } |
| 997 | |
| 998 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, |
| 999 | struct mpath_info *pinfo) |
| 1000 | { |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 1001 | struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop); |
| 1002 | |
| 1003 | if (next_hop_sta) |
| 1004 | memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1005 | else |
| 1006 | memset(next_hop, 0, ETH_ALEN); |
| 1007 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 1008 | pinfo->generation = mesh_paths_generation; |
| 1009 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1010 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1011 | MPATH_INFO_SN | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1012 | MPATH_INFO_METRIC | |
| 1013 | MPATH_INFO_EXPTIME | |
| 1014 | MPATH_INFO_DISCOVERY_TIMEOUT | |
| 1015 | MPATH_INFO_DISCOVERY_RETRIES | |
| 1016 | MPATH_INFO_FLAGS; |
| 1017 | |
| 1018 | pinfo->frame_qlen = mpath->frame_queue.qlen; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1019 | pinfo->sn = mpath->sn; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1020 | pinfo->metric = mpath->metric; |
| 1021 | if (time_before(jiffies, mpath->exp_time)) |
| 1022 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); |
| 1023 | pinfo->discovery_timeout = |
| 1024 | jiffies_to_msecs(mpath->discovery_timeout); |
| 1025 | pinfo->discovery_retries = mpath->discovery_retries; |
| 1026 | pinfo->flags = 0; |
| 1027 | if (mpath->flags & MESH_PATH_ACTIVE) |
| 1028 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; |
| 1029 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 1030 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1031 | if (mpath->flags & MESH_PATH_SN_VALID) |
| 1032 | pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1033 | if (mpath->flags & MESH_PATH_FIXED) |
| 1034 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; |
| 1035 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 1036 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
| 1037 | |
| 1038 | pinfo->flags = mpath->flags; |
| 1039 | } |
| 1040 | |
| 1041 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1042 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) |
| 1043 | |
| 1044 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1045 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1046 | struct mesh_path *mpath; |
| 1047 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1048 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1049 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1050 | rcu_read_lock(); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1051 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1052 | if (!mpath) { |
| 1053 | rcu_read_unlock(); |
| 1054 | return -ENOENT; |
| 1055 | } |
| 1056 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 1057 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 1058 | rcu_read_unlock(); |
| 1059 | return 0; |
| 1060 | } |
| 1061 | |
| 1062 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1063 | int idx, u8 *dst, u8 *next_hop, |
| 1064 | struct mpath_info *pinfo) |
| 1065 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1066 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1067 | struct mesh_path *mpath; |
| 1068 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1069 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1070 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1071 | rcu_read_lock(); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1072 | mpath = mesh_path_lookup_by_idx(idx, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1073 | if (!mpath) { |
| 1074 | rcu_read_unlock(); |
| 1075 | return -ENOENT; |
| 1076 | } |
| 1077 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 1078 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 1079 | rcu_read_unlock(); |
| 1080 | return 0; |
| 1081 | } |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1082 | |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 1083 | static int ieee80211_get_mesh_config(struct wiphy *wiphy, |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1084 | struct net_device *dev, |
| 1085 | struct mesh_config *conf) |
| 1086 | { |
| 1087 | struct ieee80211_sub_if_data *sdata; |
| 1088 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1089 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1090 | memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); |
| 1091 | return 0; |
| 1092 | } |
| 1093 | |
| 1094 | static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask) |
| 1095 | { |
| 1096 | return (mask >> (parm-1)) & 0x1; |
| 1097 | } |
| 1098 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1099 | static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh, |
| 1100 | const struct mesh_setup *setup) |
| 1101 | { |
| 1102 | u8 *new_ie; |
| 1103 | const u8 *old_ie; |
| 1104 | |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1105 | /* allocate information elements */ |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1106 | new_ie = NULL; |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1107 | old_ie = ifmsh->ie; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1108 | |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1109 | if (setup->ie_len) { |
| 1110 | new_ie = kmemdup(setup->ie, setup->ie_len, |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1111 | GFP_KERNEL); |
| 1112 | if (!new_ie) |
| 1113 | return -ENOMEM; |
| 1114 | } |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1115 | ifmsh->ie_len = setup->ie_len; |
| 1116 | ifmsh->ie = new_ie; |
| 1117 | kfree(old_ie); |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1118 | |
| 1119 | /* now copy the rest of the setup parameters */ |
| 1120 | ifmsh->mesh_id_len = setup->mesh_id_len; |
| 1121 | memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); |
| 1122 | ifmsh->mesh_pp_id = setup->path_sel_proto; |
| 1123 | ifmsh->mesh_pm_id = setup->path_metric; |
Javier Cardona | b130e5c | 2011-05-03 16:57:07 -0700 | [diff] [blame] | 1124 | ifmsh->security = IEEE80211_MESH_SEC_NONE; |
| 1125 | if (setup->is_authenticated) |
| 1126 | ifmsh->security |= IEEE80211_MESH_SEC_AUTHED; |
| 1127 | if (setup->is_secure) |
| 1128 | ifmsh->security |= IEEE80211_MESH_SEC_SECURED; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1129 | |
| 1130 | return 0; |
| 1131 | } |
| 1132 | |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 1133 | static int ieee80211_update_mesh_config(struct wiphy *wiphy, |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1134 | struct net_device *dev, u32 mask, |
| 1135 | const struct mesh_config *nconf) |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1136 | { |
| 1137 | struct mesh_config *conf; |
| 1138 | struct ieee80211_sub_if_data *sdata; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1139 | struct ieee80211_if_mesh *ifmsh; |
| 1140 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1141 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1142 | ifmsh = &sdata->u.mesh; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1143 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1144 | /* Set the config options which we are interested in setting */ |
| 1145 | conf = &(sdata->u.mesh.mshcfg); |
| 1146 | if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) |
| 1147 | conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; |
| 1148 | if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) |
| 1149 | conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; |
| 1150 | if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) |
| 1151 | conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; |
| 1152 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) |
| 1153 | conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; |
| 1154 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) |
| 1155 | conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; |
| 1156 | if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) |
| 1157 | conf->dot11MeshTTL = nconf->dot11MeshTTL; |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 1158 | if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask)) |
| 1159 | conf->dot11MeshTTL = nconf->element_ttl; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1160 | if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) |
| 1161 | conf->auto_open_plinks = nconf->auto_open_plinks; |
| 1162 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) |
| 1163 | conf->dot11MeshHWMPmaxPREQretries = |
| 1164 | nconf->dot11MeshHWMPmaxPREQretries; |
| 1165 | if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) |
| 1166 | conf->path_refresh_time = nconf->path_refresh_time; |
| 1167 | if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) |
| 1168 | conf->min_discovery_timeout = nconf->min_discovery_timeout; |
| 1169 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) |
| 1170 | conf->dot11MeshHWMPactivePathTimeout = |
| 1171 | nconf->dot11MeshHWMPactivePathTimeout; |
| 1172 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) |
| 1173 | conf->dot11MeshHWMPpreqMinInterval = |
| 1174 | nconf->dot11MeshHWMPpreqMinInterval; |
| 1175 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
| 1176 | mask)) |
| 1177 | conf->dot11MeshHWMPnetDiameterTraversalTime = |
| 1178 | nconf->dot11MeshHWMPnetDiameterTraversalTime; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1179 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) { |
| 1180 | conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode; |
| 1181 | ieee80211_mesh_root_setup(ifmsh); |
| 1182 | } |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 1183 | if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) { |
Thomas Pedersen | c6133661 | 2011-08-25 10:36:14 -0700 | [diff] [blame] | 1184 | /* our current gate announcement implementation rides on root |
| 1185 | * announcements, so require this ifmsh to also be a root node |
| 1186 | * */ |
| 1187 | if (nconf->dot11MeshGateAnnouncementProtocol && |
| 1188 | !conf->dot11MeshHWMPRootMode) { |
| 1189 | conf->dot11MeshHWMPRootMode = 1; |
| 1190 | ieee80211_mesh_root_setup(ifmsh); |
| 1191 | } |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 1192 | conf->dot11MeshGateAnnouncementProtocol = |
| 1193 | nconf->dot11MeshGateAnnouncementProtocol; |
| 1194 | } |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame] | 1195 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) { |
| 1196 | conf->dot11MeshHWMPRannInterval = |
| 1197 | nconf->dot11MeshHWMPRannInterval; |
| 1198 | } |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1199 | return 0; |
| 1200 | } |
| 1201 | |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1202 | static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev, |
| 1203 | const struct mesh_config *conf, |
| 1204 | const struct mesh_setup *setup) |
| 1205 | { |
| 1206 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1207 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1208 | int err; |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1209 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1210 | memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config)); |
| 1211 | err = copy_mesh_setup(ifmsh, setup); |
| 1212 | if (err) |
| 1213 | return err; |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1214 | ieee80211_start_mesh(sdata); |
| 1215 | |
| 1216 | return 0; |
| 1217 | } |
| 1218 | |
| 1219 | static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) |
| 1220 | { |
| 1221 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1222 | |
| 1223 | ieee80211_stop_mesh(sdata); |
| 1224 | |
| 1225 | return 0; |
| 1226 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1227 | #endif |
| 1228 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1229 | static int ieee80211_change_bss(struct wiphy *wiphy, |
| 1230 | struct net_device *dev, |
| 1231 | struct bss_parameters *params) |
| 1232 | { |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1233 | struct ieee80211_sub_if_data *sdata; |
| 1234 | u32 changed = 0; |
| 1235 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1236 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1237 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1238 | if (params->use_cts_prot >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1239 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1240 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
| 1241 | } |
| 1242 | if (params->use_short_preamble >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1243 | sdata->vif.bss_conf.use_short_preamble = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1244 | params->use_short_preamble; |
| 1245 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
| 1246 | } |
Felix Fietkau | 43d3534 | 2010-01-15 03:00:48 +0100 | [diff] [blame] | 1247 | |
| 1248 | if (!sdata->vif.bss_conf.use_short_slot && |
| 1249 | sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) { |
| 1250 | sdata->vif.bss_conf.use_short_slot = true; |
| 1251 | changed |= BSS_CHANGED_ERP_SLOT; |
| 1252 | } |
| 1253 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1254 | if (params->use_short_slot_time >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1255 | sdata->vif.bss_conf.use_short_slot = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1256 | params->use_short_slot_time; |
| 1257 | changed |= BSS_CHANGED_ERP_SLOT; |
| 1258 | } |
| 1259 | |
Jouni Malinen | 90c97a0 | 2008-10-30 16:59:22 +0200 | [diff] [blame] | 1260 | if (params->basic_rates) { |
| 1261 | int i, j; |
| 1262 | u32 rates = 0; |
| 1263 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1264 | struct ieee80211_supported_band *sband = |
| 1265 | wiphy->bands[local->oper_channel->band]; |
| 1266 | |
| 1267 | for (i = 0; i < params->basic_rates_len; i++) { |
| 1268 | int rate = (params->basic_rates[i] & 0x7f) * 5; |
| 1269 | for (j = 0; j < sband->n_bitrates; j++) { |
| 1270 | if (sband->bitrates[j].bitrate == rate) |
| 1271 | rates |= BIT(j); |
| 1272 | } |
| 1273 | } |
| 1274 | sdata->vif.bss_conf.basic_rates = rates; |
| 1275 | changed |= BSS_CHANGED_BASIC_RATES; |
| 1276 | } |
| 1277 | |
Felix Fietkau | 7b7b5e5 | 2010-04-27 01:23:36 +0200 | [diff] [blame] | 1278 | if (params->ap_isolate >= 0) { |
| 1279 | if (params->ap_isolate) |
| 1280 | sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 1281 | else |
| 1282 | sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 1283 | } |
| 1284 | |
Helmut Schaa | 80d7e40 | 2010-11-19 12:40:26 +0100 | [diff] [blame] | 1285 | if (params->ht_opmode >= 0) { |
| 1286 | sdata->vif.bss_conf.ht_operation_mode = |
| 1287 | (u16) params->ht_opmode; |
| 1288 | changed |= BSS_CHANGED_HT; |
| 1289 | } |
| 1290 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1291 | ieee80211_bss_info_change_notify(sdata, changed); |
| 1292 | |
| 1293 | return 0; |
| 1294 | } |
| 1295 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1296 | static int ieee80211_set_txq_params(struct wiphy *wiphy, |
Eliad Peller | f70f01c | 2011-09-25 20:06:53 +0300 | [diff] [blame] | 1297 | struct net_device *dev, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1298 | struct ieee80211_txq_params *params) |
| 1299 | { |
| 1300 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 1301 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1302 | struct ieee80211_tx_queue_params p; |
| 1303 | |
| 1304 | if (!local->ops->conf_tx) |
| 1305 | return -EOPNOTSUPP; |
| 1306 | |
| 1307 | memset(&p, 0, sizeof(p)); |
| 1308 | p.aifs = params->aifs; |
| 1309 | p.cw_max = params->cwmax; |
| 1310 | p.cw_min = params->cwmin; |
| 1311 | p.txop = params->txop; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1312 | |
| 1313 | /* |
| 1314 | * Setting tx queue params disables u-apsd because it's only |
| 1315 | * called in master mode. |
| 1316 | */ |
| 1317 | p.uapsd = false; |
| 1318 | |
Eliad Peller | 2683d65 | 2011-07-14 20:29:42 +0300 | [diff] [blame] | 1319 | if (params->queue >= local->hw.queues) |
| 1320 | return -EINVAL; |
| 1321 | |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 1322 | sdata->tx_conf[params->queue] = p; |
| 1323 | if (drv_conf_tx(local, sdata, params->queue, &p)) { |
Joe Perches | 0fb9a9e | 2010-08-20 16:25:38 -0700 | [diff] [blame] | 1324 | wiphy_debug(local->hw.wiphy, |
| 1325 | "failed to set TX queue parameters for queue %d\n", |
| 1326 | params->queue); |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1327 | return -EINVAL; |
| 1328 | } |
| 1329 | |
| 1330 | return 0; |
| 1331 | } |
| 1332 | |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1333 | static int ieee80211_set_channel(struct wiphy *wiphy, |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1334 | struct net_device *netdev, |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1335 | struct ieee80211_channel *chan, |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 1336 | enum nl80211_channel_type channel_type) |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1337 | { |
| 1338 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1339 | struct ieee80211_sub_if_data *sdata = NULL; |
Ben Greear | eeabee7 | 2011-01-28 10:20:47 -0800 | [diff] [blame] | 1340 | struct ieee80211_channel *old_oper; |
| 1341 | enum nl80211_channel_type old_oper_type; |
| 1342 | enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT; |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1343 | |
| 1344 | if (netdev) |
| 1345 | sdata = IEEE80211_DEV_TO_SUB_IF(netdev); |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1346 | |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1347 | switch (ieee80211_get_channel_mode(local, NULL)) { |
| 1348 | case CHAN_MODE_HOPPING: |
| 1349 | return -EBUSY; |
| 1350 | case CHAN_MODE_FIXED: |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1351 | if (local->oper_channel != chan) |
| 1352 | return -EBUSY; |
| 1353 | if (!sdata && local->_oper_channel_type == channel_type) |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1354 | return 0; |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1355 | break; |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1356 | case CHAN_MODE_UNDEFINED: |
| 1357 | break; |
| 1358 | } |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1359 | |
Ben Greear | eeabee7 | 2011-01-28 10:20:47 -0800 | [diff] [blame] | 1360 | if (sdata) |
| 1361 | old_vif_oper_type = sdata->vif.bss_conf.channel_type; |
| 1362 | old_oper_type = local->_oper_channel_type; |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1363 | |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1364 | if (!ieee80211_set_channel_type(local, sdata, channel_type)) |
| 1365 | return -EBUSY; |
| 1366 | |
Ben Greear | eeabee7 | 2011-01-28 10:20:47 -0800 | [diff] [blame] | 1367 | old_oper = local->oper_channel; |
| 1368 | local->oper_channel = chan; |
| 1369 | |
| 1370 | /* Update driver if changes were actually made. */ |
| 1371 | if ((old_oper != local->oper_channel) || |
| 1372 | (old_oper_type != local->_oper_channel_type)) |
| 1373 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
| 1374 | |
| 1375 | if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) && |
| 1376 | old_vif_oper_type != sdata->vif.bss_conf.channel_type) |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1377 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); |
| 1378 | |
| 1379 | return 0; |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1380 | } |
| 1381 | |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1382 | #ifdef CONFIG_PM |
Johannes Berg | ff1b6e6 | 2011-05-04 15:37:28 +0200 | [diff] [blame] | 1383 | static int ieee80211_suspend(struct wiphy *wiphy, |
| 1384 | struct cfg80211_wowlan *wowlan) |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1385 | { |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 1386 | return __ieee80211_suspend(wiphy_priv(wiphy), wowlan); |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1387 | } |
| 1388 | |
| 1389 | static int ieee80211_resume(struct wiphy *wiphy) |
| 1390 | { |
| 1391 | return __ieee80211_resume(wiphy_priv(wiphy)); |
| 1392 | } |
| 1393 | #else |
| 1394 | #define ieee80211_suspend NULL |
| 1395 | #define ieee80211_resume NULL |
| 1396 | #endif |
| 1397 | |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1398 | static int ieee80211_scan(struct wiphy *wiphy, |
| 1399 | struct net_device *dev, |
| 1400 | struct cfg80211_scan_request *req) |
| 1401 | { |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 1402 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1403 | |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 1404 | switch (ieee80211_vif_type_p2p(&sdata->vif)) { |
| 1405 | case NL80211_IFTYPE_STATION: |
| 1406 | case NL80211_IFTYPE_ADHOC: |
| 1407 | case NL80211_IFTYPE_MESH_POINT: |
| 1408 | case NL80211_IFTYPE_P2P_CLIENT: |
| 1409 | break; |
| 1410 | case NL80211_IFTYPE_P2P_GO: |
| 1411 | if (sdata->local->ops->hw_scan) |
| 1412 | break; |
Johannes Berg | e9d7732 | 2011-02-01 15:35:36 +0100 | [diff] [blame] | 1413 | /* |
| 1414 | * FIXME: implement NoA while scanning in software, |
| 1415 | * for now fall through to allow scanning only when |
| 1416 | * beaconing hasn't been configured yet |
| 1417 | */ |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 1418 | case NL80211_IFTYPE_AP: |
| 1419 | if (sdata->u.ap.beacon) |
| 1420 | return -EOPNOTSUPP; |
| 1421 | break; |
| 1422 | default: |
| 1423 | return -EOPNOTSUPP; |
| 1424 | } |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1425 | |
| 1426 | return ieee80211_request_scan(sdata, req); |
| 1427 | } |
| 1428 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 1429 | static int |
| 1430 | ieee80211_sched_scan_start(struct wiphy *wiphy, |
| 1431 | struct net_device *dev, |
| 1432 | struct cfg80211_sched_scan_request *req) |
| 1433 | { |
| 1434 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1435 | |
| 1436 | if (!sdata->local->ops->sched_scan_start) |
| 1437 | return -EOPNOTSUPP; |
| 1438 | |
| 1439 | return ieee80211_request_sched_scan_start(sdata, req); |
| 1440 | } |
| 1441 | |
| 1442 | static int |
Luciano Coelho | 85a9994 | 2011-05-12 16:28:29 +0300 | [diff] [blame] | 1443 | ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev) |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 1444 | { |
| 1445 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1446 | |
| 1447 | if (!sdata->local->ops->sched_scan_stop) |
| 1448 | return -EOPNOTSUPP; |
| 1449 | |
Luciano Coelho | 85a9994 | 2011-05-12 16:28:29 +0300 | [diff] [blame] | 1450 | return ieee80211_request_sched_scan_stop(sdata); |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 1451 | } |
| 1452 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1453 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
| 1454 | struct cfg80211_auth_request *req) |
| 1455 | { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1456 | return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1457 | } |
| 1458 | |
| 1459 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, |
| 1460 | struct cfg80211_assoc_request *req) |
| 1461 | { |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1462 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1463 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1464 | |
| 1465 | switch (ieee80211_get_channel_mode(local, sdata)) { |
| 1466 | case CHAN_MODE_HOPPING: |
| 1467 | return -EBUSY; |
| 1468 | case CHAN_MODE_FIXED: |
| 1469 | if (local->oper_channel == req->bss->channel) |
| 1470 | break; |
| 1471 | return -EBUSY; |
| 1472 | case CHAN_MODE_UNDEFINED: |
| 1473 | break; |
| 1474 | } |
| 1475 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1476 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1477 | } |
| 1478 | |
| 1479 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1480 | struct cfg80211_deauth_request *req, |
| 1481 | void *cookie) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1482 | { |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1483 | return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), |
| 1484 | req, cookie); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1485 | } |
| 1486 | |
| 1487 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1488 | struct cfg80211_disassoc_request *req, |
| 1489 | void *cookie) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1490 | { |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1491 | return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), |
| 1492 | req, cookie); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1493 | } |
| 1494 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1495 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
| 1496 | struct cfg80211_ibss_params *params) |
| 1497 | { |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1498 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1499 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1500 | |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1501 | switch (ieee80211_get_channel_mode(local, sdata)) { |
| 1502 | case CHAN_MODE_HOPPING: |
| 1503 | return -EBUSY; |
| 1504 | case CHAN_MODE_FIXED: |
| 1505 | if (!params->channel_fixed) |
| 1506 | return -EBUSY; |
| 1507 | if (local->oper_channel == params->channel) |
| 1508 | break; |
| 1509 | return -EBUSY; |
| 1510 | case CHAN_MODE_UNDEFINED: |
| 1511 | break; |
| 1512 | } |
| 1513 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1514 | return ieee80211_ibss_join(sdata, params); |
| 1515 | } |
| 1516 | |
| 1517 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) |
| 1518 | { |
| 1519 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1520 | |
| 1521 | return ieee80211_ibss_leave(sdata); |
| 1522 | } |
| 1523 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1524 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 1525 | { |
| 1526 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1527 | int err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1528 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 1529 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 1530 | err = drv_set_frag_threshold(local, wiphy->frag_threshold); |
| 1531 | |
| 1532 | if (err) |
| 1533 | return err; |
| 1534 | } |
| 1535 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 1536 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) { |
| 1537 | err = drv_set_coverage_class(local, wiphy->coverage_class); |
| 1538 | |
| 1539 | if (err) |
| 1540 | return err; |
| 1541 | } |
| 1542 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1543 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1544 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1545 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1546 | if (err) |
| 1547 | return err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1548 | } |
| 1549 | |
| 1550 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 1551 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
| 1552 | if (changed & WIPHY_PARAM_RETRY_LONG) |
| 1553 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
| 1554 | if (changed & |
| 1555 | (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) |
| 1556 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); |
| 1557 | |
| 1558 | return 0; |
| 1559 | } |
| 1560 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1561 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1562 | enum nl80211_tx_power_setting type, int mbm) |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1563 | { |
| 1564 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1565 | struct ieee80211_channel *chan = local->hw.conf.channel; |
| 1566 | u32 changes = 0; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1567 | |
| 1568 | switch (type) { |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1569 | case NL80211_TX_POWER_AUTOMATIC: |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1570 | local->user_power_level = -1; |
| 1571 | break; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1572 | case NL80211_TX_POWER_LIMITED: |
| 1573 | if (mbm < 0 || (mbm % 100)) |
| 1574 | return -EOPNOTSUPP; |
| 1575 | local->user_power_level = MBM_TO_DBM(mbm); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1576 | break; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1577 | case NL80211_TX_POWER_FIXED: |
| 1578 | if (mbm < 0 || (mbm % 100)) |
| 1579 | return -EOPNOTSUPP; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1580 | /* TODO: move to cfg80211 when it knows the channel */ |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1581 | if (MBM_TO_DBM(mbm) > chan->max_power) |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1582 | return -EINVAL; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1583 | local->user_power_level = MBM_TO_DBM(mbm); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1584 | break; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | ieee80211_hw_config(local, changes); |
| 1588 | |
| 1589 | return 0; |
| 1590 | } |
| 1591 | |
| 1592 | static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm) |
| 1593 | { |
| 1594 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1595 | |
| 1596 | *dbm = local->hw.conf.power_level; |
| 1597 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1598 | return 0; |
| 1599 | } |
| 1600 | |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1601 | static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 388ac77 | 2010-10-07 13:11:09 +0200 | [diff] [blame] | 1602 | const u8 *addr) |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1603 | { |
| 1604 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1605 | |
| 1606 | memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN); |
| 1607 | |
| 1608 | return 0; |
| 1609 | } |
| 1610 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 1611 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) |
| 1612 | { |
| 1613 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1614 | |
| 1615 | drv_rfkill_poll(local); |
| 1616 | } |
| 1617 | |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1618 | #ifdef CONFIG_NL80211_TESTMODE |
Johannes Berg | 99783e2 | 2009-07-07 03:54:43 +0200 | [diff] [blame] | 1619 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len) |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1620 | { |
| 1621 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1622 | |
| 1623 | if (!local->ops->testmode_cmd) |
| 1624 | return -EOPNOTSUPP; |
| 1625 | |
| 1626 | return local->ops->testmode_cmd(&local->hw, data, len); |
| 1627 | } |
Wey-Yi Guy | 71063f0 | 2011-05-20 09:05:54 -0700 | [diff] [blame] | 1628 | |
| 1629 | static int ieee80211_testmode_dump(struct wiphy *wiphy, |
| 1630 | struct sk_buff *skb, |
| 1631 | struct netlink_callback *cb, |
| 1632 | void *data, int len) |
| 1633 | { |
| 1634 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1635 | |
| 1636 | if (!local->ops->testmode_dump) |
| 1637 | return -EOPNOTSUPP; |
| 1638 | |
| 1639 | return local->ops->testmode_dump(&local->hw, skb, cb, data, len); |
| 1640 | } |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1641 | #endif |
| 1642 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1643 | int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, |
| 1644 | enum ieee80211_smps_mode smps_mode) |
| 1645 | { |
| 1646 | const u8 *ap; |
| 1647 | enum ieee80211_smps_mode old_req; |
| 1648 | int err; |
| 1649 | |
Johannes Berg | 243e6df | 2011-04-19 20:44:04 +0200 | [diff] [blame] | 1650 | lockdep_assert_held(&sdata->u.mgd.mtx); |
| 1651 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1652 | old_req = sdata->u.mgd.req_smps; |
| 1653 | sdata->u.mgd.req_smps = smps_mode; |
| 1654 | |
| 1655 | if (old_req == smps_mode && |
| 1656 | smps_mode != IEEE80211_SMPS_AUTOMATIC) |
| 1657 | return 0; |
| 1658 | |
| 1659 | /* |
| 1660 | * If not associated, or current association is not an HT |
| 1661 | * association, there's no need to send an action frame. |
| 1662 | */ |
| 1663 | if (!sdata->u.mgd.associated || |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 1664 | sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) { |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1665 | mutex_lock(&sdata->local->iflist_mtx); |
Johannes Berg | 025e6be | 2010-10-05 10:41:47 +0200 | [diff] [blame] | 1666 | ieee80211_recalc_smps(sdata->local); |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1667 | mutex_unlock(&sdata->local->iflist_mtx); |
| 1668 | return 0; |
| 1669 | } |
| 1670 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 1671 | ap = sdata->u.mgd.associated->bssid; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1672 | |
| 1673 | if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { |
| 1674 | if (sdata->u.mgd.powersave) |
| 1675 | smps_mode = IEEE80211_SMPS_DYNAMIC; |
| 1676 | else |
| 1677 | smps_mode = IEEE80211_SMPS_OFF; |
| 1678 | } |
| 1679 | |
| 1680 | /* send SM PS frame to AP */ |
| 1681 | err = ieee80211_send_smps_action(sdata, smps_mode, |
| 1682 | ap, ap); |
| 1683 | if (err) |
| 1684 | sdata->u.mgd.req_smps = old_req; |
| 1685 | |
| 1686 | return err; |
| 1687 | } |
| 1688 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1689 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 1690 | bool enabled, int timeout) |
| 1691 | { |
| 1692 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1693 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1694 | |
Benoit Papillault | e5de30c | 2010-01-15 12:21:37 +0100 | [diff] [blame] | 1695 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 1696 | return -EOPNOTSUPP; |
| 1697 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1698 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) |
| 1699 | return -EOPNOTSUPP; |
| 1700 | |
| 1701 | if (enabled == sdata->u.mgd.powersave && |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 1702 | timeout == local->dynamic_ps_forced_timeout) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1703 | return 0; |
| 1704 | |
| 1705 | sdata->u.mgd.powersave = enabled; |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 1706 | local->dynamic_ps_forced_timeout = timeout; |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1707 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1708 | /* no change, but if automatic follow powersave */ |
| 1709 | mutex_lock(&sdata->u.mgd.mtx); |
| 1710 | __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps); |
| 1711 | mutex_unlock(&sdata->u.mgd.mtx); |
| 1712 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1713 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) |
| 1714 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 1715 | |
| 1716 | ieee80211_recalc_ps(local, -1); |
| 1717 | |
| 1718 | return 0; |
| 1719 | } |
| 1720 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1721 | static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, |
| 1722 | struct net_device *dev, |
| 1723 | s32 rssi_thold, u32 rssi_hyst) |
| 1724 | { |
| 1725 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1726 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 1727 | struct ieee80211_vif *vif = &sdata->vif; |
| 1728 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
| 1729 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1730 | if (rssi_thold == bss_conf->cqm_rssi_thold && |
| 1731 | rssi_hyst == bss_conf->cqm_rssi_hyst) |
| 1732 | return 0; |
| 1733 | |
| 1734 | bss_conf->cqm_rssi_thold = rssi_thold; |
| 1735 | bss_conf->cqm_rssi_hyst = rssi_hyst; |
| 1736 | |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 1737 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) { |
| 1738 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 1739 | return -EOPNOTSUPP; |
| 1740 | return 0; |
| 1741 | } |
| 1742 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1743 | /* tell the driver upon association, unless already associated */ |
| 1744 | if (sdata->u.mgd.associated) |
| 1745 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM); |
| 1746 | |
| 1747 | return 0; |
| 1748 | } |
| 1749 | |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1750 | static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, |
| 1751 | struct net_device *dev, |
| 1752 | const u8 *addr, |
| 1753 | const struct cfg80211_bitrate_mask *mask) |
| 1754 | { |
| 1755 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1756 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 1757 | int i, ret; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1758 | |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 1759 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) { |
| 1760 | ret = drv_set_bitrate_mask(local, sdata, mask); |
| 1761 | if (ret) |
| 1762 | return ret; |
| 1763 | } |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1764 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1765 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 1766 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1767 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1768 | return 0; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1769 | } |
| 1770 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 1771 | static int ieee80211_remain_on_channel_hw(struct ieee80211_local *local, |
| 1772 | struct net_device *dev, |
| 1773 | struct ieee80211_channel *chan, |
| 1774 | enum nl80211_channel_type chantype, |
| 1775 | unsigned int duration, u64 *cookie) |
| 1776 | { |
| 1777 | int ret; |
| 1778 | u32 random_cookie; |
| 1779 | |
| 1780 | lockdep_assert_held(&local->mtx); |
| 1781 | |
| 1782 | if (local->hw_roc_cookie) |
| 1783 | return -EBUSY; |
| 1784 | /* must be nonzero */ |
| 1785 | random_cookie = random32() | 1; |
| 1786 | |
| 1787 | *cookie = random_cookie; |
| 1788 | local->hw_roc_dev = dev; |
| 1789 | local->hw_roc_cookie = random_cookie; |
| 1790 | local->hw_roc_channel = chan; |
| 1791 | local->hw_roc_channel_type = chantype; |
| 1792 | local->hw_roc_duration = duration; |
| 1793 | ret = drv_remain_on_channel(local, chan, chantype, duration); |
| 1794 | if (ret) { |
| 1795 | local->hw_roc_channel = NULL; |
| 1796 | local->hw_roc_cookie = 0; |
| 1797 | } |
| 1798 | |
| 1799 | return ret; |
| 1800 | } |
| 1801 | |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 1802 | static int ieee80211_remain_on_channel(struct wiphy *wiphy, |
| 1803 | struct net_device *dev, |
| 1804 | struct ieee80211_channel *chan, |
| 1805 | enum nl80211_channel_type channel_type, |
| 1806 | unsigned int duration, |
| 1807 | u64 *cookie) |
| 1808 | { |
| 1809 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 1810 | struct ieee80211_local *local = sdata->local; |
| 1811 | |
| 1812 | if (local->ops->remain_on_channel) { |
| 1813 | int ret; |
| 1814 | |
| 1815 | mutex_lock(&local->mtx); |
| 1816 | ret = ieee80211_remain_on_channel_hw(local, dev, |
| 1817 | chan, channel_type, |
| 1818 | duration, cookie); |
Johannes Berg | 90fc4b3 | 2010-12-18 17:20:48 +0100 | [diff] [blame] | 1819 | local->hw_roc_for_tx = false; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 1820 | mutex_unlock(&local->mtx); |
| 1821 | |
| 1822 | return ret; |
| 1823 | } |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 1824 | |
| 1825 | return ieee80211_wk_remain_on_channel(sdata, chan, channel_type, |
| 1826 | duration, cookie); |
| 1827 | } |
| 1828 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 1829 | static int ieee80211_cancel_remain_on_channel_hw(struct ieee80211_local *local, |
| 1830 | u64 cookie) |
| 1831 | { |
| 1832 | int ret; |
| 1833 | |
| 1834 | lockdep_assert_held(&local->mtx); |
| 1835 | |
| 1836 | if (local->hw_roc_cookie != cookie) |
| 1837 | return -ENOENT; |
| 1838 | |
| 1839 | ret = drv_cancel_remain_on_channel(local); |
| 1840 | if (ret) |
| 1841 | return ret; |
| 1842 | |
| 1843 | local->hw_roc_cookie = 0; |
| 1844 | local->hw_roc_channel = NULL; |
| 1845 | |
| 1846 | ieee80211_recalc_idle(local); |
| 1847 | |
| 1848 | return 0; |
| 1849 | } |
| 1850 | |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 1851 | static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, |
| 1852 | struct net_device *dev, |
| 1853 | u64 cookie) |
| 1854 | { |
| 1855 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 1856 | struct ieee80211_local *local = sdata->local; |
| 1857 | |
| 1858 | if (local->ops->cancel_remain_on_channel) { |
| 1859 | int ret; |
| 1860 | |
| 1861 | mutex_lock(&local->mtx); |
| 1862 | ret = ieee80211_cancel_remain_on_channel_hw(local, cookie); |
| 1863 | mutex_unlock(&local->mtx); |
| 1864 | |
| 1865 | return ret; |
| 1866 | } |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 1867 | |
| 1868 | return ieee80211_wk_cancel_remain_on_channel(sdata, cookie); |
| 1869 | } |
| 1870 | |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 1871 | static enum work_done_result |
| 1872 | ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb) |
| 1873 | { |
| 1874 | /* |
| 1875 | * Use the data embedded in the work struct for reporting |
| 1876 | * here so if the driver mangled the SKB before dropping |
| 1877 | * it (which is the only way we really should get here) |
| 1878 | * then we don't report mangled data. |
| 1879 | * |
| 1880 | * If there was no wait time, then by the time we get here |
| 1881 | * the driver will likely not have reported the status yet, |
| 1882 | * so in that case userspace will have to deal with it. |
| 1883 | */ |
| 1884 | |
| 1885 | if (wk->offchan_tx.wait && wk->offchan_tx.frame) |
| 1886 | cfg80211_mgmt_tx_status(wk->sdata->dev, |
| 1887 | (unsigned long) wk->offchan_tx.frame, |
| 1888 | wk->ie, wk->ie_len, false, GFP_KERNEL); |
| 1889 | |
| 1890 | return WORK_DONE_DESTROY; |
| 1891 | } |
| 1892 | |
Johannes Berg | 2e161f7 | 2010-08-12 15:38:38 +0200 | [diff] [blame] | 1893 | static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | f7ca38d | 2010-11-25 10:02:29 +0100 | [diff] [blame] | 1894 | struct ieee80211_channel *chan, bool offchan, |
Johannes Berg | 2e161f7 | 2010-08-12 15:38:38 +0200 | [diff] [blame] | 1895 | enum nl80211_channel_type channel_type, |
Johannes Berg | f7ca38d | 2010-11-25 10:02:29 +0100 | [diff] [blame] | 1896 | bool channel_type_valid, unsigned int wait, |
Rajkumar Manoharan | e9f935e | 2011-09-25 14:53:30 +0530 | [diff] [blame] | 1897 | const u8 *buf, size_t len, bool no_cck, |
| 1898 | u64 *cookie) |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 1899 | { |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1900 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1901 | struct ieee80211_local *local = sdata->local; |
| 1902 | struct sk_buff *skb; |
| 1903 | struct sta_info *sta; |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 1904 | struct ieee80211_work *wk; |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1905 | const struct ieee80211_mgmt *mgmt = (void *)buf; |
| 1906 | u32 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | |
| 1907 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 1908 | bool is_offchan = false; |
Johannes Berg | f7ca38d | 2010-11-25 10:02:29 +0100 | [diff] [blame] | 1909 | |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1910 | /* Check that we are on the requested channel for transmission */ |
| 1911 | if (chan != local->tmp_channel && |
| 1912 | chan != local->oper_channel) |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 1913 | is_offchan = true; |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1914 | if (channel_type_valid && |
| 1915 | (channel_type != local->tmp_channel_type && |
| 1916 | channel_type != local->_oper_channel_type)) |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 1917 | is_offchan = true; |
| 1918 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 1919 | if (chan == local->hw_roc_channel) { |
| 1920 | /* TODO: check channel type? */ |
| 1921 | is_offchan = false; |
| 1922 | flags |= IEEE80211_TX_CTL_TX_OFFCHAN; |
| 1923 | } |
| 1924 | |
Rajkumar Manoharan | aad14ce | 2011-09-25 14:53:31 +0530 | [diff] [blame] | 1925 | if (no_cck) |
| 1926 | flags |= IEEE80211_TX_CTL_NO_CCK_RATE; |
| 1927 | |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 1928 | if (is_offchan && !offchan) |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1929 | return -EBUSY; |
| 1930 | |
| 1931 | switch (sdata->vif.type) { |
| 1932 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 1933 | case NL80211_IFTYPE_AP: |
| 1934 | case NL80211_IFTYPE_AP_VLAN: |
| 1935 | case NL80211_IFTYPE_P2P_GO: |
Javier Cardona | c7108a7 | 2010-12-16 17:37:50 -0800 | [diff] [blame] | 1936 | case NL80211_IFTYPE_MESH_POINT: |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 1937 | if (!ieee80211_is_action(mgmt->frame_control) || |
| 1938 | mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1939 | break; |
| 1940 | rcu_read_lock(); |
| 1941 | sta = sta_info_get(sdata, mgmt->da); |
| 1942 | rcu_read_unlock(); |
| 1943 | if (!sta) |
| 1944 | return -ENOLINK; |
| 1945 | break; |
| 1946 | case NL80211_IFTYPE_STATION: |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 1947 | case NL80211_IFTYPE_P2P_CLIENT: |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1948 | break; |
| 1949 | default: |
| 1950 | return -EOPNOTSUPP; |
| 1951 | } |
| 1952 | |
| 1953 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + len); |
| 1954 | if (!skb) |
| 1955 | return -ENOMEM; |
| 1956 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 1957 | |
| 1958 | memcpy(skb_put(skb, len), buf, len); |
| 1959 | |
| 1960 | IEEE80211_SKB_CB(skb)->flags = flags; |
| 1961 | |
| 1962 | skb->dev = sdata->dev; |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 1963 | |
| 1964 | *cookie = (unsigned long) skb; |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 1965 | |
Johannes Berg | 90fc4b3 | 2010-12-18 17:20:48 +0100 | [diff] [blame] | 1966 | if (is_offchan && local->ops->remain_on_channel) { |
| 1967 | unsigned int duration; |
| 1968 | int ret; |
| 1969 | |
| 1970 | mutex_lock(&local->mtx); |
| 1971 | /* |
| 1972 | * If the duration is zero, then the driver |
| 1973 | * wouldn't actually do anything. Set it to |
| 1974 | * 100 for now. |
| 1975 | * |
| 1976 | * TODO: cancel the off-channel operation |
| 1977 | * when we get the SKB's TX status and |
| 1978 | * the wait time was zero before. |
| 1979 | */ |
| 1980 | duration = 100; |
| 1981 | if (wait) |
| 1982 | duration = wait; |
| 1983 | ret = ieee80211_remain_on_channel_hw(local, dev, chan, |
| 1984 | channel_type, |
| 1985 | duration, cookie); |
| 1986 | if (ret) { |
| 1987 | kfree_skb(skb); |
| 1988 | mutex_unlock(&local->mtx); |
| 1989 | return ret; |
| 1990 | } |
| 1991 | |
| 1992 | local->hw_roc_for_tx = true; |
| 1993 | local->hw_roc_duration = wait; |
| 1994 | |
| 1995 | /* |
| 1996 | * queue up frame for transmission after |
| 1997 | * ieee80211_ready_on_channel call |
| 1998 | */ |
| 1999 | |
| 2000 | /* modify cookie to prevent API mismatches */ |
| 2001 | *cookie ^= 2; |
| 2002 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN; |
| 2003 | local->hw_roc_skb = skb; |
Johannes Berg | 4334ec8 | 2011-02-02 16:58:06 +0100 | [diff] [blame] | 2004 | local->hw_roc_skb_for_status = skb; |
Johannes Berg | 90fc4b3 | 2010-12-18 17:20:48 +0100 | [diff] [blame] | 2005 | mutex_unlock(&local->mtx); |
| 2006 | |
| 2007 | return 0; |
| 2008 | } |
| 2009 | |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2010 | /* |
| 2011 | * Can transmit right away if the channel was the |
| 2012 | * right one and there's no wait involved... If a |
| 2013 | * wait is involved, we might otherwise not be on |
| 2014 | * the right channel for long enough! |
| 2015 | */ |
| 2016 | if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) { |
| 2017 | ieee80211_tx_skb(sdata, skb); |
| 2018 | return 0; |
| 2019 | } |
| 2020 | |
| 2021 | wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL); |
| 2022 | if (!wk) { |
| 2023 | kfree_skb(skb); |
| 2024 | return -ENOMEM; |
| 2025 | } |
| 2026 | |
| 2027 | wk->type = IEEE80211_WORK_OFFCHANNEL_TX; |
| 2028 | wk->chan = chan; |
Ben Greear | 4d51e14 | 2011-02-07 13:44:34 -0800 | [diff] [blame] | 2029 | wk->chan_type = channel_type; |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2030 | wk->sdata = sdata; |
| 2031 | wk->done = ieee80211_offchan_tx_done; |
| 2032 | wk->offchan_tx.frame = skb; |
| 2033 | wk->offchan_tx.wait = wait; |
| 2034 | wk->ie_len = len; |
| 2035 | memcpy(wk->ie, buf, len); |
| 2036 | |
| 2037 | ieee80211_add_work(wk); |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 2038 | return 0; |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 2039 | } |
| 2040 | |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2041 | static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 2042 | struct net_device *dev, |
| 2043 | u64 cookie) |
| 2044 | { |
| 2045 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2046 | struct ieee80211_local *local = sdata->local; |
| 2047 | struct ieee80211_work *wk; |
| 2048 | int ret = -ENOENT; |
| 2049 | |
| 2050 | mutex_lock(&local->mtx); |
Johannes Berg | 90fc4b3 | 2010-12-18 17:20:48 +0100 | [diff] [blame] | 2051 | |
| 2052 | if (local->ops->cancel_remain_on_channel) { |
| 2053 | cookie ^= 2; |
| 2054 | ret = ieee80211_cancel_remain_on_channel_hw(local, cookie); |
| 2055 | |
| 2056 | if (ret == 0) { |
| 2057 | kfree_skb(local->hw_roc_skb); |
| 2058 | local->hw_roc_skb = NULL; |
Johannes Berg | 4334ec8 | 2011-02-02 16:58:06 +0100 | [diff] [blame] | 2059 | local->hw_roc_skb_for_status = NULL; |
Johannes Berg | 90fc4b3 | 2010-12-18 17:20:48 +0100 | [diff] [blame] | 2060 | } |
| 2061 | |
| 2062 | mutex_unlock(&local->mtx); |
| 2063 | |
| 2064 | return ret; |
| 2065 | } |
| 2066 | |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2067 | list_for_each_entry(wk, &local->work_list, list) { |
| 2068 | if (wk->sdata != sdata) |
| 2069 | continue; |
| 2070 | |
| 2071 | if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX) |
| 2072 | continue; |
| 2073 | |
| 2074 | if (cookie != (unsigned long) wk->offchan_tx.frame) |
| 2075 | continue; |
| 2076 | |
| 2077 | wk->timeout = jiffies; |
| 2078 | |
| 2079 | ieee80211_queue_work(&local->hw, &local->work_work); |
| 2080 | ret = 0; |
| 2081 | break; |
| 2082 | } |
| 2083 | mutex_unlock(&local->mtx); |
| 2084 | |
| 2085 | return ret; |
| 2086 | } |
| 2087 | |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2088 | static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, |
| 2089 | struct net_device *dev, |
| 2090 | u16 frame_type, bool reg) |
| 2091 | { |
| 2092 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2093 | |
| 2094 | if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ)) |
| 2095 | return; |
| 2096 | |
| 2097 | if (reg) |
| 2098 | local->probe_req_reg++; |
| 2099 | else |
| 2100 | local->probe_req_reg--; |
| 2101 | |
| 2102 | ieee80211_queue_work(&local->hw, &local->reconfig_filter); |
| 2103 | } |
| 2104 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 2105 | static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant) |
| 2106 | { |
| 2107 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2108 | |
| 2109 | if (local->started) |
| 2110 | return -EOPNOTSUPP; |
| 2111 | |
| 2112 | return drv_set_antenna(local, tx_ant, rx_ant); |
| 2113 | } |
| 2114 | |
| 2115 | static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant) |
| 2116 | { |
| 2117 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2118 | |
| 2119 | return drv_get_antenna(local, tx_ant, rx_ant); |
| 2120 | } |
| 2121 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 2122 | static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx) |
| 2123 | { |
| 2124 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2125 | |
| 2126 | return drv_set_ringparam(local, tx, rx); |
| 2127 | } |
| 2128 | |
| 2129 | static void ieee80211_get_ringparam(struct wiphy *wiphy, |
| 2130 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 2131 | { |
| 2132 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2133 | |
| 2134 | drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 2135 | } |
| 2136 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 2137 | static int ieee80211_set_rekey_data(struct wiphy *wiphy, |
| 2138 | struct net_device *dev, |
| 2139 | struct cfg80211_gtk_rekey_data *data) |
| 2140 | { |
| 2141 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2142 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2143 | |
| 2144 | if (!local->ops->set_rekey_data) |
| 2145 | return -EOPNOTSUPP; |
| 2146 | |
| 2147 | drv_set_rekey_data(local, sdata, data); |
| 2148 | |
| 2149 | return 0; |
| 2150 | } |
| 2151 | |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2152 | static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb) |
| 2153 | { |
| 2154 | u8 *pos = (void *)skb_put(skb, 7); |
| 2155 | |
| 2156 | *pos++ = WLAN_EID_EXT_CAPABILITY; |
| 2157 | *pos++ = 5; /* len */ |
| 2158 | *pos++ = 0x0; |
| 2159 | *pos++ = 0x0; |
| 2160 | *pos++ = 0x0; |
| 2161 | *pos++ = 0x0; |
| 2162 | *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED; |
| 2163 | } |
| 2164 | |
| 2165 | static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata) |
| 2166 | { |
| 2167 | struct ieee80211_local *local = sdata->local; |
| 2168 | u16 capab; |
| 2169 | |
| 2170 | capab = 0; |
| 2171 | if (local->oper_channel->band != IEEE80211_BAND_2GHZ) |
| 2172 | return capab; |
| 2173 | |
| 2174 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) |
| 2175 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; |
| 2176 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) |
| 2177 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; |
| 2178 | |
| 2179 | return capab; |
| 2180 | } |
| 2181 | |
| 2182 | static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr, |
| 2183 | u8 *peer, u8 *bssid) |
| 2184 | { |
| 2185 | struct ieee80211_tdls_lnkie *lnkid; |
| 2186 | |
| 2187 | lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie)); |
| 2188 | |
| 2189 | lnkid->ie_type = WLAN_EID_LINK_ID; |
| 2190 | lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2; |
| 2191 | |
| 2192 | memcpy(lnkid->bssid, bssid, ETH_ALEN); |
| 2193 | memcpy(lnkid->init_sta, src_addr, ETH_ALEN); |
| 2194 | memcpy(lnkid->resp_sta, peer, ETH_ALEN); |
| 2195 | } |
| 2196 | |
| 2197 | static int |
| 2198 | ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, |
| 2199 | u8 *peer, u8 action_code, u8 dialog_token, |
| 2200 | u16 status_code, struct sk_buff *skb) |
| 2201 | { |
| 2202 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2203 | struct ieee80211_tdls_data *tf; |
| 2204 | |
| 2205 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); |
| 2206 | |
| 2207 | memcpy(tf->da, peer, ETH_ALEN); |
| 2208 | memcpy(tf->sa, sdata->vif.addr, ETH_ALEN); |
| 2209 | tf->ether_type = cpu_to_be16(ETH_P_TDLS); |
| 2210 | tf->payload_type = WLAN_TDLS_SNAP_RFTYPE; |
| 2211 | |
| 2212 | switch (action_code) { |
| 2213 | case WLAN_TDLS_SETUP_REQUEST: |
| 2214 | tf->category = WLAN_CATEGORY_TDLS; |
| 2215 | tf->action_code = WLAN_TDLS_SETUP_REQUEST; |
| 2216 | |
| 2217 | skb_put(skb, sizeof(tf->u.setup_req)); |
| 2218 | tf->u.setup_req.dialog_token = dialog_token; |
| 2219 | tf->u.setup_req.capability = |
| 2220 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 2221 | |
| 2222 | ieee80211_add_srates_ie(&sdata->vif, skb); |
| 2223 | ieee80211_add_ext_srates_ie(&sdata->vif, skb); |
| 2224 | ieee80211_tdls_add_ext_capab(skb); |
| 2225 | break; |
| 2226 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2227 | tf->category = WLAN_CATEGORY_TDLS; |
| 2228 | tf->action_code = WLAN_TDLS_SETUP_RESPONSE; |
| 2229 | |
| 2230 | skb_put(skb, sizeof(tf->u.setup_resp)); |
| 2231 | tf->u.setup_resp.status_code = cpu_to_le16(status_code); |
| 2232 | tf->u.setup_resp.dialog_token = dialog_token; |
| 2233 | tf->u.setup_resp.capability = |
| 2234 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 2235 | |
| 2236 | ieee80211_add_srates_ie(&sdata->vif, skb); |
| 2237 | ieee80211_add_ext_srates_ie(&sdata->vif, skb); |
| 2238 | ieee80211_tdls_add_ext_capab(skb); |
| 2239 | break; |
| 2240 | case WLAN_TDLS_SETUP_CONFIRM: |
| 2241 | tf->category = WLAN_CATEGORY_TDLS; |
| 2242 | tf->action_code = WLAN_TDLS_SETUP_CONFIRM; |
| 2243 | |
| 2244 | skb_put(skb, sizeof(tf->u.setup_cfm)); |
| 2245 | tf->u.setup_cfm.status_code = cpu_to_le16(status_code); |
| 2246 | tf->u.setup_cfm.dialog_token = dialog_token; |
| 2247 | break; |
| 2248 | case WLAN_TDLS_TEARDOWN: |
| 2249 | tf->category = WLAN_CATEGORY_TDLS; |
| 2250 | tf->action_code = WLAN_TDLS_TEARDOWN; |
| 2251 | |
| 2252 | skb_put(skb, sizeof(tf->u.teardown)); |
| 2253 | tf->u.teardown.reason_code = cpu_to_le16(status_code); |
| 2254 | break; |
| 2255 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 2256 | tf->category = WLAN_CATEGORY_TDLS; |
| 2257 | tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST; |
| 2258 | |
| 2259 | skb_put(skb, sizeof(tf->u.discover_req)); |
| 2260 | tf->u.discover_req.dialog_token = dialog_token; |
| 2261 | break; |
| 2262 | default: |
| 2263 | return -EINVAL; |
| 2264 | } |
| 2265 | |
| 2266 | return 0; |
| 2267 | } |
| 2268 | |
| 2269 | static int |
| 2270 | ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, |
| 2271 | u8 *peer, u8 action_code, u8 dialog_token, |
| 2272 | u16 status_code, struct sk_buff *skb) |
| 2273 | { |
| 2274 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2275 | struct ieee80211_mgmt *mgmt; |
| 2276 | |
| 2277 | mgmt = (void *)skb_put(skb, 24); |
| 2278 | memset(mgmt, 0, 24); |
| 2279 | memcpy(mgmt->da, peer, ETH_ALEN); |
| 2280 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
| 2281 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
| 2282 | |
| 2283 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 2284 | IEEE80211_STYPE_ACTION); |
| 2285 | |
| 2286 | switch (action_code) { |
| 2287 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 2288 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp)); |
| 2289 | mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; |
| 2290 | mgmt->u.action.u.tdls_discover_resp.action_code = |
| 2291 | WLAN_PUB_ACTION_TDLS_DISCOVER_RES; |
| 2292 | mgmt->u.action.u.tdls_discover_resp.dialog_token = |
| 2293 | dialog_token; |
| 2294 | mgmt->u.action.u.tdls_discover_resp.capability = |
| 2295 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 2296 | |
| 2297 | ieee80211_add_srates_ie(&sdata->vif, skb); |
| 2298 | ieee80211_add_ext_srates_ie(&sdata->vif, skb); |
| 2299 | ieee80211_tdls_add_ext_capab(skb); |
| 2300 | break; |
| 2301 | default: |
| 2302 | return -EINVAL; |
| 2303 | } |
| 2304 | |
| 2305 | return 0; |
| 2306 | } |
| 2307 | |
| 2308 | static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 2309 | u8 *peer, u8 action_code, u8 dialog_token, |
| 2310 | u16 status_code, const u8 *extra_ies, |
| 2311 | size_t extra_ies_len) |
| 2312 | { |
| 2313 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2314 | struct ieee80211_local *local = sdata->local; |
| 2315 | struct ieee80211_tx_info *info; |
| 2316 | struct sk_buff *skb = NULL; |
| 2317 | bool send_direct; |
| 2318 | int ret; |
| 2319 | |
| 2320 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) |
| 2321 | return -ENOTSUPP; |
| 2322 | |
| 2323 | /* make sure we are in managed mode, and associated */ |
| 2324 | if (sdata->vif.type != NL80211_IFTYPE_STATION || |
| 2325 | !sdata->u.mgd.associated) |
| 2326 | return -EINVAL; |
| 2327 | |
| 2328 | #ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG |
| 2329 | printk(KERN_DEBUG "TDLS mgmt action %d peer %pM\n", action_code, peer); |
| 2330 | #endif |
| 2331 | |
| 2332 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
| 2333 | max(sizeof(struct ieee80211_mgmt), |
| 2334 | sizeof(struct ieee80211_tdls_data)) + |
| 2335 | 50 + /* supported rates */ |
| 2336 | 7 + /* ext capab */ |
| 2337 | extra_ies_len + |
| 2338 | sizeof(struct ieee80211_tdls_lnkie)); |
| 2339 | if (!skb) |
| 2340 | return -ENOMEM; |
| 2341 | |
| 2342 | info = IEEE80211_SKB_CB(skb); |
| 2343 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 2344 | |
| 2345 | switch (action_code) { |
| 2346 | case WLAN_TDLS_SETUP_REQUEST: |
| 2347 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2348 | case WLAN_TDLS_SETUP_CONFIRM: |
| 2349 | case WLAN_TDLS_TEARDOWN: |
| 2350 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 2351 | ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer, |
| 2352 | action_code, dialog_token, |
| 2353 | status_code, skb); |
| 2354 | send_direct = false; |
| 2355 | break; |
| 2356 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 2357 | ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code, |
| 2358 | dialog_token, status_code, |
| 2359 | skb); |
| 2360 | send_direct = true; |
| 2361 | break; |
| 2362 | default: |
| 2363 | ret = -ENOTSUPP; |
| 2364 | break; |
| 2365 | } |
| 2366 | |
| 2367 | if (ret < 0) |
| 2368 | goto fail; |
| 2369 | |
| 2370 | if (extra_ies_len) |
| 2371 | memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len); |
| 2372 | |
| 2373 | /* the TDLS link IE is always added last */ |
| 2374 | switch (action_code) { |
| 2375 | case WLAN_TDLS_SETUP_REQUEST: |
| 2376 | case WLAN_TDLS_SETUP_CONFIRM: |
| 2377 | case WLAN_TDLS_TEARDOWN: |
| 2378 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 2379 | /* we are the initiator */ |
| 2380 | ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer, |
| 2381 | sdata->u.mgd.bssid); |
| 2382 | break; |
| 2383 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2384 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 2385 | /* we are the responder */ |
| 2386 | ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr, |
| 2387 | sdata->u.mgd.bssid); |
| 2388 | break; |
| 2389 | default: |
| 2390 | ret = -ENOTSUPP; |
| 2391 | goto fail; |
| 2392 | } |
| 2393 | |
| 2394 | if (send_direct) { |
| 2395 | ieee80211_tx_skb(sdata, skb); |
| 2396 | return 0; |
| 2397 | } |
| 2398 | |
| 2399 | /* |
| 2400 | * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise |
| 2401 | * we should default to AC_VI. |
| 2402 | */ |
| 2403 | switch (action_code) { |
| 2404 | case WLAN_TDLS_SETUP_REQUEST: |
| 2405 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2406 | skb_set_queue_mapping(skb, IEEE80211_AC_BK); |
| 2407 | skb->priority = 2; |
| 2408 | break; |
| 2409 | default: |
| 2410 | skb_set_queue_mapping(skb, IEEE80211_AC_VI); |
| 2411 | skb->priority = 5; |
| 2412 | break; |
| 2413 | } |
| 2414 | |
| 2415 | /* disable bottom halves when entering the Tx path */ |
| 2416 | local_bh_disable(); |
| 2417 | ret = ieee80211_subif_start_xmit(skb, dev); |
| 2418 | local_bh_enable(); |
| 2419 | |
| 2420 | return ret; |
| 2421 | |
| 2422 | fail: |
| 2423 | dev_kfree_skb(skb); |
| 2424 | return ret; |
| 2425 | } |
| 2426 | |
| 2427 | static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 2428 | u8 *peer, enum nl80211_tdls_operation oper) |
| 2429 | { |
| 2430 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2431 | |
| 2432 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) |
| 2433 | return -ENOTSUPP; |
| 2434 | |
| 2435 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 2436 | return -EINVAL; |
| 2437 | |
| 2438 | #ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG |
| 2439 | printk(KERN_DEBUG "TDLS oper %d peer %pM\n", oper, peer); |
| 2440 | #endif |
| 2441 | |
| 2442 | switch (oper) { |
| 2443 | case NL80211_TDLS_ENABLE_LINK: |
| 2444 | break; |
| 2445 | case NL80211_TDLS_DISABLE_LINK: |
| 2446 | return sta_info_destroy_addr(sdata, peer); |
| 2447 | case NL80211_TDLS_TEARDOWN: |
| 2448 | case NL80211_TDLS_SETUP: |
| 2449 | case NL80211_TDLS_DISCOVERY_REQ: |
| 2450 | /* We don't support in-driver setup/teardown/discovery */ |
| 2451 | return -ENOTSUPP; |
| 2452 | default: |
| 2453 | return -ENOTSUPP; |
| 2454 | } |
| 2455 | |
| 2456 | return 0; |
| 2457 | } |
| 2458 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2459 | struct cfg80211_ops mac80211_config_ops = { |
| 2460 | .add_virtual_intf = ieee80211_add_iface, |
| 2461 | .del_virtual_intf = ieee80211_del_iface, |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 2462 | .change_virtual_intf = ieee80211_change_iface, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 2463 | .add_key = ieee80211_add_key, |
| 2464 | .del_key = ieee80211_del_key, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 2465 | .get_key = ieee80211_get_key, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 2466 | .set_default_key = ieee80211_config_default_key, |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 2467 | .set_default_mgmt_key = ieee80211_config_default_mgmt_key, |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 2468 | .add_beacon = ieee80211_add_beacon, |
| 2469 | .set_beacon = ieee80211_set_beacon, |
| 2470 | .del_beacon = ieee80211_del_beacon, |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 2471 | .add_station = ieee80211_add_station, |
| 2472 | .del_station = ieee80211_del_station, |
| 2473 | .change_station = ieee80211_change_station, |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 2474 | .get_station = ieee80211_get_station, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 2475 | .dump_station = ieee80211_dump_station, |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 2476 | .dump_survey = ieee80211_dump_survey, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 2477 | #ifdef CONFIG_MAC80211_MESH |
| 2478 | .add_mpath = ieee80211_add_mpath, |
| 2479 | .del_mpath = ieee80211_del_mpath, |
| 2480 | .change_mpath = ieee80211_change_mpath, |
| 2481 | .get_mpath = ieee80211_get_mpath, |
| 2482 | .dump_mpath = ieee80211_dump_mpath, |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 2483 | .update_mesh_config = ieee80211_update_mesh_config, |
| 2484 | .get_mesh_config = ieee80211_get_mesh_config, |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 2485 | .join_mesh = ieee80211_join_mesh, |
| 2486 | .leave_mesh = ieee80211_leave_mesh, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 2487 | #endif |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 2488 | .change_bss = ieee80211_change_bss, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 2489 | .set_txq_params = ieee80211_set_txq_params, |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 2490 | .set_channel = ieee80211_set_channel, |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 2491 | .suspend = ieee80211_suspend, |
| 2492 | .resume = ieee80211_resume, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 2493 | .scan = ieee80211_scan, |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 2494 | .sched_scan_start = ieee80211_sched_scan_start, |
| 2495 | .sched_scan_stop = ieee80211_sched_scan_stop, |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 2496 | .auth = ieee80211_auth, |
| 2497 | .assoc = ieee80211_assoc, |
| 2498 | .deauth = ieee80211_deauth, |
| 2499 | .disassoc = ieee80211_disassoc, |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 2500 | .join_ibss = ieee80211_join_ibss, |
| 2501 | .leave_ibss = ieee80211_leave_ibss, |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 2502 | .set_wiphy_params = ieee80211_set_wiphy_params, |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 2503 | .set_tx_power = ieee80211_set_tx_power, |
| 2504 | .get_tx_power = ieee80211_get_tx_power, |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 2505 | .set_wds_peer = ieee80211_set_wds_peer, |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 2506 | .rfkill_poll = ieee80211_rfkill_poll, |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 2507 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) |
Wey-Yi Guy | 71063f0 | 2011-05-20 09:05:54 -0700 | [diff] [blame] | 2508 | CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2509 | .set_power_mgmt = ieee80211_set_power_mgmt, |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2510 | .set_bitrate_mask = ieee80211_set_bitrate_mask, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2511 | .remain_on_channel = ieee80211_remain_on_channel, |
| 2512 | .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, |
Johannes Berg | 2e161f7 | 2010-08-12 15:38:38 +0200 | [diff] [blame] | 2513 | .mgmt_tx = ieee80211_mgmt_tx, |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2514 | .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait, |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2515 | .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config, |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2516 | .mgmt_frame_register = ieee80211_mgmt_frame_register, |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 2517 | .set_antenna = ieee80211_set_antenna, |
| 2518 | .get_antenna = ieee80211_get_antenna, |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 2519 | .set_ringparam = ieee80211_set_ringparam, |
| 2520 | .get_ringparam = ieee80211_get_ringparam, |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 2521 | .set_rekey_data = ieee80211_set_rekey_data, |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2522 | .tdls_oper = ieee80211_tdls_oper, |
| 2523 | .tdls_mgmt = ieee80211_tdls_mgmt, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2524 | }; |