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> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/netdevice.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/slab.h> |
| 15 | #include <linux/skbuff.h> |
| 16 | #include <linux/if_arp.h> |
Johannes Berg | 0d17440 | 2007-12-17 15:07:43 +0100 | [diff] [blame] | 17 | #include <linux/timer.h> |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 18 | #include <linux/rtnetlink.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 19 | |
| 20 | #include <net/mac80211.h> |
| 21 | #include "ieee80211_i.h" |
| 22 | #include "ieee80211_rate.h" |
| 23 | #include "sta_info.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 24 | #include "debugfs_sta.h" |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 25 | #include "mesh.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 26 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 27 | /** |
| 28 | * DOC: STA information lifetime rules |
| 29 | * |
| 30 | * STA info structures (&struct sta_info) are managed in a hash table |
| 31 | * for faster lookup and a list for iteration. They are managed using |
| 32 | * RCU, i.e. access to the list and hash table is protected by RCU. |
| 33 | * |
| 34 | * STA info structures are always "alive" when they are added with |
| 35 | * @sta_info_add() [this may be changed in the future to allow allocating |
| 36 | * outside of a critical section!], they are then added to the hash |
| 37 | * table and list. Therefore, @sta_info_add() must also be RCU protected, |
| 38 | * also, the caller of @sta_info_add() cannot assume that it owns the |
| 39 | * structure. |
| 40 | * |
| 41 | * Because there are debugfs entries for each station, and adding those |
| 42 | * must be able to sleep, it is also possible to "pin" a station entry, |
| 43 | * that means it can be removed from the hash table but not be freed. |
| 44 | * See the comment in @__sta_info_unlink() for more information. |
| 45 | * |
| 46 | * In order to remove a STA info structure, the caller needs to first |
| 47 | * unlink it (@sta_info_unlink()) from the list and hash tables and |
| 48 | * then wait for an RCU synchronisation before it can be freed. Due to |
| 49 | * the pinning and the possibility of multiple callers trying to remove |
| 50 | * the same STA info at the same time, @sta_info_unlink() can clear the |
| 51 | * STA info pointer it is passed to indicate that the STA info is owned |
| 52 | * by somebody else now. |
| 53 | * |
| 54 | * If @sta_info_unlink() did not clear the pointer then the caller owns |
| 55 | * the STA info structure now and is responsible of destroying it with |
| 56 | * a call to @sta_info_destroy(), not before RCU synchronisation, of |
| 57 | * course. Note that sta_info_destroy() must be protected by the RTNL. |
| 58 | * |
| 59 | * In all other cases, there is no concept of ownership on a STA entry, |
| 60 | * each structure is owned by the global hash table/list until it is |
| 61 | * removed. All users of the structure need to be RCU protected so that |
| 62 | * the structure won't be freed before they are done using it. |
| 63 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 64 | |
| 65 | /* Caller must hold local->sta_lock */ |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 66 | static int sta_info_hash_del(struct ieee80211_local *local, |
| 67 | struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 68 | { |
| 69 | struct sta_info *s; |
| 70 | |
| 71 | s = local->sta_hash[STA_HASH(sta->addr)]; |
| 72 | if (!s) |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 73 | return -ENOENT; |
| 74 | if (s == sta) { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 75 | rcu_assign_pointer(local->sta_hash[STA_HASH(sta->addr)], |
| 76 | s->hnext); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 77 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 80 | while (s->hnext && s->hnext != sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 81 | s = s->hnext; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 82 | if (s->hnext) { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 83 | rcu_assign_pointer(s->hnext, sta->hnext); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 84 | return 0; |
| 85 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 86 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 87 | return -ENOENT; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 90 | /* protected by RCU */ |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 91 | static struct sta_info *__sta_info_find(struct ieee80211_local *local, |
| 92 | u8 *addr) |
| 93 | { |
| 94 | struct sta_info *sta; |
| 95 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 96 | sta = rcu_dereference(local->sta_hash[STA_HASH(addr)]); |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 97 | while (sta) { |
| 98 | if (compare_ether_addr(sta->addr, addr) == 0) |
| 99 | break; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 100 | sta = rcu_dereference(sta->hnext); |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 101 | } |
| 102 | return sta; |
| 103 | } |
| 104 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 105 | struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr) |
| 106 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 107 | return __sta_info_find(local, addr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 108 | } |
| 109 | EXPORT_SYMBOL(sta_info_get); |
| 110 | |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 111 | struct sta_info *sta_info_get_by_idx(struct ieee80211_local *local, int idx, |
| 112 | struct net_device *dev) |
| 113 | { |
| 114 | struct sta_info *sta; |
| 115 | int i = 0; |
| 116 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 117 | list_for_each_entry_rcu(sta, &local->sta_list, list) { |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 118 | if (i < idx) { |
| 119 | ++i; |
| 120 | continue; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 121 | } else if (!dev || dev == sta->sdata->dev) { |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 122 | return sta; |
| 123 | } |
| 124 | } |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 125 | |
| 126 | return NULL; |
| 127 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 128 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 129 | void sta_info_destroy(struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 130 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 131 | struct ieee80211_local *local = sta->local; |
| 132 | struct sk_buff *skb; |
Ron Rindjunsky | 07db218 | 2007-12-25 17:00:33 +0200 | [diff] [blame] | 133 | int i; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 134 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 135 | ASSERT_RTNL(); |
| 136 | might_sleep(); |
| 137 | |
| 138 | rate_control_remove_sta_debugfs(sta); |
| 139 | ieee80211_sta_debugfs_remove(sta); |
| 140 | |
| 141 | #ifdef CONFIG_MAC80211_MESH |
| 142 | if (ieee80211_vif_is_mesh(&sta->sdata->vif)) |
| 143 | mesh_plink_deactivate(sta); |
| 144 | #endif |
| 145 | |
| 146 | /* |
| 147 | * NOTE: This will call synchronize_rcu() internally to |
| 148 | * make sure no key references can be in use. We rely on |
| 149 | * that here for the mesh code! |
| 150 | */ |
| 151 | ieee80211_key_free(sta->key); |
| 152 | WARN_ON(sta->key); |
| 153 | |
| 154 | #ifdef CONFIG_MAC80211_MESH |
| 155 | if (ieee80211_vif_is_mesh(&sta->sdata->vif)) |
| 156 | del_timer_sync(&sta->plink_timer); |
| 157 | #endif |
| 158 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 159 | while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) { |
| 160 | local->total_ps_buffered--; |
| 161 | dev_kfree_skb_any(skb); |
| 162 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 163 | |
| 164 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 165 | dev_kfree_skb_any(skb); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 166 | |
Ron Rindjunsky | fe3bf0f | 2008-01-28 14:07:19 +0200 | [diff] [blame] | 167 | for (i = 0; i < STA_TID_NUM; i++) { |
Ron Rindjunsky | 07db218 | 2007-12-25 17:00:33 +0200 | [diff] [blame] | 168 | del_timer_sync(&sta->ampdu_mlme.tid_rx[i].session_timer); |
Ron Rindjunsky | fe3bf0f | 2008-01-28 14:07:19 +0200 | [diff] [blame] | 169 | del_timer_sync(&sta->ampdu_mlme.tid_tx[i].addba_resp_timer); |
| 170 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 171 | rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv); |
| 172 | rate_control_put(sta->rate_ctrl); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 173 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 174 | kfree(sta); |
| 175 | } |
| 176 | |
| 177 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 178 | /* Caller must hold local->sta_lock */ |
| 179 | static void sta_info_hash_add(struct ieee80211_local *local, |
| 180 | struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 181 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 182 | sta->hnext = local->sta_hash[STA_HASH(sta->addr)]; |
| 183 | rcu_assign_pointer(local->sta_hash[STA_HASH(sta->addr)], sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 184 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 185 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 186 | struct sta_info *sta_info_add(struct ieee80211_sub_if_data *sdata, |
| 187 | u8 *addr) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 188 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 189 | struct ieee80211_local *local = sdata->local; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 190 | struct sta_info *sta; |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 191 | int i; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 192 | DECLARE_MAC_BUF(mac); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 193 | unsigned long flags; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 194 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 195 | sta = kzalloc(sizeof(*sta), GFP_ATOMIC); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 196 | if (!sta) |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 197 | return ERR_PTR(-ENOMEM); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 198 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 199 | memcpy(sta->addr, addr, ETH_ALEN); |
| 200 | sta->local = local; |
| 201 | sta->sdata = sdata; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 202 | |
| 203 | sta->rate_ctrl = rate_control_get(local->rate_ctrl); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 204 | sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, |
| 205 | GFP_ATOMIC); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 206 | if (!sta->rate_ctrl_priv) { |
| 207 | rate_control_put(sta->rate_ctrl); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 208 | kfree(sta); |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 209 | return ERR_PTR(-ENOMEM); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 212 | spin_lock_init(&sta->ampdu_mlme.ampdu_rx); |
Ron Rindjunsky | fe3bf0f | 2008-01-28 14:07:19 +0200 | [diff] [blame] | 213 | spin_lock_init(&sta->ampdu_mlme.ampdu_tx); |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 214 | for (i = 0; i < STA_TID_NUM; i++) { |
| 215 | /* timer_to_tid must be initialized with identity mapping to |
| 216 | * enable session_timer's data differentiation. refer to |
| 217 | * sta_rx_agg_session_timer_expired for useage */ |
| 218 | sta->timer_to_tid[i] = i; |
Ron Rindjunsky | fe3bf0f | 2008-01-28 14:07:19 +0200 | [diff] [blame] | 219 | /* tid to tx queue: initialize according to HW (0 is valid) */ |
| 220 | sta->tid_to_tx_q[i] = local->hw.queues; |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 221 | /* rx timers */ |
| 222 | sta->ampdu_mlme.tid_rx[i].session_timer.function = |
| 223 | sta_rx_agg_session_timer_expired; |
| 224 | sta->ampdu_mlme.tid_rx[i].session_timer.data = |
| 225 | (unsigned long)&sta->timer_to_tid[i]; |
| 226 | init_timer(&sta->ampdu_mlme.tid_rx[i].session_timer); |
Ron Rindjunsky | fe3bf0f | 2008-01-28 14:07:19 +0200 | [diff] [blame] | 227 | /* tx timers */ |
| 228 | sta->ampdu_mlme.tid_tx[i].addba_resp_timer.function = |
| 229 | sta_addba_resp_timer_expired; |
| 230 | sta->ampdu_mlme.tid_tx[i].addba_resp_timer.data = |
| 231 | (unsigned long)&sta->timer_to_tid[i]; |
| 232 | init_timer(&sta->ampdu_mlme.tid_tx[i].addba_resp_timer); |
Ron Rindjunsky | 16c5f15 | 2007-12-25 17:00:34 +0200 | [diff] [blame] | 233 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 234 | skb_queue_head_init(&sta->ps_tx_buf); |
| 235 | skb_queue_head_init(&sta->tx_filtered); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 236 | spin_lock_irqsave(&local->sta_lock, flags); |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 237 | /* check if STA exists already */ |
| 238 | if (__sta_info_find(local, addr)) { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 239 | spin_unlock_irqrestore(&local->sta_lock, flags); |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 240 | return ERR_PTR(-EEXIST); |
| 241 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 242 | list_add(&sta->list, &local->sta_list); |
| 243 | local->num_sta++; |
| 244 | sta_info_hash_add(local, sta); |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 245 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 246 | /* notify driver */ |
| 247 | if (local->ops->sta_notify) { |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 248 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN) |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 249 | sdata = sdata->u.vlan.ap; |
| 250 | |
| 251 | local->ops->sta_notify(local_to_hw(local), &sdata->vif, |
| 252 | STA_NOTIFY_ADD, addr); |
| 253 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 254 | |
| 255 | spin_unlock_irqrestore(&local->sta_lock, flags); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 256 | |
| 257 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 258 | printk(KERN_DEBUG "%s: Added STA %s\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 259 | wiphy_name(local->hw.wiphy), print_mac(mac, addr)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 260 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
| 261 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 262 | #ifdef CONFIG_MAC80211_DEBUGFS |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 263 | /* debugfs entry adding might sleep, so schedule process |
| 264 | * context task for adding entry for STAs that do not yet |
| 265 | * have one. */ |
| 266 | queue_work(local->hw.workqueue, &local->sta_debugfs_add); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 267 | #endif |
| 268 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 269 | return sta; |
| 270 | } |
| 271 | |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 272 | static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid) |
| 273 | { |
| 274 | /* |
| 275 | * This format has been mandated by the IEEE specifications, |
| 276 | * so this line may not be changed to use the __set_bit() format. |
| 277 | */ |
| 278 | bss->tim[aid / 8] |= (1 << (aid % 8)); |
| 279 | } |
| 280 | |
| 281 | static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid) |
| 282 | { |
| 283 | /* |
| 284 | * This format has been mandated by the IEEE specifications, |
| 285 | * so this line may not be changed to use the __clear_bit() format. |
| 286 | */ |
| 287 | bss->tim[aid / 8] &= ~(1 << (aid % 8)); |
| 288 | } |
| 289 | |
| 290 | static void __sta_info_set_tim_bit(struct ieee80211_if_ap *bss, |
| 291 | struct sta_info *sta) |
| 292 | { |
| 293 | if (bss) |
| 294 | __bss_tim_set(bss, sta->aid); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 295 | if (sta->local->ops->set_tim) { |
| 296 | sta->local->tim_in_locked_section = true; |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 297 | sta->local->ops->set_tim(local_to_hw(sta->local), sta->aid, 1); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 298 | sta->local->tim_in_locked_section = false; |
| 299 | } |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | void sta_info_set_tim_bit(struct sta_info *sta) |
| 303 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 304 | unsigned long flags; |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 305 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 306 | spin_lock_irqsave(&sta->local->sta_lock, flags); |
| 307 | __sta_info_set_tim_bit(sta->sdata->bss, sta); |
| 308 | spin_unlock_irqrestore(&sta->local->sta_lock, flags); |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | static void __sta_info_clear_tim_bit(struct ieee80211_if_ap *bss, |
| 312 | struct sta_info *sta) |
| 313 | { |
| 314 | if (bss) |
| 315 | __bss_tim_clear(bss, sta->aid); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 316 | if (sta->local->ops->set_tim) { |
| 317 | sta->local->tim_in_locked_section = true; |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 318 | sta->local->ops->set_tim(local_to_hw(sta->local), sta->aid, 0); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 319 | sta->local->tim_in_locked_section = false; |
| 320 | } |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | void sta_info_clear_tim_bit(struct sta_info *sta) |
| 324 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 325 | unsigned long flags; |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 326 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 327 | spin_lock_irqsave(&sta->local->sta_lock, flags); |
| 328 | __sta_info_clear_tim_bit(sta->sdata->bss, sta); |
| 329 | spin_unlock_irqrestore(&sta->local->sta_lock, flags); |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 330 | } |
| 331 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 332 | /* |
| 333 | * See comment in __sta_info_unlink, |
| 334 | * caller must hold local->sta_lock. |
| 335 | */ |
| 336 | static void __sta_info_pin(struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 337 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 338 | WARN_ON(sta->pin_status != STA_INFO_PIN_STAT_NORMAL); |
| 339 | sta->pin_status = STA_INFO_PIN_STAT_PINNED; |
| 340 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 341 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 342 | /* |
| 343 | * See comment in __sta_info_unlink, returns sta if it |
| 344 | * needs to be destroyed. |
| 345 | */ |
| 346 | static struct sta_info *__sta_info_unpin(struct sta_info *sta) |
| 347 | { |
| 348 | struct sta_info *ret = NULL; |
| 349 | unsigned long flags; |
| 350 | |
| 351 | spin_lock_irqsave(&sta->local->sta_lock, flags); |
| 352 | WARN_ON(sta->pin_status != STA_INFO_PIN_STAT_DESTROY && |
| 353 | sta->pin_status != STA_INFO_PIN_STAT_PINNED); |
| 354 | if (sta->pin_status == STA_INFO_PIN_STAT_DESTROY) |
| 355 | ret = sta; |
| 356 | sta->pin_status = STA_INFO_PIN_STAT_NORMAL; |
| 357 | spin_unlock_irqrestore(&sta->local->sta_lock, flags); |
| 358 | |
| 359 | return ret; |
| 360 | } |
| 361 | |
| 362 | static void __sta_info_unlink(struct sta_info **sta) |
| 363 | { |
| 364 | struct ieee80211_local *local = (*sta)->local; |
| 365 | struct ieee80211_sub_if_data *sdata = (*sta)->sdata; |
| 366 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
| 367 | DECLARE_MAC_BUF(mbuf); |
| 368 | #endif |
| 369 | /* |
| 370 | * pull caller's reference if we're already gone. |
| 371 | */ |
| 372 | if (sta_info_hash_del(local, *sta)) { |
| 373 | *sta = NULL; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 374 | return; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 375 | } |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 376 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 377 | /* |
| 378 | * Also pull caller's reference if the STA is pinned by the |
| 379 | * task that is adding the debugfs entries. In that case, we |
| 380 | * leave the STA "to be freed". |
| 381 | * |
| 382 | * The rules are not trivial, but not too complex either: |
| 383 | * (1) pin_status is only modified under the sta_lock |
| 384 | * (2) sta_info_debugfs_add_work() will set the status |
| 385 | * to PINNED when it found an item that needs a new |
| 386 | * debugfs directory created. In that case, that item |
| 387 | * must not be freed although all *RCU* users are done |
| 388 | * with it. Hence, we tell the caller of _unlink() |
| 389 | * that the item is already gone (as can happen when |
| 390 | * two tasks try to unlink/destroy at the same time) |
| 391 | * (3) We set the pin_status to DESTROY here when we |
| 392 | * find such an item. |
| 393 | * (4) sta_info_debugfs_add_work() will reset the pin_status |
| 394 | * from PINNED to NORMAL when it is done with the item, |
| 395 | * but will check for DESTROY before resetting it in |
| 396 | * which case it will free the item. |
| 397 | */ |
| 398 | if ((*sta)->pin_status == STA_INFO_PIN_STAT_PINNED) { |
| 399 | (*sta)->pin_status = STA_INFO_PIN_STAT_DESTROY; |
| 400 | *sta = NULL; |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | list_del(&(*sta)->list); |
| 405 | |
| 406 | if ((*sta)->flags & WLAN_STA_PS) { |
| 407 | (*sta)->flags &= ~WLAN_STA_PS; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 408 | if (sdata->bss) |
| 409 | atomic_dec(&sdata->bss->num_sta_ps); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 410 | __sta_info_clear_tim_bit(sdata->bss, *sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 411 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 412 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 413 | local->num_sta--; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 414 | |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 415 | if (local->ops->sta_notify) { |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 416 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN) |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 417 | sdata = sdata->u.vlan.ap; |
| 418 | |
| 419 | local->ops->sta_notify(local_to_hw(local), &sdata->vif, |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 420 | STA_NOTIFY_REMOVE, (*sta)->addr); |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 421 | } |
Tomas Winkler | 478f8d2 | 2007-09-30 13:52:37 +0200 | [diff] [blame] | 422 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 423 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
| 424 | mesh_accept_plinks_update(sdata); |
| 425 | #ifdef CONFIG_MAC80211_MESH |
| 426 | del_timer(&(*sta)->plink_timer); |
| 427 | #endif |
| 428 | } |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 429 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 430 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
| 431 | printk(KERN_DEBUG "%s: Removed STA %s\n", |
| 432 | wiphy_name(local->hw.wiphy), print_mac(mbuf, (*sta)->addr)); |
| 433 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 434 | } |
| 435 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 436 | void sta_info_unlink(struct sta_info **sta) |
| 437 | { |
| 438 | struct ieee80211_local *local = (*sta)->local; |
| 439 | unsigned long flags; |
| 440 | |
| 441 | spin_lock_irqsave(&local->sta_lock, flags); |
| 442 | __sta_info_unlink(sta); |
| 443 | spin_unlock_irqrestore(&local->sta_lock, flags); |
| 444 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 445 | |
| 446 | static inline int sta_info_buffer_expired(struct ieee80211_local *local, |
| 447 | struct sta_info *sta, |
| 448 | struct sk_buff *skb) |
| 449 | { |
| 450 | struct ieee80211_tx_packet_data *pkt_data; |
| 451 | int timeout; |
| 452 | |
| 453 | if (!skb) |
| 454 | return 0; |
| 455 | |
| 456 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; |
| 457 | |
| 458 | /* Timeout: (2 * listen_interval * beacon_int * 1024 / 1000000) sec */ |
| 459 | timeout = (sta->listen_interval * local->hw.conf.beacon_int * 32 / |
| 460 | 15625) * HZ; |
| 461 | if (timeout < STA_TX_BUFFER_EXPIRE) |
| 462 | timeout = STA_TX_BUFFER_EXPIRE; |
| 463 | return time_after(jiffies, pkt_data->jiffies + timeout); |
| 464 | } |
| 465 | |
| 466 | |
| 467 | static void sta_info_cleanup_expire_buffered(struct ieee80211_local *local, |
| 468 | struct sta_info *sta) |
| 469 | { |
| 470 | unsigned long flags; |
| 471 | struct sk_buff *skb; |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 472 | struct ieee80211_sub_if_data *sdata; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 473 | DECLARE_MAC_BUF(mac); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 474 | |
| 475 | if (skb_queue_empty(&sta->ps_tx_buf)) |
| 476 | return; |
| 477 | |
| 478 | for (;;) { |
| 479 | spin_lock_irqsave(&sta->ps_tx_buf.lock, flags); |
| 480 | skb = skb_peek(&sta->ps_tx_buf); |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 481 | if (sta_info_buffer_expired(local, sta, skb)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 482 | skb = __skb_dequeue(&sta->ps_tx_buf); |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 483 | else |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 484 | skb = NULL; |
| 485 | spin_unlock_irqrestore(&sta->ps_tx_buf.lock, flags); |
| 486 | |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 487 | if (!skb) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 488 | break; |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 489 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 490 | sdata = sta->sdata; |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 491 | local->total_ps_buffered--; |
| 492 | printk(KERN_DEBUG "Buffered frame expired (STA " |
| 493 | "%s)\n", print_mac(mac, sta->addr)); |
| 494 | dev_kfree_skb(skb); |
| 495 | |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 496 | if (skb_queue_empty(&sta->ps_tx_buf)) |
| 497 | sta_info_clear_tim_bit(sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | |
| 501 | |
| 502 | static void sta_info_cleanup(unsigned long data) |
| 503 | { |
| 504 | struct ieee80211_local *local = (struct ieee80211_local *) data; |
| 505 | struct sta_info *sta; |
| 506 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 507 | rcu_read_lock(); |
| 508 | list_for_each_entry_rcu(sta, &local->sta_list, list) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 509 | sta_info_cleanup_expire_buffered(local, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 510 | rcu_read_unlock(); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 511 | |
Johannes Berg | 0d17440 | 2007-12-17 15:07:43 +0100 | [diff] [blame] | 512 | local->sta_cleanup.expires = |
| 513 | round_jiffies(jiffies + STA_INFO_CLEANUP_INTERVAL); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 514 | add_timer(&local->sta_cleanup); |
| 515 | } |
| 516 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 517 | #ifdef CONFIG_MAC80211_DEBUGFS |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 518 | static void sta_info_debugfs_add_work(struct work_struct *work) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 519 | { |
| 520 | struct ieee80211_local *local = |
| 521 | container_of(work, struct ieee80211_local, sta_debugfs_add); |
| 522 | struct sta_info *sta, *tmp; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 523 | unsigned long flags; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 524 | |
| 525 | while (1) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 526 | sta = NULL; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 527 | |
| 528 | spin_lock_irqsave(&local->sta_lock, flags); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 529 | list_for_each_entry(tmp, &local->sta_list, list) { |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 530 | if (!tmp->debugfs.dir) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 531 | sta = tmp; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 532 | __sta_info_pin(sta); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 533 | break; |
| 534 | } |
| 535 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 536 | spin_unlock_irqrestore(&local->sta_lock, flags); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 537 | |
| 538 | if (!sta) |
| 539 | break; |
| 540 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 541 | ieee80211_sta_debugfs_add(sta); |
| 542 | rate_control_add_sta_debugfs(sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 543 | |
| 544 | sta = __sta_info_unpin(sta); |
| 545 | |
| 546 | if (sta) { |
| 547 | synchronize_rcu(); |
| 548 | sta_info_destroy(sta); |
| 549 | } |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 550 | } |
| 551 | } |
| 552 | #endif |
| 553 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 554 | void sta_info_init(struct ieee80211_local *local) |
| 555 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 556 | spin_lock_init(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 557 | INIT_LIST_HEAD(&local->sta_list); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 558 | |
Pavel Emelyanov | b24b8a2 | 2008-01-23 21:20:07 -0800 | [diff] [blame] | 559 | setup_timer(&local->sta_cleanup, sta_info_cleanup, |
| 560 | (unsigned long)local); |
Johannes Berg | 0d17440 | 2007-12-17 15:07:43 +0100 | [diff] [blame] | 561 | local->sta_cleanup.expires = |
| 562 | round_jiffies(jiffies + STA_INFO_CLEANUP_INTERVAL); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 563 | |
| 564 | #ifdef CONFIG_MAC80211_DEBUGFS |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 565 | INIT_WORK(&local->sta_debugfs_add, sta_info_debugfs_add_work); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 566 | #endif |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | int sta_info_start(struct ieee80211_local *local) |
| 570 | { |
| 571 | add_timer(&local->sta_cleanup); |
| 572 | return 0; |
| 573 | } |
| 574 | |
| 575 | void sta_info_stop(struct ieee80211_local *local) |
| 576 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 577 | del_timer(&local->sta_cleanup); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 578 | sta_info_flush(local, NULL); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 579 | } |
| 580 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 581 | /** |
| 582 | * sta_info_flush - flush matching STA entries from the STA table |
| 583 | * @local: local interface data |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 584 | * @sdata: matching rule for the net device (sta->dev) or %NULL to match all STAs |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 585 | */ |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 586 | void sta_info_flush(struct ieee80211_local *local, |
| 587 | struct ieee80211_sub_if_data *sdata) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 588 | { |
| 589 | struct sta_info *sta, *tmp; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 590 | LIST_HEAD(tmp_list); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 591 | unsigned long flags; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 592 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 593 | might_sleep(); |
| 594 | |
| 595 | spin_lock_irqsave(&local->sta_lock, flags); |
| 596 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { |
| 597 | if (!sdata || sdata == sta->sdata) { |
| 598 | __sta_info_unlink(&sta); |
| 599 | if (sta) |
| 600 | list_add_tail(&sta->list, &tmp_list); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 601 | } |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 602 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame^] | 603 | spin_unlock_irqrestore(&local->sta_lock, flags); |
| 604 | |
| 605 | synchronize_rcu(); |
| 606 | |
| 607 | list_for_each_entry_safe(sta, tmp, &tmp_list, list) |
| 608 | sta_info_destroy(sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 609 | } |