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> |
| 17 | |
| 18 | #include <net/mac80211.h> |
| 19 | #include "ieee80211_i.h" |
| 20 | #include "ieee80211_rate.h" |
| 21 | #include "sta_info.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 22 | #include "debugfs_sta.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 23 | |
| 24 | /* Caller must hold local->sta_lock */ |
| 25 | static void sta_info_hash_add(struct ieee80211_local *local, |
| 26 | struct sta_info *sta) |
| 27 | { |
| 28 | sta->hnext = local->sta_hash[STA_HASH(sta->addr)]; |
| 29 | local->sta_hash[STA_HASH(sta->addr)] = sta; |
| 30 | } |
| 31 | |
| 32 | |
| 33 | /* Caller must hold local->sta_lock */ |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 34 | static int sta_info_hash_del(struct ieee80211_local *local, |
| 35 | struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 36 | { |
| 37 | struct sta_info *s; |
| 38 | |
| 39 | s = local->sta_hash[STA_HASH(sta->addr)]; |
| 40 | if (!s) |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 41 | return -ENOENT; |
| 42 | if (s == sta) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 43 | local->sta_hash[STA_HASH(sta->addr)] = s->hnext; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 44 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 47 | while (s->hnext && s->hnext != sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 48 | s = s->hnext; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 49 | if (s->hnext) { |
| 50 | s->hnext = sta->hnext; |
| 51 | return 0; |
| 52 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 53 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 54 | return -ENOENT; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr) |
| 58 | { |
| 59 | struct sta_info *sta; |
| 60 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 61 | read_lock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 62 | sta = local->sta_hash[STA_HASH(addr)]; |
| 63 | while (sta) { |
| 64 | if (memcmp(sta->addr, addr, ETH_ALEN) == 0) { |
| 65 | __sta_info_get(sta); |
| 66 | break; |
| 67 | } |
| 68 | sta = sta->hnext; |
| 69 | } |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 70 | read_unlock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 71 | |
| 72 | return sta; |
| 73 | } |
| 74 | EXPORT_SYMBOL(sta_info_get); |
| 75 | |
| 76 | int sta_info_min_txrate_get(struct ieee80211_local *local) |
| 77 | { |
| 78 | struct sta_info *sta; |
| 79 | struct ieee80211_hw_mode *mode; |
| 80 | int min_txrate = 9999999; |
| 81 | int i; |
| 82 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 83 | read_lock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 84 | mode = local->oper_hw_mode; |
| 85 | for (i = 0; i < STA_HASH_SIZE; i++) { |
| 86 | sta = local->sta_hash[i]; |
| 87 | while (sta) { |
| 88 | if (sta->txrate < min_txrate) |
| 89 | min_txrate = sta->txrate; |
| 90 | sta = sta->hnext; |
| 91 | } |
| 92 | } |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 93 | read_unlock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 94 | if (min_txrate == 9999999) |
| 95 | min_txrate = 0; |
| 96 | |
| 97 | return mode->rates[min_txrate].rate; |
| 98 | } |
| 99 | |
| 100 | |
| 101 | static void sta_info_release(struct kref *kref) |
| 102 | { |
| 103 | struct sta_info *sta = container_of(kref, struct sta_info, kref); |
| 104 | struct ieee80211_local *local = sta->local; |
| 105 | struct sk_buff *skb; |
| 106 | |
| 107 | /* free sta structure; it has already been removed from |
| 108 | * hash table etc. external structures. Make sure that all |
| 109 | * buffered frames are release (one might have been added |
| 110 | * after sta_info_free() was called). */ |
| 111 | while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) { |
| 112 | local->total_ps_buffered--; |
| 113 | dev_kfree_skb_any(skb); |
| 114 | } |
| 115 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { |
| 116 | dev_kfree_skb_any(skb); |
| 117 | } |
| 118 | rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv); |
| 119 | rate_control_put(sta->rate_ctrl); |
| 120 | kfree(sta); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | void sta_info_put(struct sta_info *sta) |
| 125 | { |
| 126 | kref_put(&sta->kref, sta_info_release); |
| 127 | } |
| 128 | EXPORT_SYMBOL(sta_info_put); |
| 129 | |
| 130 | |
| 131 | struct sta_info * sta_info_add(struct ieee80211_local *local, |
| 132 | struct net_device *dev, u8 *addr, gfp_t gfp) |
| 133 | { |
| 134 | struct sta_info *sta; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 135 | DECLARE_MAC_BUF(mac); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 136 | |
| 137 | sta = kzalloc(sizeof(*sta), gfp); |
| 138 | if (!sta) |
| 139 | return NULL; |
| 140 | |
| 141 | kref_init(&sta->kref); |
| 142 | |
| 143 | sta->rate_ctrl = rate_control_get(local->rate_ctrl); |
| 144 | sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, gfp); |
| 145 | if (!sta->rate_ctrl_priv) { |
| 146 | rate_control_put(sta->rate_ctrl); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 147 | kfree(sta); |
| 148 | return NULL; |
| 149 | } |
| 150 | |
| 151 | memcpy(sta->addr, addr, ETH_ALEN); |
| 152 | sta->local = local; |
| 153 | sta->dev = dev; |
| 154 | skb_queue_head_init(&sta->ps_tx_buf); |
| 155 | skb_queue_head_init(&sta->tx_filtered); |
| 156 | __sta_info_get(sta); /* sta used by caller, decremented by |
| 157 | * sta_info_put() */ |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 158 | write_lock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 159 | list_add(&sta->list, &local->sta_list); |
| 160 | local->num_sta++; |
| 161 | sta_info_hash_add(local, sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 162 | if (local->ops->sta_table_notification) |
| 163 | local->ops->sta_table_notification(local_to_hw(local), |
| 164 | local->num_sta); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 165 | write_unlock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 166 | |
| 167 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 168 | printk(KERN_DEBUG "%s: Added STA %s\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame^] | 169 | wiphy_name(local->hw.wiphy), print_mac(mac, addr)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 170 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
| 171 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 172 | #ifdef CONFIG_MAC80211_DEBUGFS |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 173 | /* debugfs entry adding might sleep, so schedule process |
| 174 | * context task for adding entry for STAs that do not yet |
| 175 | * have one. */ |
| 176 | queue_work(local->hw.workqueue, &local->sta_debugfs_add); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 177 | #endif |
| 178 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 179 | return sta; |
| 180 | } |
| 181 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 182 | /* Caller must hold local->sta_lock */ |
| 183 | void sta_info_remove(struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 184 | { |
| 185 | struct ieee80211_local *local = sta->local; |
| 186 | struct ieee80211_sub_if_data *sdata; |
| 187 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 188 | /* don't do anything if we've been removed already */ |
| 189 | if (sta_info_hash_del(local, sta)) |
| 190 | return; |
| 191 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 192 | list_del(&sta->list); |
| 193 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
| 194 | if (sta->flags & WLAN_STA_PS) { |
| 195 | sta->flags &= ~WLAN_STA_PS; |
| 196 | if (sdata->bss) |
| 197 | atomic_dec(&sdata->bss->num_sta_ps); |
| 198 | } |
| 199 | local->num_sta--; |
| 200 | sta_info_remove_aid_ptr(sta); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 201 | |
| 202 | if (local->ops->sta_table_notification) |
| 203 | local->ops->sta_table_notification(local_to_hw(local), |
| 204 | local->num_sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 207 | void sta_info_free(struct sta_info *sta) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 208 | { |
| 209 | struct sk_buff *skb; |
| 210 | struct ieee80211_local *local = sta->local; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 211 | DECLARE_MAC_BUF(mac); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 212 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 213 | might_sleep(); |
| 214 | |
| 215 | write_lock_bh(&local->sta_lock); |
| 216 | sta_info_remove(sta); |
| 217 | write_unlock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 218 | |
| 219 | while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) { |
| 220 | local->total_ps_buffered--; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 221 | dev_kfree_skb(skb); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 222 | } |
| 223 | while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) { |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 224 | dev_kfree_skb(skb); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 227 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 228 | printk(KERN_DEBUG "%s: Removed STA %s\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame^] | 229 | wiphy_name(local->hw.wiphy), print_mac(mac, sta->addr)); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 230 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
| 231 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 232 | ieee80211_key_free(sta->key); |
| 233 | sta->key = NULL; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 234 | |
| 235 | rate_control_remove_sta_debugfs(sta); |
| 236 | ieee80211_sta_debugfs_remove(sta); |
| 237 | |
| 238 | sta_info_put(sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | |
| 242 | static inline int sta_info_buffer_expired(struct ieee80211_local *local, |
| 243 | struct sta_info *sta, |
| 244 | struct sk_buff *skb) |
| 245 | { |
| 246 | struct ieee80211_tx_packet_data *pkt_data; |
| 247 | int timeout; |
| 248 | |
| 249 | if (!skb) |
| 250 | return 0; |
| 251 | |
| 252 | pkt_data = (struct ieee80211_tx_packet_data *) skb->cb; |
| 253 | |
| 254 | /* Timeout: (2 * listen_interval * beacon_int * 1024 / 1000000) sec */ |
| 255 | timeout = (sta->listen_interval * local->hw.conf.beacon_int * 32 / |
| 256 | 15625) * HZ; |
| 257 | if (timeout < STA_TX_BUFFER_EXPIRE) |
| 258 | timeout = STA_TX_BUFFER_EXPIRE; |
| 259 | return time_after(jiffies, pkt_data->jiffies + timeout); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | static void sta_info_cleanup_expire_buffered(struct ieee80211_local *local, |
| 264 | struct sta_info *sta) |
| 265 | { |
| 266 | unsigned long flags; |
| 267 | struct sk_buff *skb; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 268 | DECLARE_MAC_BUF(mac); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 269 | |
| 270 | if (skb_queue_empty(&sta->ps_tx_buf)) |
| 271 | return; |
| 272 | |
| 273 | for (;;) { |
| 274 | spin_lock_irqsave(&sta->ps_tx_buf.lock, flags); |
| 275 | skb = skb_peek(&sta->ps_tx_buf); |
| 276 | if (sta_info_buffer_expired(local, sta, skb)) { |
| 277 | skb = __skb_dequeue(&sta->ps_tx_buf); |
| 278 | if (skb_queue_empty(&sta->ps_tx_buf)) |
| 279 | sta->flags &= ~WLAN_STA_TIM; |
| 280 | } else |
| 281 | skb = NULL; |
| 282 | spin_unlock_irqrestore(&sta->ps_tx_buf.lock, flags); |
| 283 | |
| 284 | if (skb) { |
| 285 | local->total_ps_buffered--; |
| 286 | printk(KERN_DEBUG "Buffered frame expired (STA " |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 287 | "%s)\n", print_mac(mac, sta->addr)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 288 | dev_kfree_skb(skb); |
| 289 | } else |
| 290 | break; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | |
| 295 | static void sta_info_cleanup(unsigned long data) |
| 296 | { |
| 297 | struct ieee80211_local *local = (struct ieee80211_local *) data; |
| 298 | struct sta_info *sta; |
| 299 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 300 | read_lock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 301 | list_for_each_entry(sta, &local->sta_list, list) { |
| 302 | __sta_info_get(sta); |
| 303 | sta_info_cleanup_expire_buffered(local, sta); |
| 304 | sta_info_put(sta); |
| 305 | } |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 306 | read_unlock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 307 | |
| 308 | local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL; |
| 309 | add_timer(&local->sta_cleanup); |
| 310 | } |
| 311 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 312 | #ifdef CONFIG_MAC80211_DEBUGFS |
| 313 | static void sta_info_debugfs_add_task(struct work_struct *work) |
| 314 | { |
| 315 | struct ieee80211_local *local = |
| 316 | container_of(work, struct ieee80211_local, sta_debugfs_add); |
| 317 | struct sta_info *sta, *tmp; |
| 318 | |
| 319 | while (1) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 320 | sta = NULL; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 321 | read_lock_bh(&local->sta_lock); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 322 | list_for_each_entry(tmp, &local->sta_list, list) { |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 323 | if (!tmp->debugfs.dir) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 324 | sta = tmp; |
| 325 | __sta_info_get(sta); |
| 326 | break; |
| 327 | } |
| 328 | } |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 329 | read_unlock_bh(&local->sta_lock); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 330 | |
| 331 | if (!sta) |
| 332 | break; |
| 333 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 334 | ieee80211_sta_debugfs_add(sta); |
| 335 | rate_control_add_sta_debugfs(sta); |
| 336 | sta_info_put(sta); |
| 337 | } |
| 338 | } |
| 339 | #endif |
| 340 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 341 | void sta_info_init(struct ieee80211_local *local) |
| 342 | { |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 343 | rwlock_init(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 344 | INIT_LIST_HEAD(&local->sta_list); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 345 | |
| 346 | init_timer(&local->sta_cleanup); |
| 347 | local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL; |
| 348 | local->sta_cleanup.data = (unsigned long) local; |
| 349 | local->sta_cleanup.function = sta_info_cleanup; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 350 | |
| 351 | #ifdef CONFIG_MAC80211_DEBUGFS |
| 352 | INIT_WORK(&local->sta_debugfs_add, sta_info_debugfs_add_task); |
| 353 | #endif |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | int sta_info_start(struct ieee80211_local *local) |
| 357 | { |
| 358 | add_timer(&local->sta_cleanup); |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | void sta_info_stop(struct ieee80211_local *local) |
| 363 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 364 | del_timer(&local->sta_cleanup); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 365 | sta_info_flush(local, NULL); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | void sta_info_remove_aid_ptr(struct sta_info *sta) |
| 369 | { |
| 370 | struct ieee80211_sub_if_data *sdata; |
| 371 | |
| 372 | if (sta->aid <= 0) |
| 373 | return; |
| 374 | |
| 375 | sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
| 376 | |
| 377 | if (sdata->local->ops->set_tim) |
| 378 | sdata->local->ops->set_tim(local_to_hw(sdata->local), |
| 379 | sta->aid, 0); |
| 380 | if (sdata->bss) |
| 381 | __bss_tim_clear(sdata->bss, sta->aid); |
| 382 | } |
| 383 | |
| 384 | |
| 385 | /** |
| 386 | * sta_info_flush - flush matching STA entries from the STA table |
| 387 | * @local: local interface data |
| 388 | * @dev: matching rule for the net device (sta->dev) or %NULL to match all STAs |
| 389 | */ |
| 390 | void sta_info_flush(struct ieee80211_local *local, struct net_device *dev) |
| 391 | { |
| 392 | struct sta_info *sta, *tmp; |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 393 | LIST_HEAD(tmp_list); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 394 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 395 | write_lock_bh(&local->sta_lock); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 396 | list_for_each_entry_safe(sta, tmp, &local->sta_list, list) |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 397 | if (!dev || dev == sta->dev) { |
| 398 | __sta_info_get(sta); |
| 399 | sta_info_remove(sta); |
| 400 | list_add_tail(&sta->list, &tmp_list); |
| 401 | } |
| 402 | write_unlock_bh(&local->sta_lock); |
| 403 | |
| 404 | list_for_each_entry_safe(sta, tmp, &tmp_list, list) { |
| 405 | sta_info_free(sta); |
| 406 | sta_info_put(sta); |
| 407 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 408 | } |