aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-09-11 11:57:42 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-10-17 05:02:10 -0400
commit3448c0058327356049f140116fc6632bbfd0c122 (patch)
treed7cd9c0889c79a978a8c7bfd76dc9eefaa5f87a8
parent04ecd2578e712c301fa1369d2a8f298a2b4b146a (diff)
mac80211: add channel context iterator
Drivers may need to iterate the active channel contexts, export an iterator function to allow that. To make it possible, use RCU-safe list functions. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--include/net/mac80211.h21
-rw-r--r--net/mac80211/chan.c22
2 files changed, 41 insertions, 2 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 3560881d17e..f12df5bb529 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3597,6 +3597,27 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
3597 void *iter_data); 3597 void *iter_data);
3598 3598
3599/** 3599/**
3600 * ieee80211_iter_chan_contexts_atomic - iterate channel contexts
3601 * @hw: pointre obtained from ieee80211_alloc_hw().
3602 * @iter: iterator function
3603 * @iter_data: data passed to iterator function
3604 *
3605 * Iterate all active channel contexts. This function is atomic and
3606 * doesn't acquire any locks internally that might be held in other
3607 * places while calling into the driver.
3608 *
3609 * The iterator will not find a context that's being added (during
3610 * the driver callback to add it) but will find it while it's being
3611 * removed.
3612 */
3613void ieee80211_iter_chan_contexts_atomic(
3614 struct ieee80211_hw *hw,
3615 void (*iter)(struct ieee80211_hw *hw,
3616 struct ieee80211_chanctx_conf *chanctx_conf,
3617 void *data),
3618 void *iter_data);
3619
3620/**
3600 * ieee80211_ap_probereq_get - retrieve a Probe Request template 3621 * ieee80211_ap_probereq_get - retrieve a Probe Request template
3601 * @hw: pointer obtained from ieee80211_alloc_hw(). 3622 * @hw: pointer obtained from ieee80211_alloc_hw().
3602 * @vif: &struct ieee80211_vif pointer from the add_interface callback. 3623 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index bfaa486d928..f84b86028a9 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/nl80211.h> 5#include <linux/nl80211.h>
6#include <linux/export.h>
6#include <net/cfg80211.h> 7#include <net/cfg80211.h>
7#include "ieee80211_i.h" 8#include "ieee80211_i.h"
8#include "driver-ops.h" 9#include "driver-ops.h"
@@ -134,7 +135,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local,
134 } 135 }
135 } 136 }
136 137
137 list_add(&ctx->list, &local->chanctx_list); 138 list_add_rcu(&ctx->list, &local->chanctx_list);
138 139
139 return ctx; 140 return ctx;
140} 141}
@@ -153,7 +154,7 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local,
153 drv_remove_chanctx(local, ctx); 154 drv_remove_chanctx(local, ctx);
154 } 155 }
155 156
156 list_del(&ctx->list); 157 list_del_rcu(&ctx->list);
157 kfree_rcu(ctx, rcu_head); 158 kfree_rcu(ctx, rcu_head);
158} 159}
159 160
@@ -379,3 +380,20 @@ void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
379 __ieee80211_vif_release_channel(sdata); 380 __ieee80211_vif_release_channel(sdata);
380 mutex_unlock(&sdata->local->chanctx_mtx); 381 mutex_unlock(&sdata->local->chanctx_mtx);
381} 382}
383
384void ieee80211_iter_chan_contexts_atomic(
385 struct ieee80211_hw *hw,
386 void (*iter)(struct ieee80211_hw *hw,
387 struct ieee80211_chanctx_conf *chanctx_conf,
388 void *data),
389 void *iter_data)
390{
391 struct ieee80211_local *local = hw_to_local(hw);
392 struct ieee80211_chanctx *ctx;
393
394 rcu_read_lock();
395 list_for_each_entry_rcu(ctx, &local->chanctx_list, list)
396 iter(hw, &ctx->conf, iter_data);
397 rcu_read_unlock();
398}
399EXPORT_SYMBOL_GPL(ieee80211_iter_chan_contexts_atomic);