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