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