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