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 | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 23 | static struct wireless_dev *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); |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 29 | struct wireless_dev *wdev; |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 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 | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 33 | err = ieee80211_if_add(local, name, &wdev, 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) { |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 38 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | f9e10ce | 2010-12-03 09:20:42 +0100 | [diff] [blame] | 39 | sdata->u.mntr_flags = *flags; |
| 40 | } |
| 41 | |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 42 | return wdev; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 45 | static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 46 | { |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 47 | ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 48 | |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 49 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Johannes Berg | e36d56b | 2009-06-09 21:04:43 +0200 | [diff] [blame] | 52 | static int ieee80211_change_iface(struct wiphy *wiphy, |
| 53 | struct net_device *dev, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 54 | enum nl80211_iftype type, u32 *flags, |
| 55 | struct vif_params *params) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 56 | { |
Johannes Berg | 9607e6b66 | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 57 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 58 | int ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 59 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 60 | ret = ieee80211_if_change_type(sdata, type); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 61 | if (ret) |
| 62 | return ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 63 | |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 64 | if (type == NL80211_IFTYPE_AP_VLAN && |
| 65 | params && params->use_4addr == 0) |
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 | |
Simon Wunderlich | b53be79 | 2011-11-18 14:20:44 +0100 | [diff] [blame] | 105 | static int ieee80211_set_noack_map(struct wiphy *wiphy, |
| 106 | struct net_device *dev, |
| 107 | u16 noack_map) |
| 108 | { |
| 109 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 110 | |
| 111 | sdata->noack_map = noack_map; |
| 112 | return 0; |
| 113 | } |
| 114 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 115 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 116 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 117 | struct key_params *params) |
| 118 | { |
Johannes Berg | 26a5845 | 2010-08-27 12:35:55 +0200 | [diff] [blame] | 119 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 120 | struct sta_info *sta = NULL; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 121 | struct ieee80211_key *key; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 122 | int err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 123 | |
Johannes Berg | 26a5845 | 2010-08-27 12:35:55 +0200 | [diff] [blame] | 124 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 125 | return -ENETDOWN; |
| 126 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 127 | /* reject WEP and TKIP keys if WEP failed to initialize */ |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 128 | switch (params->cipher) { |
| 129 | case WLAN_CIPHER_SUITE_WEP40: |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 130 | case WLAN_CIPHER_SUITE_TKIP: |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 131 | case WLAN_CIPHER_SUITE_WEP104: |
| 132 | if (IS_ERR(sdata->local->wep_tx_tfm)) |
| 133 | return -EINVAL; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 134 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 135 | default: |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 136 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 137 | } |
| 138 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 139 | key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, |
| 140 | params->key, params->seq_len, params->seq); |
Ben Hutchings | 1ac62ba | 2010-08-01 17:37:03 +0100 | [diff] [blame] | 141 | if (IS_ERR(key)) |
| 142 | return PTR_ERR(key); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 143 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 144 | if (pairwise) |
| 145 | key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE; |
| 146 | |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 147 | mutex_lock(&sdata->local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 148 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 149 | if (mac_addr) { |
Thomas Pedersen | ff973af | 2011-05-03 16:57:12 -0700 | [diff] [blame] | 150 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
| 151 | sta = sta_info_get(sdata, mac_addr); |
| 152 | else |
| 153 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 154 | if (!sta) { |
Jouni Malinen | 32162a4 | 2010-07-26 15:52:03 -0700 | [diff] [blame] | 155 | ieee80211_key_free(sdata->local, key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 156 | err = -ENOENT; |
| 157 | goto out_unlock; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 158 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Johannes Berg | 3ffc2a9 | 2010-08-27 14:26:52 +0300 | [diff] [blame] | 161 | err = ieee80211_key_link(key, sdata, sta); |
| 162 | if (err) |
| 163 | ieee80211_key_free(sdata->local, key); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 164 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 165 | out_unlock: |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 166 | mutex_unlock(&sdata->local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 167 | |
| 168 | return err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 172 | u8 key_idx, bool pairwise, const u8 *mac_addr) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 173 | { |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 174 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 175 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 176 | struct sta_info *sta; |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 177 | struct ieee80211_key *key = NULL; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 178 | int ret; |
| 179 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 180 | mutex_lock(&local->sta_mtx); |
| 181 | mutex_lock(&local->key_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 182 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 183 | if (mac_addr) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 184 | ret = -ENOENT; |
| 185 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 186 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 187 | if (!sta) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 188 | goto out_unlock; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 189 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 190 | if (pairwise) |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 191 | key = key_mtx_dereference(local, sta->ptk); |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 192 | else |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 193 | key = key_mtx_dereference(local, sta->gtk[key_idx]); |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 194 | } else |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 195 | key = key_mtx_dereference(local, sdata->keys[key_idx]); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 196 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 197 | if (!key) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 198 | ret = -ENOENT; |
| 199 | goto out_unlock; |
| 200 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 201 | |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 202 | __ieee80211_key_free(key); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 203 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 204 | ret = 0; |
| 205 | out_unlock: |
Johannes Berg | 5c0c364 | 2011-05-12 14:31:49 +0200 | [diff] [blame] | 206 | mutex_unlock(&local->key_mtx); |
| 207 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 208 | |
| 209 | return ret; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 210 | } |
| 211 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 212 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 213 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
| 214 | void *cookie, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 215 | void (*callback)(void *cookie, |
| 216 | struct key_params *params)) |
| 217 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 218 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 219 | struct sta_info *sta = NULL; |
| 220 | u8 seq[6] = {0}; |
| 221 | struct key_params params; |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 222 | struct ieee80211_key *key = NULL; |
Johannes Berg | aba83a0b | 2011-07-06 21:59:39 +0200 | [diff] [blame] | 223 | u64 pn64; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 224 | u32 iv32; |
| 225 | u16 iv16; |
| 226 | int err = -ENOENT; |
| 227 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 228 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 229 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 230 | rcu_read_lock(); |
| 231 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 232 | if (mac_addr) { |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 233 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 234 | if (!sta) |
| 235 | goto out; |
| 236 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 237 | if (pairwise) |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 238 | key = rcu_dereference(sta->ptk); |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 239 | else if (key_idx < NUM_DEFAULT_KEYS) |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 240 | key = rcu_dereference(sta->gtk[key_idx]); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 241 | } else |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 242 | key = rcu_dereference(sdata->keys[key_idx]); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 243 | |
| 244 | if (!key) |
| 245 | goto out; |
| 246 | |
| 247 | memset(¶ms, 0, sizeof(params)); |
| 248 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 249 | params.cipher = key->conf.cipher; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 250 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 251 | switch (key->conf.cipher) { |
| 252 | case WLAN_CIPHER_SUITE_TKIP: |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 253 | iv32 = key->u.tkip.tx.iv32; |
| 254 | iv16 = key->u.tkip.tx.iv16; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 255 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 256 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) |
| 257 | drv_get_tkip_seq(sdata->local, |
| 258 | key->conf.hw_key_idx, |
| 259 | &iv32, &iv16); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 260 | |
| 261 | seq[0] = iv16 & 0xff; |
| 262 | seq[1] = (iv16 >> 8) & 0xff; |
| 263 | seq[2] = iv32 & 0xff; |
| 264 | seq[3] = (iv32 >> 8) & 0xff; |
| 265 | seq[4] = (iv32 >> 16) & 0xff; |
| 266 | seq[5] = (iv32 >> 24) & 0xff; |
| 267 | params.seq = seq; |
| 268 | params.seq_len = 6; |
| 269 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 270 | case WLAN_CIPHER_SUITE_CCMP: |
Johannes Berg | aba83a0b | 2011-07-06 21:59:39 +0200 | [diff] [blame] | 271 | pn64 = atomic64_read(&key->u.ccmp.tx_pn); |
| 272 | seq[0] = pn64; |
| 273 | seq[1] = pn64 >> 8; |
| 274 | seq[2] = pn64 >> 16; |
| 275 | seq[3] = pn64 >> 24; |
| 276 | seq[4] = pn64 >> 32; |
| 277 | seq[5] = pn64 >> 40; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 278 | params.seq = seq; |
| 279 | params.seq_len = 6; |
| 280 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 281 | case WLAN_CIPHER_SUITE_AES_CMAC: |
Johannes Berg | 75396ae | 2011-07-06 22:00:35 +0200 | [diff] [blame] | 282 | pn64 = atomic64_read(&key->u.aes_cmac.tx_pn); |
| 283 | seq[0] = pn64; |
| 284 | seq[1] = pn64 >> 8; |
| 285 | seq[2] = pn64 >> 16; |
| 286 | seq[3] = pn64 >> 24; |
| 287 | seq[4] = pn64 >> 32; |
| 288 | seq[5] = pn64 >> 40; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 289 | params.seq = seq; |
| 290 | params.seq_len = 6; |
| 291 | break; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | params.key = key->conf.key; |
| 295 | params.key_len = key->conf.keylen; |
| 296 | |
| 297 | callback(cookie, ¶ms); |
| 298 | err = 0; |
| 299 | |
| 300 | out: |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 301 | rcu_read_unlock(); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 302 | return err; |
| 303 | } |
| 304 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 305 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
| 306 | struct net_device *dev, |
Johannes Berg | dbd2fd6 | 2010-12-09 19:58:59 +0100 | [diff] [blame] | 307 | u8 key_idx, bool uni, |
| 308 | bool multi) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 309 | { |
Johannes Berg | ad0e2b5 | 2010-06-01 10:19:19 +0200 | [diff] [blame] | 310 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 311 | |
Johannes Berg | f7e0104 | 2010-12-09 19:49:02 +0100 | [diff] [blame] | 312 | ieee80211_set_default_key(sdata, key_idx, uni, multi); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 313 | |
| 314 | return 0; |
| 315 | } |
| 316 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 317 | static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, |
| 318 | struct net_device *dev, |
| 319 | u8 key_idx) |
| 320 | { |
Johannes Berg | 66c5242 | 2010-07-22 13:58:51 +0200 | [diff] [blame] | 321 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 322 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 323 | ieee80211_set_default_mgmt_key(sdata, key_idx); |
| 324 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 325 | return 0; |
| 326 | } |
| 327 | |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 328 | static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx) |
| 329 | { |
| 330 | if (!(rate->flags & RATE_INFO_FLAGS_MCS)) { |
| 331 | struct ieee80211_supported_band *sband; |
| 332 | sband = sta->local->hw.wiphy->bands[ |
| 333 | sta->local->hw.conf.channel->band]; |
| 334 | rate->legacy = sband->bitrates[idx].bitrate; |
| 335 | } else |
| 336 | rate->mcs = idx; |
| 337 | } |
| 338 | |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 339 | void sta_set_rate_info_tx(struct sta_info *sta, |
| 340 | const struct ieee80211_tx_rate *rate, |
| 341 | struct rate_info *rinfo) |
| 342 | { |
| 343 | rinfo->flags = 0; |
| 344 | if (rate->flags & IEEE80211_TX_RC_MCS) |
| 345 | rinfo->flags |= RATE_INFO_FLAGS_MCS; |
| 346 | if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
| 347 | rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 348 | if (rate->flags & IEEE80211_TX_RC_SHORT_GI) |
| 349 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 350 | rate_idx_to_bitrate(rinfo, sta, rate->idx); |
| 351 | } |
| 352 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 353 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
| 354 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 355 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 356 | struct ieee80211_local *local = sdata->local; |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 357 | struct timespec uptime; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 358 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 359 | sinfo->generation = sdata->local->sta_generation; |
| 360 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 361 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
| 362 | STATION_INFO_RX_BYTES | |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 363 | STATION_INFO_TX_BYTES | |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 364 | STATION_INFO_RX_PACKETS | |
| 365 | STATION_INFO_TX_PACKETS | |
Bruno Randolf | b206b4ef | 2010-10-06 18:34:12 +0900 | [diff] [blame] | 366 | STATION_INFO_TX_RETRIES | |
| 367 | STATION_INFO_TX_FAILED | |
Ben Greear | 5a5c731 | 2010-10-07 16:39:20 -0700 | [diff] [blame] | 368 | STATION_INFO_TX_BITRATE | |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 369 | STATION_INFO_RX_BITRATE | |
Paul Stewart | f4263c9 | 2011-03-31 09:25:41 -0700 | [diff] [blame] | 370 | STATION_INFO_RX_DROP_MISC | |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 371 | STATION_INFO_BSS_PARAM | |
Helmut Schaa | 7a72476 | 2011-10-13 16:30:40 +0200 | [diff] [blame] | 372 | STATION_INFO_CONNECTED_TIME | |
Paul Stewart | a85e1d5 | 2011-12-09 11:01:49 -0800 | [diff] [blame] | 373 | STATION_INFO_STA_FLAGS | |
| 374 | STATION_INFO_BEACON_LOSS_COUNT; |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 375 | |
| 376 | do_posix_clock_monotonic_gettime(&uptime); |
| 377 | sinfo->connected_time = uptime.tv_sec - sta->last_connected; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 378 | |
| 379 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
| 380 | sinfo->rx_bytes = sta->rx_bytes; |
| 381 | sinfo->tx_bytes = sta->tx_bytes; |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 382 | sinfo->rx_packets = sta->rx_packets; |
| 383 | sinfo->tx_packets = sta->tx_packets; |
Bruno Randolf | b206b4ef | 2010-10-06 18:34:12 +0900 | [diff] [blame] | 384 | sinfo->tx_retries = sta->tx_retry_count; |
| 385 | sinfo->tx_failed = sta->tx_retry_failed; |
Ben Greear | 5a5c731 | 2010-10-07 16:39:20 -0700 | [diff] [blame] | 386 | sinfo->rx_dropped_misc = sta->rx_dropped; |
Paul Stewart | a85e1d5 | 2011-12-09 11:01:49 -0800 | [diff] [blame] | 387 | sinfo->beacon_loss_count = sta->beacon_loss_count; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 388 | |
John W. Linville | 19deffb | 2009-12-08 17:10:13 -0500 | [diff] [blame] | 389 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
| 390 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 391 | sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG; |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 392 | if (!local->ops->get_rssi || |
| 393 | drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal)) |
| 394 | sinfo->signal = (s8)sta->last_signal; |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 395 | sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 396 | } |
| 397 | |
Thomas Pedersen | 6b62bf3 | 2012-03-05 15:31:48 -0800 | [diff] [blame] | 398 | sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 399 | |
Felix Fietkau | 3af6334 | 2011-02-27 22:08:01 +0100 | [diff] [blame] | 400 | sinfo->rxrate.flags = 0; |
| 401 | if (sta->last_rx_rate_flag & RX_FLAG_HT) |
| 402 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS; |
| 403 | if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) |
| 404 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 405 | if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) |
| 406 | sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 407 | rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx); |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 408 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 409 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 410 | #ifdef CONFIG_MAC80211_MESH |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 411 | sinfo->filled |= STATION_INFO_LLID | |
| 412 | STATION_INFO_PLID | |
| 413 | STATION_INFO_PLINK_STATE; |
| 414 | |
| 415 | sinfo->llid = le16_to_cpu(sta->llid); |
| 416 | sinfo->plid = le16_to_cpu(sta->plid); |
| 417 | sinfo->plink_state = sta->plink_state; |
Javier Cardona | d299a1f | 2012-03-31 11:31:33 -0700 | [diff] [blame] | 418 | if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { |
| 419 | sinfo->filled |= STATION_INFO_T_OFFSET; |
| 420 | sinfo->t_offset = sta->t_offset; |
| 421 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 422 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 423 | } |
Paul Stewart | f4263c9 | 2011-03-31 09:25:41 -0700 | [diff] [blame] | 424 | |
| 425 | sinfo->bss_param.flags = 0; |
| 426 | if (sdata->vif.bss_conf.use_cts_prot) |
| 427 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; |
| 428 | if (sdata->vif.bss_conf.use_short_preamble) |
| 429 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; |
| 430 | if (sdata->vif.bss_conf.use_short_slot) |
| 431 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; |
| 432 | sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period; |
| 433 | sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; |
Helmut Schaa | 7a72476 | 2011-10-13 16:30:40 +0200 | [diff] [blame] | 434 | |
| 435 | sinfo->sta_flags.set = 0; |
| 436 | sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | |
| 437 | BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | |
| 438 | BIT(NL80211_STA_FLAG_WME) | |
| 439 | BIT(NL80211_STA_FLAG_MFP) | |
Helmut Schaa | e412156 | 2011-11-05 14:15:24 +0100 | [diff] [blame] | 440 | BIT(NL80211_STA_FLAG_AUTHENTICATED) | |
| 441 | BIT(NL80211_STA_FLAG_TDLS_PEER); |
Helmut Schaa | 7a72476 | 2011-10-13 16:30:40 +0200 | [diff] [blame] | 442 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
| 443 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); |
| 444 | if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) |
| 445 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); |
| 446 | if (test_sta_flag(sta, WLAN_STA_WME)) |
| 447 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); |
| 448 | if (test_sta_flag(sta, WLAN_STA_MFP)) |
| 449 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); |
| 450 | if (test_sta_flag(sta, WLAN_STA_AUTH)) |
| 451 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); |
Helmut Schaa | e412156 | 2011-11-05 14:15:24 +0100 | [diff] [blame] | 452 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) |
| 453 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 454 | } |
| 455 | |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 456 | static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = { |
| 457 | "rx_packets", "rx_bytes", "wep_weak_iv_count", |
| 458 | "rx_duplicates", "rx_fragments", "rx_dropped", |
| 459 | "tx_packets", "tx_bytes", "tx_fragments", |
| 460 | "tx_filtered", "tx_retry_failed", "tx_retries", |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 461 | "beacon_loss", "sta_state", "txrate", "rxrate", "signal", |
| 462 | "channel", "noise", "ch_time", "ch_time_busy", |
| 463 | "ch_time_ext_busy", "ch_time_rx", "ch_time_tx" |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 464 | }; |
| 465 | #define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats) |
| 466 | |
| 467 | static int ieee80211_get_et_sset_count(struct wiphy *wiphy, |
| 468 | struct net_device *dev, |
| 469 | int sset) |
| 470 | { |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 471 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 472 | int rv = 0; |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 473 | |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 474 | if (sset == ETH_SS_STATS) |
| 475 | rv += STA_STATS_LEN; |
| 476 | |
| 477 | rv += drv_get_et_sset_count(sdata, sset); |
| 478 | |
| 479 | if (rv == 0) |
| 480 | return -EOPNOTSUPP; |
| 481 | return rv; |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | static void ieee80211_get_et_stats(struct wiphy *wiphy, |
| 485 | struct net_device *dev, |
| 486 | struct ethtool_stats *stats, |
| 487 | u64 *data) |
| 488 | { |
| 489 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 490 | struct sta_info *sta; |
| 491 | struct ieee80211_local *local = sdata->local; |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 492 | struct station_info sinfo; |
| 493 | struct survey_info survey; |
| 494 | int i, q; |
| 495 | #define STA_STATS_SURVEY_LEN 7 |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 496 | |
| 497 | memset(data, 0, sizeof(u64) * STA_STATS_LEN); |
| 498 | |
| 499 | #define ADD_STA_STATS(sta) \ |
| 500 | do { \ |
| 501 | data[i++] += sta->rx_packets; \ |
| 502 | data[i++] += sta->rx_bytes; \ |
| 503 | data[i++] += sta->wep_weak_iv_count; \ |
| 504 | data[i++] += sta->num_duplicates; \ |
| 505 | data[i++] += sta->rx_fragments; \ |
| 506 | data[i++] += sta->rx_dropped; \ |
| 507 | \ |
| 508 | data[i++] += sta->tx_packets; \ |
| 509 | data[i++] += sta->tx_bytes; \ |
| 510 | data[i++] += sta->tx_fragments; \ |
| 511 | data[i++] += sta->tx_filtered_count; \ |
| 512 | data[i++] += sta->tx_retry_failed; \ |
| 513 | data[i++] += sta->tx_retry_count; \ |
| 514 | data[i++] += sta->beacon_loss_count; \ |
| 515 | } while (0) |
| 516 | |
| 517 | /* For Managed stations, find the single station based on BSSID |
| 518 | * and use that. For interface types, iterate through all available |
| 519 | * stations and add stats for any station that is assigned to this |
| 520 | * network device. |
| 521 | */ |
| 522 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 523 | mutex_lock(&local->sta_mtx); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 524 | |
| 525 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
| 526 | sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid); |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 527 | |
| 528 | if (!(sta && !WARN_ON(sta->sdata->dev != dev))) |
| 529 | goto do_survey; |
| 530 | |
| 531 | i = 0; |
| 532 | ADD_STA_STATS(sta); |
| 533 | |
| 534 | data[i++] = sta->sta_state; |
| 535 | |
| 536 | sinfo.filled = 0; |
| 537 | sta_set_sinfo(sta, &sinfo); |
| 538 | |
Joe Perches | 5204267 | 2012-05-30 13:25:54 -0700 | [diff] [blame] | 539 | if (sinfo.filled & STATION_INFO_TX_BITRATE) |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 540 | data[i] = 100000 * |
| 541 | cfg80211_calculate_bitrate(&sinfo.txrate); |
| 542 | i++; |
Joe Perches | 5204267 | 2012-05-30 13:25:54 -0700 | [diff] [blame] | 543 | if (sinfo.filled & STATION_INFO_RX_BITRATE) |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 544 | data[i] = 100000 * |
| 545 | cfg80211_calculate_bitrate(&sinfo.rxrate); |
| 546 | i++; |
| 547 | |
Joe Perches | 5204267 | 2012-05-30 13:25:54 -0700 | [diff] [blame] | 548 | if (sinfo.filled & STATION_INFO_SIGNAL_AVG) |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 549 | data[i] = (u8)sinfo.signal_avg; |
| 550 | i++; |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 551 | } else { |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 552 | list_for_each_entry(sta, &local->sta_list, list) { |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 553 | /* Make sure this station belongs to the proper dev */ |
| 554 | if (sta->sdata->dev != dev) |
| 555 | continue; |
| 556 | |
| 557 | i = 0; |
| 558 | ADD_STA_STATS(sta); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 559 | } |
| 560 | } |
| 561 | |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 562 | do_survey: |
| 563 | i = STA_STATS_LEN - STA_STATS_SURVEY_LEN; |
| 564 | /* Get survey stats for current channel */ |
| 565 | q = 0; |
| 566 | while (true) { |
| 567 | survey.filled = 0; |
| 568 | if (drv_get_survey(local, q, &survey) != 0) { |
| 569 | survey.filled = 0; |
| 570 | break; |
| 571 | } |
| 572 | |
| 573 | if (survey.channel && |
| 574 | (local->oper_channel->center_freq == |
| 575 | survey.channel->center_freq)) |
| 576 | break; |
| 577 | q++; |
| 578 | } |
| 579 | |
| 580 | if (survey.filled) |
| 581 | data[i++] = survey.channel->center_freq; |
| 582 | else |
| 583 | data[i++] = 0; |
| 584 | if (survey.filled & SURVEY_INFO_NOISE_DBM) |
| 585 | data[i++] = (u8)survey.noise; |
| 586 | else |
| 587 | data[i++] = -1LL; |
| 588 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME) |
| 589 | data[i++] = survey.channel_time; |
| 590 | else |
| 591 | data[i++] = -1LL; |
| 592 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY) |
| 593 | data[i++] = survey.channel_time_busy; |
| 594 | else |
| 595 | data[i++] = -1LL; |
| 596 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY) |
| 597 | data[i++] = survey.channel_time_ext_busy; |
| 598 | else |
| 599 | data[i++] = -1LL; |
| 600 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX) |
| 601 | data[i++] = survey.channel_time_rx; |
| 602 | else |
| 603 | data[i++] = -1LL; |
| 604 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX) |
| 605 | data[i++] = survey.channel_time_tx; |
| 606 | else |
| 607 | data[i++] = -1LL; |
| 608 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 609 | mutex_unlock(&local->sta_mtx); |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 610 | |
Ben Greear | 3073a7c | 2012-04-23 12:50:32 -0700 | [diff] [blame] | 611 | if (WARN_ON(i != STA_STATS_LEN)) |
| 612 | return; |
| 613 | |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 614 | drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN])); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | static void ieee80211_get_et_strings(struct wiphy *wiphy, |
| 618 | struct net_device *dev, |
| 619 | u32 sset, u8 *data) |
| 620 | { |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 621 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 622 | int sz_sta_stats = 0; |
| 623 | |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 624 | if (sset == ETH_SS_STATS) { |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 625 | sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 626 | memcpy(data, *ieee80211_gstrings_sta_stats, sz_sta_stats); |
| 627 | } |
Ben Greear | e352114 | 2012-04-23 12:50:31 -0700 | [diff] [blame] | 628 | drv_get_et_strings(sdata, sset, &(data[sz_sta_stats])); |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 629 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 630 | |
| 631 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 632 | int idx, u8 *mac, struct station_info *sinfo) |
| 633 | { |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 634 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 635 | struct ieee80211_local *local = sdata->local; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 636 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 637 | int ret = -ENOENT; |
| 638 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 639 | mutex_lock(&local->sta_mtx); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 640 | |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 641 | sta = sta_info_get_by_idx(sdata, idx); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 642 | if (sta) { |
| 643 | ret = 0; |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 644 | memcpy(mac, sta->sta.addr, ETH_ALEN); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 645 | sta_set_sinfo(sta, sinfo); |
| 646 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 647 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 648 | mutex_unlock(&local->sta_mtx); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 649 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 650 | return ret; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 651 | } |
| 652 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 653 | static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, |
| 654 | int idx, struct survey_info *survey) |
| 655 | { |
| 656 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 657 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 658 | return drv_get_survey(local, idx, survey); |
| 659 | } |
| 660 | |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 661 | 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] | 662 | u8 *mac, struct station_info *sinfo) |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 663 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 664 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 665 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 666 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 667 | int ret = -ENOENT; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 668 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 669 | mutex_lock(&local->sta_mtx); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 670 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 671 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 672 | if (sta) { |
| 673 | ret = 0; |
| 674 | sta_set_sinfo(sta, sinfo); |
| 675 | } |
| 676 | |
Victor Goldenshtein | 66572cf | 2012-06-21 10:56:46 +0300 | [diff] [blame] | 677 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 678 | |
| 679 | return ret; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 680 | } |
| 681 | |
Johannes Berg | 3d9e6e1 | 2012-05-16 23:50:16 +0200 | [diff] [blame] | 682 | static int ieee80211_set_channel(struct wiphy *wiphy, |
| 683 | struct net_device *netdev, |
| 684 | struct ieee80211_channel *chan, |
| 685 | enum nl80211_channel_type channel_type) |
| 686 | { |
| 687 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 688 | struct ieee80211_sub_if_data *sdata = NULL; |
| 689 | |
| 690 | if (netdev) |
| 691 | sdata = IEEE80211_DEV_TO_SUB_IF(netdev); |
| 692 | |
| 693 | switch (ieee80211_get_channel_mode(local, NULL)) { |
| 694 | case CHAN_MODE_HOPPING: |
| 695 | return -EBUSY; |
| 696 | case CHAN_MODE_FIXED: |
Pontus Fuchs | ac4d82f | 2012-06-12 14:13:19 +0200 | [diff] [blame] | 697 | if (local->oper_channel != chan || |
| 698 | (!sdata && local->_oper_channel_type != channel_type)) |
Johannes Berg | 3d9e6e1 | 2012-05-16 23:50:16 +0200 | [diff] [blame] | 699 | return -EBUSY; |
| 700 | if (!sdata && local->_oper_channel_type == channel_type) |
| 701 | return 0; |
| 702 | break; |
| 703 | case CHAN_MODE_UNDEFINED: |
| 704 | break; |
| 705 | } |
| 706 | |
| 707 | if (!ieee80211_set_channel_type(local, sdata, channel_type)) |
| 708 | return -EBUSY; |
| 709 | |
| 710 | local->oper_channel = chan; |
| 711 | |
| 712 | /* auto-detects changes */ |
| 713 | ieee80211_hw_config(local, 0); |
| 714 | |
| 715 | return 0; |
| 716 | } |
| 717 | |
Johannes Berg | e8c9bd5 | 2012-06-06 08:18:22 +0200 | [diff] [blame] | 718 | static int ieee80211_set_monitor_channel(struct wiphy *wiphy, |
| 719 | struct ieee80211_channel *chan, |
| 720 | enum nl80211_channel_type channel_type) |
| 721 | { |
| 722 | return ieee80211_set_channel(wiphy, NULL, chan, channel_type); |
| 723 | } |
| 724 | |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 725 | static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 726 | const u8 *resp, size_t resp_len) |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 727 | { |
| 728 | struct sk_buff *new, *old; |
| 729 | |
| 730 | if (!resp || !resp_len) |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 731 | return 1; |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 732 | |
Arik Nemtsov | f724828 | 2011-11-19 10:51:26 +0200 | [diff] [blame] | 733 | old = rtnl_dereference(sdata->u.ap.probe_resp); |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 734 | |
| 735 | new = dev_alloc_skb(resp_len); |
| 736 | if (!new) |
| 737 | return -ENOMEM; |
| 738 | |
| 739 | memcpy(skb_put(new, resp_len), resp, resp_len); |
| 740 | |
| 741 | rcu_assign_pointer(sdata->u.ap.probe_resp, new); |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 742 | if (old) { |
| 743 | /* TODO: use call_rcu() */ |
| 744 | synchronize_rcu(); |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 745 | dev_kfree_skb(old); |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 746 | } |
Arik Nemtsov | 0294582 | 2011-11-10 11:28:57 +0200 | [diff] [blame] | 747 | |
| 748 | return 0; |
| 749 | } |
| 750 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 751 | static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, |
| 752 | struct cfg80211_beacon_data *params) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 753 | { |
| 754 | struct beacon_data *new, *old; |
| 755 | int new_head_len, new_tail_len; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 756 | int size, err; |
| 757 | u32 changed = BSS_CHANGED_BEACON; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 758 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 759 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 760 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 761 | /* Need to have a beacon head if we don't have one yet */ |
| 762 | if (!params->head && !old) |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 763 | return -EINVAL; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 764 | |
| 765 | /* new or old head? */ |
| 766 | if (params->head) |
| 767 | new_head_len = params->head_len; |
| 768 | else |
| 769 | new_head_len = old->head_len; |
| 770 | |
| 771 | /* new or old tail? */ |
| 772 | if (params->tail || !old) |
| 773 | /* params->tail_len will be zero for !params->tail */ |
| 774 | new_tail_len = params->tail_len; |
| 775 | else |
| 776 | new_tail_len = old->tail_len; |
| 777 | |
| 778 | size = sizeof(*new) + new_head_len + new_tail_len; |
| 779 | |
| 780 | new = kzalloc(size, GFP_KERNEL); |
| 781 | if (!new) |
| 782 | return -ENOMEM; |
| 783 | |
| 784 | /* start filling the new info now */ |
| 785 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 786 | /* |
| 787 | * pointers go into the block we allocated, |
| 788 | * memory is | beacon_data | head | tail | |
| 789 | */ |
| 790 | new->head = ((u8 *) new) + sizeof(*new); |
| 791 | new->tail = new->head + new_head_len; |
| 792 | new->head_len = new_head_len; |
| 793 | new->tail_len = new_tail_len; |
| 794 | |
| 795 | /* copy in head */ |
| 796 | if (params->head) |
| 797 | memcpy(new->head, params->head, new_head_len); |
| 798 | else |
| 799 | memcpy(new->head, old->head, new_head_len); |
| 800 | |
| 801 | /* copy in optional tail */ |
| 802 | if (params->tail) |
| 803 | memcpy(new->tail, params->tail, new_tail_len); |
| 804 | else |
| 805 | if (old) |
| 806 | memcpy(new->tail, old->tail, new_tail_len); |
| 807 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 808 | err = ieee80211_set_probe_resp(sdata, params->probe_resp, |
| 809 | params->probe_resp_len); |
| 810 | if (err < 0) |
| 811 | return err; |
| 812 | if (err == 0) |
| 813 | changed |= BSS_CHANGED_AP_PROBE_RESP; |
Johannes Berg | 19885c4 | 2010-02-05 11:45:06 +0100 | [diff] [blame] | 814 | |
Eric Dumazet | cf778b0 | 2012-01-12 04:41:32 +0000 | [diff] [blame] | 815 | rcu_assign_pointer(sdata->u.ap.beacon, new); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 816 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 817 | if (old) |
| 818 | kfree_rcu(old, rcu_head); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 819 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 820 | return changed; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 821 | } |
| 822 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 823 | static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, |
| 824 | struct cfg80211_ap_settings *params) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 825 | { |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 826 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 827 | struct beacon_data *old; |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 828 | struct ieee80211_sub_if_data *vlan; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 829 | u32 changed = BSS_CHANGED_BEACON_INT | |
| 830 | BSS_CHANGED_BEACON_ENABLED | |
| 831 | BSS_CHANGED_BEACON | |
| 832 | BSS_CHANGED_SSID; |
| 833 | int err; |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 834 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 835 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 836 | if (old) |
| 837 | return -EALREADY; |
| 838 | |
Johannes Berg | aa430da | 2012-05-16 23:50:18 +0200 | [diff] [blame] | 839 | err = ieee80211_set_channel(wiphy, dev, params->channel, |
| 840 | params->channel_type); |
| 841 | if (err) |
| 842 | return err; |
| 843 | |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 844 | /* |
| 845 | * Apply control port protocol, this allows us to |
| 846 | * not encrypt dynamic WEP control frames. |
| 847 | */ |
| 848 | sdata->control_port_protocol = params->crypto.control_port_ethertype; |
| 849 | sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt; |
| 850 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { |
| 851 | vlan->control_port_protocol = |
| 852 | params->crypto.control_port_ethertype; |
| 853 | vlan->control_port_no_encrypt = |
| 854 | params->crypto.control_port_no_encrypt; |
| 855 | } |
| 856 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 857 | sdata->vif.bss_conf.beacon_int = params->beacon_interval; |
| 858 | sdata->vif.bss_conf.dtim_period = params->dtim_period; |
| 859 | |
| 860 | sdata->vif.bss_conf.ssid_len = params->ssid_len; |
| 861 | if (params->ssid_len) |
| 862 | memcpy(sdata->vif.bss_conf.ssid, params->ssid, |
| 863 | params->ssid_len); |
| 864 | sdata->vif.bss_conf.hidden_ssid = |
| 865 | (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); |
| 866 | |
| 867 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon); |
| 868 | if (err < 0) |
| 869 | return err; |
| 870 | changed |= err; |
| 871 | |
| 872 | ieee80211_bss_info_change_notify(sdata, changed); |
| 873 | |
Johannes Berg | 3edaf3e | 2012-04-03 10:24:00 +0200 | [diff] [blame] | 874 | netif_carrier_on(dev); |
| 875 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
| 876 | netif_carrier_on(vlan->dev); |
| 877 | |
Johannes Berg | 665c93a | 2011-11-04 11:18:11 +0100 | [diff] [blame] | 878 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 879 | } |
| 880 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 881 | static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 882 | struct cfg80211_beacon_data *params) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 883 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 884 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 885 | struct beacon_data *old; |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 886 | int err; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 887 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 888 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 889 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 890 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 891 | if (!old) |
| 892 | return -ENOENT; |
| 893 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 894 | err = ieee80211_assign_beacon(sdata, params); |
| 895 | if (err < 0) |
| 896 | return err; |
| 897 | ieee80211_bss_info_change_notify(sdata, err); |
| 898 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 899 | } |
| 900 | |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 901 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 902 | { |
Johannes Berg | 3edaf3e | 2012-04-03 10:24:00 +0200 | [diff] [blame] | 903 | struct ieee80211_sub_if_data *sdata, *vlan; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 904 | struct beacon_data *old; |
| 905 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 906 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 907 | |
Johannes Berg | 40b275b | 2011-05-13 14:15:49 +0200 | [diff] [blame] | 908 | old = rtnl_dereference(sdata->u.ap.beacon); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 909 | if (!old) |
| 910 | return -ENOENT; |
| 911 | |
Johannes Berg | 3edaf3e | 2012-04-03 10:24:00 +0200 | [diff] [blame] | 912 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
| 913 | netif_carrier_off(vlan->dev); |
| 914 | netif_carrier_off(dev); |
| 915 | |
Stephen Hemminger | a9b3cd7 | 2011-08-01 16:19:00 +0000 | [diff] [blame] | 916 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 917 | |
| 918 | kfree_rcu(old, rcu_head); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 919 | |
Eliad Peller | 99102bd | 2012-07-18 15:36:04 +0300 | [diff] [blame] | 920 | sta_info_flush(sdata->local, sdata); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 921 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 922 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 923 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 924 | } |
| 925 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 926 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
| 927 | struct iapp_layer2_update { |
| 928 | u8 da[ETH_ALEN]; /* broadcast */ |
| 929 | u8 sa[ETH_ALEN]; /* STA addr */ |
| 930 | __be16 len; /* 6 */ |
| 931 | u8 dsap; /* 0 */ |
| 932 | u8 ssap; /* 0 */ |
| 933 | u8 control; |
| 934 | u8 xid_info[3]; |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 935 | } __packed; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 936 | |
| 937 | static void ieee80211_send_layer2_update(struct sta_info *sta) |
| 938 | { |
| 939 | struct iapp_layer2_update *msg; |
| 940 | struct sk_buff *skb; |
| 941 | |
| 942 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 |
| 943 | * bridge devices */ |
| 944 | |
| 945 | skb = dev_alloc_skb(sizeof(*msg)); |
| 946 | if (!skb) |
| 947 | return; |
| 948 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); |
| 949 | |
| 950 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) |
| 951 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ |
| 952 | |
| 953 | memset(msg->da, 0xff, ETH_ALEN); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 954 | memcpy(msg->sa, sta->sta.addr, ETH_ALEN); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 955 | msg->len = htons(6); |
| 956 | msg->dsap = 0; |
| 957 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ |
| 958 | msg->control = 0xaf; /* XID response lsb.1111F101. |
| 959 | * F=0 (no poll command; unsolicited frame) */ |
| 960 | msg->xid_info[0] = 0x81; /* XID format identifier */ |
| 961 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ |
| 962 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ |
| 963 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 964 | skb->dev = sta->sdata->dev; |
| 965 | skb->protocol = eth_type_trans(skb, sta->sdata->dev); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 966 | memset(skb->cb, 0, sizeof(skb->cb)); |
John W. Linville | 06ee1c2 | 2010-07-19 11:52:59 -0400 | [diff] [blame] | 967 | netif_rx_ni(skb); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 968 | } |
| 969 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 970 | static int sta_apply_parameters(struct ieee80211_local *local, |
| 971 | struct sta_info *sta, |
| 972 | struct station_parameters *params) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 973 | { |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 974 | int ret = 0; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 975 | u32 rates; |
| 976 | int i, j; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 977 | struct ieee80211_supported_band *sband; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 978 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 979 | u32 mask, set; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 980 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 981 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
| 982 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 983 | mask = params->sta_flags_mask; |
| 984 | set = params->sta_flags_set; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 985 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 986 | /* |
| 987 | * In mesh mode, we can clear AUTHENTICATED flag but must |
| 988 | * also make ASSOCIATED follow appropriately for the driver |
| 989 | * API. See also below, after AUTHORIZED changes. |
| 990 | */ |
| 991 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) { |
| 992 | /* cfg80211 should not allow this in non-mesh modes */ |
| 993 | if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif))) |
| 994 | return -EINVAL; |
| 995 | |
| 996 | if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) && |
| 997 | !test_sta_flag(sta, WLAN_STA_AUTH)) { |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 998 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 999 | if (ret) |
| 1000 | return ret; |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 1001 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1002 | if (ret) |
| 1003 | return ret; |
| 1004 | } |
| 1005 | } |
| 1006 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1007 | if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1008 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 1009 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); |
Johannes Berg | 543d1b9 | 2012-01-13 14:17:59 +0100 | [diff] [blame] | 1010 | else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 1011 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1012 | if (ret) |
| 1013 | return ret; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1014 | } |
| 1015 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1016 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) { |
| 1017 | /* cfg80211 should not allow this in non-mesh modes */ |
| 1018 | if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif))) |
| 1019 | return -EINVAL; |
| 1020 | |
| 1021 | if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) && |
| 1022 | test_sta_flag(sta, WLAN_STA_AUTH)) { |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 1023 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1024 | if (ret) |
| 1025 | return ret; |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 1026 | ret = sta_info_move_state(sta, IEEE80211_STA_NONE); |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1027 | if (ret) |
| 1028 | return ret; |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1033 | if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1034 | if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1035 | set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); |
| 1036 | else |
| 1037 | clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1038 | } |
| 1039 | |
| 1040 | if (mask & BIT(NL80211_STA_FLAG_WME)) { |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 1041 | if (set & BIT(NL80211_STA_FLAG_WME)) { |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1042 | set_sta_flag(sta, WLAN_STA_WME); |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 1043 | sta->sta.wme = true; |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1044 | } else { |
| 1045 | clear_sta_flag(sta, WLAN_STA_WME); |
| 1046 | sta->sta.wme = false; |
Arik Nemtsov | 39df600 | 2011-06-27 23:58:45 +0300 | [diff] [blame] | 1047 | } |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1048 | } |
| 1049 | |
| 1050 | if (mask & BIT(NL80211_STA_FLAG_MFP)) { |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1051 | if (set & BIT(NL80211_STA_FLAG_MFP)) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1052 | set_sta_flag(sta, WLAN_STA_MFP); |
| 1053 | else |
| 1054 | clear_sta_flag(sta, WLAN_STA_MFP); |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1055 | } |
Javier Cardona | b39c48f | 2011-04-07 15:08:30 -0700 | [diff] [blame] | 1056 | |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame] | 1057 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame] | 1058 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1059 | set_sta_flag(sta, WLAN_STA_TDLS_PEER); |
| 1060 | else |
| 1061 | clear_sta_flag(sta, WLAN_STA_TDLS_PEER); |
Arik Nemtsov | 07ba55d | 2011-09-28 14:12:53 +0300 | [diff] [blame] | 1062 | } |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 1063 | |
Johannes Berg | 3b9ce80 | 2011-09-27 20:56:12 +0200 | [diff] [blame] | 1064 | if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) { |
| 1065 | sta->sta.uapsd_queues = params->uapsd_queues; |
| 1066 | sta->sta.max_sp = params->max_sp; |
| 1067 | } |
Eliad Peller | 9533b4a | 2011-08-23 14:37:47 +0300 | [diff] [blame] | 1068 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1069 | /* |
Johannes Berg | 51b50fb | 2009-05-24 16:42:30 +0200 | [diff] [blame] | 1070 | * cfg80211 validates this (1-2007) and allows setting the AID |
| 1071 | * only when creating a new station entry |
| 1072 | */ |
| 1073 | if (params->aid) |
| 1074 | sta->sta.aid = params->aid; |
| 1075 | |
| 1076 | /* |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1077 | * FIXME: updating the following information is racy when this |
| 1078 | * function is called from ieee80211_change_station(). |
| 1079 | * However, all this information should be static so |
| 1080 | * maybe we should just reject attemps to change it. |
| 1081 | */ |
| 1082 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1083 | if (params->listen_interval >= 0) |
| 1084 | sta->listen_interval = params->listen_interval; |
| 1085 | |
| 1086 | if (params->supported_rates) { |
| 1087 | rates = 0; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 1088 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1089 | for (i = 0; i < params->supported_rates_len; i++) { |
| 1090 | int rate = (params->supported_rates[i] & 0x7f) * 5; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 1091 | for (j = 0; j < sband->n_bitrates; j++) { |
| 1092 | if (sband->bitrates[j].bitrate == rate) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1093 | rates |= BIT(j); |
| 1094 | } |
| 1095 | } |
Johannes Berg | 323ce79 | 2008-09-11 02:45:11 +0200 | [diff] [blame] | 1096 | sta->sta.supp_rates[local->oper_channel->band] = rates; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1097 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1098 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 1099 | if (params->ht_capa) |
Ben Greear | ef96a842 | 2011-11-18 11:32:00 -0800 | [diff] [blame] | 1100 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 1101 | params->ht_capa, |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 1102 | &sta->sta.ht_cap); |
Jouni Malinen | 36aedc9 | 2008-08-25 11:58:58 +0300 | [diff] [blame] | 1103 | |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 1104 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Yogesh Ashok Powar | 4daf50f | 2011-05-12 09:32:17 -0400 | [diff] [blame] | 1105 | #ifdef CONFIG_MAC80211_MESH |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 1106 | if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) |
| 1107 | switch (params->plink_state) { |
Javier Cardona | 57cf804 | 2011-05-13 10:45:43 -0700 | [diff] [blame] | 1108 | case NL80211_PLINK_LISTEN: |
| 1109 | case NL80211_PLINK_ESTAB: |
| 1110 | case NL80211_PLINK_BLOCKED: |
Javier Cardona | 9c3990a | 2011-05-03 16:57:11 -0700 | [diff] [blame] | 1111 | sta->plink_state = params->plink_state; |
| 1112 | break; |
| 1113 | default: |
| 1114 | /* nothing */ |
| 1115 | break; |
| 1116 | } |
| 1117 | else |
| 1118 | switch (params->plink_action) { |
| 1119 | case PLINK_ACTION_OPEN: |
| 1120 | mesh_plink_open(sta); |
| 1121 | break; |
| 1122 | case PLINK_ACTION_BLOCK: |
| 1123 | mesh_plink_block(sta); |
| 1124 | break; |
| 1125 | } |
Yogesh Ashok Powar | 4daf50f | 2011-05-12 09:32:17 -0400 | [diff] [blame] | 1126 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 1127 | } |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1128 | |
| 1129 | return 0; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
| 1133 | u8 *mac, struct station_parameters *params) |
| 1134 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1135 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1136 | struct sta_info *sta; |
| 1137 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1138 | int err; |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 1139 | int layer2_update; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1140 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1141 | if (params->vlan) { |
| 1142 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 1143 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 1144 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 1145 | sdata->vif.type != NL80211_IFTYPE_AP) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1146 | return -EINVAL; |
| 1147 | } else |
| 1148 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1149 | |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 1150 | if (ether_addr_equal(mac, sdata->vif.addr)) |
Johannes Berg | 03e4497 | 2008-02-27 09:56:40 +0100 | [diff] [blame] | 1151 | return -EINVAL; |
| 1152 | |
| 1153 | if (is_multicast_ether_addr(mac)) |
| 1154 | return -EINVAL; |
| 1155 | |
| 1156 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1157 | if (!sta) |
| 1158 | return -ENOMEM; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1159 | |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 1160 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); |
| 1161 | sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1162 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1163 | err = sta_apply_parameters(local, sta, params); |
| 1164 | if (err) { |
| 1165 | sta_info_free(local, sta); |
| 1166 | return err; |
| 1167 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1168 | |
Arik Nemtsov | d64cf63 | 2011-11-07 23:24:39 +0200 | [diff] [blame] | 1169 | /* |
| 1170 | * for TDLS, rate control should be initialized only when supported |
| 1171 | * rates are known. |
| 1172 | */ |
| 1173 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) |
| 1174 | rate_control_rate_init(sta); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1175 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 1176 | layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
| 1177 | sdata->vif.type == NL80211_IFTYPE_AP; |
| 1178 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1179 | err = sta_info_insert_rcu(sta); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1180 | if (err) { |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1181 | rcu_read_unlock(); |
| 1182 | return err; |
| 1183 | } |
| 1184 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 1185 | if (layer2_update) |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 1186 | ieee80211_send_layer2_update(sta); |
| 1187 | |
| 1188 | rcu_read_unlock(); |
| 1189 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1190 | return 0; |
| 1191 | } |
| 1192 | |
| 1193 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 1194 | u8 *mac) |
| 1195 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1196 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1197 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1198 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1199 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1200 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1201 | if (mac) |
| 1202 | return sta_info_destroy_addr_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1203 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1204 | sta_info_flush(local, sdata); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1205 | return 0; |
| 1206 | } |
| 1207 | |
| 1208 | static int ieee80211_change_station(struct wiphy *wiphy, |
| 1209 | struct net_device *dev, |
| 1210 | u8 *mac, |
| 1211 | struct station_parameters *params) |
| 1212 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1213 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1214 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1215 | struct sta_info *sta; |
| 1216 | struct ieee80211_sub_if_data *vlansdata; |
Eliad Peller | 35b8862 | 2011-12-29 14:41:39 +0200 | [diff] [blame] | 1217 | int err; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1218 | |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1219 | mutex_lock(&local->sta_mtx); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1220 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 1221 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1222 | if (!sta) { |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1223 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1224 | return -ENOENT; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1225 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1226 | |
Johannes Berg | bdd90d5 | 2011-12-14 12:20:27 +0100 | [diff] [blame] | 1227 | /* in station mode, supported rates are only valid with TDLS */ |
| 1228 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
| 1229 | params->supported_rates && |
| 1230 | !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1231 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | bdd90d5 | 2011-12-14 12:20:27 +0100 | [diff] [blame] | 1232 | return -EINVAL; |
| 1233 | } |
| 1234 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1235 | if (params->vlan && params->vlan != sta->sdata->dev) { |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1236 | bool prev_4addr = false; |
| 1237 | bool new_4addr = false; |
| 1238 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1239 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 1240 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 1241 | if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 1242 | vlansdata->vif.type != NL80211_IFTYPE_AP) { |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1243 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1244 | return -EINVAL; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1245 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1246 | |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 1247 | if (params->vlan->ieee80211_ptr->use_4addr) { |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 1248 | if (vlansdata->u.vlan.sta) { |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1249 | mutex_unlock(&local->sta_mtx); |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 1250 | return -EBUSY; |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 1251 | } |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 1252 | |
Eric Dumazet | cf778b0 | 2012-01-12 04:41:32 +0000 | [diff] [blame] | 1253 | rcu_assign_pointer(vlansdata->u.vlan.sta, sta); |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1254 | new_4addr = true; |
| 1255 | } |
| 1256 | |
| 1257 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
| 1258 | sta->sdata->u.vlan.sta) { |
| 1259 | rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL); |
| 1260 | prev_4addr = true; |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 1261 | } |
| 1262 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1263 | sta->sdata = vlansdata; |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1264 | |
| 1265 | if (sta->sta_state == IEEE80211_STA_AUTHORIZED && |
| 1266 | prev_4addr != new_4addr) { |
| 1267 | if (new_4addr) |
| 1268 | atomic_dec(&sta->sdata->bss->num_mcast_sta); |
| 1269 | else |
| 1270 | atomic_inc(&sta->sdata->bss->num_mcast_sta); |
| 1271 | } |
| 1272 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1273 | ieee80211_send_layer2_update(sta); |
| 1274 | } |
| 1275 | |
Eliad Peller | 35b8862 | 2011-12-29 14:41:39 +0200 | [diff] [blame] | 1276 | err = sta_apply_parameters(local, sta, params); |
| 1277 | if (err) { |
| 1278 | mutex_unlock(&local->sta_mtx); |
| 1279 | return err; |
| 1280 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1281 | |
Arik Nemtsov | d64cf63 | 2011-11-07 23:24:39 +0200 | [diff] [blame] | 1282 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates) |
| 1283 | rate_control_rate_init(sta); |
| 1284 | |
Johannes Berg | 87be1e1 | 2011-12-14 12:20:29 +0100 | [diff] [blame] | 1285 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 1286 | |
Jason Young | 808118c | 2011-03-10 16:43:19 -0800 | [diff] [blame] | 1287 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
| 1288 | params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
| 1289 | ieee80211_recalc_ps(local, -1); |
| 1290 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1291 | return 0; |
| 1292 | } |
| 1293 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1294 | #ifdef CONFIG_MAC80211_MESH |
| 1295 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1296 | u8 *dst, u8 *next_hop) |
| 1297 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1298 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1299 | struct mesh_path *mpath; |
| 1300 | struct sta_info *sta; |
| 1301 | int err; |
| 1302 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1303 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1304 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1305 | rcu_read_lock(); |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1306 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1307 | if (!sta) { |
| 1308 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1309 | return -ENOENT; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1310 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1311 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1312 | err = mesh_path_add(dst, sdata); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1313 | if (err) { |
| 1314 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1315 | return err; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1316 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1317 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1318 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1319 | if (!mpath) { |
| 1320 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1321 | return -ENXIO; |
| 1322 | } |
| 1323 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1324 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1325 | rcu_read_unlock(); |
| 1326 | return 0; |
| 1327 | } |
| 1328 | |
| 1329 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1330 | u8 *dst) |
| 1331 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1332 | 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] | 1333 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1334 | if (dst) |
| 1335 | return mesh_path_del(dst, sdata); |
| 1336 | |
Javier Cardona | ece1a2e | 2011-08-29 13:23:04 -0700 | [diff] [blame] | 1337 | mesh_path_flush_by_iface(sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1338 | return 0; |
| 1339 | } |
| 1340 | |
| 1341 | static int ieee80211_change_mpath(struct wiphy *wiphy, |
| 1342 | struct net_device *dev, |
| 1343 | u8 *dst, u8 *next_hop) |
| 1344 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1345 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1346 | struct mesh_path *mpath; |
| 1347 | struct sta_info *sta; |
| 1348 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1349 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1350 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1351 | rcu_read_lock(); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1352 | |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1353 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1354 | if (!sta) { |
| 1355 | rcu_read_unlock(); |
| 1356 | return -ENOENT; |
| 1357 | } |
| 1358 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1359 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1360 | if (!mpath) { |
| 1361 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1362 | return -ENOENT; |
| 1363 | } |
| 1364 | |
| 1365 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 1366 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1367 | rcu_read_unlock(); |
| 1368 | return 0; |
| 1369 | } |
| 1370 | |
| 1371 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, |
| 1372 | struct mpath_info *pinfo) |
| 1373 | { |
Johannes Berg | a3836e0 | 2011-05-12 15:11:37 +0200 | [diff] [blame] | 1374 | struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop); |
| 1375 | |
| 1376 | if (next_hop_sta) |
| 1377 | memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1378 | else |
| 1379 | memset(next_hop, 0, ETH_ALEN); |
| 1380 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 1381 | pinfo->generation = mesh_paths_generation; |
| 1382 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1383 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1384 | MPATH_INFO_SN | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1385 | MPATH_INFO_METRIC | |
| 1386 | MPATH_INFO_EXPTIME | |
| 1387 | MPATH_INFO_DISCOVERY_TIMEOUT | |
| 1388 | MPATH_INFO_DISCOVERY_RETRIES | |
| 1389 | MPATH_INFO_FLAGS; |
| 1390 | |
| 1391 | pinfo->frame_qlen = mpath->frame_queue.qlen; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1392 | pinfo->sn = mpath->sn; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1393 | pinfo->metric = mpath->metric; |
| 1394 | if (time_before(jiffies, mpath->exp_time)) |
| 1395 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); |
| 1396 | pinfo->discovery_timeout = |
| 1397 | jiffies_to_msecs(mpath->discovery_timeout); |
| 1398 | pinfo->discovery_retries = mpath->discovery_retries; |
| 1399 | pinfo->flags = 0; |
| 1400 | if (mpath->flags & MESH_PATH_ACTIVE) |
| 1401 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; |
| 1402 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 1403 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 1404 | if (mpath->flags & MESH_PATH_SN_VALID) |
| 1405 | pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1406 | if (mpath->flags & MESH_PATH_FIXED) |
| 1407 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; |
| 1408 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 1409 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
| 1410 | |
| 1411 | pinfo->flags = mpath->flags; |
| 1412 | } |
| 1413 | |
| 1414 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1415 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) |
| 1416 | |
| 1417 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1418 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1419 | struct mesh_path *mpath; |
| 1420 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1421 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1422 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1423 | rcu_read_lock(); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1424 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1425 | if (!mpath) { |
| 1426 | rcu_read_unlock(); |
| 1427 | return -ENOENT; |
| 1428 | } |
| 1429 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 1430 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 1431 | rcu_read_unlock(); |
| 1432 | return 0; |
| 1433 | } |
| 1434 | |
| 1435 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 1436 | int idx, u8 *dst, u8 *next_hop, |
| 1437 | struct mpath_info *pinfo) |
| 1438 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1439 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1440 | struct mesh_path *mpath; |
| 1441 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 1442 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1443 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1444 | rcu_read_lock(); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 1445 | mpath = mesh_path_lookup_by_idx(idx, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1446 | if (!mpath) { |
| 1447 | rcu_read_unlock(); |
| 1448 | return -ENOENT; |
| 1449 | } |
| 1450 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 1451 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 1452 | rcu_read_unlock(); |
| 1453 | return 0; |
| 1454 | } |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1455 | |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 1456 | static int ieee80211_get_mesh_config(struct wiphy *wiphy, |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1457 | struct net_device *dev, |
| 1458 | struct mesh_config *conf) |
| 1459 | { |
| 1460 | struct ieee80211_sub_if_data *sdata; |
| 1461 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1462 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1463 | memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); |
| 1464 | return 0; |
| 1465 | } |
| 1466 | |
| 1467 | static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask) |
| 1468 | { |
| 1469 | return (mask >> (parm-1)) & 0x1; |
| 1470 | } |
| 1471 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1472 | static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh, |
| 1473 | const struct mesh_setup *setup) |
| 1474 | { |
| 1475 | u8 *new_ie; |
| 1476 | const u8 *old_ie; |
Chun-Yeow Yeoh | 4bb6234 | 2011-11-24 17:15:20 -0800 | [diff] [blame] | 1477 | struct ieee80211_sub_if_data *sdata = container_of(ifmsh, |
| 1478 | struct ieee80211_sub_if_data, u.mesh); |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1479 | |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1480 | /* allocate information elements */ |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1481 | new_ie = NULL; |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1482 | old_ie = ifmsh->ie; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1483 | |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1484 | if (setup->ie_len) { |
| 1485 | new_ie = kmemdup(setup->ie, setup->ie_len, |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1486 | GFP_KERNEL); |
| 1487 | if (!new_ie) |
| 1488 | return -ENOMEM; |
| 1489 | } |
Javier Cardona | 581a8b0 | 2011-04-07 15:08:27 -0700 | [diff] [blame] | 1490 | ifmsh->ie_len = setup->ie_len; |
| 1491 | ifmsh->ie = new_ie; |
| 1492 | kfree(old_ie); |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1493 | |
| 1494 | /* now copy the rest of the setup parameters */ |
| 1495 | ifmsh->mesh_id_len = setup->mesh_id_len; |
| 1496 | memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); |
Javier Cardona | d299a1f | 2012-03-31 11:31:33 -0700 | [diff] [blame] | 1497 | ifmsh->mesh_sp_id = setup->sync_method; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1498 | ifmsh->mesh_pp_id = setup->path_sel_proto; |
| 1499 | ifmsh->mesh_pm_id = setup->path_metric; |
Javier Cardona | b130e5c | 2011-05-03 16:57:07 -0700 | [diff] [blame] | 1500 | ifmsh->security = IEEE80211_MESH_SEC_NONE; |
| 1501 | if (setup->is_authenticated) |
| 1502 | ifmsh->security |= IEEE80211_MESH_SEC_AUTHED; |
| 1503 | if (setup->is_secure) |
| 1504 | ifmsh->security |= IEEE80211_MESH_SEC_SECURED; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1505 | |
Chun-Yeow Yeoh | 4bb6234 | 2011-11-24 17:15:20 -0800 | [diff] [blame] | 1506 | /* mcast rate setting in Mesh Node */ |
| 1507 | memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate, |
| 1508 | sizeof(setup->mcast_rate)); |
| 1509 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1510 | return 0; |
| 1511 | } |
| 1512 | |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 1513 | static int ieee80211_update_mesh_config(struct wiphy *wiphy, |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1514 | struct net_device *dev, u32 mask, |
| 1515 | const struct mesh_config *nconf) |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1516 | { |
| 1517 | struct mesh_config *conf; |
| 1518 | struct ieee80211_sub_if_data *sdata; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1519 | struct ieee80211_if_mesh *ifmsh; |
| 1520 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1521 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1522 | ifmsh = &sdata->u.mesh; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1523 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1524 | /* Set the config options which we are interested in setting */ |
| 1525 | conf = &(sdata->u.mesh.mshcfg); |
| 1526 | if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) |
| 1527 | conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; |
| 1528 | if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) |
| 1529 | conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; |
| 1530 | if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) |
| 1531 | conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; |
| 1532 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) |
| 1533 | conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; |
| 1534 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) |
| 1535 | conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; |
| 1536 | if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) |
| 1537 | conf->dot11MeshTTL = nconf->dot11MeshTTL; |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 1538 | if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask)) |
Chun-Yeow Yeoh | 58886a9 | 2012-06-15 00:23:53 +0800 | [diff] [blame] | 1539 | conf->element_ttl = nconf->element_ttl; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1540 | if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) |
| 1541 | conf->auto_open_plinks = nconf->auto_open_plinks; |
Javier Cardona | d299a1f | 2012-03-31 11:31:33 -0700 | [diff] [blame] | 1542 | if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask)) |
| 1543 | conf->dot11MeshNbrOffsetMaxNeighbor = |
| 1544 | nconf->dot11MeshNbrOffsetMaxNeighbor; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1545 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) |
| 1546 | conf->dot11MeshHWMPmaxPREQretries = |
| 1547 | nconf->dot11MeshHWMPmaxPREQretries; |
| 1548 | if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) |
| 1549 | conf->path_refresh_time = nconf->path_refresh_time; |
| 1550 | if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) |
| 1551 | conf->min_discovery_timeout = nconf->min_discovery_timeout; |
| 1552 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) |
| 1553 | conf->dot11MeshHWMPactivePathTimeout = |
| 1554 | nconf->dot11MeshHWMPactivePathTimeout; |
| 1555 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) |
| 1556 | conf->dot11MeshHWMPpreqMinInterval = |
| 1557 | nconf->dot11MeshHWMPpreqMinInterval; |
Thomas Pedersen | dca7e94 | 2011-11-24 17:15:24 -0800 | [diff] [blame] | 1558 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask)) |
| 1559 | conf->dot11MeshHWMPperrMinInterval = |
| 1560 | nconf->dot11MeshHWMPperrMinInterval; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1561 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
| 1562 | mask)) |
| 1563 | conf->dot11MeshHWMPnetDiameterTraversalTime = |
| 1564 | nconf->dot11MeshHWMPnetDiameterTraversalTime; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1565 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) { |
| 1566 | conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode; |
| 1567 | ieee80211_mesh_root_setup(ifmsh); |
| 1568 | } |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 1569 | if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) { |
Thomas Pedersen | c6133661 | 2011-08-25 10:36:14 -0700 | [diff] [blame] | 1570 | /* our current gate announcement implementation rides on root |
| 1571 | * announcements, so require this ifmsh to also be a root node |
| 1572 | * */ |
| 1573 | if (nconf->dot11MeshGateAnnouncementProtocol && |
Chun-Yeow Yeoh | dbb912c | 2012-06-14 02:06:09 +0800 | [diff] [blame] | 1574 | !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) { |
| 1575 | conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN; |
Thomas Pedersen | c6133661 | 2011-08-25 10:36:14 -0700 | [diff] [blame] | 1576 | ieee80211_mesh_root_setup(ifmsh); |
| 1577 | } |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 1578 | conf->dot11MeshGateAnnouncementProtocol = |
| 1579 | nconf->dot11MeshGateAnnouncementProtocol; |
| 1580 | } |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 1581 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame] | 1582 | conf->dot11MeshHWMPRannInterval = |
| 1583 | nconf->dot11MeshHWMPRannInterval; |
Chun-Yeow Yeoh | 94f9065 | 2012-01-21 01:02:16 +0800 | [diff] [blame] | 1584 | if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask)) |
| 1585 | conf->dot11MeshForwarding = nconf->dot11MeshForwarding; |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 1586 | if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) { |
| 1587 | /* our RSSI threshold implementation is supported only for |
| 1588 | * devices that report signal in dBm. |
| 1589 | */ |
| 1590 | if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)) |
| 1591 | return -ENOTSUPP; |
| 1592 | conf->rssi_threshold = nconf->rssi_threshold; |
| 1593 | } |
Ashok Nagarajan | 70c33ea | 2012-04-30 14:20:32 -0700 | [diff] [blame] | 1594 | if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) { |
| 1595 | conf->ht_opmode = nconf->ht_opmode; |
| 1596 | sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode; |
| 1597 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); |
| 1598 | } |
Chun-Yeow Yeoh | ac1073a | 2012-06-14 02:06:06 +0800 | [diff] [blame] | 1599 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask)) |
| 1600 | conf->dot11MeshHWMPactivePathToRootTimeout = |
| 1601 | nconf->dot11MeshHWMPactivePathToRootTimeout; |
| 1602 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask)) |
| 1603 | conf->dot11MeshHWMProotInterval = |
| 1604 | nconf->dot11MeshHWMProotInterval; |
Chun-Yeow Yeoh | 728b19e | 2012-06-14 02:06:10 +0800 | [diff] [blame] | 1605 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask)) |
| 1606 | conf->dot11MeshHWMPconfirmationInterval = |
| 1607 | nconf->dot11MeshHWMPconfirmationInterval; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1608 | return 0; |
| 1609 | } |
| 1610 | |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1611 | static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev, |
| 1612 | const struct mesh_config *conf, |
| 1613 | const struct mesh_setup *setup) |
| 1614 | { |
| 1615 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1616 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1617 | int err; |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1618 | |
Javier Cardona | c80d545 | 2010-12-16 17:37:49 -0800 | [diff] [blame] | 1619 | memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config)); |
| 1620 | err = copy_mesh_setup(ifmsh, setup); |
| 1621 | if (err) |
| 1622 | return err; |
Johannes Berg | cc1d280 | 2012-05-16 23:50:20 +0200 | [diff] [blame] | 1623 | |
| 1624 | err = ieee80211_set_channel(wiphy, dev, setup->channel, |
| 1625 | setup->channel_type); |
| 1626 | if (err) |
| 1627 | return err; |
| 1628 | |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 1629 | ieee80211_start_mesh(sdata); |
| 1630 | |
| 1631 | return 0; |
| 1632 | } |
| 1633 | |
| 1634 | static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) |
| 1635 | { |
| 1636 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1637 | |
| 1638 | ieee80211_stop_mesh(sdata); |
| 1639 | |
| 1640 | return 0; |
| 1641 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1642 | #endif |
| 1643 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1644 | static int ieee80211_change_bss(struct wiphy *wiphy, |
| 1645 | struct net_device *dev, |
| 1646 | struct bss_parameters *params) |
| 1647 | { |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1648 | struct ieee80211_sub_if_data *sdata; |
| 1649 | u32 changed = 0; |
| 1650 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1651 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1652 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1653 | if (params->use_cts_prot >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1654 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1655 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
| 1656 | } |
| 1657 | if (params->use_short_preamble >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1658 | sdata->vif.bss_conf.use_short_preamble = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1659 | params->use_short_preamble; |
| 1660 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
| 1661 | } |
Felix Fietkau | 43d3534 | 2010-01-15 03:00:48 +0100 | [diff] [blame] | 1662 | |
| 1663 | if (!sdata->vif.bss_conf.use_short_slot && |
| 1664 | sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) { |
| 1665 | sdata->vif.bss_conf.use_short_slot = true; |
| 1666 | changed |= BSS_CHANGED_ERP_SLOT; |
| 1667 | } |
| 1668 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1669 | if (params->use_short_slot_time >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1670 | sdata->vif.bss_conf.use_short_slot = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1671 | params->use_short_slot_time; |
| 1672 | changed |= BSS_CHANGED_ERP_SLOT; |
| 1673 | } |
| 1674 | |
Jouni Malinen | 90c97a0 | 2008-10-30 16:59:22 +0200 | [diff] [blame] | 1675 | if (params->basic_rates) { |
| 1676 | int i, j; |
| 1677 | u32 rates = 0; |
| 1678 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1679 | struct ieee80211_supported_band *sband = |
| 1680 | wiphy->bands[local->oper_channel->band]; |
| 1681 | |
| 1682 | for (i = 0; i < params->basic_rates_len; i++) { |
| 1683 | int rate = (params->basic_rates[i] & 0x7f) * 5; |
| 1684 | for (j = 0; j < sband->n_bitrates; j++) { |
| 1685 | if (sband->bitrates[j].bitrate == rate) |
| 1686 | rates |= BIT(j); |
| 1687 | } |
| 1688 | } |
| 1689 | sdata->vif.bss_conf.basic_rates = rates; |
| 1690 | changed |= BSS_CHANGED_BASIC_RATES; |
| 1691 | } |
| 1692 | |
Felix Fietkau | 7b7b5e5 | 2010-04-27 01:23:36 +0200 | [diff] [blame] | 1693 | if (params->ap_isolate >= 0) { |
| 1694 | if (params->ap_isolate) |
| 1695 | sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 1696 | else |
| 1697 | sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 1698 | } |
| 1699 | |
Helmut Schaa | 80d7e40 | 2010-11-19 12:40:26 +0100 | [diff] [blame] | 1700 | if (params->ht_opmode >= 0) { |
| 1701 | sdata->vif.bss_conf.ht_operation_mode = |
| 1702 | (u16) params->ht_opmode; |
| 1703 | changed |= BSS_CHANGED_HT; |
| 1704 | } |
| 1705 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1706 | ieee80211_bss_info_change_notify(sdata, changed); |
| 1707 | |
| 1708 | return 0; |
| 1709 | } |
| 1710 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1711 | static int ieee80211_set_txq_params(struct wiphy *wiphy, |
Eliad Peller | f70f01c | 2011-09-25 20:06:53 +0300 | [diff] [blame] | 1712 | struct net_device *dev, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1713 | struct ieee80211_txq_params *params) |
| 1714 | { |
| 1715 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Eliad Peller | f6f3def | 2011-09-25 20:06:54 +0300 | [diff] [blame] | 1716 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1717 | struct ieee80211_tx_queue_params p; |
| 1718 | |
| 1719 | if (!local->ops->conf_tx) |
| 1720 | return -EOPNOTSUPP; |
| 1721 | |
Johannes Berg | 54bcbc6 | 2012-03-28 11:04:25 +0200 | [diff] [blame] | 1722 | if (local->hw.queues < IEEE80211_NUM_ACS) |
| 1723 | return -EOPNOTSUPP; |
| 1724 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1725 | memset(&p, 0, sizeof(p)); |
| 1726 | p.aifs = params->aifs; |
| 1727 | p.cw_max = params->cwmax; |
| 1728 | p.cw_min = params->cwmin; |
| 1729 | p.txop = params->txop; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1730 | |
| 1731 | /* |
| 1732 | * Setting tx queue params disables u-apsd because it's only |
| 1733 | * called in master mode. |
| 1734 | */ |
| 1735 | p.uapsd = false; |
| 1736 | |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 1737 | sdata->tx_conf[params->ac] = p; |
| 1738 | if (drv_conf_tx(local, sdata, params->ac, &p)) { |
Joe Perches | 0fb9a9e | 2010-08-20 16:25:38 -0700 | [diff] [blame] | 1739 | wiphy_debug(local->hw.wiphy, |
Johannes Berg | a3304b0 | 2012-03-28 11:04:24 +0200 | [diff] [blame] | 1740 | "failed to set TX queue parameters for AC %d\n", |
| 1741 | params->ac); |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1742 | return -EINVAL; |
| 1743 | } |
| 1744 | |
Johannes Berg | 7d25745 | 2012-07-06 17:37:43 +0200 | [diff] [blame] | 1745 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS); |
| 1746 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1747 | return 0; |
| 1748 | } |
| 1749 | |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1750 | #ifdef CONFIG_PM |
Johannes Berg | ff1b6e6 | 2011-05-04 15:37:28 +0200 | [diff] [blame] | 1751 | static int ieee80211_suspend(struct wiphy *wiphy, |
| 1752 | struct cfg80211_wowlan *wowlan) |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1753 | { |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 1754 | return __ieee80211_suspend(wiphy_priv(wiphy), wowlan); |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1755 | } |
| 1756 | |
| 1757 | static int ieee80211_resume(struct wiphy *wiphy) |
| 1758 | { |
| 1759 | return __ieee80211_resume(wiphy_priv(wiphy)); |
| 1760 | } |
| 1761 | #else |
| 1762 | #define ieee80211_suspend NULL |
| 1763 | #define ieee80211_resume NULL |
| 1764 | #endif |
| 1765 | |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1766 | static int ieee80211_scan(struct wiphy *wiphy, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1767 | struct cfg80211_scan_request *req) |
| 1768 | { |
Johannes Berg | fd01428 | 2012-06-18 19:17:03 +0200 | [diff] [blame] | 1769 | struct ieee80211_sub_if_data *sdata; |
| 1770 | |
| 1771 | sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev); |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1772 | |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 1773 | switch (ieee80211_vif_type_p2p(&sdata->vif)) { |
| 1774 | case NL80211_IFTYPE_STATION: |
| 1775 | case NL80211_IFTYPE_ADHOC: |
| 1776 | case NL80211_IFTYPE_MESH_POINT: |
| 1777 | case NL80211_IFTYPE_P2P_CLIENT: |
| 1778 | break; |
| 1779 | case NL80211_IFTYPE_P2P_GO: |
| 1780 | if (sdata->local->ops->hw_scan) |
| 1781 | break; |
Johannes Berg | e9d7732 | 2011-02-01 15:35:36 +0100 | [diff] [blame] | 1782 | /* |
| 1783 | * FIXME: implement NoA while scanning in software, |
| 1784 | * for now fall through to allow scanning only when |
| 1785 | * beaconing hasn't been configured yet |
| 1786 | */ |
Johannes Berg | 2ca27bc | 2010-09-16 14:58:23 +0200 | [diff] [blame] | 1787 | case NL80211_IFTYPE_AP: |
| 1788 | if (sdata->u.ap.beacon) |
| 1789 | return -EOPNOTSUPP; |
| 1790 | break; |
| 1791 | default: |
| 1792 | return -EOPNOTSUPP; |
| 1793 | } |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1794 | |
| 1795 | return ieee80211_request_scan(sdata, req); |
| 1796 | } |
| 1797 | |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 1798 | static int |
| 1799 | ieee80211_sched_scan_start(struct wiphy *wiphy, |
| 1800 | struct net_device *dev, |
| 1801 | struct cfg80211_sched_scan_request *req) |
| 1802 | { |
| 1803 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1804 | |
| 1805 | if (!sdata->local->ops->sched_scan_start) |
| 1806 | return -EOPNOTSUPP; |
| 1807 | |
| 1808 | return ieee80211_request_sched_scan_start(sdata, req); |
| 1809 | } |
| 1810 | |
| 1811 | static int |
Luciano Coelho | 85a9994 | 2011-05-12 16:28:29 +0300 | [diff] [blame] | 1812 | ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev) |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 1813 | { |
| 1814 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1815 | |
| 1816 | if (!sdata->local->ops->sched_scan_stop) |
| 1817 | return -EOPNOTSUPP; |
| 1818 | |
Luciano Coelho | 85a9994 | 2011-05-12 16:28:29 +0300 | [diff] [blame] | 1819 | return ieee80211_request_sched_scan_stop(sdata); |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 1820 | } |
| 1821 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1822 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
| 1823 | struct cfg80211_auth_request *req) |
| 1824 | { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1825 | return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1826 | } |
| 1827 | |
| 1828 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, |
| 1829 | struct cfg80211_assoc_request *req) |
| 1830 | { |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1831 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1832 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1833 | |
| 1834 | switch (ieee80211_get_channel_mode(local, sdata)) { |
| 1835 | case CHAN_MODE_HOPPING: |
| 1836 | return -EBUSY; |
| 1837 | case CHAN_MODE_FIXED: |
| 1838 | if (local->oper_channel == req->bss->channel) |
| 1839 | break; |
| 1840 | return -EBUSY; |
| 1841 | case CHAN_MODE_UNDEFINED: |
| 1842 | break; |
| 1843 | } |
| 1844 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1845 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1846 | } |
| 1847 | |
| 1848 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 1849 | struct cfg80211_deauth_request *req) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1850 | { |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 1851 | return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1852 | } |
| 1853 | |
| 1854 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 1855 | struct cfg80211_disassoc_request *req) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1856 | { |
Johannes Berg | 63c9c5e | 2012-02-24 13:50:51 +0100 | [diff] [blame] | 1857 | return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1858 | } |
| 1859 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1860 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
| 1861 | struct cfg80211_ibss_params *params) |
| 1862 | { |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1863 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1864 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1865 | |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1866 | switch (ieee80211_get_channel_mode(local, sdata)) { |
| 1867 | case CHAN_MODE_HOPPING: |
| 1868 | return -EBUSY; |
| 1869 | case CHAN_MODE_FIXED: |
| 1870 | if (!params->channel_fixed) |
| 1871 | return -EBUSY; |
| 1872 | if (local->oper_channel == params->channel) |
| 1873 | break; |
| 1874 | return -EBUSY; |
| 1875 | case CHAN_MODE_UNDEFINED: |
| 1876 | break; |
| 1877 | } |
| 1878 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1879 | return ieee80211_ibss_join(sdata, params); |
| 1880 | } |
| 1881 | |
| 1882 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) |
| 1883 | { |
| 1884 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1885 | |
| 1886 | return ieee80211_ibss_leave(sdata); |
| 1887 | } |
| 1888 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1889 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 1890 | { |
| 1891 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1892 | int err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1893 | |
Arik Nemtsov | f23a478 | 2010-11-08 11:51:06 +0200 | [diff] [blame] | 1894 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 1895 | err = drv_set_frag_threshold(local, wiphy->frag_threshold); |
| 1896 | |
| 1897 | if (err) |
| 1898 | return err; |
| 1899 | } |
| 1900 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 1901 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) { |
| 1902 | err = drv_set_coverage_class(local, wiphy->coverage_class); |
| 1903 | |
| 1904 | if (err) |
| 1905 | return err; |
| 1906 | } |
| 1907 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1908 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1909 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1910 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1911 | if (err) |
| 1912 | return err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1913 | } |
| 1914 | |
| 1915 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 1916 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
| 1917 | if (changed & WIPHY_PARAM_RETRY_LONG) |
| 1918 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
| 1919 | if (changed & |
| 1920 | (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) |
| 1921 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); |
| 1922 | |
| 1923 | return 0; |
| 1924 | } |
| 1925 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1926 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1927 | enum nl80211_tx_power_setting type, int mbm) |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1928 | { |
| 1929 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1930 | struct ieee80211_channel *chan = local->hw.conf.channel; |
| 1931 | u32 changes = 0; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1932 | |
| 1933 | switch (type) { |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1934 | case NL80211_TX_POWER_AUTOMATIC: |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1935 | local->user_power_level = -1; |
| 1936 | break; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1937 | case NL80211_TX_POWER_LIMITED: |
| 1938 | if (mbm < 0 || (mbm % 100)) |
| 1939 | return -EOPNOTSUPP; |
| 1940 | local->user_power_level = MBM_TO_DBM(mbm); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1941 | break; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1942 | case NL80211_TX_POWER_FIXED: |
| 1943 | if (mbm < 0 || (mbm % 100)) |
| 1944 | return -EOPNOTSUPP; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1945 | /* TODO: move to cfg80211 when it knows the channel */ |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1946 | if (MBM_TO_DBM(mbm) > chan->max_power) |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1947 | return -EINVAL; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 1948 | local->user_power_level = MBM_TO_DBM(mbm); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1949 | break; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1950 | } |
| 1951 | |
| 1952 | ieee80211_hw_config(local, changes); |
| 1953 | |
| 1954 | return 0; |
| 1955 | } |
| 1956 | |
| 1957 | static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm) |
| 1958 | { |
| 1959 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1960 | |
| 1961 | *dbm = local->hw.conf.power_level; |
| 1962 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1963 | return 0; |
| 1964 | } |
| 1965 | |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1966 | 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] | 1967 | const u8 *addr) |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1968 | { |
| 1969 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1970 | |
| 1971 | memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN); |
| 1972 | |
| 1973 | return 0; |
| 1974 | } |
| 1975 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 1976 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) |
| 1977 | { |
| 1978 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1979 | |
| 1980 | drv_rfkill_poll(local); |
| 1981 | } |
| 1982 | |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1983 | #ifdef CONFIG_NL80211_TESTMODE |
Johannes Berg | 99783e2 | 2009-07-07 03:54:43 +0200 | [diff] [blame] | 1984 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len) |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1985 | { |
| 1986 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1987 | |
| 1988 | if (!local->ops->testmode_cmd) |
| 1989 | return -EOPNOTSUPP; |
| 1990 | |
| 1991 | return local->ops->testmode_cmd(&local->hw, data, len); |
| 1992 | } |
Wey-Yi Guy | 71063f0 | 2011-05-20 09:05:54 -0700 | [diff] [blame] | 1993 | |
| 1994 | static int ieee80211_testmode_dump(struct wiphy *wiphy, |
| 1995 | struct sk_buff *skb, |
| 1996 | struct netlink_callback *cb, |
| 1997 | void *data, int len) |
| 1998 | { |
| 1999 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2000 | |
| 2001 | if (!local->ops->testmode_dump) |
| 2002 | return -EOPNOTSUPP; |
| 2003 | |
| 2004 | return local->ops->testmode_dump(&local->hw, skb, cb, data, len); |
| 2005 | } |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 2006 | #endif |
| 2007 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2008 | int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, |
| 2009 | enum ieee80211_smps_mode smps_mode) |
| 2010 | { |
| 2011 | const u8 *ap; |
| 2012 | enum ieee80211_smps_mode old_req; |
| 2013 | int err; |
| 2014 | |
Johannes Berg | 243e6df | 2011-04-19 20:44:04 +0200 | [diff] [blame] | 2015 | lockdep_assert_held(&sdata->u.mgd.mtx); |
| 2016 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2017 | old_req = sdata->u.mgd.req_smps; |
| 2018 | sdata->u.mgd.req_smps = smps_mode; |
| 2019 | |
| 2020 | if (old_req == smps_mode && |
| 2021 | smps_mode != IEEE80211_SMPS_AUTOMATIC) |
| 2022 | return 0; |
| 2023 | |
| 2024 | /* |
| 2025 | * If not associated, or current association is not an HT |
| 2026 | * association, there's no need to send an action frame. |
| 2027 | */ |
| 2028 | if (!sdata->u.mgd.associated || |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame] | 2029 | sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) { |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2030 | mutex_lock(&sdata->local->iflist_mtx); |
Johannes Berg | 025e6be | 2010-10-05 10:41:47 +0200 | [diff] [blame] | 2031 | ieee80211_recalc_smps(sdata->local); |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2032 | mutex_unlock(&sdata->local->iflist_mtx); |
| 2033 | return 0; |
| 2034 | } |
| 2035 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 2036 | ap = sdata->u.mgd.associated->bssid; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2037 | |
| 2038 | if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { |
| 2039 | if (sdata->u.mgd.powersave) |
| 2040 | smps_mode = IEEE80211_SMPS_DYNAMIC; |
| 2041 | else |
| 2042 | smps_mode = IEEE80211_SMPS_OFF; |
| 2043 | } |
| 2044 | |
| 2045 | /* send SM PS frame to AP */ |
| 2046 | err = ieee80211_send_smps_action(sdata, smps_mode, |
| 2047 | ap, ap); |
| 2048 | if (err) |
| 2049 | sdata->u.mgd.req_smps = old_req; |
| 2050 | |
| 2051 | return err; |
| 2052 | } |
| 2053 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2054 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 2055 | bool enabled, int timeout) |
| 2056 | { |
| 2057 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2058 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2059 | |
Benoit Papillault | e5de30c | 2010-01-15 12:21:37 +0100 | [diff] [blame] | 2060 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 2061 | return -EOPNOTSUPP; |
| 2062 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2063 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) |
| 2064 | return -EOPNOTSUPP; |
| 2065 | |
| 2066 | if (enabled == sdata->u.mgd.powersave && |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 2067 | timeout == local->dynamic_ps_forced_timeout) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2068 | return 0; |
| 2069 | |
| 2070 | sdata->u.mgd.powersave = enabled; |
Juuso Oikarinen | ff61638 | 2010-06-09 09:51:52 +0300 | [diff] [blame] | 2071 | local->dynamic_ps_forced_timeout = timeout; |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2072 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 2073 | /* no change, but if automatic follow powersave */ |
| 2074 | mutex_lock(&sdata->u.mgd.mtx); |
| 2075 | __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps); |
| 2076 | mutex_unlock(&sdata->u.mgd.mtx); |
| 2077 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 2078 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) |
| 2079 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 2080 | |
| 2081 | ieee80211_recalc_ps(local, -1); |
| 2082 | |
| 2083 | return 0; |
| 2084 | } |
| 2085 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2086 | static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, |
| 2087 | struct net_device *dev, |
| 2088 | s32 rssi_thold, u32 rssi_hyst) |
| 2089 | { |
| 2090 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2091 | struct ieee80211_vif *vif = &sdata->vif; |
| 2092 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
| 2093 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2094 | if (rssi_thold == bss_conf->cqm_rssi_thold && |
| 2095 | rssi_hyst == bss_conf->cqm_rssi_hyst) |
| 2096 | return 0; |
| 2097 | |
| 2098 | bss_conf->cqm_rssi_thold = rssi_thold; |
| 2099 | bss_conf->cqm_rssi_hyst = rssi_hyst; |
| 2100 | |
| 2101 | /* tell the driver upon association, unless already associated */ |
Johannes Berg | ea08635 | 2012-01-19 09:29:58 +0100 | [diff] [blame] | 2102 | if (sdata->u.mgd.associated && |
| 2103 | sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI) |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 2104 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM); |
| 2105 | |
| 2106 | return 0; |
| 2107 | } |
| 2108 | |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2109 | static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, |
| 2110 | struct net_device *dev, |
| 2111 | const u8 *addr, |
| 2112 | const struct cfg80211_bitrate_mask *mask) |
| 2113 | { |
| 2114 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2115 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 2116 | int i, ret; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2117 | |
Eliad Peller | 554a43d | 2012-06-12 12:41:15 +0300 | [diff] [blame] | 2118 | if (!ieee80211_sdata_running(sdata)) |
| 2119 | return -ENETDOWN; |
| 2120 | |
Sujith Manoharan | bdbfd6b | 2011-04-27 16:56:51 +0530 | [diff] [blame] | 2121 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) { |
| 2122 | ret = drv_set_bitrate_mask(local, sdata, mask); |
| 2123 | if (ret) |
| 2124 | return ret; |
| 2125 | } |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2126 | |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 2127 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) { |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 2128 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 2129 | memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs, |
| 2130 | sizeof(mask->control[i].mcs)); |
| 2131 | } |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2132 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 2133 | return 0; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 2134 | } |
| 2135 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2136 | static int ieee80211_start_roc_work(struct ieee80211_local *local, |
| 2137 | struct ieee80211_sub_if_data *sdata, |
| 2138 | struct ieee80211_channel *channel, |
| 2139 | enum nl80211_channel_type channel_type, |
| 2140 | unsigned int duration, u64 *cookie, |
| 2141 | struct sk_buff *txskb) |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2142 | { |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2143 | struct ieee80211_roc_work *roc, *tmp; |
| 2144 | bool queued = false; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2145 | int ret; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2146 | |
| 2147 | lockdep_assert_held(&local->mtx); |
| 2148 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2149 | roc = kzalloc(sizeof(*roc), GFP_KERNEL); |
| 2150 | if (!roc) |
| 2151 | return -ENOMEM; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2152 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2153 | roc->chan = channel; |
| 2154 | roc->chan_type = channel_type; |
| 2155 | roc->duration = duration; |
| 2156 | roc->req_duration = duration; |
| 2157 | roc->frame = txskb; |
| 2158 | roc->mgmt_tx_cookie = (unsigned long)txskb; |
| 2159 | roc->sdata = sdata; |
| 2160 | INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work); |
| 2161 | INIT_LIST_HEAD(&roc->dependents); |
| 2162 | |
| 2163 | /* if there's one pending or we're scanning, queue this one */ |
| 2164 | if (!list_empty(&local->roc_list) || local->scanning) |
| 2165 | goto out_check_combine; |
| 2166 | |
| 2167 | /* if not HW assist, just queue & schedule work */ |
| 2168 | if (!local->ops->remain_on_channel) { |
| 2169 | ieee80211_queue_delayed_work(&local->hw, &roc->work, 0); |
| 2170 | goto out_queue; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2171 | } |
| 2172 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2173 | /* otherwise actually kick it off here (for error handling) */ |
| 2174 | |
| 2175 | /* |
| 2176 | * If the duration is zero, then the driver |
| 2177 | * wouldn't actually do anything. Set it to |
| 2178 | * 10 for now. |
| 2179 | * |
| 2180 | * TODO: cancel the off-channel operation |
| 2181 | * when we get the SKB's TX status and |
| 2182 | * the wait time was zero before. |
| 2183 | */ |
| 2184 | if (!duration) |
| 2185 | duration = 10; |
| 2186 | |
| 2187 | ret = drv_remain_on_channel(local, channel, channel_type, duration); |
| 2188 | if (ret) { |
| 2189 | kfree(roc); |
| 2190 | return ret; |
| 2191 | } |
| 2192 | |
| 2193 | roc->started = true; |
| 2194 | goto out_queue; |
| 2195 | |
| 2196 | out_check_combine: |
| 2197 | list_for_each_entry(tmp, &local->roc_list, list) { |
| 2198 | if (tmp->chan != channel || tmp->chan_type != channel_type) |
| 2199 | continue; |
| 2200 | |
| 2201 | /* |
| 2202 | * Extend this ROC if possible: |
| 2203 | * |
| 2204 | * If it hasn't started yet, just increase the duration |
| 2205 | * and add the new one to the list of dependents. |
| 2206 | */ |
| 2207 | if (!tmp->started) { |
| 2208 | list_add_tail(&roc->list, &tmp->dependents); |
| 2209 | tmp->duration = max(tmp->duration, roc->duration); |
| 2210 | queued = true; |
| 2211 | break; |
| 2212 | } |
| 2213 | |
| 2214 | /* If it has already started, it's more difficult ... */ |
| 2215 | if (local->ops->remain_on_channel) { |
| 2216 | unsigned long j = jiffies; |
| 2217 | |
| 2218 | /* |
| 2219 | * In the offloaded ROC case, if it hasn't begun, add |
| 2220 | * this new one to the dependent list to be handled |
| 2221 | * when the the master one begins. If it has begun, |
| 2222 | * check that there's still a minimum time left and |
| 2223 | * if so, start this one, transmitting the frame, but |
| 2224 | * add it to the list directly after this one with a |
| 2225 | * a reduced time so we'll ask the driver to execute |
| 2226 | * it right after finishing the previous one, in the |
| 2227 | * hope that it'll also be executed right afterwards, |
| 2228 | * effectively extending the old one. |
| 2229 | * If there's no minimum time left, just add it to the |
| 2230 | * normal list. |
| 2231 | */ |
| 2232 | if (!tmp->hw_begun) { |
| 2233 | list_add_tail(&roc->list, &tmp->dependents); |
| 2234 | queued = true; |
| 2235 | break; |
| 2236 | } |
| 2237 | |
| 2238 | if (time_before(j + IEEE80211_ROC_MIN_LEFT, |
| 2239 | tmp->hw_start_time + |
| 2240 | msecs_to_jiffies(tmp->duration))) { |
| 2241 | int new_dur; |
| 2242 | |
| 2243 | ieee80211_handle_roc_started(roc); |
| 2244 | |
| 2245 | new_dur = roc->duration - |
| 2246 | jiffies_to_msecs(tmp->hw_start_time + |
| 2247 | msecs_to_jiffies( |
| 2248 | tmp->duration) - |
| 2249 | j); |
| 2250 | |
| 2251 | if (new_dur > 0) { |
| 2252 | /* add right after tmp */ |
| 2253 | list_add(&roc->list, &tmp->list); |
| 2254 | } else { |
| 2255 | list_add_tail(&roc->list, |
| 2256 | &tmp->dependents); |
| 2257 | } |
| 2258 | queued = true; |
| 2259 | } |
| 2260 | } else if (del_timer_sync(&tmp->work.timer)) { |
| 2261 | unsigned long new_end; |
| 2262 | |
| 2263 | /* |
| 2264 | * In the software ROC case, cancel the timer, if |
| 2265 | * that fails then the finish work is already |
| 2266 | * queued/pending and thus we queue the new ROC |
| 2267 | * normally, if that succeeds then we can extend |
| 2268 | * the timer duration and TX the frame (if any.) |
| 2269 | */ |
| 2270 | |
| 2271 | list_add_tail(&roc->list, &tmp->dependents); |
| 2272 | queued = true; |
| 2273 | |
| 2274 | new_end = jiffies + msecs_to_jiffies(roc->duration); |
| 2275 | |
| 2276 | /* ok, it was started & we canceled timer */ |
| 2277 | if (time_after(new_end, tmp->work.timer.expires)) |
| 2278 | mod_timer(&tmp->work.timer, new_end); |
| 2279 | else |
| 2280 | add_timer(&tmp->work.timer); |
| 2281 | |
| 2282 | ieee80211_handle_roc_started(roc); |
| 2283 | } |
| 2284 | break; |
| 2285 | } |
| 2286 | |
| 2287 | out_queue: |
| 2288 | if (!queued) |
| 2289 | list_add_tail(&roc->list, &local->roc_list); |
| 2290 | |
| 2291 | /* |
| 2292 | * cookie is either the roc (for normal roc) |
| 2293 | * or the SKB (for mgmt TX) |
| 2294 | */ |
| 2295 | if (txskb) |
| 2296 | *cookie = (unsigned long)txskb; |
| 2297 | else |
| 2298 | *cookie = (unsigned long)roc; |
| 2299 | |
| 2300 | return 0; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2301 | } |
| 2302 | |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2303 | static int ieee80211_remain_on_channel(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2304 | struct wireless_dev *wdev, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2305 | struct ieee80211_channel *chan, |
| 2306 | enum nl80211_channel_type channel_type, |
| 2307 | unsigned int duration, |
| 2308 | u64 *cookie) |
| 2309 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2310 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2311 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2312 | int ret; |
| 2313 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2314 | mutex_lock(&local->mtx); |
| 2315 | ret = ieee80211_start_roc_work(local, sdata, chan, channel_type, |
| 2316 | duration, cookie, NULL); |
| 2317 | mutex_unlock(&local->mtx); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2318 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2319 | return ret; |
| 2320 | } |
| 2321 | |
| 2322 | static int ieee80211_cancel_roc(struct ieee80211_local *local, |
| 2323 | u64 cookie, bool mgmt_tx) |
| 2324 | { |
| 2325 | struct ieee80211_roc_work *roc, *tmp, *found = NULL; |
| 2326 | int ret; |
| 2327 | |
| 2328 | mutex_lock(&local->mtx); |
| 2329 | list_for_each_entry_safe(roc, tmp, &local->roc_list, list) { |
Johannes Berg | e979e33 | 2012-06-11 17:09:41 +0200 | [diff] [blame] | 2330 | struct ieee80211_roc_work *dep, *tmp2; |
| 2331 | |
| 2332 | list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) { |
| 2333 | if (!mgmt_tx && (unsigned long)dep != cookie) |
| 2334 | continue; |
| 2335 | else if (mgmt_tx && dep->mgmt_tx_cookie != cookie) |
| 2336 | continue; |
| 2337 | /* found dependent item -- just remove it */ |
| 2338 | list_del(&dep->list); |
| 2339 | mutex_unlock(&local->mtx); |
| 2340 | |
| 2341 | ieee80211_roc_notify_destroy(dep); |
| 2342 | return 0; |
| 2343 | } |
| 2344 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2345 | if (!mgmt_tx && (unsigned long)roc != cookie) |
| 2346 | continue; |
| 2347 | else if (mgmt_tx && roc->mgmt_tx_cookie != cookie) |
| 2348 | continue; |
| 2349 | |
| 2350 | found = roc; |
| 2351 | break; |
| 2352 | } |
| 2353 | |
| 2354 | if (!found) { |
| 2355 | mutex_unlock(&local->mtx); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2356 | return -ENOENT; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2357 | } |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2358 | |
Johannes Berg | e979e33 | 2012-06-11 17:09:41 +0200 | [diff] [blame] | 2359 | /* |
| 2360 | * We found the item to cancel, so do that. Note that it |
| 2361 | * may have dependents, which we also cancel (and send |
| 2362 | * the expired signal for.) Not doing so would be quite |
| 2363 | * tricky here, but we may need to fix it later. |
| 2364 | */ |
| 2365 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2366 | if (local->ops->remain_on_channel) { |
| 2367 | if (found->started) { |
| 2368 | ret = drv_cancel_remain_on_channel(local); |
| 2369 | if (WARN_ON_ONCE(ret)) { |
| 2370 | mutex_unlock(&local->mtx); |
| 2371 | return ret; |
| 2372 | } |
| 2373 | } |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2374 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2375 | list_del(&found->list); |
| 2376 | |
Johannes Berg | 0f6b3f5 | 2012-06-20 20:11:33 +0200 | [diff] [blame] | 2377 | if (found->started) |
| 2378 | ieee80211_start_next_roc(local); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2379 | mutex_unlock(&local->mtx); |
| 2380 | |
| 2381 | ieee80211_roc_notify_destroy(found); |
| 2382 | } else { |
| 2383 | /* work may be pending so use it all the time */ |
| 2384 | found->abort = true; |
| 2385 | ieee80211_queue_delayed_work(&local->hw, &found->work, 0); |
| 2386 | |
| 2387 | mutex_unlock(&local->mtx); |
| 2388 | |
| 2389 | /* work will clean up etc */ |
| 2390 | flush_delayed_work(&found->work); |
| 2391 | } |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2392 | |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2393 | return 0; |
| 2394 | } |
| 2395 | |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2396 | static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2397 | struct wireless_dev *wdev, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 2398 | u64 cookie) |
| 2399 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2400 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 21f8358 | 2010-12-18 17:20:47 +0100 | [diff] [blame] | 2401 | struct ieee80211_local *local = sdata->local; |
| 2402 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2403 | return ieee80211_cancel_roc(local, cookie, false); |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2404 | } |
| 2405 | |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2406 | static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
Johannes Berg | f7ca38d | 2010-11-25 10:02:29 +0100 | [diff] [blame] | 2407 | struct ieee80211_channel *chan, bool offchan, |
Johannes Berg | 2e161f7 | 2010-08-12 15:38:38 +0200 | [diff] [blame] | 2408 | enum nl80211_channel_type channel_type, |
Johannes Berg | f7ca38d | 2010-11-25 10:02:29 +0100 | [diff] [blame] | 2409 | bool channel_type_valid, unsigned int wait, |
Rajkumar Manoharan | e9f935e | 2011-09-25 14:53:30 +0530 | [diff] [blame] | 2410 | const u8 *buf, size_t len, bool no_cck, |
Johannes Berg | e247bd90 | 2011-11-04 11:18:21 +0100 | [diff] [blame] | 2411 | bool dont_wait_for_ack, u64 *cookie) |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 2412 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2413 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 2414 | struct ieee80211_local *local = sdata->local; |
| 2415 | struct sk_buff *skb; |
| 2416 | struct sta_info *sta; |
| 2417 | const struct ieee80211_mgmt *mgmt = (void *)buf; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2418 | bool need_offchan = false; |
Johannes Berg | e247bd90 | 2011-11-04 11:18:21 +0100 | [diff] [blame] | 2419 | u32 flags; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2420 | int ret; |
Johannes Berg | f7ca38d | 2010-11-25 10:02:29 +0100 | [diff] [blame] | 2421 | |
Johannes Berg | e247bd90 | 2011-11-04 11:18:21 +0100 | [diff] [blame] | 2422 | if (dont_wait_for_ack) |
| 2423 | flags = IEEE80211_TX_CTL_NO_ACK; |
| 2424 | else |
| 2425 | flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | |
| 2426 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
| 2427 | |
Rajkumar Manoharan | aad14ce | 2011-09-25 14:53:31 +0530 | [diff] [blame] | 2428 | if (no_cck) |
| 2429 | flags |= IEEE80211_TX_CTL_NO_CCK_RATE; |
| 2430 | |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 2431 | switch (sdata->vif.type) { |
| 2432 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2433 | if (!sdata->vif.bss_conf.ibss_joined) |
| 2434 | need_offchan = true; |
| 2435 | /* fall through */ |
| 2436 | #ifdef CONFIG_MAC80211_MESH |
| 2437 | case NL80211_IFTYPE_MESH_POINT: |
| 2438 | if (ieee80211_vif_is_mesh(&sdata->vif) && |
| 2439 | !sdata->u.mesh.mesh_id_len) |
| 2440 | need_offchan = true; |
| 2441 | /* fall through */ |
| 2442 | #endif |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 2443 | case NL80211_IFTYPE_AP: |
| 2444 | case NL80211_IFTYPE_AP_VLAN: |
| 2445 | case NL80211_IFTYPE_P2P_GO: |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2446 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC && |
| 2447 | !ieee80211_vif_is_mesh(&sdata->vif) && |
| 2448 | !rcu_access_pointer(sdata->bss->beacon)) |
| 2449 | need_offchan = true; |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 2450 | if (!ieee80211_is_action(mgmt->frame_control) || |
| 2451 | mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 2452 | break; |
| 2453 | rcu_read_lock(); |
| 2454 | sta = sta_info_get(sdata, mgmt->da); |
| 2455 | rcu_read_unlock(); |
| 2456 | if (!sta) |
| 2457 | return -ENOLINK; |
| 2458 | break; |
| 2459 | case NL80211_IFTYPE_STATION: |
Johannes Berg | 663fcaf | 2010-09-30 21:06:09 +0200 | [diff] [blame] | 2460 | case NL80211_IFTYPE_P2P_CLIENT: |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2461 | if (!sdata->u.mgd.associated) |
| 2462 | need_offchan = true; |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 2463 | break; |
| 2464 | default: |
| 2465 | return -EOPNOTSUPP; |
| 2466 | } |
| 2467 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2468 | mutex_lock(&local->mtx); |
| 2469 | |
| 2470 | /* Check if the operating channel is the requested channel */ |
| 2471 | if (!need_offchan) { |
| 2472 | need_offchan = chan != local->oper_channel; |
| 2473 | if (channel_type_valid && |
| 2474 | channel_type != local->_oper_channel_type) |
| 2475 | need_offchan = true; |
| 2476 | } |
| 2477 | |
| 2478 | if (need_offchan && !offchan) { |
| 2479 | ret = -EBUSY; |
| 2480 | goto out_unlock; |
| 2481 | } |
| 2482 | |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 2483 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + len); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2484 | if (!skb) { |
| 2485 | ret = -ENOMEM; |
| 2486 | goto out_unlock; |
| 2487 | } |
Johannes Berg | 9d38d85 | 2010-06-09 17:20:33 +0200 | [diff] [blame] | 2488 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 2489 | |
| 2490 | memcpy(skb_put(skb, len), buf, len); |
| 2491 | |
| 2492 | IEEE80211_SKB_CB(skb)->flags = flags; |
| 2493 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2494 | skb->dev = sdata->dev; |
| 2495 | |
| 2496 | if (!need_offchan) { |
Nicolas Cavallari | 7f9f78a | 2012-07-16 18:36:52 +0200 | [diff] [blame] | 2497 | *cookie = (unsigned long) skb; |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2498 | ieee80211_tx_skb(sdata, skb); |
| 2499 | ret = 0; |
| 2500 | goto out_unlock; |
| 2501 | } |
| 2502 | |
| 2503 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN; |
| 2504 | if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL) |
Johannes Berg | 3a25a8c | 2012-04-03 16:28:50 +0200 | [diff] [blame] | 2505 | IEEE80211_SKB_CB(skb)->hw_queue = |
| 2506 | local->hw.offchannel_tx_hw_queue; |
| 2507 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2508 | /* This will handle all kinds of coalescing and immediate TX */ |
| 2509 | ret = ieee80211_start_roc_work(local, sdata, chan, channel_type, |
| 2510 | wait, cookie, skb); |
| 2511 | if (ret) |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2512 | kfree_skb(skb); |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2513 | out_unlock: |
| 2514 | mutex_unlock(&local->mtx); |
| 2515 | return ret; |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 2516 | } |
| 2517 | |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2518 | static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2519 | struct wireless_dev *wdev, |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2520 | u64 cookie) |
| 2521 | { |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2522 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2523 | |
Johannes Berg | 2eb278e | 2012-06-05 14:28:42 +0200 | [diff] [blame] | 2524 | return ieee80211_cancel_roc(local, cookie, true); |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 2525 | } |
| 2526 | |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2527 | static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2528 | struct wireless_dev *wdev, |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2529 | u16 frame_type, bool reg) |
| 2530 | { |
| 2531 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 71bbc99 | 2012-06-15 15:30:18 +0200 | [diff] [blame] | 2532 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2533 | |
Will Hawkins | 6abe056 | 2012-06-20 11:51:14 -0400 | [diff] [blame] | 2534 | switch (frame_type) { |
| 2535 | case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH: |
| 2536 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
| 2537 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2538 | |
Will Hawkins | 6abe056 | 2012-06-20 11:51:14 -0400 | [diff] [blame] | 2539 | if (reg) |
| 2540 | ifibss->auth_frame_registrations++; |
| 2541 | else |
| 2542 | ifibss->auth_frame_registrations--; |
| 2543 | } |
| 2544 | break; |
| 2545 | case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ: |
| 2546 | if (reg) |
| 2547 | local->probe_req_reg++; |
| 2548 | else |
| 2549 | local->probe_req_reg--; |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2550 | |
Will Hawkins | 6abe056 | 2012-06-20 11:51:14 -0400 | [diff] [blame] | 2551 | ieee80211_queue_work(&local->hw, &local->reconfig_filter); |
| 2552 | break; |
| 2553 | default: |
| 2554 | break; |
| 2555 | } |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 2556 | } |
| 2557 | |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 2558 | static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant) |
| 2559 | { |
| 2560 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2561 | |
| 2562 | if (local->started) |
| 2563 | return -EOPNOTSUPP; |
| 2564 | |
| 2565 | return drv_set_antenna(local, tx_ant, rx_ant); |
| 2566 | } |
| 2567 | |
| 2568 | static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant) |
| 2569 | { |
| 2570 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2571 | |
| 2572 | return drv_get_antenna(local, tx_ant, rx_ant); |
| 2573 | } |
| 2574 | |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 2575 | static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx) |
| 2576 | { |
| 2577 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2578 | |
| 2579 | return drv_set_ringparam(local, tx, rx); |
| 2580 | } |
| 2581 | |
| 2582 | static void ieee80211_get_ringparam(struct wiphy *wiphy, |
| 2583 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) |
| 2584 | { |
| 2585 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2586 | |
| 2587 | drv_get_ringparam(local, tx, tx_max, rx, rx_max); |
| 2588 | } |
| 2589 | |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 2590 | static int ieee80211_set_rekey_data(struct wiphy *wiphy, |
| 2591 | struct net_device *dev, |
| 2592 | struct cfg80211_gtk_rekey_data *data) |
| 2593 | { |
| 2594 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2595 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2596 | |
| 2597 | if (!local->ops->set_rekey_data) |
| 2598 | return -EOPNOTSUPP; |
| 2599 | |
| 2600 | drv_set_rekey_data(local, sdata, data); |
| 2601 | |
| 2602 | return 0; |
| 2603 | } |
| 2604 | |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2605 | static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb) |
| 2606 | { |
| 2607 | u8 *pos = (void *)skb_put(skb, 7); |
| 2608 | |
| 2609 | *pos++ = WLAN_EID_EXT_CAPABILITY; |
| 2610 | *pos++ = 5; /* len */ |
| 2611 | *pos++ = 0x0; |
| 2612 | *pos++ = 0x0; |
| 2613 | *pos++ = 0x0; |
| 2614 | *pos++ = 0x0; |
| 2615 | *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED; |
| 2616 | } |
| 2617 | |
| 2618 | static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata) |
| 2619 | { |
| 2620 | struct ieee80211_local *local = sdata->local; |
| 2621 | u16 capab; |
| 2622 | |
| 2623 | capab = 0; |
| 2624 | if (local->oper_channel->band != IEEE80211_BAND_2GHZ) |
| 2625 | return capab; |
| 2626 | |
| 2627 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) |
| 2628 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; |
| 2629 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) |
| 2630 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; |
| 2631 | |
| 2632 | return capab; |
| 2633 | } |
| 2634 | |
| 2635 | static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr, |
| 2636 | u8 *peer, u8 *bssid) |
| 2637 | { |
| 2638 | struct ieee80211_tdls_lnkie *lnkid; |
| 2639 | |
| 2640 | lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie)); |
| 2641 | |
| 2642 | lnkid->ie_type = WLAN_EID_LINK_ID; |
| 2643 | lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2; |
| 2644 | |
| 2645 | memcpy(lnkid->bssid, bssid, ETH_ALEN); |
| 2646 | memcpy(lnkid->init_sta, src_addr, ETH_ALEN); |
| 2647 | memcpy(lnkid->resp_sta, peer, ETH_ALEN); |
| 2648 | } |
| 2649 | |
| 2650 | static int |
| 2651 | ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, |
| 2652 | u8 *peer, u8 action_code, u8 dialog_token, |
| 2653 | u16 status_code, struct sk_buff *skb) |
| 2654 | { |
| 2655 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2656 | struct ieee80211_tdls_data *tf; |
| 2657 | |
| 2658 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); |
| 2659 | |
| 2660 | memcpy(tf->da, peer, ETH_ALEN); |
| 2661 | memcpy(tf->sa, sdata->vif.addr, ETH_ALEN); |
| 2662 | tf->ether_type = cpu_to_be16(ETH_P_TDLS); |
| 2663 | tf->payload_type = WLAN_TDLS_SNAP_RFTYPE; |
| 2664 | |
| 2665 | switch (action_code) { |
| 2666 | case WLAN_TDLS_SETUP_REQUEST: |
| 2667 | tf->category = WLAN_CATEGORY_TDLS; |
| 2668 | tf->action_code = WLAN_TDLS_SETUP_REQUEST; |
| 2669 | |
| 2670 | skb_put(skb, sizeof(tf->u.setup_req)); |
| 2671 | tf->u.setup_req.dialog_token = dialog_token; |
| 2672 | tf->u.setup_req.capability = |
| 2673 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 2674 | |
Johannes Berg | fc8a732 | 2012-06-28 10:33:25 +0200 | [diff] [blame] | 2675 | ieee80211_add_srates_ie(sdata, skb, false); |
| 2676 | ieee80211_add_ext_srates_ie(sdata, skb, false); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2677 | ieee80211_tdls_add_ext_capab(skb); |
| 2678 | break; |
| 2679 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2680 | tf->category = WLAN_CATEGORY_TDLS; |
| 2681 | tf->action_code = WLAN_TDLS_SETUP_RESPONSE; |
| 2682 | |
| 2683 | skb_put(skb, sizeof(tf->u.setup_resp)); |
| 2684 | tf->u.setup_resp.status_code = cpu_to_le16(status_code); |
| 2685 | tf->u.setup_resp.dialog_token = dialog_token; |
| 2686 | tf->u.setup_resp.capability = |
| 2687 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 2688 | |
Johannes Berg | fc8a732 | 2012-06-28 10:33:25 +0200 | [diff] [blame] | 2689 | ieee80211_add_srates_ie(sdata, skb, false); |
| 2690 | ieee80211_add_ext_srates_ie(sdata, skb, false); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2691 | ieee80211_tdls_add_ext_capab(skb); |
| 2692 | break; |
| 2693 | case WLAN_TDLS_SETUP_CONFIRM: |
| 2694 | tf->category = WLAN_CATEGORY_TDLS; |
| 2695 | tf->action_code = WLAN_TDLS_SETUP_CONFIRM; |
| 2696 | |
| 2697 | skb_put(skb, sizeof(tf->u.setup_cfm)); |
| 2698 | tf->u.setup_cfm.status_code = cpu_to_le16(status_code); |
| 2699 | tf->u.setup_cfm.dialog_token = dialog_token; |
| 2700 | break; |
| 2701 | case WLAN_TDLS_TEARDOWN: |
| 2702 | tf->category = WLAN_CATEGORY_TDLS; |
| 2703 | tf->action_code = WLAN_TDLS_TEARDOWN; |
| 2704 | |
| 2705 | skb_put(skb, sizeof(tf->u.teardown)); |
| 2706 | tf->u.teardown.reason_code = cpu_to_le16(status_code); |
| 2707 | break; |
| 2708 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 2709 | tf->category = WLAN_CATEGORY_TDLS; |
| 2710 | tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST; |
| 2711 | |
| 2712 | skb_put(skb, sizeof(tf->u.discover_req)); |
| 2713 | tf->u.discover_req.dialog_token = dialog_token; |
| 2714 | break; |
| 2715 | default: |
| 2716 | return -EINVAL; |
| 2717 | } |
| 2718 | |
| 2719 | return 0; |
| 2720 | } |
| 2721 | |
| 2722 | static int |
| 2723 | ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, |
| 2724 | u8 *peer, u8 action_code, u8 dialog_token, |
| 2725 | u16 status_code, struct sk_buff *skb) |
| 2726 | { |
| 2727 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2728 | struct ieee80211_mgmt *mgmt; |
| 2729 | |
| 2730 | mgmt = (void *)skb_put(skb, 24); |
| 2731 | memset(mgmt, 0, 24); |
| 2732 | memcpy(mgmt->da, peer, ETH_ALEN); |
| 2733 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
| 2734 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
| 2735 | |
| 2736 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 2737 | IEEE80211_STYPE_ACTION); |
| 2738 | |
| 2739 | switch (action_code) { |
| 2740 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 2741 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp)); |
| 2742 | mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; |
| 2743 | mgmt->u.action.u.tdls_discover_resp.action_code = |
| 2744 | WLAN_PUB_ACTION_TDLS_DISCOVER_RES; |
| 2745 | mgmt->u.action.u.tdls_discover_resp.dialog_token = |
| 2746 | dialog_token; |
| 2747 | mgmt->u.action.u.tdls_discover_resp.capability = |
| 2748 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
| 2749 | |
Johannes Berg | fc8a732 | 2012-06-28 10:33:25 +0200 | [diff] [blame] | 2750 | ieee80211_add_srates_ie(sdata, skb, false); |
| 2751 | ieee80211_add_ext_srates_ie(sdata, skb, false); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2752 | ieee80211_tdls_add_ext_capab(skb); |
| 2753 | break; |
| 2754 | default: |
| 2755 | return -EINVAL; |
| 2756 | } |
| 2757 | |
| 2758 | return 0; |
| 2759 | } |
| 2760 | |
| 2761 | static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 2762 | u8 *peer, u8 action_code, u8 dialog_token, |
| 2763 | u16 status_code, const u8 *extra_ies, |
| 2764 | size_t extra_ies_len) |
| 2765 | { |
| 2766 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2767 | struct ieee80211_local *local = sdata->local; |
| 2768 | struct ieee80211_tx_info *info; |
| 2769 | struct sk_buff *skb = NULL; |
| 2770 | bool send_direct; |
| 2771 | int ret; |
| 2772 | |
| 2773 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) |
| 2774 | return -ENOTSUPP; |
| 2775 | |
| 2776 | /* make sure we are in managed mode, and associated */ |
| 2777 | if (sdata->vif.type != NL80211_IFTYPE_STATION || |
| 2778 | !sdata->u.mgd.associated) |
| 2779 | return -EINVAL; |
| 2780 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2781 | tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n", |
| 2782 | action_code, peer); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2783 | |
| 2784 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + |
| 2785 | max(sizeof(struct ieee80211_mgmt), |
| 2786 | sizeof(struct ieee80211_tdls_data)) + |
| 2787 | 50 + /* supported rates */ |
| 2788 | 7 + /* ext capab */ |
| 2789 | extra_ies_len + |
| 2790 | sizeof(struct ieee80211_tdls_lnkie)); |
| 2791 | if (!skb) |
| 2792 | return -ENOMEM; |
| 2793 | |
| 2794 | info = IEEE80211_SKB_CB(skb); |
| 2795 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 2796 | |
| 2797 | switch (action_code) { |
| 2798 | case WLAN_TDLS_SETUP_REQUEST: |
| 2799 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2800 | case WLAN_TDLS_SETUP_CONFIRM: |
| 2801 | case WLAN_TDLS_TEARDOWN: |
| 2802 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 2803 | ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer, |
| 2804 | action_code, dialog_token, |
| 2805 | status_code, skb); |
| 2806 | send_direct = false; |
| 2807 | break; |
| 2808 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 2809 | ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code, |
| 2810 | dialog_token, status_code, |
| 2811 | skb); |
| 2812 | send_direct = true; |
| 2813 | break; |
| 2814 | default: |
| 2815 | ret = -ENOTSUPP; |
| 2816 | break; |
| 2817 | } |
| 2818 | |
| 2819 | if (ret < 0) |
| 2820 | goto fail; |
| 2821 | |
| 2822 | if (extra_ies_len) |
| 2823 | memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len); |
| 2824 | |
| 2825 | /* the TDLS link IE is always added last */ |
| 2826 | switch (action_code) { |
| 2827 | case WLAN_TDLS_SETUP_REQUEST: |
| 2828 | case WLAN_TDLS_SETUP_CONFIRM: |
| 2829 | case WLAN_TDLS_TEARDOWN: |
| 2830 | case WLAN_TDLS_DISCOVERY_REQUEST: |
| 2831 | /* we are the initiator */ |
| 2832 | ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer, |
| 2833 | sdata->u.mgd.bssid); |
| 2834 | break; |
| 2835 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2836 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: |
| 2837 | /* we are the responder */ |
| 2838 | ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr, |
| 2839 | sdata->u.mgd.bssid); |
| 2840 | break; |
| 2841 | default: |
| 2842 | ret = -ENOTSUPP; |
| 2843 | goto fail; |
| 2844 | } |
| 2845 | |
| 2846 | if (send_direct) { |
| 2847 | ieee80211_tx_skb(sdata, skb); |
| 2848 | return 0; |
| 2849 | } |
| 2850 | |
| 2851 | /* |
| 2852 | * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise |
| 2853 | * we should default to AC_VI. |
| 2854 | */ |
| 2855 | switch (action_code) { |
| 2856 | case WLAN_TDLS_SETUP_REQUEST: |
| 2857 | case WLAN_TDLS_SETUP_RESPONSE: |
| 2858 | skb_set_queue_mapping(skb, IEEE80211_AC_BK); |
| 2859 | skb->priority = 2; |
| 2860 | break; |
| 2861 | default: |
| 2862 | skb_set_queue_mapping(skb, IEEE80211_AC_VI); |
| 2863 | skb->priority = 5; |
| 2864 | break; |
| 2865 | } |
| 2866 | |
| 2867 | /* disable bottom halves when entering the Tx path */ |
| 2868 | local_bh_disable(); |
| 2869 | ret = ieee80211_subif_start_xmit(skb, dev); |
| 2870 | local_bh_enable(); |
| 2871 | |
| 2872 | return ret; |
| 2873 | |
| 2874 | fail: |
| 2875 | dev_kfree_skb(skb); |
| 2876 | return ret; |
| 2877 | } |
| 2878 | |
| 2879 | static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 2880 | u8 *peer, enum nl80211_tdls_operation oper) |
| 2881 | { |
Arik Nemtsov | 941c93c | 2011-09-28 14:12:54 +0300 | [diff] [blame] | 2882 | struct sta_info *sta; |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2883 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2884 | |
| 2885 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) |
| 2886 | return -ENOTSUPP; |
| 2887 | |
| 2888 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 2889 | return -EINVAL; |
| 2890 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 2891 | tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2892 | |
| 2893 | switch (oper) { |
| 2894 | case NL80211_TDLS_ENABLE_LINK: |
Arik Nemtsov | 941c93c | 2011-09-28 14:12:54 +0300 | [diff] [blame] | 2895 | rcu_read_lock(); |
| 2896 | sta = sta_info_get(sdata, peer); |
| 2897 | if (!sta) { |
| 2898 | rcu_read_unlock(); |
| 2899 | return -ENOLINK; |
| 2900 | } |
| 2901 | |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 2902 | set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH); |
Arik Nemtsov | 941c93c | 2011-09-28 14:12:54 +0300 | [diff] [blame] | 2903 | rcu_read_unlock(); |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 2904 | break; |
| 2905 | case NL80211_TDLS_DISABLE_LINK: |
| 2906 | return sta_info_destroy_addr(sdata, peer); |
| 2907 | case NL80211_TDLS_TEARDOWN: |
| 2908 | case NL80211_TDLS_SETUP: |
| 2909 | case NL80211_TDLS_DISCOVERY_REQ: |
| 2910 | /* We don't support in-driver setup/teardown/discovery */ |
| 2911 | return -ENOTSUPP; |
| 2912 | default: |
| 2913 | return -ENOTSUPP; |
| 2914 | } |
| 2915 | |
| 2916 | return 0; |
| 2917 | } |
| 2918 | |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 2919 | static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, |
| 2920 | const u8 *peer, u64 *cookie) |
| 2921 | { |
| 2922 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 2923 | struct ieee80211_local *local = sdata->local; |
| 2924 | struct ieee80211_qos_hdr *nullfunc; |
| 2925 | struct sk_buff *skb; |
| 2926 | int size = sizeof(*nullfunc); |
| 2927 | __le16 fc; |
| 2928 | bool qos; |
| 2929 | struct ieee80211_tx_info *info; |
| 2930 | struct sta_info *sta; |
| 2931 | |
| 2932 | rcu_read_lock(); |
| 2933 | sta = sta_info_get(sdata, peer); |
Johannes Berg | b4487c2 | 2011-11-11 20:22:30 +0100 | [diff] [blame] | 2934 | if (sta) { |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 2935 | qos = test_sta_flag(sta, WLAN_STA_WME); |
Johannes Berg | b4487c2 | 2011-11-11 20:22:30 +0100 | [diff] [blame] | 2936 | rcu_read_unlock(); |
| 2937 | } else { |
| 2938 | rcu_read_unlock(); |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 2939 | return -ENOLINK; |
Johannes Berg | b4487c2 | 2011-11-11 20:22:30 +0100 | [diff] [blame] | 2940 | } |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 2941 | |
| 2942 | if (qos) { |
| 2943 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 2944 | IEEE80211_STYPE_QOS_NULLFUNC | |
| 2945 | IEEE80211_FCTL_FROMDS); |
| 2946 | } else { |
| 2947 | size -= 2; |
| 2948 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 2949 | IEEE80211_STYPE_NULLFUNC | |
| 2950 | IEEE80211_FCTL_FROMDS); |
| 2951 | } |
| 2952 | |
| 2953 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); |
| 2954 | if (!skb) |
| 2955 | return -ENOMEM; |
| 2956 | |
| 2957 | skb->dev = dev; |
| 2958 | |
| 2959 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 2960 | |
| 2961 | nullfunc = (void *) skb_put(skb, size); |
| 2962 | nullfunc->frame_control = fc; |
| 2963 | nullfunc->duration_id = 0; |
| 2964 | memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); |
| 2965 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); |
| 2966 | memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); |
| 2967 | nullfunc->seq_ctrl = 0; |
| 2968 | |
| 2969 | info = IEEE80211_SKB_CB(skb); |
| 2970 | |
| 2971 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | |
| 2972 | IEEE80211_TX_INTFL_NL80211_FRAME_TX; |
| 2973 | |
| 2974 | skb_set_queue_mapping(skb, IEEE80211_AC_VO); |
| 2975 | skb->priority = 7; |
| 2976 | if (qos) |
| 2977 | nullfunc->qos_ctrl = cpu_to_le16(7); |
| 2978 | |
| 2979 | local_bh_disable(); |
| 2980 | ieee80211_xmit(sdata, skb); |
| 2981 | local_bh_enable(); |
| 2982 | |
| 2983 | *cookie = (unsigned long) skb; |
| 2984 | return 0; |
| 2985 | } |
| 2986 | |
Johannes Berg | 5b7ccaf | 2012-07-12 19:45:08 +0200 | [diff] [blame] | 2987 | static struct ieee80211_channel * |
| 2988 | ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 2989 | enum nl80211_channel_type *type) |
| 2990 | { |
| 2991 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 2992 | |
| 2993 | *type = local->_oper_channel_type; |
| 2994 | return local->oper_channel; |
| 2995 | } |
| 2996 | |
Johannes Berg | 6d52563 | 2012-04-04 15:05:25 +0200 | [diff] [blame] | 2997 | #ifdef CONFIG_PM |
| 2998 | static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled) |
| 2999 | { |
| 3000 | drv_set_wakeup(wiphy_priv(wiphy), enabled); |
| 3001 | } |
| 3002 | #endif |
| 3003 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 3004 | struct cfg80211_ops mac80211_config_ops = { |
| 3005 | .add_virtual_intf = ieee80211_add_iface, |
| 3006 | .del_virtual_intf = ieee80211_del_iface, |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 3007 | .change_virtual_intf = ieee80211_change_iface, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 3008 | .add_key = ieee80211_add_key, |
| 3009 | .del_key = ieee80211_del_key, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 3010 | .get_key = ieee80211_get_key, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 3011 | .set_default_key = ieee80211_config_default_key, |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 3012 | .set_default_mgmt_key = ieee80211_config_default_mgmt_key, |
Johannes Berg | 8860020 | 2012-02-13 15:17:18 +0100 | [diff] [blame] | 3013 | .start_ap = ieee80211_start_ap, |
| 3014 | .change_beacon = ieee80211_change_beacon, |
| 3015 | .stop_ap = ieee80211_stop_ap, |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 3016 | .add_station = ieee80211_add_station, |
| 3017 | .del_station = ieee80211_del_station, |
| 3018 | .change_station = ieee80211_change_station, |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 3019 | .get_station = ieee80211_get_station, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 3020 | .dump_station = ieee80211_dump_station, |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 3021 | .dump_survey = ieee80211_dump_survey, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 3022 | #ifdef CONFIG_MAC80211_MESH |
| 3023 | .add_mpath = ieee80211_add_mpath, |
| 3024 | .del_mpath = ieee80211_del_mpath, |
| 3025 | .change_mpath = ieee80211_change_mpath, |
| 3026 | .get_mpath = ieee80211_get_mpath, |
| 3027 | .dump_mpath = ieee80211_dump_mpath, |
Javier Cardona | 24bdd9f | 2010-12-16 17:37:48 -0800 | [diff] [blame] | 3028 | .update_mesh_config = ieee80211_update_mesh_config, |
| 3029 | .get_mesh_config = ieee80211_get_mesh_config, |
Johannes Berg | 29cbe68 | 2010-12-03 09:20:44 +0100 | [diff] [blame] | 3030 | .join_mesh = ieee80211_join_mesh, |
| 3031 | .leave_mesh = ieee80211_leave_mesh, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 3032 | #endif |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 3033 | .change_bss = ieee80211_change_bss, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 3034 | .set_txq_params = ieee80211_set_txq_params, |
Johannes Berg | e8c9bd5 | 2012-06-06 08:18:22 +0200 | [diff] [blame] | 3035 | .set_monitor_channel = ieee80211_set_monitor_channel, |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 3036 | .suspend = ieee80211_suspend, |
| 3037 | .resume = ieee80211_resume, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 3038 | .scan = ieee80211_scan, |
Luciano Coelho | 79f460c | 2011-05-11 17:09:36 +0300 | [diff] [blame] | 3039 | .sched_scan_start = ieee80211_sched_scan_start, |
| 3040 | .sched_scan_stop = ieee80211_sched_scan_stop, |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 3041 | .auth = ieee80211_auth, |
| 3042 | .assoc = ieee80211_assoc, |
| 3043 | .deauth = ieee80211_deauth, |
| 3044 | .disassoc = ieee80211_disassoc, |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 3045 | .join_ibss = ieee80211_join_ibss, |
| 3046 | .leave_ibss = ieee80211_leave_ibss, |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 3047 | .set_wiphy_params = ieee80211_set_wiphy_params, |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 3048 | .set_tx_power = ieee80211_set_tx_power, |
| 3049 | .get_tx_power = ieee80211_get_tx_power, |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 3050 | .set_wds_peer = ieee80211_set_wds_peer, |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 3051 | .rfkill_poll = ieee80211_rfkill_poll, |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 3052 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) |
Wey-Yi Guy | 71063f0 | 2011-05-20 09:05:54 -0700 | [diff] [blame] | 3053 | CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 3054 | .set_power_mgmt = ieee80211_set_power_mgmt, |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 3055 | .set_bitrate_mask = ieee80211_set_bitrate_mask, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 3056 | .remain_on_channel = ieee80211_remain_on_channel, |
| 3057 | .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, |
Johannes Berg | 2e161f7 | 2010-08-12 15:38:38 +0200 | [diff] [blame] | 3058 | .mgmt_tx = ieee80211_mgmt_tx, |
Johannes Berg | f30221e | 2010-11-25 10:02:30 +0100 | [diff] [blame] | 3059 | .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait, |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 3060 | .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config, |
Johannes Berg | 7be5086 | 2010-10-13 12:06:24 +0200 | [diff] [blame] | 3061 | .mgmt_frame_register = ieee80211_mgmt_frame_register, |
Bruno Randolf | 15d9675 | 2010-11-10 12:50:56 +0900 | [diff] [blame] | 3062 | .set_antenna = ieee80211_set_antenna, |
| 3063 | .get_antenna = ieee80211_get_antenna, |
John W. Linville | 38c0915 | 2011-03-07 16:19:18 -0500 | [diff] [blame] | 3064 | .set_ringparam = ieee80211_set_ringparam, |
| 3065 | .get_ringparam = ieee80211_get_ringparam, |
Johannes Berg | c68f4b8 | 2011-07-05 16:35:41 +0200 | [diff] [blame] | 3066 | .set_rekey_data = ieee80211_set_rekey_data, |
Arik Nemtsov | dfe018b | 2011-09-28 14:12:52 +0300 | [diff] [blame] | 3067 | .tdls_oper = ieee80211_tdls_oper, |
| 3068 | .tdls_mgmt = ieee80211_tdls_mgmt, |
Johannes Berg | 0650073 | 2011-11-04 11:18:16 +0100 | [diff] [blame] | 3069 | .probe_client = ieee80211_probe_client, |
Simon Wunderlich | b53be79 | 2011-11-18 14:20:44 +0100 | [diff] [blame] | 3070 | .set_noack_map = ieee80211_set_noack_map, |
Johannes Berg | 6d52563 | 2012-04-04 15:05:25 +0200 | [diff] [blame] | 3071 | #ifdef CONFIG_PM |
| 3072 | .set_wakeup = ieee80211_set_wakeup, |
| 3073 | #endif |
Ben Greear | b1ab792 | 2012-04-23 12:50:30 -0700 | [diff] [blame] | 3074 | .get_et_sset_count = ieee80211_get_et_sset_count, |
| 3075 | .get_et_stats = ieee80211_get_et_stats, |
| 3076 | .get_et_strings = ieee80211_get_et_strings, |
Johannes Berg | 5b7ccaf | 2012-07-12 19:45:08 +0200 | [diff] [blame] | 3077 | .get_channel = ieee80211_cfg_get_channel, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 3078 | }; |