Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2002-2005, Instant802 Networks, Inc. |
| 3 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> |
Johannes Berg | d98ad83 | 2014-09-03 15:24:57 +0300 | [diff] [blame] | 4 | * Copyright 2013-2014 Intel Mobile Communications GmbH |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/init.h> |
Felix Fietkau | 888d04d | 2012-03-01 15:22:09 +0100 | [diff] [blame] | 13 | #include <linux/etherdevice.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 14 | #include <linux/netdevice.h> |
| 15 | #include <linux/types.h> |
| 16 | #include <linux/slab.h> |
| 17 | #include <linux/skbuff.h> |
| 18 | #include <linux/if_arp.h> |
Johannes Berg | 0d17440 | 2007-12-17 15:07:43 +0100 | [diff] [blame] | 19 | #include <linux/timer.h> |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 20 | #include <linux/rtnetlink.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 21 | |
| 22 | #include <net/mac80211.h> |
| 23 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 24 | #include "driver-ops.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 25 | #include "rate.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 26 | #include "sta_info.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 27 | #include "debugfs_sta.h" |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 28 | #include "mesh.h" |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 29 | #include "wme.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 30 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 31 | /** |
| 32 | * DOC: STA information lifetime rules |
| 33 | * |
| 34 | * STA info structures (&struct sta_info) are managed in a hash table |
| 35 | * for faster lookup and a list for iteration. They are managed using |
| 36 | * RCU, i.e. access to the list and hash table is protected by RCU. |
| 37 | * |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 38 | * Upon allocating a STA info structure with sta_info_alloc(), the caller |
| 39 | * owns that structure. It must then insert it into the hash table using |
| 40 | * either sta_info_insert() or sta_info_insert_rcu(); only in the latter |
| 41 | * case (which acquires an rcu read section but must not be called from |
| 42 | * within one) will the pointer still be valid after the call. Note that |
| 43 | * the caller may not do much with the STA info before inserting it, in |
| 44 | * particular, it may not start any mesh peer link management or add |
| 45 | * encryption keys. |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 46 | * |
| 47 | * When the insertion fails (sta_info_insert()) returns non-zero), the |
| 48 | * structure will have been freed by sta_info_insert()! |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 49 | * |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 50 | * Station entries are added by mac80211 when you establish a link with a |
Luis R. Rodriguez | 7e189a1 | 2009-06-02 18:38:14 -0400 | [diff] [blame] | 51 | * peer. This means different things for the different type of interfaces |
| 52 | * we support. For a regular station this mean we add the AP sta when we |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 53 | * receive an association response from the AP. For IBSS this occurs when |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 54 | * get to know about a peer on the same IBSS. For WDS we add the sta for |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 55 | * the peer immediately upon device open. When using AP mode we add stations |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 56 | * for each respective station upon request from userspace through nl80211. |
Luis R. Rodriguez | 7e189a1 | 2009-06-02 18:38:14 -0400 | [diff] [blame] | 57 | * |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 58 | * In order to remove a STA info structure, various sta_info_destroy_*() |
| 59 | * calls are available. |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 60 | * |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 61 | * There is no concept of ownership on a STA entry, each structure is |
| 62 | * owned by the global hash table/list until it is removed. All users of |
| 63 | * the structure need to be RCU protected so that the structure won't be |
| 64 | * freed before they are done using it. |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 65 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 66 | |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 67 | static const struct rhashtable_params sta_rht_params = { |
| 68 | .nelem_hint = 3, /* start small */ |
| 69 | .head_offset = offsetof(struct sta_info, hash_node), |
| 70 | .key_offset = offsetof(struct sta_info, sta.addr), |
| 71 | .key_len = ETH_ALEN, |
| 72 | .hashfn = sta_addr_hash, |
| 73 | }; |
| 74 | |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 75 | /* Caller must hold local->sta_mtx */ |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 76 | static int sta_info_hash_del(struct ieee80211_local *local, |
| 77 | struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 78 | { |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 79 | return rhashtable_remove_fast(&local->sta_hash, &sta->hash_node, |
| 80 | sta_rht_params); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Johannes Berg | 5108ca8 | 2014-02-17 20:49:03 +0100 | [diff] [blame] | 83 | static void __cleanup_single_sta(struct sta_info *sta) |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 84 | { |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 85 | int ac, i; |
| 86 | struct tid_ampdu_tx *tid_tx; |
| 87 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
| 88 | struct ieee80211_local *local = sdata->local; |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 89 | struct ps_data *ps; |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 90 | |
Johannes Berg | e3685e0 | 2014-02-20 11:19:58 +0100 | [diff] [blame] | 91 | if (test_sta_flag(sta, WLAN_STA_PS_STA) || |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 92 | test_sta_flag(sta, WLAN_STA_PS_DRIVER) || |
| 93 | test_sta_flag(sta, WLAN_STA_PS_DELIVER)) { |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 94 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP || |
| 95 | sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
| 96 | ps = &sdata->bss->ps; |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 97 | else if (ieee80211_vif_is_mesh(&sdata->vif)) |
| 98 | ps = &sdata->u.mesh.ps; |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 99 | else |
| 100 | return; |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 101 | |
| 102 | clear_sta_flag(sta, WLAN_STA_PS_STA); |
Johannes Berg | e3685e0 | 2014-02-20 11:19:58 +0100 | [diff] [blame] | 103 | clear_sta_flag(sta, WLAN_STA_PS_DRIVER); |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 104 | clear_sta_flag(sta, WLAN_STA_PS_DELIVER); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 105 | |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 106 | atomic_dec(&ps->num_sta_ps); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
| 110 | local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); |
Felix Fietkau | 1f98ab7 | 2012-11-10 03:44:14 +0100 | [diff] [blame] | 111 | ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]); |
| 112 | ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 113 | } |
| 114 | |
Thomas Pedersen | 45b5028 | 2013-02-06 10:17:21 -0800 | [diff] [blame] | 115 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
| 116 | mesh_sta_cleanup(sta); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 117 | |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 118 | cancel_work_sync(&sta->drv_deliver_wk); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 119 | |
| 120 | /* |
| 121 | * Destroy aggregation state here. It would be nice to wait for the |
| 122 | * driver to finish aggregation stop and then clean up, but for now |
| 123 | * drivers have to handle aggregation stop being requested, followed |
| 124 | * directly by station destruction. |
| 125 | */ |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 126 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { |
Johannes Berg | 661eb38 | 2013-06-12 22:47:56 +0200 | [diff] [blame] | 127 | kfree(sta->ampdu_mlme.tid_start_tx[i]); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 128 | tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); |
| 129 | if (!tid_tx) |
| 130 | continue; |
Felix Fietkau | 1f98ab7 | 2012-11-10 03:44:14 +0100 | [diff] [blame] | 131 | ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 132 | kfree(tid_tx); |
| 133 | } |
Johannes Berg | 5108ca8 | 2014-02-17 20:49:03 +0100 | [diff] [blame] | 134 | } |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 135 | |
Johannes Berg | 5108ca8 | 2014-02-17 20:49:03 +0100 | [diff] [blame] | 136 | static void cleanup_single_sta(struct sta_info *sta) |
| 137 | { |
| 138 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
| 139 | struct ieee80211_local *local = sdata->local; |
| 140 | |
| 141 | __cleanup_single_sta(sta); |
Eliad Peller | b22cfcf | 2012-09-09 14:43:51 +0300 | [diff] [blame] | 142 | sta_info_free(local, sta); |
| 143 | } |
| 144 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 145 | /* protected by RCU */ |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 146 | struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, |
| 147 | const u8 *addr) |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 148 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 149 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 150 | |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 151 | return rhashtable_lookup_fast(&local->sta_hash, addr, sta_rht_params); |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 152 | } |
| 153 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 154 | /* |
| 155 | * Get sta info either from the specified interface |
| 156 | * or from one of its vlans |
| 157 | */ |
| 158 | struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, |
| 159 | const u8 *addr) |
| 160 | { |
| 161 | struct ieee80211_local *local = sdata->local; |
| 162 | struct sta_info *sta; |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 163 | struct rhash_head *tmp; |
| 164 | const struct bucket_table *tbl; |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 165 | |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 166 | rcu_read_lock(); |
| 167 | tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); |
| 168 | |
| 169 | for_each_sta_info(local, tbl, addr, sta, tmp) { |
| 170 | if (sta->sdata == sdata || |
| 171 | (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { |
| 172 | rcu_read_unlock(); |
| 173 | /* this is safe as the caller must already hold |
| 174 | * another rcu read section or the mutex |
| 175 | */ |
| 176 | return sta; |
| 177 | } |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 178 | } |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 179 | rcu_read_unlock(); |
| 180 | return NULL; |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 181 | } |
| 182 | |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 183 | struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata, |
| 184 | int idx) |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 185 | { |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 186 | struct ieee80211_local *local = sdata->local; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 187 | struct sta_info *sta; |
| 188 | int i = 0; |
| 189 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 190 | list_for_each_entry_rcu(sta, &local->sta_list, list) { |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 191 | if (sdata != sta->sdata) |
Luis Carlos Cobo | 2a8ca29 | 2008-02-29 17:51:25 -0800 | [diff] [blame] | 192 | continue; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 193 | if (i < idx) { |
| 194 | ++i; |
| 195 | continue; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 196 | } |
Luis Carlos Cobo | 2a8ca29 | 2008-02-29 17:51:25 -0800 | [diff] [blame] | 197 | return sta; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 198 | } |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 199 | |
| 200 | return NULL; |
| 201 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 202 | |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 203 | /** |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 204 | * sta_info_free - free STA |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 205 | * |
Randy Dunlap | 6ef307b | 2008-07-03 13:52:18 -0700 | [diff] [blame] | 206 | * @local: pointer to the global information |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 207 | * @sta: STA info to free |
| 208 | * |
| 209 | * This function must undo everything done by sta_info_alloc() |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 210 | * that may happen before sta_info_insert(). It may only be |
| 211 | * called when sta_info_insert() has not been attempted (and |
| 212 | * if that fails, the station is freed anyway.) |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 213 | */ |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 214 | void sta_info_free(struct ieee80211_local *local, struct sta_info *sta) |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 215 | { |
Johannes Berg | 889cbb9 | 2012-01-17 10:33:29 +0100 | [diff] [blame] | 216 | if (sta->rate_ctrl) |
Johannes Berg | af65cd96 | 2009-11-17 18:18:36 +0100 | [diff] [blame] | 217 | rate_control_free_sta(sta); |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 218 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 219 | sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 220 | |
Felix Fietkau | 53d0452 | 2014-05-27 22:33:57 +0200 | [diff] [blame] | 221 | kfree(rcu_dereference_raw(sta->sta.rates)); |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 222 | kfree(sta); |
| 223 | } |
| 224 | |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 225 | /* Caller must hold local->sta_mtx */ |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 226 | static void sta_info_hash_add(struct ieee80211_local *local, |
| 227 | struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 228 | { |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 229 | rhashtable_insert_fast(&local->sta_hash, &sta->hash_node, |
| 230 | sta_rht_params); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 231 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 232 | |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 233 | static void sta_deliver_ps_frames(struct work_struct *wk) |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 234 | { |
| 235 | struct sta_info *sta; |
| 236 | |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 237 | sta = container_of(wk, struct sta_info, drv_deliver_wk); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 238 | |
| 239 | if (sta->dead) |
| 240 | return; |
| 241 | |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 242 | local_bh_disable(); |
| 243 | if (!test_sta_flag(sta, WLAN_STA_PS_STA)) |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 244 | ieee80211_sta_ps_deliver_wakeup(sta); |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 245 | else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 246 | ieee80211_sta_ps_deliver_poll_response(sta); |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 247 | else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD)) |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 248 | ieee80211_sta_ps_deliver_uapsd(sta); |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 249 | local_bh_enable(); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 250 | } |
| 251 | |
Johannes Berg | af65cd96 | 2009-11-17 18:18:36 +0100 | [diff] [blame] | 252 | static int sta_prepare_rate_control(struct ieee80211_local *local, |
| 253 | struct sta_info *sta, gfp_t gfp) |
| 254 | { |
| 255 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) |
| 256 | return 0; |
| 257 | |
Johannes Berg | 889cbb9 | 2012-01-17 10:33:29 +0100 | [diff] [blame] | 258 | sta->rate_ctrl = local->rate_ctrl; |
Johannes Berg | af65cd96 | 2009-11-17 18:18:36 +0100 | [diff] [blame] | 259 | sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, |
| 260 | &sta->sta, gfp); |
Johannes Berg | 889cbb9 | 2012-01-17 10:33:29 +0100 | [diff] [blame] | 261 | if (!sta->rate_ctrl_priv) |
Johannes Berg | af65cd96 | 2009-11-17 18:18:36 +0100 | [diff] [blame] | 262 | return -ENOMEM; |
Johannes Berg | af65cd96 | 2009-11-17 18:18:36 +0100 | [diff] [blame] | 263 | |
| 264 | return 0; |
| 265 | } |
| 266 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 267 | struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 5654416 | 2011-12-14 13:28:46 +0100 | [diff] [blame] | 268 | const u8 *addr, gfp_t gfp) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 269 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 270 | struct ieee80211_local *local = sdata->local; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 271 | struct sta_info *sta; |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 272 | struct timespec uptime; |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 273 | int i; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 274 | |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 275 | sta = kzalloc(sizeof(*sta) + local->hw.sta_data_size, gfp); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 276 | if (!sta) |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 277 | return NULL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 278 | |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 279 | spin_lock_init(&sta->lock); |
Emmanuel Grumbach | 1d147bf | 2014-02-20 09:22:11 +0200 | [diff] [blame] | 280 | spin_lock_init(&sta->ps_lock); |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 281 | INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); |
Johannes Berg | 67c282c | 2010-06-10 10:21:43 +0200 | [diff] [blame] | 282 | INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); |
Johannes Berg | a93e364 | 2010-06-10 10:21:46 +0200 | [diff] [blame] | 283 | mutex_init(&sta->ampdu_mlme.mtx); |
Thomas Pedersen | 87f59c7 | 2013-03-01 22:02:52 -0800 | [diff] [blame] | 284 | #ifdef CONFIG_MAC80211_MESH |
| 285 | if (ieee80211_vif_is_mesh(&sdata->vif) && |
| 286 | !sdata->u.mesh.user_mpm) |
| 287 | init_timer(&sta->plink_timer); |
Thomas Pedersen | 6c7c4cb | 2013-06-20 23:50:59 -0700 | [diff] [blame] | 288 | sta->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; |
Thomas Pedersen | 87f59c7 | 2013-03-01 22:02:52 -0800 | [diff] [blame] | 289 | #endif |
Johannes Berg | 07346f81 | 2008-05-03 01:02:02 +0200 | [diff] [blame] | 290 | |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 291 | memcpy(sta->sta.addr, addr, ETH_ALEN); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 292 | sta->local = local; |
| 293 | sta->sdata = sdata; |
Felix Fietkau | 8bc8aec | 2011-03-21 20:01:00 +0100 | [diff] [blame] | 294 | sta->last_rx = jiffies; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 295 | |
Johannes Berg | 71ec375 | 2012-01-20 13:55:20 +0100 | [diff] [blame] | 296 | sta->sta_state = IEEE80211_STA_NONE; |
| 297 | |
Liad Kaufman | b6da911 | 2014-11-19 13:47:38 +0200 | [diff] [blame] | 298 | /* Mark TID as unreserved */ |
| 299 | sta->reserved_tid = IEEE80211_TID_UNRESERVED; |
| 300 | |
Thomas Gleixner | 1817152 | 2014-06-11 23:59:14 +0000 | [diff] [blame] | 301 | ktime_get_ts(&uptime); |
Mohammed Shafi Shajakhan | ebe27c9 | 2011-04-08 21:24:24 +0530 | [diff] [blame] | 302 | sta->last_connected = uptime.tv_sec; |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 303 | ewma_init(&sta->avg_signal, 1024, 8); |
Felix Fietkau | ef0621e | 2013-04-22 16:29:31 +0200 | [diff] [blame] | 304 | for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++) |
| 305 | ewma_init(&sta->chain_signal_avg[i], 1024, 8); |
Bruno Randolf | 541a45a | 2010-12-02 19:12:43 +0900 | [diff] [blame] | 306 | |
Johannes Berg | abfbc3a | 2015-02-25 10:03:25 +0100 | [diff] [blame] | 307 | if (sta_prepare_rate_control(local, sta, gfp)) { |
| 308 | kfree(sta); |
| 309 | return NULL; |
| 310 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 311 | |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 312 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { |
Johannes Berg | a622ab7 | 2010-06-10 10:21:39 +0200 | [diff] [blame] | 313 | /* |
| 314 | * timer_to_tid must be initialized with identity mapping |
| 315 | * to enable session_timer's data differentiation. See |
| 316 | * sta_rx_agg_session_timer_expired for usage. |
| 317 | */ |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 318 | sta->timer_to_tid[i] = i; |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 319 | } |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 320 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
| 321 | skb_queue_head_init(&sta->ps_tx_buf[i]); |
| 322 | skb_queue_head_init(&sta->tx_filtered[i]); |
| 323 | } |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 324 | |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 325 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) |
Alexey Dobriyan | 4be929b | 2010-05-24 14:33:03 -0700 | [diff] [blame] | 326 | sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX); |
Senthil Balasubramanian | cccaec9 | 2009-05-14 18:42:08 +0530 | [diff] [blame] | 327 | |
Johannes Berg | af0ed69 | 2013-02-12 14:21:00 +0100 | [diff] [blame] | 328 | sta->sta.smps_mode = IEEE80211_SMPS_OFF; |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 329 | if (sdata->vif.type == NL80211_IFTYPE_AP || |
| 330 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { |
| 331 | struct ieee80211_supported_band *sband = |
| 332 | local->hw.wiphy->bands[ieee80211_get_sdata_band(sdata)]; |
| 333 | u8 smps = (sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> |
| 334 | IEEE80211_HT_CAP_SM_PS_SHIFT; |
| 335 | /* |
| 336 | * Assume that hostapd advertises our caps in the beacon and |
| 337 | * this is the known_smps_mode for a station that just assciated |
| 338 | */ |
| 339 | switch (smps) { |
| 340 | case WLAN_HT_SMPS_CONTROL_DISABLED: |
| 341 | sta->known_smps_mode = IEEE80211_SMPS_OFF; |
| 342 | break; |
| 343 | case WLAN_HT_SMPS_CONTROL_STATIC: |
| 344 | sta->known_smps_mode = IEEE80211_SMPS_STATIC; |
| 345 | break; |
| 346 | case WLAN_HT_SMPS_CONTROL_DYNAMIC: |
| 347 | sta->known_smps_mode = IEEE80211_SMPS_DYNAMIC; |
| 348 | break; |
| 349 | default: |
| 350 | WARN_ON(1); |
| 351 | } |
| 352 | } |
Johannes Berg | af0ed69 | 2013-02-12 14:21:00 +0100 | [diff] [blame] | 353 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 354 | sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); |
Johannes Berg | ef04a29 | 2014-01-06 15:56:59 +0100 | [diff] [blame] | 355 | |
Johannes Berg | abfbc3a | 2015-02-25 10:03:25 +0100 | [diff] [blame] | 356 | return sta; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 357 | } |
| 358 | |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 359 | static int sta_info_insert_check(struct sta_info *sta) |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 360 | { |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 361 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 362 | |
Johannes Berg | 03e4497 | 2008-02-27 09:56:40 +0100 | [diff] [blame] | 363 | /* |
| 364 | * Can't be a WARN_ON because it can be triggered through a race: |
| 365 | * something inserts a STA (on one CPU) without holding the RTNL |
| 366 | * and another CPU turns off the net device. |
| 367 | */ |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 368 | if (unlikely(!ieee80211_sdata_running(sdata))) |
| 369 | return -ENETDOWN; |
Johannes Berg | 03e4497 | 2008-02-27 09:56:40 +0100 | [diff] [blame] | 370 | |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 371 | if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) || |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 372 | is_multicast_ether_addr(sta->sta.addr))) |
| 373 | return -EINVAL; |
| 374 | |
| 375 | return 0; |
| 376 | } |
| 377 | |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 378 | static int sta_info_insert_drv_state(struct ieee80211_local *local, |
| 379 | struct ieee80211_sub_if_data *sdata, |
| 380 | struct sta_info *sta) |
| 381 | { |
| 382 | enum ieee80211_sta_state state; |
| 383 | int err = 0; |
| 384 | |
| 385 | for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { |
| 386 | err = drv_sta_state(local, sdata, sta, state, state + 1); |
| 387 | if (err) |
| 388 | break; |
| 389 | } |
| 390 | |
| 391 | if (!err) { |
Johannes Berg | a4ec45a | 2012-01-20 13:55:22 +0100 | [diff] [blame] | 392 | /* |
| 393 | * Drivers using legacy sta_add/sta_remove callbacks only |
| 394 | * get uploaded set to true after sta_add is called. |
| 395 | */ |
| 396 | if (!local->ops->sta_add) |
| 397 | sta->uploaded = true; |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 402 | sdata_info(sdata, |
| 403 | "failed to move IBSS STA %pM to state %d (%d) - keeping it anyway\n", |
| 404 | sta->sta.addr, state + 1, err); |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 405 | err = 0; |
| 406 | } |
| 407 | |
| 408 | /* unwind on error */ |
| 409 | for (; state > IEEE80211_STA_NOTEXIST; state--) |
| 410 | WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); |
| 411 | |
| 412 | return err; |
| 413 | } |
| 414 | |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 415 | /* |
| 416 | * should be called with sta_mtx locked |
| 417 | * this function replaces the mutex lock |
| 418 | * with a RCU lock |
| 419 | */ |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 420 | static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 421 | { |
| 422 | struct ieee80211_local *local = sta->local; |
| 423 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 424 | struct station_info sinfo; |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 425 | int err = 0; |
| 426 | |
| 427 | lockdep_assert_held(&local->sta_mtx); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 428 | |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 429 | /* check if STA exists already */ |
| 430 | if (sta_info_get_bss(sdata, sta->sta.addr)) { |
| 431 | err = -EEXIST; |
| 432 | goto out_err; |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 433 | } |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 434 | |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 435 | local->num_sta++; |
| 436 | local->sta_generation++; |
| 437 | smp_mb(); |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 438 | |
Johannes Berg | 5108ca8 | 2014-02-17 20:49:03 +0100 | [diff] [blame] | 439 | /* simplify things and don't accept BA sessions yet */ |
| 440 | set_sta_flag(sta, WLAN_STA_BLOCK_BA); |
| 441 | |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 442 | /* make the station visible */ |
| 443 | sta_info_hash_add(local, sta); |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 444 | |
Arik Nemtsov | 2bad7748 | 2014-10-22 12:32:16 +0300 | [diff] [blame] | 445 | list_add_tail_rcu(&sta->list, &local->sta_list); |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 446 | |
Johannes Berg | 5108ca8 | 2014-02-17 20:49:03 +0100 | [diff] [blame] | 447 | /* notify driver */ |
| 448 | err = sta_info_insert_drv_state(local, sdata, sta); |
| 449 | if (err) |
| 450 | goto out_remove; |
| 451 | |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 452 | set_sta_flag(sta, WLAN_STA_INSERTED); |
Johannes Berg | 5108ca8 | 2014-02-17 20:49:03 +0100 | [diff] [blame] | 453 | /* accept BA sessions now */ |
| 454 | clear_sta_flag(sta, WLAN_STA_BLOCK_BA); |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 455 | |
Eliad Peller | 21f659b | 2013-11-11 20:14:01 +0200 | [diff] [blame] | 456 | ieee80211_recalc_min_chandef(sdata); |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 457 | ieee80211_sta_debugfs_add(sta); |
| 458 | rate_control_add_sta_debugfs(sta); |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 459 | |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 460 | memset(&sinfo, 0, sizeof(sinfo)); |
| 461 | sinfo.filled = 0; |
| 462 | sinfo.generation = local->sta_generation; |
| 463 | cfg80211_new_sta(sdata->dev, sta->sta.addr, &sinfo, GFP_KERNEL); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 464 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 465 | sta_dbg(sdata, "Inserted STA %pM\n", sta->sta.addr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 466 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 467 | /* move reference to rcu-protected */ |
| 468 | rcu_read_lock(); |
| 469 | mutex_unlock(&local->sta_mtx); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 470 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 471 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
| 472 | mesh_accept_plinks_update(sdata); |
| 473 | |
| 474 | return 0; |
Johannes Berg | 5108ca8 | 2014-02-17 20:49:03 +0100 | [diff] [blame] | 475 | out_remove: |
| 476 | sta_info_hash_del(local, sta); |
| 477 | list_del_rcu(&sta->list); |
| 478 | local->num_sta--; |
| 479 | synchronize_net(); |
| 480 | __cleanup_single_sta(sta); |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 481 | out_err: |
| 482 | mutex_unlock(&local->sta_mtx); |
| 483 | rcu_read_lock(); |
| 484 | return err; |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU) |
| 488 | { |
| 489 | struct ieee80211_local *local = sta->local; |
Zhao, Gang | 308f7fc | 2014-04-21 12:53:00 +0800 | [diff] [blame] | 490 | int err; |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 491 | |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 492 | might_sleep(); |
| 493 | |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 494 | err = sta_info_insert_check(sta); |
| 495 | if (err) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 496 | rcu_read_lock(); |
| 497 | goto out_free; |
| 498 | } |
| 499 | |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 500 | mutex_lock(&local->sta_mtx); |
| 501 | |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 502 | err = sta_info_insert_finish(sta); |
Guy Eilam | 8c71df7 | 2011-08-17 15:18:14 +0300 | [diff] [blame] | 503 | if (err) |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 504 | goto out_free; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 505 | |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 506 | return 0; |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 507 | out_free: |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 508 | sta_info_free(local, sta); |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 509 | return err; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 510 | } |
| 511 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 512 | int sta_info_insert(struct sta_info *sta) |
| 513 | { |
| 514 | int err = sta_info_insert_rcu(sta); |
| 515 | |
| 516 | rcu_read_unlock(); |
| 517 | |
| 518 | return err; |
| 519 | } |
| 520 | |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 521 | static inline void __bss_tim_set(u8 *tim, u16 id) |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 522 | { |
| 523 | /* |
| 524 | * This format has been mandated by the IEEE specifications, |
| 525 | * so this line may not be changed to use the __set_bit() format. |
| 526 | */ |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 527 | tim[id / 8] |= (1 << (id % 8)); |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 528 | } |
| 529 | |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 530 | static inline void __bss_tim_clear(u8 *tim, u16 id) |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 531 | { |
| 532 | /* |
| 533 | * This format has been mandated by the IEEE specifications, |
| 534 | * so this line may not be changed to use the __clear_bit() format. |
| 535 | */ |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 536 | tim[id / 8] &= ~(1 << (id % 8)); |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 537 | } |
| 538 | |
Ilan Peer | 3d5839b | 2013-03-05 15:27:20 +0200 | [diff] [blame] | 539 | static inline bool __bss_tim_get(u8 *tim, u16 id) |
| 540 | { |
| 541 | /* |
| 542 | * This format has been mandated by the IEEE specifications, |
| 543 | * so this line may not be changed to use the test_bit() format. |
| 544 | */ |
| 545 | return tim[id / 8] & (1 << (id % 8)); |
| 546 | } |
| 547 | |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 548 | static unsigned long ieee80211_tids_for_ac(int ac) |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 549 | { |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 550 | /* If we ever support TIDs > 7, this obviously needs to be adjusted */ |
| 551 | switch (ac) { |
| 552 | case IEEE80211_AC_VO: |
| 553 | return BIT(6) | BIT(7); |
| 554 | case IEEE80211_AC_VI: |
| 555 | return BIT(4) | BIT(5); |
| 556 | case IEEE80211_AC_BE: |
| 557 | return BIT(0) | BIT(3); |
| 558 | case IEEE80211_AC_BK: |
| 559 | return BIT(1) | BIT(2); |
| 560 | default: |
| 561 | WARN_ON(1); |
| 562 | return 0; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 563 | } |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 564 | } |
| 565 | |
Johannes Berg | 9b7a86f | 2015-01-09 11:40:39 +0100 | [diff] [blame] | 566 | static void __sta_info_recalc_tim(struct sta_info *sta, bool ignore_pending) |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 567 | { |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 568 | struct ieee80211_local *local = sta->local; |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 569 | struct ps_data *ps; |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 570 | bool indicate_tim = false; |
| 571 | u8 ignore_for_tim = sta->sta.uapsd_queues; |
| 572 | int ac; |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 573 | u16 id; |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 574 | |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 575 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP || |
| 576 | sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { |
| 577 | if (WARN_ON_ONCE(!sta->sdata->bss)) |
| 578 | return; |
| 579 | |
| 580 | ps = &sta->sdata->bss->ps; |
| 581 | id = sta->sta.aid; |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 582 | #ifdef CONFIG_MAC80211_MESH |
| 583 | } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { |
| 584 | ps = &sta->sdata->u.mesh.ps; |
Thomas Pedersen | 204d130 | 2013-11-05 11:17:05 -0800 | [diff] [blame] | 585 | /* TIM map only for 1 <= PLID <= IEEE80211_MAX_AID */ |
Chun-Yeow Yeoh | 6f101ef | 2013-11-13 15:43:03 +0800 | [diff] [blame] | 586 | id = sta->plid % (IEEE80211_MAX_AID + 1); |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 587 | #endif |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 588 | } else { |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 589 | return; |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 590 | } |
Johannes Berg | 3e122be | 2008-07-09 14:40:34 +0200 | [diff] [blame] | 591 | |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 592 | /* No need to do anything if the driver does all */ |
| 593 | if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) |
| 594 | return; |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 595 | |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 596 | if (sta->dead) |
| 597 | goto done; |
Johannes Berg | 3e122be | 2008-07-09 14:40:34 +0200 | [diff] [blame] | 598 | |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 599 | /* |
| 600 | * If all ACs are delivery-enabled then we should build |
| 601 | * the TIM bit for all ACs anyway; if only some are then |
| 602 | * we ignore those and build the TIM bit using only the |
| 603 | * non-enabled ones. |
| 604 | */ |
| 605 | if (ignore_for_tim == BIT(IEEE80211_NUM_ACS) - 1) |
| 606 | ignore_for_tim = 0; |
Johannes Berg | 3e122be | 2008-07-09 14:40:34 +0200 | [diff] [blame] | 607 | |
Johannes Berg | 9b7a86f | 2015-01-09 11:40:39 +0100 | [diff] [blame] | 608 | if (ignore_pending) |
| 609 | ignore_for_tim = BIT(IEEE80211_NUM_ACS) - 1; |
| 610 | |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 611 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
| 612 | unsigned long tids; |
| 613 | |
| 614 | if (ignore_for_tim & BIT(ac)) |
| 615 | continue; |
| 616 | |
| 617 | indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) || |
| 618 | !skb_queue_empty(&sta->ps_tx_buf[ac]); |
| 619 | if (indicate_tim) |
| 620 | break; |
| 621 | |
| 622 | tids = ieee80211_tids_for_ac(ac); |
| 623 | |
| 624 | indicate_tim |= |
| 625 | sta->driver_buffered_tids & tids; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 626 | } |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 627 | |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 628 | done: |
Johannes Berg | 65f704a | 2013-02-13 17:39:53 +0100 | [diff] [blame] | 629 | spin_lock_bh(&local->tim_lock); |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 630 | |
Ilan Peer | 3d5839b | 2013-03-05 15:27:20 +0200 | [diff] [blame] | 631 | if (indicate_tim == __bss_tim_get(ps->tim, id)) |
| 632 | goto out_unlock; |
| 633 | |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 634 | if (indicate_tim) |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 635 | __bss_tim_set(ps->tim, id); |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 636 | else |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 637 | __bss_tim_clear(ps->tim, id); |
Johannes Berg | 3e122be | 2008-07-09 14:40:34 +0200 | [diff] [blame] | 638 | |
Johannes Berg | 9b7a86f | 2015-01-09 11:40:39 +0100 | [diff] [blame] | 639 | if (local->ops->set_tim && !WARN_ON(sta->dead)) { |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 640 | local->tim_in_locked_section = true; |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 641 | drv_set_tim(local, &sta->sta, indicate_tim); |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 642 | local->tim_in_locked_section = false; |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 643 | } |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 644 | |
Ilan Peer | 3d5839b | 2013-03-05 15:27:20 +0200 | [diff] [blame] | 645 | out_unlock: |
Johannes Berg | 65f704a | 2013-02-13 17:39:53 +0100 | [diff] [blame] | 646 | spin_unlock_bh(&local->tim_lock); |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 647 | } |
| 648 | |
Johannes Berg | 9b7a86f | 2015-01-09 11:40:39 +0100 | [diff] [blame] | 649 | void sta_info_recalc_tim(struct sta_info *sta) |
| 650 | { |
| 651 | __sta_info_recalc_tim(sta, false); |
| 652 | } |
| 653 | |
Johannes Berg | cd0b8d8 | 2011-09-06 14:13:06 +0200 | [diff] [blame] | 654 | static bool sta_info_buffer_expired(struct sta_info *sta, struct sk_buff *skb) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 655 | { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 656 | struct ieee80211_tx_info *info; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 657 | int timeout; |
| 658 | |
| 659 | if (!skb) |
Johannes Berg | cd0b8d8 | 2011-09-06 14:13:06 +0200 | [diff] [blame] | 660 | return false; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 661 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 662 | info = IEEE80211_SKB_CB(skb); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 663 | |
| 664 | /* Timeout: (2 * listen_interval * beacon_int * 1024 / 1000000) sec */ |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 665 | timeout = (sta->listen_interval * |
| 666 | sta->sdata->vif.bss_conf.beacon_int * |
| 667 | 32 / 15625) * HZ; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 668 | if (timeout < STA_TX_BUFFER_EXPIRE) |
| 669 | timeout = STA_TX_BUFFER_EXPIRE; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 670 | return time_after(jiffies, info->control.jiffies + timeout); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 674 | static bool sta_info_cleanup_expire_buffered_ac(struct ieee80211_local *local, |
| 675 | struct sta_info *sta, int ac) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 676 | { |
| 677 | unsigned long flags; |
| 678 | struct sk_buff *skb; |
| 679 | |
Johannes Berg | 6075039 | 2011-09-29 16:04:28 +0200 | [diff] [blame] | 680 | /* |
| 681 | * First check for frames that should expire on the filtered |
| 682 | * queue. Frames here were rejected by the driver and are on |
| 683 | * a separate queue to avoid reordering with normal PS-buffered |
| 684 | * frames. They also aren't accounted for right now in the |
| 685 | * total_ps_buffered counter. |
| 686 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 687 | for (;;) { |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 688 | spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); |
| 689 | skb = skb_peek(&sta->tx_filtered[ac]); |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 690 | if (sta_info_buffer_expired(sta, skb)) |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 691 | skb = __skb_dequeue(&sta->tx_filtered[ac]); |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 692 | else |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 693 | skb = NULL; |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 694 | spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 695 | |
Johannes Berg | 6075039 | 2011-09-29 16:04:28 +0200 | [diff] [blame] | 696 | /* |
| 697 | * Frames are queued in order, so if this one |
| 698 | * hasn't expired yet we can stop testing. If |
| 699 | * we actually reached the end of the queue we |
| 700 | * also need to stop, of course. |
| 701 | */ |
| 702 | if (!skb) |
| 703 | break; |
Felix Fietkau | d4fa14c | 2012-10-10 22:40:23 +0200 | [diff] [blame] | 704 | ieee80211_free_txskb(&local->hw, skb); |
Johannes Berg | 6075039 | 2011-09-29 16:04:28 +0200 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | /* |
| 708 | * Now also check the normal PS-buffered queue, this will |
| 709 | * only find something if the filtered queue was emptied |
| 710 | * since the filtered frames are all before the normal PS |
| 711 | * buffered frames. |
| 712 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 713 | for (;;) { |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 714 | spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); |
| 715 | skb = skb_peek(&sta->ps_tx_buf[ac]); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 716 | if (sta_info_buffer_expired(sta, skb)) |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 717 | skb = __skb_dequeue(&sta->ps_tx_buf[ac]); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 718 | else |
| 719 | skb = NULL; |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 720 | spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 721 | |
Johannes Berg | 6075039 | 2011-09-29 16:04:28 +0200 | [diff] [blame] | 722 | /* |
| 723 | * frames are queued in order, so if this one |
| 724 | * hasn't expired yet (or we reached the end of |
| 725 | * the queue) we can stop testing |
| 726 | */ |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 727 | if (!skb) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 728 | break; |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 729 | |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 730 | local->total_ps_buffered--; |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 731 | ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", |
| 732 | sta->sta.addr); |
Felix Fietkau | d4fa14c | 2012-10-10 22:40:23 +0200 | [diff] [blame] | 733 | ieee80211_free_txskb(&local->hw, skb); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 734 | } |
Juuso Oikarinen | 3393a60 | 2010-04-19 10:12:52 +0300 | [diff] [blame] | 735 | |
Johannes Berg | 6075039 | 2011-09-29 16:04:28 +0200 | [diff] [blame] | 736 | /* |
| 737 | * Finally, recalculate the TIM bit for this station -- it might |
| 738 | * now be clear because the station was too slow to retrieve its |
| 739 | * frames. |
| 740 | */ |
| 741 | sta_info_recalc_tim(sta); |
| 742 | |
| 743 | /* |
| 744 | * Return whether there are any frames still buffered, this is |
| 745 | * used to check whether the cleanup timer still needs to run, |
| 746 | * if there are no frames we don't need to rearm the timer. |
| 747 | */ |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 748 | return !(skb_queue_empty(&sta->ps_tx_buf[ac]) && |
| 749 | skb_queue_empty(&sta->tx_filtered[ac])); |
| 750 | } |
| 751 | |
| 752 | static bool sta_info_cleanup_expire_buffered(struct ieee80211_local *local, |
| 753 | struct sta_info *sta) |
| 754 | { |
| 755 | bool have_buffered = false; |
| 756 | int ac; |
| 757 | |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 758 | /* This is only necessary for stations on BSS/MBSS interfaces */ |
| 759 | if (!sta->sdata->bss && |
| 760 | !ieee80211_vif_is_mesh(&sta->sdata->vif)) |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 761 | return false; |
| 762 | |
| 763 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 764 | have_buffered |= |
| 765 | sta_info_cleanup_expire_buffered_ac(local, sta, ac); |
| 766 | |
| 767 | return have_buffered; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 768 | } |
| 769 | |
Johannes Berg | d778207 | 2013-12-04 23:12:31 +0100 | [diff] [blame] | 770 | static int __must_check __sta_info_destroy_part1(struct sta_info *sta) |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 771 | { |
| 772 | struct ieee80211_local *local; |
| 773 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 6d10e46 | 2013-03-06 23:09:11 +0100 | [diff] [blame] | 774 | int ret; |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 775 | |
| 776 | might_sleep(); |
| 777 | |
| 778 | if (!sta) |
| 779 | return -ENOENT; |
| 780 | |
| 781 | local = sta->local; |
| 782 | sdata = sta->sdata; |
| 783 | |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 784 | lockdep_assert_held(&local->sta_mtx); |
| 785 | |
Johannes Berg | 098a607 | 2010-04-06 11:18:47 +0200 | [diff] [blame] | 786 | /* |
| 787 | * Before removing the station from the driver and |
| 788 | * rate control, it might still start new aggregation |
| 789 | * sessions -- block that to make sure the tear-down |
| 790 | * will be sufficient. |
| 791 | */ |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 792 | set_sta_flag(sta, WLAN_STA_BLOCK_BA); |
Johannes Berg | c82c4a8 | 2012-07-18 13:31:31 +0200 | [diff] [blame] | 793 | ieee80211_sta_tear_down_BA_sessions(sta, AGG_STOP_DESTROY_STA); |
Johannes Berg | 098a607 | 2010-04-06 11:18:47 +0200 | [diff] [blame] | 794 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 795 | ret = sta_info_hash_del(local, sta); |
Johannes Berg | b01711b | 2013-12-04 20:25:27 +0100 | [diff] [blame] | 796 | if (WARN_ON(ret)) |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 797 | return ret; |
| 798 | |
Arik Nemtsov | a7a6bdd | 2014-11-09 18:50:19 +0200 | [diff] [blame] | 799 | /* |
| 800 | * for TDLS peers, make sure to return to the base channel before |
| 801 | * removal. |
| 802 | */ |
| 803 | if (test_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL)) { |
| 804 | drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); |
| 805 | clear_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL); |
| 806 | } |
| 807 | |
Arik Nemtsov | 794454c | 2012-06-03 23:32:32 +0300 | [diff] [blame] | 808 | list_del_rcu(&sta->list); |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 809 | |
Johannes Berg | 6a9d1b9 | 2013-12-04 22:39:17 +0100 | [diff] [blame] | 810 | drv_sta_pre_rcu_remove(local, sta->sdata, sta); |
| 811 | |
Johannes Berg | a710c81 | 2013-12-04 20:11:06 +0100 | [diff] [blame] | 812 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
| 813 | rcu_access_pointer(sdata->u.vlan.sta) == sta) |
| 814 | RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); |
| 815 | |
Johannes Berg | d778207 | 2013-12-04 23:12:31 +0100 | [diff] [blame] | 816 | return 0; |
| 817 | } |
| 818 | |
| 819 | static void __sta_info_destroy_part2(struct sta_info *sta) |
| 820 | { |
| 821 | struct ieee80211_local *local = sta->local; |
| 822 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | 6f7a8d2 | 2014-11-14 20:32:57 +0100 | [diff] [blame] | 823 | struct station_info sinfo = {}; |
Johannes Berg | d778207 | 2013-12-04 23:12:31 +0100 | [diff] [blame] | 824 | int ret; |
| 825 | |
| 826 | /* |
| 827 | * NOTE: This assumes at least synchronize_net() was done |
| 828 | * after _part1 and before _part2! |
| 829 | */ |
| 830 | |
| 831 | might_sleep(); |
| 832 | lockdep_assert_held(&local->sta_mtx); |
| 833 | |
Johannes Berg | c878207 | 2013-12-04 23:05:45 +0100 | [diff] [blame] | 834 | /* now keys can no longer be reached */ |
Johannes Berg | 6d10e46 | 2013-03-06 23:09:11 +0100 | [diff] [blame] | 835 | ieee80211_free_sta_keys(local, sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 836 | |
Johannes Berg | 9b7a86f | 2015-01-09 11:40:39 +0100 | [diff] [blame] | 837 | /* disable TIM bit - last chance to tell driver */ |
| 838 | __sta_info_recalc_tim(sta, true); |
| 839 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 840 | sta->dead = true; |
| 841 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 842 | local->num_sta--; |
| 843 | local->sta_generation++; |
| 844 | |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 845 | while (sta->sta_state > IEEE80211_STA_NONE) { |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 846 | ret = sta_info_move_state(sta, sta->sta_state - 1); |
| 847 | if (ret) { |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 848 | WARN_ON_ONCE(1); |
| 849 | break; |
| 850 | } |
| 851 | } |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 852 | |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 853 | if (sta->uploaded) { |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 854 | ret = drv_sta_state(local, sdata, sta, IEEE80211_STA_NONE, |
| 855 | IEEE80211_STA_NOTEXIST); |
| 856 | WARN_ON_ONCE(ret != 0); |
| 857 | } |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 858 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 859 | sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); |
| 860 | |
Johannes Berg | 6f7a8d2 | 2014-11-14 20:32:57 +0100 | [diff] [blame] | 861 | sta_set_sinfo(sta, &sinfo); |
| 862 | cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, &sinfo, GFP_KERNEL); |
Jouni Malinen | ec15e68 | 2011-03-23 15:29:52 +0200 | [diff] [blame] | 863 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 864 | rate_control_remove_sta_debugfs(sta); |
| 865 | ieee80211_sta_debugfs_remove(sta); |
Eliad Peller | 21f659b | 2013-11-11 20:14:01 +0200 | [diff] [blame] | 866 | ieee80211_recalc_min_chandef(sdata); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 867 | |
Johannes Berg | d34ba21 | 2013-12-04 22:46:11 +0100 | [diff] [blame] | 868 | cleanup_single_sta(sta); |
Johannes Berg | d778207 | 2013-12-04 23:12:31 +0100 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | int __must_check __sta_info_destroy(struct sta_info *sta) |
| 872 | { |
| 873 | int err = __sta_info_destroy_part1(sta); |
| 874 | |
| 875 | if (err) |
| 876 | return err; |
| 877 | |
| 878 | synchronize_net(); |
| 879 | |
| 880 | __sta_info_destroy_part2(sta); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 881 | |
| 882 | return 0; |
| 883 | } |
| 884 | |
| 885 | int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, const u8 *addr) |
| 886 | { |
| 887 | struct sta_info *sta; |
| 888 | int ret; |
| 889 | |
| 890 | mutex_lock(&sdata->local->sta_mtx); |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 891 | sta = sta_info_get(sdata, addr); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 892 | ret = __sta_info_destroy(sta); |
| 893 | mutex_unlock(&sdata->local->sta_mtx); |
| 894 | |
| 895 | return ret; |
| 896 | } |
| 897 | |
| 898 | int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata, |
| 899 | const u8 *addr) |
| 900 | { |
| 901 | struct sta_info *sta; |
| 902 | int ret; |
| 903 | |
| 904 | mutex_lock(&sdata->local->sta_mtx); |
Johannes Berg | 7852e36 | 2012-01-20 13:55:24 +0100 | [diff] [blame] | 905 | sta = sta_info_get_bss(sdata, addr); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 906 | ret = __sta_info_destroy(sta); |
| 907 | mutex_unlock(&sdata->local->sta_mtx); |
| 908 | |
| 909 | return ret; |
| 910 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 911 | |
| 912 | static void sta_info_cleanup(unsigned long data) |
| 913 | { |
| 914 | struct ieee80211_local *local = (struct ieee80211_local *) data; |
| 915 | struct sta_info *sta; |
Juuso Oikarinen | 3393a60 | 2010-04-19 10:12:52 +0300 | [diff] [blame] | 916 | bool timer_needed = false; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 917 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 918 | rcu_read_lock(); |
| 919 | list_for_each_entry_rcu(sta, &local->sta_list, list) |
Juuso Oikarinen | 3393a60 | 2010-04-19 10:12:52 +0300 | [diff] [blame] | 920 | if (sta_info_cleanup_expire_buffered(local, sta)) |
| 921 | timer_needed = true; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 922 | rcu_read_unlock(); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 923 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 924 | if (local->quiescing) |
| 925 | return; |
| 926 | |
Juuso Oikarinen | 3393a60 | 2010-04-19 10:12:52 +0300 | [diff] [blame] | 927 | if (!timer_needed) |
| 928 | return; |
| 929 | |
Johannes Berg | 26d5953 | 2011-04-01 13:52:48 +0200 | [diff] [blame] | 930 | mod_timer(&local->sta_cleanup, |
| 931 | round_jiffies(jiffies + STA_INFO_CLEANUP_INTERVAL)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 934 | u32 sta_addr_hash(const void *key, u32 length, u32 seed) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 935 | { |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 936 | return jhash(key, ETH_ALEN, seed); |
| 937 | } |
| 938 | |
| 939 | int sta_info_init(struct ieee80211_local *local) |
| 940 | { |
| 941 | int err; |
| 942 | |
| 943 | err = rhashtable_init(&local->sta_hash, &sta_rht_params); |
| 944 | if (err) |
| 945 | return err; |
| 946 | |
Johannes Berg | 4d33960 | 2011-12-15 11:24:20 +0100 | [diff] [blame] | 947 | spin_lock_init(&local->tim_lock); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 948 | mutex_init(&local->sta_mtx); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 949 | INIT_LIST_HEAD(&local->sta_list); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 950 | |
Pavel Emelyanov | b24b8a2 | 2008-01-23 21:20:07 -0800 | [diff] [blame] | 951 | setup_timer(&local->sta_cleanup, sta_info_cleanup, |
| 952 | (unsigned long)local); |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 953 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | void sta_info_stop(struct ieee80211_local *local) |
| 957 | { |
Johannes Berg | a56f992 | 2012-12-13 23:08:52 +0100 | [diff] [blame] | 958 | del_timer_sync(&local->sta_cleanup); |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 959 | rhashtable_destroy(&local->sta_hash); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 960 | } |
| 961 | |
Johannes Berg | 051007d | 2012-12-13 23:49:02 +0100 | [diff] [blame] | 962 | |
Johannes Berg | e716251 | 2013-12-04 23:18:37 +0100 | [diff] [blame] | 963 | int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 964 | { |
Johannes Berg | b998e8b | 2012-12-13 23:07:46 +0100 | [diff] [blame] | 965 | struct ieee80211_local *local = sdata->local; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 966 | struct sta_info *sta, *tmp; |
Johannes Berg | d778207 | 2013-12-04 23:12:31 +0100 | [diff] [blame] | 967 | LIST_HEAD(free_list); |
Johannes Berg | 44213b5 | 2008-02-25 16:27:49 +0100 | [diff] [blame] | 968 | int ret = 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 969 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 970 | might_sleep(); |
| 971 | |
Johannes Berg | e716251 | 2013-12-04 23:18:37 +0100 | [diff] [blame] | 972 | WARN_ON(vlans && sdata->vif.type != NL80211_IFTYPE_AP); |
| 973 | WARN_ON(vlans && !sdata->bss); |
| 974 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 975 | mutex_lock(&local->sta_mtx); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 976 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { |
Johannes Berg | e716251 | 2013-12-04 23:18:37 +0100 | [diff] [blame] | 977 | if (sdata == sta->sdata || |
| 978 | (vlans && sdata->bss == sta->sdata->bss)) { |
Johannes Berg | d778207 | 2013-12-04 23:12:31 +0100 | [diff] [blame] | 979 | if (!WARN_ON(__sta_info_destroy_part1(sta))) |
| 980 | list_add(&sta->free_list, &free_list); |
Johannes Berg | 3431683 | 2012-02-25 21:40:46 +0100 | [diff] [blame] | 981 | ret++; |
| 982 | } |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 983 | } |
Johannes Berg | d778207 | 2013-12-04 23:12:31 +0100 | [diff] [blame] | 984 | |
| 985 | if (!list_empty(&free_list)) { |
| 986 | synchronize_net(); |
| 987 | list_for_each_entry_safe(sta, tmp, &free_list, free_list) |
| 988 | __sta_info_destroy_part2(sta); |
| 989 | } |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 990 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 44213b5 | 2008-02-25 16:27:49 +0100 | [diff] [blame] | 991 | |
Johannes Berg | 051007d | 2012-12-13 23:49:02 +0100 | [diff] [blame] | 992 | return ret; |
| 993 | } |
| 994 | |
Johannes Berg | 24723d1 | 2008-09-11 00:01:46 +0200 | [diff] [blame] | 995 | void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, |
| 996 | unsigned long exp_time) |
| 997 | { |
| 998 | struct ieee80211_local *local = sdata->local; |
| 999 | struct sta_info *sta, *tmp; |
Johannes Berg | 24723d1 | 2008-09-11 00:01:46 +0200 | [diff] [blame] | 1000 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1001 | mutex_lock(&local->sta_mtx); |
Mohammed Shafi Shajakhan | e46a2cf | 2011-12-26 10:43:29 +0530 | [diff] [blame] | 1002 | |
| 1003 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { |
Marek Lindner | ec2b774 | 2011-12-20 23:16:52 +0800 | [diff] [blame] | 1004 | if (sdata != sta->sdata) |
| 1005 | continue; |
| 1006 | |
Johannes Berg | 24723d1 | 2008-09-11 00:01:46 +0200 | [diff] [blame] | 1007 | if (time_after(jiffies, sta->last_rx + exp_time)) { |
Mohammed Shafi Shajakhan | eea57d4 | 2012-10-08 21:33:47 +0530 | [diff] [blame] | 1008 | sta_dbg(sta->sdata, "expiring inactive STA %pM\n", |
| 1009 | sta->sta.addr); |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 1010 | |
| 1011 | if (ieee80211_vif_is_mesh(&sdata->vif) && |
| 1012 | test_sta_flag(sta, WLAN_STA_PS_STA)) |
| 1013 | atomic_dec(&sdata->u.mesh.ps.num_sta_ps); |
| 1014 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1015 | WARN_ON(__sta_info_destroy(sta)); |
Johannes Berg | 24723d1 | 2008-09-11 00:01:46 +0200 | [diff] [blame] | 1016 | } |
Mohammed Shafi Shajakhan | e46a2cf | 2011-12-26 10:43:29 +0530 | [diff] [blame] | 1017 | } |
| 1018 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 1019 | mutex_unlock(&local->sta_mtx); |
Johannes Berg | 24723d1 | 2008-09-11 00:01:46 +0200 | [diff] [blame] | 1020 | } |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1021 | |
Ben Greear | 686b9cb | 2010-09-23 09:44:36 -0700 | [diff] [blame] | 1022 | struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 1023 | const u8 *addr, |
| 1024 | const u8 *localaddr) |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1025 | { |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 1026 | struct ieee80211_local *local = hw_to_local(hw); |
| 1027 | struct sta_info *sta; |
| 1028 | struct rhash_head *tmp; |
| 1029 | const struct bucket_table *tbl; |
| 1030 | |
| 1031 | tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1032 | |
Ben Greear | 686b9cb | 2010-09-23 09:44:36 -0700 | [diff] [blame] | 1033 | /* |
| 1034 | * Just return a random station if localaddr is NULL |
| 1035 | * ... first in list. |
| 1036 | */ |
Johannes Berg | 7bedd0c | 2015-02-13 21:55:15 +0100 | [diff] [blame^] | 1037 | for_each_sta_info(local, tbl, addr, sta, tmp) { |
Ben Greear | 686b9cb | 2010-09-23 09:44:36 -0700 | [diff] [blame] | 1038 | if (localaddr && |
Joe Perches | b203ca3 | 2012-05-08 18:56:52 +0000 | [diff] [blame] | 1039 | !ether_addr_equal(sta->sdata->vif.addr, localaddr)) |
Ben Greear | 686b9cb | 2010-09-23 09:44:36 -0700 | [diff] [blame] | 1040 | continue; |
Johannes Berg | f7c6559 | 2010-04-30 13:48:36 +0200 | [diff] [blame] | 1041 | if (!sta->uploaded) |
| 1042 | return NULL; |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1043 | return &sta->sta; |
Johannes Berg | f7c6559 | 2010-04-30 13:48:36 +0200 | [diff] [blame] | 1044 | } |
| 1045 | |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 1046 | return NULL; |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1047 | } |
Ben Greear | 686b9cb | 2010-09-23 09:44:36 -0700 | [diff] [blame] | 1048 | EXPORT_SYMBOL_GPL(ieee80211_find_sta_by_ifaddr); |
Johannes Berg | 5ed176e | 2009-11-04 14:42:28 +0100 | [diff] [blame] | 1049 | |
| 1050 | struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif, |
| 1051 | const u8 *addr) |
| 1052 | { |
Johannes Berg | f7c6559 | 2010-04-30 13:48:36 +0200 | [diff] [blame] | 1053 | struct sta_info *sta; |
Johannes Berg | 5ed176e | 2009-11-04 14:42:28 +0100 | [diff] [blame] | 1054 | |
| 1055 | if (!vif) |
| 1056 | return NULL; |
| 1057 | |
Johannes Berg | f7c6559 | 2010-04-30 13:48:36 +0200 | [diff] [blame] | 1058 | sta = sta_info_get_bss(vif_to_sdata(vif), addr); |
| 1059 | if (!sta) |
| 1060 | return NULL; |
Johannes Berg | 5ed176e | 2009-11-04 14:42:28 +0100 | [diff] [blame] | 1061 | |
Johannes Berg | f7c6559 | 2010-04-30 13:48:36 +0200 | [diff] [blame] | 1062 | if (!sta->uploaded) |
| 1063 | return NULL; |
| 1064 | |
| 1065 | return &sta->sta; |
Johannes Berg | 5ed176e | 2009-11-04 14:42:28 +0100 | [diff] [blame] | 1066 | } |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 1067 | EXPORT_SYMBOL(ieee80211_find_sta); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1068 | |
Johannes Berg | e3685e0 | 2014-02-20 11:19:58 +0100 | [diff] [blame] | 1069 | /* powersave support code */ |
| 1070 | void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) |
Johannes Berg | 50a9432 | 2010-11-16 11:50:28 -0800 | [diff] [blame] | 1071 | { |
Helmut Schaa | 608383b | 2012-01-30 15:18:00 +0100 | [diff] [blame] | 1072 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | e3685e0 | 2014-02-20 11:19:58 +0100 | [diff] [blame] | 1073 | struct ieee80211_local *local = sdata->local; |
| 1074 | struct sk_buff_head pending; |
| 1075 | int filtered = 0, buffered = 0, ac; |
| 1076 | unsigned long flags; |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 1077 | struct ps_data *ps; |
| 1078 | |
Felix Fietkau | 3918edb | 2014-07-25 16:20:23 +0200 | [diff] [blame] | 1079 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
| 1080 | sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, |
| 1081 | u.ap); |
| 1082 | |
| 1083 | if (sdata->vif.type == NL80211_IFTYPE_AP) |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 1084 | ps = &sdata->bss->ps; |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 1085 | else if (ieee80211_vif_is_mesh(&sdata->vif)) |
| 1086 | ps = &sdata->u.mesh.ps; |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 1087 | else |
| 1088 | return; |
Johannes Berg | 50a9432 | 2010-11-16 11:50:28 -0800 | [diff] [blame] | 1089 | |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1090 | clear_sta_flag(sta, WLAN_STA_SP); |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1091 | |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 1092 | BUILD_BUG_ON(BITS_TO_LONGS(IEEE80211_NUM_TIDS) > 1); |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1093 | sta->driver_buffered_tids = 0; |
| 1094 | |
Arik Nemtsov | d057e5a | 2011-01-31 22:29:13 +0200 | [diff] [blame] | 1095 | if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS)) |
| 1096 | drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1097 | |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1098 | skb_queue_head_init(&pending); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1099 | |
Emmanuel Grumbach | 1d147bf | 2014-02-20 09:22:11 +0200 | [diff] [blame] | 1100 | /* sync with ieee80211_tx_h_unicast_ps_buf */ |
| 1101 | spin_lock(&sta->ps_lock); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1102 | /* Send all buffered frames to the station */ |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1103 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
| 1104 | int count = skb_queue_len(&pending), tmp; |
| 1105 | |
Arik Nemtsov | 987c285 | 2012-11-05 10:27:52 +0200 | [diff] [blame] | 1106 | spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1107 | skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); |
Arik Nemtsov | 987c285 | 2012-11-05 10:27:52 +0200 | [diff] [blame] | 1108 | spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1109 | tmp = skb_queue_len(&pending); |
| 1110 | filtered += tmp - count; |
| 1111 | count = tmp; |
| 1112 | |
Arik Nemtsov | 987c285 | 2012-11-05 10:27:52 +0200 | [diff] [blame] | 1113 | spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1114 | skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); |
Arik Nemtsov | 987c285 | 2012-11-05 10:27:52 +0200 | [diff] [blame] | 1115 | spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1116 | tmp = skb_queue_len(&pending); |
| 1117 | buffered += tmp - count; |
| 1118 | } |
| 1119 | |
Johannes Berg | e3685e0 | 2014-02-20 11:19:58 +0100 | [diff] [blame] | 1120 | ieee80211_add_pending_skbs(local, &pending); |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 1121 | |
| 1122 | /* now we're no longer in the deliver code */ |
| 1123 | clear_sta_flag(sta, WLAN_STA_PS_DELIVER); |
| 1124 | |
| 1125 | /* The station might have polled and then woken up before we responded, |
| 1126 | * so clear these flags now to avoid them sticking around. |
| 1127 | */ |
| 1128 | clear_sta_flag(sta, WLAN_STA_PSPOLL); |
| 1129 | clear_sta_flag(sta, WLAN_STA_UAPSD); |
Emmanuel Grumbach | 1d147bf | 2014-02-20 09:22:11 +0200 | [diff] [blame] | 1130 | spin_unlock(&sta->ps_lock); |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1131 | |
Johannes Berg | e3685e0 | 2014-02-20 11:19:58 +0100 | [diff] [blame] | 1132 | atomic_dec(&ps->num_sta_ps); |
| 1133 | |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 1134 | /* This station just woke up and isn't aware of our SMPS state */ |
Chun-Yeow Yeoh | 062f1d6 | 2014-04-22 18:19:25 +0800 | [diff] [blame] | 1135 | if (!ieee80211_vif_is_mesh(&sdata->vif) && |
| 1136 | !ieee80211_smps_is_restrictive(sta->known_smps_mode, |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 1137 | sdata->smps_mode) && |
| 1138 | sta->known_smps_mode != sdata->bss->req_smps && |
| 1139 | sta_info_tx_streams(sta) != 1) { |
| 1140 | ht_dbg(sdata, |
| 1141 | "%pM just woke up and MIMO capable - update SMPS\n", |
| 1142 | sta->sta.addr); |
| 1143 | ieee80211_send_smps_action(sdata, sdata->bss->req_smps, |
| 1144 | sta->sta.addr, |
| 1145 | sdata->vif.bss_conf.bssid); |
| 1146 | } |
| 1147 | |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1148 | local->total_ps_buffered -= buffered; |
| 1149 | |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 1150 | sta_info_recalc_tim(sta); |
| 1151 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1152 | ps_dbg(sdata, |
| 1153 | "STA %pM aid %d sending %d filtered/%d PS frames since STA not sleeping anymore\n", |
| 1154 | sta->sta.addr, sta->sta.aid, filtered, buffered); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1155 | } |
| 1156 | |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1157 | static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, |
| 1158 | struct sta_info *sta, int tid, |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1159 | enum ieee80211_frame_release_type reason, |
| 1160 | bool call_driver) |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1161 | { |
| 1162 | struct ieee80211_local *local = sdata->local; |
| 1163 | struct ieee80211_qos_hdr *nullfunc; |
| 1164 | struct sk_buff *skb; |
| 1165 | int size = sizeof(*nullfunc); |
| 1166 | __le16 fc; |
Johannes Berg | a74a8c8 | 2014-07-22 14:50:47 +0200 | [diff] [blame] | 1167 | bool qos = sta->sta.wme; |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1168 | struct ieee80211_tx_info *info; |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1169 | struct ieee80211_chanctx_conf *chanctx_conf; |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1170 | |
| 1171 | if (qos) { |
| 1172 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 1173 | IEEE80211_STYPE_QOS_NULLFUNC | |
| 1174 | IEEE80211_FCTL_FROMDS); |
| 1175 | } else { |
| 1176 | size -= 2; |
| 1177 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | |
| 1178 | IEEE80211_STYPE_NULLFUNC | |
| 1179 | IEEE80211_FCTL_FROMDS); |
| 1180 | } |
| 1181 | |
| 1182 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); |
| 1183 | if (!skb) |
| 1184 | return; |
| 1185 | |
| 1186 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 1187 | |
| 1188 | nullfunc = (void *) skb_put(skb, size); |
| 1189 | nullfunc->frame_control = fc; |
| 1190 | nullfunc->duration_id = 0; |
| 1191 | memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); |
| 1192 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); |
| 1193 | memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); |
Johannes Berg | 864a604 | 2014-03-04 13:46:53 +0100 | [diff] [blame] | 1194 | nullfunc->seq_ctrl = 0; |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1195 | |
Johannes Berg | 59b6625 | 2011-10-13 13:19:19 +0200 | [diff] [blame] | 1196 | skb->priority = tid; |
| 1197 | skb_set_queue_mapping(skb, ieee802_1d_to_ac[tid]); |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1198 | if (qos) { |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1199 | nullfunc->qos_ctrl = cpu_to_le16(tid); |
| 1200 | |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 1201 | if (reason == IEEE80211_FRAME_RELEASE_UAPSD) |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1202 | nullfunc->qos_ctrl |= |
| 1203 | cpu_to_le16(IEEE80211_QOS_CTL_EOSP); |
| 1204 | } |
| 1205 | |
| 1206 | info = IEEE80211_SKB_CB(skb); |
| 1207 | |
| 1208 | /* |
| 1209 | * Tell TX path to send this frame even though the |
| 1210 | * STA may still remain is PS mode after this frame |
Johannes Berg | deeaee1 | 2011-09-29 16:04:35 +0200 | [diff] [blame] | 1211 | * exchange. Also set EOSP to indicate this packet |
| 1212 | * ends the poll/service period. |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1213 | */ |
Johannes Berg | 02f2f1a | 2012-02-27 12:18:30 +0100 | [diff] [blame] | 1214 | info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | |
Johannes Berg | deeaee1 | 2011-09-29 16:04:35 +0200 | [diff] [blame] | 1215 | IEEE80211_TX_STATUS_EOSP | |
| 1216 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1217 | |
Sujith Manoharan | 6b127c7 | 2014-12-10 21:26:10 +0530 | [diff] [blame] | 1218 | info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; |
| 1219 | |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1220 | if (call_driver) |
| 1221 | drv_allow_buffered_frames(local, sta, BIT(tid), 1, |
| 1222 | reason, false); |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 1223 | |
Johannes Berg | 89afe61 | 2013-02-13 15:39:57 +0100 | [diff] [blame] | 1224 | skb->dev = sdata->dev; |
| 1225 | |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1226 | rcu_read_lock(); |
| 1227 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
| 1228 | if (WARN_ON(!chanctx_conf)) { |
| 1229 | rcu_read_unlock(); |
| 1230 | kfree_skb(skb); |
| 1231 | return; |
| 1232 | } |
| 1233 | |
Johannes Berg | 73c4e19 | 2014-11-09 18:50:09 +0200 | [diff] [blame] | 1234 | info->band = chanctx_conf->def.chan->band; |
Johannes Berg | 7c10770 | 2015-03-20 14:18:27 +0100 | [diff] [blame] | 1235 | ieee80211_xmit(sdata, sta, skb); |
Johannes Berg | 55de908 | 2012-07-26 17:24:39 +0200 | [diff] [blame] | 1236 | rcu_read_unlock(); |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1237 | } |
| 1238 | |
Johannes Berg | 0a1cb80 | 2014-01-09 11:05:31 +0100 | [diff] [blame] | 1239 | static int find_highest_prio_tid(unsigned long tids) |
| 1240 | { |
| 1241 | /* lower 3 TIDs aren't ordered perfectly */ |
| 1242 | if (tids & 0xF8) |
| 1243 | return fls(tids) - 1; |
| 1244 | /* TID 0 is BE just like TID 3 */ |
| 1245 | if (tids & BIT(0)) |
| 1246 | return 0; |
| 1247 | return fls(tids) - 1; |
| 1248 | } |
| 1249 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1250 | static void |
| 1251 | ieee80211_sta_ps_deliver_response(struct sta_info *sta, |
| 1252 | int n_frames, u8 ignored_acs, |
| 1253 | enum ieee80211_frame_release_type reason) |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1254 | { |
| 1255 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
| 1256 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1257 | bool more_data = false; |
| 1258 | int ac; |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1259 | unsigned long driver_release_tids = 0; |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1260 | struct sk_buff_head frames; |
| 1261 | |
Johannes Berg | deeaee1 | 2011-09-29 16:04:35 +0200 | [diff] [blame] | 1262 | /* Service or PS-Poll period starts */ |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1263 | set_sta_flag(sta, WLAN_STA_SP); |
Johannes Berg | deeaee1 | 2011-09-29 16:04:35 +0200 | [diff] [blame] | 1264 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1265 | __skb_queue_head_init(&frames); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1266 | |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1267 | /* Get response frame(s) and more data bit for the last one. */ |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1268 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1269 | unsigned long tids; |
| 1270 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1271 | if (ignored_acs & BIT(ac)) |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1272 | continue; |
| 1273 | |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1274 | tids = ieee80211_tids_for_ac(ac); |
| 1275 | |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1276 | /* if we already have frames from software, then we can't also |
| 1277 | * release from hardware queues |
| 1278 | */ |
| 1279 | if (skb_queue_empty(&frames)) |
| 1280 | driver_release_tids |= sta->driver_buffered_tids & tids; |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1281 | |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1282 | if (driver_release_tids) { |
| 1283 | /* If the driver has data on more than one TID then |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1284 | * certainly there's more data if we release just a |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1285 | * single frame now (from a single TID). This will |
| 1286 | * only happen for PS-Poll. |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1287 | */ |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1288 | if (reason == IEEE80211_FRAME_RELEASE_PSPOLL && |
| 1289 | hweight16(driver_release_tids) > 1) { |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1290 | more_data = true; |
| 1291 | driver_release_tids = |
Johannes Berg | 0a1cb80 | 2014-01-09 11:05:31 +0100 | [diff] [blame] | 1292 | BIT(find_highest_prio_tid( |
| 1293 | driver_release_tids)); |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1294 | break; |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1295 | } |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1296 | } else { |
| 1297 | struct sk_buff *skb; |
| 1298 | |
| 1299 | while (n_frames > 0) { |
| 1300 | skb = skb_dequeue(&sta->tx_filtered[ac]); |
| 1301 | if (!skb) { |
| 1302 | skb = skb_dequeue( |
| 1303 | &sta->ps_tx_buf[ac]); |
| 1304 | if (skb) |
| 1305 | local->total_ps_buffered--; |
| 1306 | } |
| 1307 | if (!skb) |
| 1308 | break; |
| 1309 | n_frames--; |
| 1310 | __skb_queue_tail(&frames, skb); |
| 1311 | } |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1312 | } |
| 1313 | |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1314 | /* If we have more frames buffered on this AC, then set the |
| 1315 | * more-data bit and abort the loop since we can't send more |
| 1316 | * data from other ACs before the buffered frames from this. |
| 1317 | */ |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1318 | if (!skb_queue_empty(&sta->tx_filtered[ac]) || |
| 1319 | !skb_queue_empty(&sta->ps_tx_buf[ac])) { |
| 1320 | more_data = true; |
| 1321 | break; |
| 1322 | } |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1323 | } |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1324 | |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1325 | if (skb_queue_empty(&frames) && !driver_release_tids) { |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1326 | int tid; |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1327 | |
Johannes Berg | ce662b44 | 2011-09-29 16:04:34 +0200 | [diff] [blame] | 1328 | /* |
| 1329 | * For PS-Poll, this can only happen due to a race condition |
| 1330 | * when we set the TIM bit and the station notices it, but |
| 1331 | * before it can poll for the frame we expire it. |
| 1332 | * |
| 1333 | * For uAPSD, this is said in the standard (11.2.1.5 h): |
| 1334 | * At each unscheduled SP for a non-AP STA, the AP shall |
| 1335 | * attempt to transmit at least one MSDU or MMPDU, but no |
| 1336 | * more than the value specified in the Max SP Length field |
| 1337 | * in the QoS Capability element from delivery-enabled ACs, |
| 1338 | * that are destined for the non-AP STA. |
| 1339 | * |
| 1340 | * Since we have no other MSDU/MMPDU, transmit a QoS null frame. |
| 1341 | */ |
| 1342 | |
| 1343 | /* This will evaluate to 1, 3, 5 or 7. */ |
| 1344 | tid = 7 - ((ffs(~ignored_acs) - 1) << 1); |
| 1345 | |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1346 | ieee80211_send_null_response(sdata, sta, tid, reason, true); |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1347 | } else if (!driver_release_tids) { |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1348 | struct sk_buff_head pending; |
| 1349 | struct sk_buff *skb; |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 1350 | int num = 0; |
| 1351 | u16 tids = 0; |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1352 | bool need_null = false; |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1353 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1354 | skb_queue_head_init(&pending); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1355 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1356 | while ((skb = __skb_dequeue(&frames))) { |
| 1357 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 1358 | struct ieee80211_hdr *hdr = (void *) skb->data; |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 1359 | u8 *qoshdr = NULL; |
| 1360 | |
| 1361 | num++; |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1362 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1363 | /* |
| 1364 | * Tell TX path to send this frame even though the |
| 1365 | * STA may still remain is PS mode after this frame |
| 1366 | * exchange. |
| 1367 | */ |
Sujith Manoharan | 6b127c7 | 2014-12-10 21:26:10 +0530 | [diff] [blame] | 1368 | info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; |
| 1369 | info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1370 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1371 | /* |
| 1372 | * Use MoreData flag to indicate whether there are |
| 1373 | * more buffered frames for this STA |
| 1374 | */ |
Janusz.Dziedzic@tieto.com | 24b9c37 | 2011-11-07 09:47:47 +0200 | [diff] [blame] | 1375 | if (more_data || !skb_queue_empty(&frames)) |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1376 | hdr->frame_control |= |
| 1377 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
Janusz.Dziedzic@tieto.com | 24b9c37 | 2011-11-07 09:47:47 +0200 | [diff] [blame] | 1378 | else |
| 1379 | hdr->frame_control &= |
| 1380 | cpu_to_le16(~IEEE80211_FCTL_MOREDATA); |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1381 | |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 1382 | if (ieee80211_is_data_qos(hdr->frame_control) || |
| 1383 | ieee80211_is_qos_nullfunc(hdr->frame_control)) |
| 1384 | qoshdr = ieee80211_get_qos_ctl(hdr); |
| 1385 | |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1386 | tids |= BIT(skb->priority); |
| 1387 | |
| 1388 | __skb_queue_tail(&pending, skb); |
| 1389 | |
| 1390 | /* end service period after last frame or add one */ |
| 1391 | if (!skb_queue_empty(&frames)) |
| 1392 | continue; |
| 1393 | |
| 1394 | if (reason != IEEE80211_FRAME_RELEASE_UAPSD) { |
| 1395 | /* for PS-Poll, there's only one frame */ |
| 1396 | info->flags |= IEEE80211_TX_STATUS_EOSP | |
| 1397 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
| 1398 | break; |
| 1399 | } |
| 1400 | |
| 1401 | /* For uAPSD, things are a bit more complicated. If the |
| 1402 | * last frame has a QoS header (i.e. is a QoS-data or |
| 1403 | * QoS-nulldata frame) then just set the EOSP bit there |
| 1404 | * and be done. |
| 1405 | * If the frame doesn't have a QoS header (which means |
| 1406 | * it should be a bufferable MMPDU) then we can't set |
| 1407 | * the EOSP bit in the QoS header; add a QoS-nulldata |
| 1408 | * frame to the list to send it after the MMPDU. |
| 1409 | * |
| 1410 | * Note that this code is only in the mac80211-release |
| 1411 | * code path, we assume that the driver will not buffer |
| 1412 | * anything but QoS-data frames, or if it does, will |
| 1413 | * create the QoS-nulldata frame by itself if needed. |
| 1414 | * |
| 1415 | * Cf. 802.11-2012 10.2.1.10 (c). |
| 1416 | */ |
| 1417 | if (qoshdr) { |
| 1418 | *qoshdr |= IEEE80211_QOS_CTL_EOSP; |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1419 | |
Marco Porsch | 52a3f20 | 2012-03-16 15:30:26 +0100 | [diff] [blame] | 1420 | info->flags |= IEEE80211_TX_STATUS_EOSP | |
| 1421 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1422 | } else { |
| 1423 | /* The standard isn't completely clear on this |
| 1424 | * as it says the more-data bit should be set |
| 1425 | * if there are more BUs. The QoS-Null frame |
| 1426 | * we're about to send isn't buffered yet, we |
| 1427 | * only create it below, but let's pretend it |
| 1428 | * was buffered just in case some clients only |
| 1429 | * expect more-data=0 when eosp=1. |
| 1430 | */ |
| 1431 | hdr->frame_control |= |
| 1432 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
| 1433 | need_null = true; |
| 1434 | num++; |
Marco Porsch | 52a3f20 | 2012-03-16 15:30:26 +0100 | [diff] [blame] | 1435 | } |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1436 | break; |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1437 | } |
| 1438 | |
Johannes Berg | 40b9640 | 2011-09-29 16:04:38 +0200 | [diff] [blame] | 1439 | drv_allow_buffered_frames(local, sta, tids, num, |
| 1440 | reason, more_data); |
| 1441 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1442 | ieee80211_add_pending_skbs(local, &pending); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1443 | |
Johannes Berg | b77cf4f | 2014-01-09 00:00:38 +0100 | [diff] [blame] | 1444 | if (need_null) |
| 1445 | ieee80211_send_null_response( |
| 1446 | sdata, sta, find_highest_prio_tid(tids), |
| 1447 | reason, false); |
| 1448 | |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 1449 | sta_info_recalc_tim(sta); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1450 | } else { |
| 1451 | /* |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1452 | * We need to release a frame that is buffered somewhere in the |
| 1453 | * driver ... it'll have to handle that. |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1454 | * Note that the driver also has to check the number of frames |
| 1455 | * on the TIDs we're releasing from - if there are more than |
| 1456 | * n_frames it has to set the more-data bit (if we didn't ask |
| 1457 | * it to set it anyway due to other buffered frames); if there |
| 1458 | * are fewer than n_frames it has to make sure to adjust that |
| 1459 | * to allow the service period to end properly. |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1460 | */ |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1461 | drv_release_buffered_frames(local, sta, driver_release_tids, |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1462 | n_frames, reason, more_data); |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1463 | |
| 1464 | /* |
| 1465 | * Note that we don't recalculate the TIM bit here as it would |
| 1466 | * most likely have no effect at all unless the driver told us |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1467 | * that the TID(s) became empty before returning here from the |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1468 | * release function. |
Johannes Berg | f9f760b | 2014-01-08 17:45:07 +0100 | [diff] [blame] | 1469 | * Either way, however, when the driver tells us that the TID(s) |
Johannes Berg | 4049e09 | 2011-09-29 16:04:32 +0200 | [diff] [blame] | 1470 | * became empty we'll do the TIM recalculation. |
| 1471 | */ |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1472 | } |
| 1473 | } |
| 1474 | |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1475 | void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta) |
| 1476 | { |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1477 | u8 ignore_for_response = sta->sta.uapsd_queues; |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1478 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1479 | /* |
| 1480 | * If all ACs are delivery-enabled then we should reply |
| 1481 | * from any of them, if only some are enabled we reply |
| 1482 | * only from the non-enabled ones. |
| 1483 | */ |
| 1484 | if (ignore_for_response == BIT(IEEE80211_NUM_ACS) - 1) |
| 1485 | ignore_for_response = 0; |
| 1486 | |
| 1487 | ieee80211_sta_ps_deliver_response(sta, 1, ignore_for_response, |
| 1488 | IEEE80211_FRAME_RELEASE_PSPOLL); |
| 1489 | } |
| 1490 | |
| 1491 | void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta) |
| 1492 | { |
| 1493 | int n_frames = sta->sta.max_sp; |
| 1494 | u8 delivery_enabled = sta->sta.uapsd_queues; |
| 1495 | |
| 1496 | /* |
| 1497 | * If we ever grow support for TSPEC this might happen if |
| 1498 | * the TSPEC update from hostapd comes in between a trigger |
| 1499 | * frame setting WLAN_STA_UAPSD in the RX path and this |
| 1500 | * actually getting called. |
| 1501 | */ |
| 1502 | if (!delivery_enabled) |
| 1503 | return; |
| 1504 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1505 | switch (sta->sta.max_sp) { |
| 1506 | case 1: |
| 1507 | n_frames = 2; |
| 1508 | break; |
| 1509 | case 2: |
| 1510 | n_frames = 4; |
| 1511 | break; |
| 1512 | case 3: |
| 1513 | n_frames = 6; |
| 1514 | break; |
| 1515 | case 0: |
| 1516 | /* XXX: what is a good value? */ |
Andrei Otcheretianski | 13a8098 | 2014-11-04 11:33:04 +0200 | [diff] [blame] | 1517 | n_frames = 128; |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1518 | break; |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1519 | } |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1520 | |
Johannes Berg | 47086fc | 2011-09-29 16:04:33 +0200 | [diff] [blame] | 1521 | ieee80211_sta_ps_deliver_response(sta, n_frames, ~delivery_enabled, |
| 1522 | IEEE80211_FRAME_RELEASE_UAPSD); |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1523 | } |
| 1524 | |
| 1525 | void ieee80211_sta_block_awake(struct ieee80211_hw *hw, |
| 1526 | struct ieee80211_sta *pubsta, bool block) |
| 1527 | { |
| 1528 | struct sta_info *sta = container_of(pubsta, struct sta_info, sta); |
| 1529 | |
Johannes Berg | b5878a2 | 2010-04-07 16:48:40 +0200 | [diff] [blame] | 1530 | trace_api_sta_block_awake(sta->local, pubsta, block); |
| 1531 | |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 1532 | if (block) { |
Johannes Berg | c2c98fd | 2011-09-29 16:04:36 +0200 | [diff] [blame] | 1533 | set_sta_flag(sta, WLAN_STA_PS_DRIVER); |
Johannes Berg | 5ac2e35 | 2014-05-27 16:32:27 +0200 | [diff] [blame] | 1534 | return; |
| 1535 | } |
| 1536 | |
| 1537 | if (!test_sta_flag(sta, WLAN_STA_PS_DRIVER)) |
| 1538 | return; |
| 1539 | |
| 1540 | if (!test_sta_flag(sta, WLAN_STA_PS_STA)) { |
| 1541 | set_sta_flag(sta, WLAN_STA_PS_DELIVER); |
| 1542 | clear_sta_flag(sta, WLAN_STA_PS_DRIVER); |
| 1543 | ieee80211_queue_work(hw, &sta->drv_deliver_wk); |
| 1544 | } else if (test_sta_flag(sta, WLAN_STA_PSPOLL) || |
| 1545 | test_sta_flag(sta, WLAN_STA_UAPSD)) { |
| 1546 | /* must be asleep in this case */ |
| 1547 | clear_sta_flag(sta, WLAN_STA_PS_DRIVER); |
| 1548 | ieee80211_queue_work(hw, &sta->drv_deliver_wk); |
| 1549 | } else { |
| 1550 | clear_sta_flag(sta, WLAN_STA_PS_DRIVER); |
| 1551 | } |
Johannes Berg | af81858 | 2009-11-06 11:35:50 +0100 | [diff] [blame] | 1552 | } |
| 1553 | EXPORT_SYMBOL(ieee80211_sta_block_awake); |
Felix Fietkau | dcf55fb | 2011-04-17 17:45:00 +0200 | [diff] [blame] | 1554 | |
Johannes Berg | e943789 | 2013-02-15 21:38:08 +0100 | [diff] [blame] | 1555 | void ieee80211_sta_eosp(struct ieee80211_sta *pubsta) |
Johannes Berg | 37fbd90 | 2011-09-29 16:04:39 +0200 | [diff] [blame] | 1556 | { |
| 1557 | struct sta_info *sta = container_of(pubsta, struct sta_info, sta); |
| 1558 | struct ieee80211_local *local = sta->local; |
Johannes Berg | 37fbd90 | 2011-09-29 16:04:39 +0200 | [diff] [blame] | 1559 | |
| 1560 | trace_api_eosp(local, pubsta); |
| 1561 | |
Johannes Berg | e943789 | 2013-02-15 21:38:08 +0100 | [diff] [blame] | 1562 | clear_sta_flag(sta, WLAN_STA_SP); |
Johannes Berg | 37fbd90 | 2011-09-29 16:04:39 +0200 | [diff] [blame] | 1563 | } |
Johannes Berg | e943789 | 2013-02-15 21:38:08 +0100 | [diff] [blame] | 1564 | EXPORT_SYMBOL(ieee80211_sta_eosp); |
Johannes Berg | 37fbd90 | 2011-09-29 16:04:39 +0200 | [diff] [blame] | 1565 | |
Johannes Berg | 042ec45 | 2011-09-29 16:04:26 +0200 | [diff] [blame] | 1566 | void ieee80211_sta_set_buffered(struct ieee80211_sta *pubsta, |
| 1567 | u8 tid, bool buffered) |
Felix Fietkau | dcf55fb | 2011-04-17 17:45:00 +0200 | [diff] [blame] | 1568 | { |
| 1569 | struct sta_info *sta = container_of(pubsta, struct sta_info, sta); |
| 1570 | |
Johannes Berg | 5a306f5 | 2012-11-14 23:22:21 +0100 | [diff] [blame] | 1571 | if (WARN_ON(tid >= IEEE80211_NUM_TIDS)) |
Johannes Berg | 042ec45 | 2011-09-29 16:04:26 +0200 | [diff] [blame] | 1572 | return; |
| 1573 | |
Johannes Berg | 1b00078 | 2013-12-19 10:47:48 +0100 | [diff] [blame] | 1574 | trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); |
| 1575 | |
Johannes Berg | 948d887 | 2011-09-29 16:04:29 +0200 | [diff] [blame] | 1576 | if (buffered) |
| 1577 | set_bit(tid, &sta->driver_buffered_tids); |
| 1578 | else |
| 1579 | clear_bit(tid, &sta->driver_buffered_tids); |
| 1580 | |
Johannes Berg | c868cb35 | 2011-09-29 16:04:27 +0200 | [diff] [blame] | 1581 | sta_info_recalc_tim(sta); |
Felix Fietkau | dcf55fb | 2011-04-17 17:45:00 +0200 | [diff] [blame] | 1582 | } |
Johannes Berg | 042ec45 | 2011-09-29 16:04:26 +0200 | [diff] [blame] | 1583 | EXPORT_SYMBOL(ieee80211_sta_set_buffered); |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1584 | |
Johannes Berg | 83d5cc0 | 2012-01-12 09:31:10 +0100 | [diff] [blame] | 1585 | int sta_info_move_state(struct sta_info *sta, |
| 1586 | enum ieee80211_sta_state new_state) |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1587 | { |
Johannes Berg | 8bf11d8 | 2011-12-15 11:17:37 +0100 | [diff] [blame] | 1588 | might_sleep(); |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1589 | |
| 1590 | if (sta->sta_state == new_state) |
| 1591 | return 0; |
| 1592 | |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1593 | /* check allowed transitions first */ |
| 1594 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1595 | switch (new_state) { |
| 1596 | case IEEE80211_STA_NONE: |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1597 | if (sta->sta_state != IEEE80211_STA_AUTH) |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1598 | return -EINVAL; |
| 1599 | break; |
| 1600 | case IEEE80211_STA_AUTH: |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1601 | if (sta->sta_state != IEEE80211_STA_NONE && |
| 1602 | sta->sta_state != IEEE80211_STA_ASSOC) |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1603 | return -EINVAL; |
| 1604 | break; |
| 1605 | case IEEE80211_STA_ASSOC: |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1606 | if (sta->sta_state != IEEE80211_STA_AUTH && |
| 1607 | sta->sta_state != IEEE80211_STA_AUTHORIZED) |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1608 | return -EINVAL; |
| 1609 | break; |
| 1610 | case IEEE80211_STA_AUTHORIZED: |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1611 | if (sta->sta_state != IEEE80211_STA_ASSOC) |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1612 | return -EINVAL; |
| 1613 | break; |
| 1614 | default: |
| 1615 | WARN(1, "invalid state %d", new_state); |
| 1616 | return -EINVAL; |
| 1617 | } |
| 1618 | |
Johannes Berg | bdcbd8e | 2012-06-22 11:29:50 +0200 | [diff] [blame] | 1619 | sta_dbg(sta->sdata, "moving STA %pM to state %d\n", |
| 1620 | sta->sta.addr, new_state); |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1621 | |
| 1622 | /* |
| 1623 | * notify the driver before the actual changes so it can |
| 1624 | * fail the transition |
| 1625 | */ |
| 1626 | if (test_sta_flag(sta, WLAN_STA_INSERTED)) { |
| 1627 | int err = drv_sta_state(sta->local, sta->sdata, sta, |
| 1628 | sta->sta_state, new_state); |
| 1629 | if (err) |
| 1630 | return err; |
| 1631 | } |
| 1632 | |
| 1633 | /* reflect the change in all state variables */ |
| 1634 | |
| 1635 | switch (new_state) { |
| 1636 | case IEEE80211_STA_NONE: |
| 1637 | if (sta->sta_state == IEEE80211_STA_AUTH) |
| 1638 | clear_bit(WLAN_STA_AUTH, &sta->_flags); |
| 1639 | break; |
| 1640 | case IEEE80211_STA_AUTH: |
| 1641 | if (sta->sta_state == IEEE80211_STA_NONE) |
| 1642 | set_bit(WLAN_STA_AUTH, &sta->_flags); |
| 1643 | else if (sta->sta_state == IEEE80211_STA_ASSOC) |
| 1644 | clear_bit(WLAN_STA_ASSOC, &sta->_flags); |
| 1645 | break; |
| 1646 | case IEEE80211_STA_ASSOC: |
| 1647 | if (sta->sta_state == IEEE80211_STA_AUTH) { |
| 1648 | set_bit(WLAN_STA_ASSOC, &sta->_flags); |
| 1649 | } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1650 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP || |
| 1651 | (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
| 1652 | !sta->sdata->u.vlan.sta)) |
| 1653 | atomic_dec(&sta->sdata->bss->num_mcast_sta); |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1654 | clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); |
| 1655 | } |
| 1656 | break; |
| 1657 | case IEEE80211_STA_AUTHORIZED: |
| 1658 | if (sta->sta_state == IEEE80211_STA_ASSOC) { |
Felix Fietkau | 7e3ed02 | 2012-04-23 19:49:03 +0200 | [diff] [blame] | 1659 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP || |
| 1660 | (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
| 1661 | !sta->sdata->u.vlan.sta)) |
| 1662 | atomic_inc(&sta->sdata->bss->num_mcast_sta); |
Johannes Berg | f09603a | 2012-01-20 13:55:21 +0100 | [diff] [blame] | 1663 | set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); |
| 1664 | } |
| 1665 | break; |
| 1666 | default: |
| 1667 | break; |
| 1668 | } |
| 1669 | |
Johannes Berg | d9a7ddb | 2011-12-14 12:35:30 +0100 | [diff] [blame] | 1670 | sta->sta_state = new_state; |
| 1671 | |
| 1672 | return 0; |
| 1673 | } |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 1674 | |
| 1675 | u8 sta_info_tx_streams(struct sta_info *sta) |
| 1676 | { |
| 1677 | struct ieee80211_sta_ht_cap *ht_cap = &sta->sta.ht_cap; |
| 1678 | u8 rx_streams; |
| 1679 | |
| 1680 | if (!sta->sta.ht_cap.ht_supported) |
| 1681 | return 1; |
| 1682 | |
| 1683 | if (sta->sta.vht_cap.vht_supported) { |
| 1684 | int i; |
| 1685 | u16 tx_mcs_map = |
| 1686 | le16_to_cpu(sta->sta.vht_cap.vht_mcs.tx_mcs_map); |
| 1687 | |
| 1688 | for (i = 7; i >= 0; i--) |
| 1689 | if ((tx_mcs_map & (0x3 << (i * 2))) != |
| 1690 | IEEE80211_VHT_MCS_NOT_SUPPORTED) |
| 1691 | return i + 1; |
| 1692 | } |
| 1693 | |
| 1694 | if (ht_cap->mcs.rx_mask[3]) |
| 1695 | rx_streams = 4; |
| 1696 | else if (ht_cap->mcs.rx_mask[2]) |
| 1697 | rx_streams = 3; |
| 1698 | else if (ht_cap->mcs.rx_mask[1]) |
| 1699 | rx_streams = 2; |
| 1700 | else |
| 1701 | rx_streams = 1; |
| 1702 | |
| 1703 | if (!(ht_cap->mcs.tx_params & IEEE80211_HT_MCS_TX_RX_DIFF)) |
| 1704 | return rx_streams; |
| 1705 | |
| 1706 | return ((ht_cap->mcs.tx_params & IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) |
| 1707 | >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT) + 1; |
| 1708 | } |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1709 | |
| 1710 | void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
| 1711 | { |
| 1712 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
| 1713 | struct ieee80211_local *local = sdata->local; |
John W. Linville | 9a24440 | 2014-07-25 10:22:36 -0400 | [diff] [blame] | 1714 | struct rate_control_ref *ref = NULL; |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1715 | struct timespec uptime; |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1716 | u32 thr = 0; |
| 1717 | int i, ac; |
| 1718 | |
John W. Linville | 9a24440 | 2014-07-25 10:22:36 -0400 | [diff] [blame] | 1719 | if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) |
| 1720 | ref = local->rate_ctrl; |
| 1721 | |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1722 | sinfo->generation = sdata->local->sta_generation; |
| 1723 | |
Johannes Berg | 225b818 | 2015-01-21 21:09:02 +0100 | [diff] [blame] | 1724 | /* do before driver, so beacon filtering drivers have a |
| 1725 | * chance to e.g. just add the number of filtered beacons |
| 1726 | * (or just modify the value entirely, of course) |
| 1727 | */ |
| 1728 | if (sdata->vif.type == NL80211_IFTYPE_STATION) |
| 1729 | sinfo->rx_beacon = sdata->u.mgd.count_beacon_signal; |
| 1730 | |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1731 | drv_sta_statistics(local, sdata, &sta->sta, sinfo); |
| 1732 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1733 | sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME) | |
| 1734 | BIT(NL80211_STA_INFO_STA_FLAGS) | |
| 1735 | BIT(NL80211_STA_INFO_BSS_PARAM) | |
| 1736 | BIT(NL80211_STA_INFO_CONNECTED_TIME) | |
| 1737 | BIT(NL80211_STA_INFO_RX_DROP_MISC) | |
| 1738 | BIT(NL80211_STA_INFO_BEACON_LOSS); |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1739 | |
Thomas Gleixner | 1817152 | 2014-06-11 23:59:14 +0000 | [diff] [blame] | 1740 | ktime_get_ts(&uptime); |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1741 | sinfo->connected_time = uptime.tv_sec - sta->last_connected; |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1742 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1743 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1744 | if (!(sinfo->filled & (BIT(NL80211_STA_INFO_TX_BYTES64) | |
| 1745 | BIT(NL80211_STA_INFO_TX_BYTES)))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1746 | sinfo->tx_bytes = 0; |
| 1747 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 1748 | sinfo->tx_bytes += sta->tx_bytes[ac]; |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1749 | sinfo->filled |= BIT(NL80211_STA_INFO_TX_BYTES64); |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1750 | } |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1751 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1752 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_PACKETS))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1753 | sinfo->tx_packets = 0; |
| 1754 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 1755 | sinfo->tx_packets += sta->tx_packets[ac]; |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1756 | sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1757 | } |
| 1758 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1759 | if (!(sinfo->filled & (BIT(NL80211_STA_INFO_RX_BYTES64) | |
| 1760 | BIT(NL80211_STA_INFO_RX_BYTES)))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1761 | sinfo->rx_bytes = sta->rx_bytes; |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1762 | sinfo->filled |= BIT(NL80211_STA_INFO_RX_BYTES64); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1763 | } |
| 1764 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1765 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_PACKETS))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1766 | sinfo->rx_packets = sta->rx_packets; |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1767 | sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1768 | } |
| 1769 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1770 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_RETRIES))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1771 | sinfo->tx_retries = sta->tx_retry_count; |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1772 | sinfo->filled |= BIT(NL80211_STA_INFO_TX_RETRIES); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1773 | } |
| 1774 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1775 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_FAILED))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1776 | sinfo->tx_failed = sta->tx_retry_failed; |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1777 | sinfo->filled |= BIT(NL80211_STA_INFO_TX_FAILED); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1778 | } |
| 1779 | |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1780 | sinfo->rx_dropped_misc = sta->rx_dropped; |
| 1781 | sinfo->beacon_loss_count = sta->beacon_loss_count; |
| 1782 | |
Johannes Berg | 225b818 | 2015-01-21 21:09:02 +0100 | [diff] [blame] | 1783 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
| 1784 | !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { |
| 1785 | sinfo->filled |= BIT(NL80211_STA_INFO_BEACON_RX) | |
| 1786 | BIT(NL80211_STA_INFO_BEACON_SIGNAL_AVG); |
| 1787 | sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif); |
| 1788 | } |
| 1789 | |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1790 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
| 1791 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1792 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL))) { |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1793 | sinfo->signal = (s8)sta->last_signal; |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1794 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1795 | } |
| 1796 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1797 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL_AVG))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1798 | sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal); |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1799 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1800 | } |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1801 | } |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1802 | |
| 1803 | if (sta->chains && |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1804 | !(sinfo->filled & (BIT(NL80211_STA_INFO_CHAIN_SIGNAL) | |
| 1805 | BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)))) { |
| 1806 | sinfo->filled |= BIT(NL80211_STA_INFO_CHAIN_SIGNAL) | |
| 1807 | BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1808 | |
| 1809 | sinfo->chains = sta->chains; |
| 1810 | for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { |
| 1811 | sinfo->chain_signal[i] = sta->chain_signal_last[i]; |
| 1812 | sinfo->chain_signal_avg[i] = |
| 1813 | (s8) -ewma_read(&sta->chain_signal_avg[i]); |
| 1814 | } |
| 1815 | } |
| 1816 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1817 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1818 | sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1819 | sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1820 | } |
| 1821 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1822 | if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))) { |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1823 | sta_set_rate_info_rx(sta, &sinfo->rxrate); |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1824 | sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE); |
Johannes Berg | 2b9a7e1 | 2014-11-17 11:35:23 +0100 | [diff] [blame] | 1825 | } |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1826 | |
Johannes Berg | 79c892b | 2014-11-21 14:26:31 +0100 | [diff] [blame] | 1827 | sinfo->filled |= BIT(NL80211_STA_INFO_TID_STATS); |
| 1828 | for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) { |
| 1829 | struct cfg80211_tid_stats *tidstats = &sinfo->pertid[i]; |
| 1830 | |
| 1831 | if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) { |
| 1832 | tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU); |
| 1833 | tidstats->rx_msdu = sta->rx_msdu[i]; |
| 1834 | } |
| 1835 | |
| 1836 | if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) { |
| 1837 | tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU); |
| 1838 | tidstats->tx_msdu = sta->tx_msdu[i]; |
| 1839 | } |
| 1840 | |
| 1841 | if (!(tidstats->filled & |
| 1842 | BIT(NL80211_TID_STATS_TX_MSDU_RETRIES)) && |
| 1843 | local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) { |
| 1844 | tidstats->filled |= |
| 1845 | BIT(NL80211_TID_STATS_TX_MSDU_RETRIES); |
| 1846 | tidstats->tx_msdu_retries = sta->tx_msdu_retries[i]; |
| 1847 | } |
| 1848 | |
| 1849 | if (!(tidstats->filled & |
| 1850 | BIT(NL80211_TID_STATS_TX_MSDU_FAILED)) && |
| 1851 | local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) { |
| 1852 | tidstats->filled |= |
| 1853 | BIT(NL80211_TID_STATS_TX_MSDU_FAILED); |
| 1854 | tidstats->tx_msdu_failed = sta->tx_msdu_failed[i]; |
| 1855 | } |
| 1856 | } |
| 1857 | |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1858 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
| 1859 | #ifdef CONFIG_MAC80211_MESH |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1860 | sinfo->filled |= BIT(NL80211_STA_INFO_LLID) | |
| 1861 | BIT(NL80211_STA_INFO_PLID) | |
| 1862 | BIT(NL80211_STA_INFO_PLINK_STATE) | |
| 1863 | BIT(NL80211_STA_INFO_LOCAL_PM) | |
| 1864 | BIT(NL80211_STA_INFO_PEER_PM) | |
| 1865 | BIT(NL80211_STA_INFO_NONPEER_PM); |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1866 | |
| 1867 | sinfo->llid = sta->llid; |
| 1868 | sinfo->plid = sta->plid; |
| 1869 | sinfo->plink_state = sta->plink_state; |
| 1870 | if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1871 | sinfo->filled |= BIT(NL80211_STA_INFO_T_OFFSET); |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1872 | sinfo->t_offset = sta->t_offset; |
| 1873 | } |
| 1874 | sinfo->local_pm = sta->local_pm; |
| 1875 | sinfo->peer_pm = sta->peer_pm; |
| 1876 | sinfo->nonpeer_pm = sta->nonpeer_pm; |
| 1877 | #endif |
| 1878 | } |
| 1879 | |
| 1880 | sinfo->bss_param.flags = 0; |
| 1881 | if (sdata->vif.bss_conf.use_cts_prot) |
| 1882 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; |
| 1883 | if (sdata->vif.bss_conf.use_short_preamble) |
| 1884 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; |
| 1885 | if (sdata->vif.bss_conf.use_short_slot) |
| 1886 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; |
Emmanuel Grumbach | 785e21a | 2014-09-03 15:25:04 +0300 | [diff] [blame] | 1887 | sinfo->bss_param.dtim_period = sdata->vif.bss_conf.dtim_period; |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1888 | sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; |
| 1889 | |
| 1890 | sinfo->sta_flags.set = 0; |
| 1891 | sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | |
| 1892 | BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | |
| 1893 | BIT(NL80211_STA_FLAG_WME) | |
| 1894 | BIT(NL80211_STA_FLAG_MFP) | |
| 1895 | BIT(NL80211_STA_FLAG_AUTHENTICATED) | |
| 1896 | BIT(NL80211_STA_FLAG_ASSOCIATED) | |
| 1897 | BIT(NL80211_STA_FLAG_TDLS_PEER); |
| 1898 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
| 1899 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); |
| 1900 | if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) |
| 1901 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); |
Johannes Berg | a74a8c8 | 2014-07-22 14:50:47 +0200 | [diff] [blame] | 1902 | if (sta->sta.wme) |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1903 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); |
| 1904 | if (test_sta_flag(sta, WLAN_STA_MFP)) |
| 1905 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); |
| 1906 | if (test_sta_flag(sta, WLAN_STA_AUTH)) |
| 1907 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); |
| 1908 | if (test_sta_flag(sta, WLAN_STA_ASSOC)) |
| 1909 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); |
| 1910 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) |
| 1911 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); |
| 1912 | |
| 1913 | /* check if the driver has a SW RC implementation */ |
| 1914 | if (ref && ref->ops->get_expected_throughput) |
| 1915 | thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); |
| 1916 | else |
| 1917 | thr = drv_get_expected_throughput(local, &sta->sta); |
| 1918 | |
| 1919 | if (thr != 0) { |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 1920 | sinfo->filled |= BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT); |
Johannes Berg | b7ffbd7 | 2014-06-04 17:31:56 +0200 | [diff] [blame] | 1921 | sinfo->expected_throughput = thr; |
| 1922 | } |
| 1923 | } |