blob: 78c0d90dd641e459dcec9972be0d97634d58a5c6 [file] [log] [blame]
Johannes Bergf444de02010-05-05 15:25:02 +02001/*
2 * mac80211 - channel management
3 */
4
Johannes Berg0aaffa92010-05-05 15:28:27 +02005#include <linux/nl80211.h>
Johannes Berg3448c002012-09-11 17:57:42 +02006#include <linux/export.h>
Johannes Berg4d76d212012-12-11 20:38:41 +01007#include <linux/rtnetlink.h>
Paul Stewart3117bbdb2012-03-13 07:46:18 -07008#include <net/cfg80211.h>
Johannes Bergf444de02010-05-05 15:25:02 +02009#include "ieee80211_i.h"
Michal Kazior35f2fce2012-06-26 14:37:20 +020010#include "driver-ops.h"
Johannes Bergf444de02010-05-05 15:25:02 +020011
Johannes Berg18942d32013-02-07 21:30:37 +010012static void ieee80211_change_chanctx(struct ieee80211_local *local,
Johannes Berg4bf88532012-11-09 11:39:59 +010013 struct ieee80211_chanctx *ctx,
14 const struct cfg80211_chan_def *chandef)
Michal Kazior23a85b452012-06-26 14:37:21 +020015{
Johannes Berg4bf88532012-11-09 11:39:59 +010016 if (cfg80211_chandef_identical(&ctx->conf.def, chandef))
Michal Kaziore89a96f2012-06-26 14:37:22 +020017 return;
18
Johannes Berg4bf88532012-11-09 11:39:59 +010019 WARN_ON(!cfg80211_chandef_compatible(&ctx->conf.def, chandef));
20
21 ctx->conf.def = *chandef;
22 drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_WIDTH);
Johannes Berg55de9082012-07-26 17:24:39 +020023
24 if (!local->use_chanctx) {
Johannes Berg4bf88532012-11-09 11:39:59 +010025 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
Johannes Berg55de9082012-07-26 17:24:39 +020026 ieee80211_hw_config(local, 0);
27 }
Johannes Berg0aaffa92010-05-05 15:28:27 +020028}
Michal Kaziord01a1e62012-06-26 14:37:16 +020029
30static struct ieee80211_chanctx *
31ieee80211_find_chanctx(struct ieee80211_local *local,
Johannes Berg4bf88532012-11-09 11:39:59 +010032 const struct cfg80211_chan_def *chandef,
Michal Kaziord01a1e62012-06-26 14:37:16 +020033 enum ieee80211_chanctx_mode mode)
34{
35 struct ieee80211_chanctx *ctx;
36
37 lockdep_assert_held(&local->chanctx_mtx);
38
39 if (mode == IEEE80211_CHANCTX_EXCLUSIVE)
40 return NULL;
Michal Kaziord01a1e62012-06-26 14:37:16 +020041
42 list_for_each_entry(ctx, &local->chanctx_list, list) {
Johannes Berg4bf88532012-11-09 11:39:59 +010043 const struct cfg80211_chan_def *compat;
Michal Kaziore89a96f2012-06-26 14:37:22 +020044
Michal Kaziord01a1e62012-06-26 14:37:16 +020045 if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
46 continue;
Johannes Berg4bf88532012-11-09 11:39:59 +010047
48 compat = cfg80211_chandef_compatible(&ctx->conf.def, chandef);
49 if (!compat)
Michal Kaziord01a1e62012-06-26 14:37:16 +020050 continue;
51
Johannes Berg18942d32013-02-07 21:30:37 +010052 ieee80211_change_chanctx(local, ctx, compat);
Michal Kaziore89a96f2012-06-26 14:37:22 +020053
Michal Kaziord01a1e62012-06-26 14:37:16 +020054 return ctx;
55 }
56
57 return NULL;
58}
59
60static struct ieee80211_chanctx *
61ieee80211_new_chanctx(struct ieee80211_local *local,
Johannes Berg4bf88532012-11-09 11:39:59 +010062 const struct cfg80211_chan_def *chandef,
Michal Kaziord01a1e62012-06-26 14:37:16 +020063 enum ieee80211_chanctx_mode mode)
64{
65 struct ieee80211_chanctx *ctx;
Michal Kazior35f2fce2012-06-26 14:37:20 +020066 int err;
Michal Kaziord01a1e62012-06-26 14:37:16 +020067
68 lockdep_assert_held(&local->chanctx_mtx);
69
70 ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL);
71 if (!ctx)
72 return ERR_PTR(-ENOMEM);
73
Johannes Berg4bf88532012-11-09 11:39:59 +010074 ctx->conf.def = *chandef;
Johannes Berg04ecd252012-09-11 14:34:12 +020075 ctx->conf.rx_chains_static = 1;
76 ctx->conf.rx_chains_dynamic = 1;
Michal Kaziord01a1e62012-06-26 14:37:16 +020077 ctx->mode = mode;
78
Johannes Berg55de9082012-07-26 17:24:39 +020079 if (!local->use_chanctx) {
Johannes Berg4bf88532012-11-09 11:39:59 +010080 local->_oper_channel_type =
81 cfg80211_get_chandef_type(chandef);
82 local->_oper_channel = chandef->chan;
Johannes Berg55de9082012-07-26 17:24:39 +020083 ieee80211_hw_config(local, 0);
84 } else {
85 err = drv_add_chanctx(local, ctx);
86 if (err) {
87 kfree(ctx);
88 return ERR_PTR(err);
89 }
Michal Kazior35f2fce2012-06-26 14:37:20 +020090 }
91
Johannes Berg3448c002012-09-11 17:57:42 +020092 list_add_rcu(&ctx->list, &local->chanctx_list);
Michal Kaziord01a1e62012-06-26 14:37:16 +020093
Johannes Bergfd0f9792013-02-07 00:14:51 +010094 mutex_lock(&local->mtx);
95 ieee80211_recalc_idle(local);
96 mutex_unlock(&local->mtx);
97
Michal Kaziord01a1e62012-06-26 14:37:16 +020098 return ctx;
99}
100
101static void ieee80211_free_chanctx(struct ieee80211_local *local,
102 struct ieee80211_chanctx *ctx)
103{
104 lockdep_assert_held(&local->chanctx_mtx);
105
106 WARN_ON_ONCE(ctx->refcount != 0);
107
Johannes Berg55de9082012-07-26 17:24:39 +0200108 if (!local->use_chanctx) {
109 local->_oper_channel_type = NL80211_CHAN_NO_HT;
110 ieee80211_hw_config(local, 0);
111 } else {
112 drv_remove_chanctx(local, ctx);
113 }
Michal Kazior35f2fce2012-06-26 14:37:20 +0200114
Johannes Berg3448c002012-09-11 17:57:42 +0200115 list_del_rcu(&ctx->list);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200116 kfree_rcu(ctx, rcu_head);
Johannes Bergfd0f9792013-02-07 00:14:51 +0100117
118 mutex_lock(&local->mtx);
119 ieee80211_recalc_idle(local);
120 mutex_unlock(&local->mtx);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200121}
122
123static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
124 struct ieee80211_chanctx *ctx)
125{
Michal Kazior35f2fce2012-06-26 14:37:20 +0200126 struct ieee80211_local *local = sdata->local;
127 int ret;
Michal Kaziord01a1e62012-06-26 14:37:16 +0200128
129 lockdep_assert_held(&local->chanctx_mtx);
130
Michal Kazior35f2fce2012-06-26 14:37:20 +0200131 ret = drv_assign_vif_chanctx(local, sdata, ctx);
132 if (ret)
133 return ret;
134
Michal Kaziord01a1e62012-06-26 14:37:16 +0200135 rcu_assign_pointer(sdata->vif.chanctx_conf, &ctx->conf);
136 ctx->refcount++;
137
Johannes Berg1ea6f9c2012-10-24 10:59:25 +0200138 ieee80211_recalc_txpower(sdata);
Johannes Bergfd0f9792013-02-07 00:14:51 +0100139 sdata->vif.bss_conf.idle = false;
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100140
141 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
142 sdata->vif.type != NL80211_IFTYPE_MONITOR)
143 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IDLE);
Johannes Berg1ea6f9c2012-10-24 10:59:25 +0200144
Michal Kaziord01a1e62012-06-26 14:37:16 +0200145 return 0;
146}
147
Johannes Berg4bf88532012-11-09 11:39:59 +0100148static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
149 struct ieee80211_chanctx *ctx)
Michal Kaziore89a96f2012-06-26 14:37:22 +0200150{
151 struct ieee80211_chanctx_conf *conf = &ctx->conf;
152 struct ieee80211_sub_if_data *sdata;
Johannes Berg4bf88532012-11-09 11:39:59 +0100153 const struct cfg80211_chan_def *compat = NULL;
Michal Kaziore89a96f2012-06-26 14:37:22 +0200154
155 lockdep_assert_held(&local->chanctx_mtx);
156
157 rcu_read_lock();
158 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
Johannes Berg4bf88532012-11-09 11:39:59 +0100159
Michal Kaziore89a96f2012-06-26 14:37:22 +0200160 if (!ieee80211_sdata_running(sdata))
161 continue;
162 if (rcu_access_pointer(sdata->vif.chanctx_conf) != conf)
163 continue;
164
Johannes Berg4bf88532012-11-09 11:39:59 +0100165 if (!compat)
166 compat = &sdata->vif.bss_conf.chandef;
167
168 compat = cfg80211_chandef_compatible(
169 &sdata->vif.bss_conf.chandef, compat);
170 if (!compat)
171 break;
Michal Kaziore89a96f2012-06-26 14:37:22 +0200172 }
173 rcu_read_unlock();
174
Johannes Berg4bf88532012-11-09 11:39:59 +0100175 if (WARN_ON_ONCE(!compat))
176 return;
Michal Kaziore89a96f2012-06-26 14:37:22 +0200177
Johannes Berg18942d32013-02-07 21:30:37 +0100178 ieee80211_change_chanctx(local, ctx, compat);
Michal Kaziore89a96f2012-06-26 14:37:22 +0200179}
180
Michal Kaziord01a1e62012-06-26 14:37:16 +0200181static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
182 struct ieee80211_chanctx *ctx)
183{
Michal Kazior35f2fce2012-06-26 14:37:20 +0200184 struct ieee80211_local *local = sdata->local;
Michal Kaziord01a1e62012-06-26 14:37:16 +0200185
186 lockdep_assert_held(&local->chanctx_mtx);
187
188 ctx->refcount--;
189 rcu_assign_pointer(sdata->vif.chanctx_conf, NULL);
Michal Kazior35f2fce2012-06-26 14:37:20 +0200190
Johannes Bergfd0f9792013-02-07 00:14:51 +0100191 sdata->vif.bss_conf.idle = true;
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100192
193 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
194 sdata->vif.type != NL80211_IFTYPE_MONITOR)
195 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IDLE);
Johannes Bergfd0f9792013-02-07 00:14:51 +0100196
Michal Kazior35f2fce2012-06-26 14:37:20 +0200197 drv_unassign_vif_chanctx(local, sdata, ctx);
Michal Kaziore89a96f2012-06-26 14:37:22 +0200198
Johannes Berg04ecd252012-09-11 14:34:12 +0200199 if (ctx->refcount > 0) {
Michal Kaziore89a96f2012-06-26 14:37:22 +0200200 ieee80211_recalc_chanctx_chantype(sdata->local, ctx);
Johannes Berg04ecd252012-09-11 14:34:12 +0200201 ieee80211_recalc_smps_chanctx(local, ctx);
Simon Wunderlich164eb022013-02-08 18:16:20 +0100202 ieee80211_recalc_radar_chanctx(local, ctx);
Johannes Berg04ecd252012-09-11 14:34:12 +0200203 }
Michal Kaziord01a1e62012-06-26 14:37:16 +0200204}
205
206static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
207{
208 struct ieee80211_local *local = sdata->local;
209 struct ieee80211_chanctx_conf *conf;
210 struct ieee80211_chanctx *ctx;
211
212 lockdep_assert_held(&local->chanctx_mtx);
213
214 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
215 lockdep_is_held(&local->chanctx_mtx));
216 if (!conf)
217 return;
218
219 ctx = container_of(conf, struct ieee80211_chanctx, conf);
220
221 ieee80211_unassign_vif_chanctx(sdata, ctx);
222 if (ctx->refcount == 0)
223 ieee80211_free_chanctx(local, ctx);
224}
225
Simon Wunderlich164eb022013-02-08 18:16:20 +0100226void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
227 struct ieee80211_chanctx *chanctx)
228{
229 struct ieee80211_sub_if_data *sdata;
230 bool radar_enabled = false;
231
232 lockdep_assert_held(&local->chanctx_mtx);
233
234 rcu_read_lock();
235 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
236 if (sdata->radar_required) {
237 radar_enabled = true;
238 break;
239 }
240 }
241 rcu_read_unlock();
242
243 if (radar_enabled == chanctx->conf.radar_enabled)
244 return;
245
246 chanctx->conf.radar_enabled = radar_enabled;
247 local->radar_detect_enabled = chanctx->conf.radar_enabled;
248
249 if (!local->use_chanctx) {
250 local->hw.conf.radar_enabled = chanctx->conf.radar_enabled;
251 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
252 }
253
254 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RADAR);
255}
256
Johannes Berg04ecd252012-09-11 14:34:12 +0200257void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
258 struct ieee80211_chanctx *chanctx)
259{
260 struct ieee80211_sub_if_data *sdata;
261 u8 rx_chains_static, rx_chains_dynamic;
262
263 lockdep_assert_held(&local->chanctx_mtx);
264
265 rx_chains_static = 1;
266 rx_chains_dynamic = 1;
267
268 rcu_read_lock();
269 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
270 u8 needed_static, needed_dynamic;
271
272 if (!ieee80211_sdata_running(sdata))
273 continue;
274
275 if (rcu_access_pointer(sdata->vif.chanctx_conf) !=
276 &chanctx->conf)
277 continue;
278
279 switch (sdata->vif.type) {
280 case NL80211_IFTYPE_P2P_DEVICE:
281 continue;
282 case NL80211_IFTYPE_STATION:
283 if (!sdata->u.mgd.associated)
284 continue;
285 break;
286 case NL80211_IFTYPE_AP_VLAN:
287 continue;
288 case NL80211_IFTYPE_AP:
289 case NL80211_IFTYPE_ADHOC:
290 case NL80211_IFTYPE_WDS:
291 case NL80211_IFTYPE_MESH_POINT:
292 break;
293 default:
294 WARN_ON_ONCE(1);
295 }
296
297 switch (sdata->smps_mode) {
298 default:
299 WARN_ONCE(1, "Invalid SMPS mode %d\n",
300 sdata->smps_mode);
301 /* fall through */
302 case IEEE80211_SMPS_OFF:
303 needed_static = sdata->needed_rx_chains;
304 needed_dynamic = sdata->needed_rx_chains;
305 break;
306 case IEEE80211_SMPS_DYNAMIC:
307 needed_static = 1;
308 needed_dynamic = sdata->needed_rx_chains;
309 break;
310 case IEEE80211_SMPS_STATIC:
311 needed_static = 1;
312 needed_dynamic = 1;
313 break;
314 }
315
316 rx_chains_static = max(rx_chains_static, needed_static);
317 rx_chains_dynamic = max(rx_chains_dynamic, needed_dynamic);
318 }
319 rcu_read_unlock();
320
321 if (!local->use_chanctx) {
322 if (rx_chains_static > 1)
323 local->smps_mode = IEEE80211_SMPS_OFF;
324 else if (rx_chains_dynamic > 1)
325 local->smps_mode = IEEE80211_SMPS_DYNAMIC;
326 else
327 local->smps_mode = IEEE80211_SMPS_STATIC;
328 ieee80211_hw_config(local, 0);
329 }
330
331 if (rx_chains_static == chanctx->conf.rx_chains_static &&
332 rx_chains_dynamic == chanctx->conf.rx_chains_dynamic)
333 return;
334
335 chanctx->conf.rx_chains_static = rx_chains_static;
336 chanctx->conf.rx_chains_dynamic = rx_chains_dynamic;
337 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS);
338}
339
Michal Kaziord01a1e62012-06-26 14:37:16 +0200340int ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
Johannes Berg4bf88532012-11-09 11:39:59 +0100341 const struct cfg80211_chan_def *chandef,
Michal Kaziord01a1e62012-06-26 14:37:16 +0200342 enum ieee80211_chanctx_mode mode)
343{
344 struct ieee80211_local *local = sdata->local;
345 struct ieee80211_chanctx *ctx;
346 int ret;
347
Johannes Berg55de9082012-07-26 17:24:39 +0200348 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
349
Michal Kaziord01a1e62012-06-26 14:37:16 +0200350 mutex_lock(&local->chanctx_mtx);
351 __ieee80211_vif_release_channel(sdata);
352
Johannes Berg4bf88532012-11-09 11:39:59 +0100353 ctx = ieee80211_find_chanctx(local, chandef, mode);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200354 if (!ctx)
Johannes Berg4bf88532012-11-09 11:39:59 +0100355 ctx = ieee80211_new_chanctx(local, chandef, mode);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200356 if (IS_ERR(ctx)) {
357 ret = PTR_ERR(ctx);
358 goto out;
359 }
360
Johannes Berg4bf88532012-11-09 11:39:59 +0100361 sdata->vif.bss_conf.chandef = *chandef;
Johannes Berg55de9082012-07-26 17:24:39 +0200362
Michal Kaziord01a1e62012-06-26 14:37:16 +0200363 ret = ieee80211_assign_vif_chanctx(sdata, ctx);
364 if (ret) {
365 /* if assign fails refcount stays the same */
366 if (ctx->refcount == 0)
367 ieee80211_free_chanctx(local, ctx);
368 goto out;
369 }
370
Johannes Berg04ecd252012-09-11 14:34:12 +0200371 ieee80211_recalc_smps_chanctx(local, ctx);
Simon Wunderlich164eb022013-02-08 18:16:20 +0100372 ieee80211_recalc_radar_chanctx(local, ctx);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200373 out:
374 mutex_unlock(&local->chanctx_mtx);
375 return ret;
376}
377
Johannes Berg2c9b7352013-02-07 21:37:29 +0100378int ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
379 const struct cfg80211_chan_def *chandef,
380 u32 *changed)
381{
382 struct ieee80211_local *local = sdata->local;
383 struct ieee80211_chanctx_conf *conf;
384 struct ieee80211_chanctx *ctx;
385 int ret;
386
387 if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
388 IEEE80211_CHAN_DISABLED))
389 return -EINVAL;
390
391 mutex_lock(&local->chanctx_mtx);
392 if (cfg80211_chandef_identical(chandef, &sdata->vif.bss_conf.chandef)) {
393 ret = 0;
394 goto out;
395 }
396
397 if (chandef->width == NL80211_CHAN_WIDTH_20_NOHT ||
398 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) {
399 ret = -EINVAL;
400 goto out;
401 }
402
403 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
404 lockdep_is_held(&local->chanctx_mtx));
405 if (!conf) {
406 ret = -EINVAL;
407 goto out;
408 }
409
410 ctx = container_of(conf, struct ieee80211_chanctx, conf);
411 if (!cfg80211_chandef_compatible(&conf->def, chandef)) {
412 ret = -EINVAL;
413 goto out;
414 }
415
416 sdata->vif.bss_conf.chandef = *chandef;
417
418 ieee80211_recalc_chanctx_chantype(local, ctx);
419
420 *changed |= BSS_CHANGED_BANDWIDTH;
421 ret = 0;
422 out:
423 mutex_unlock(&local->chanctx_mtx);
424 return ret;
425}
426
Michal Kaziord01a1e62012-06-26 14:37:16 +0200427void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
428{
Johannes Berg55de9082012-07-26 17:24:39 +0200429 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
430
Michal Kaziord01a1e62012-06-26 14:37:16 +0200431 mutex_lock(&sdata->local->chanctx_mtx);
432 __ieee80211_vif_release_channel(sdata);
433 mutex_unlock(&sdata->local->chanctx_mtx);
434}
Johannes Berg3448c002012-09-11 17:57:42 +0200435
Johannes Berg4d76d212012-12-11 20:38:41 +0100436void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata)
437{
438 struct ieee80211_local *local = sdata->local;
439 struct ieee80211_sub_if_data *ap;
440 struct ieee80211_chanctx_conf *conf;
441
442 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->bss))
443 return;
444
445 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap);
446
447 mutex_lock(&local->chanctx_mtx);
448
449 conf = rcu_dereference_protected(ap->vif.chanctx_conf,
450 lockdep_is_held(&local->chanctx_mtx));
451 rcu_assign_pointer(sdata->vif.chanctx_conf, conf);
452 mutex_unlock(&local->chanctx_mtx);
453}
454
Johannes Berg1f4ac5a2013-02-08 12:07:44 +0100455void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
456 bool clear)
457{
458 struct ieee80211_local *local = sdata->local;
459 struct ieee80211_sub_if_data *vlan;
460 struct ieee80211_chanctx_conf *conf;
461
462 ASSERT_RTNL();
463
464 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP))
465 return;
466
467 mutex_lock(&local->chanctx_mtx);
468
469 /*
470 * Check that conf exists, even when clearing this function
471 * must be called with the AP's channel context still there
472 * as it would otherwise cause VLANs to have an invalid
473 * channel context pointer for a while, possibly pointing
474 * to a channel context that has already been freed.
475 */
476 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
477 lockdep_is_held(&local->chanctx_mtx));
478 WARN_ON(!conf);
479
480 if (clear)
481 conf = NULL;
482
483 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
484 rcu_assign_pointer(vlan->vif.chanctx_conf, conf);
485
486 mutex_unlock(&local->chanctx_mtx);
487}
488
Johannes Berg3448c002012-09-11 17:57:42 +0200489void ieee80211_iter_chan_contexts_atomic(
490 struct ieee80211_hw *hw,
491 void (*iter)(struct ieee80211_hw *hw,
492 struct ieee80211_chanctx_conf *chanctx_conf,
493 void *data),
494 void *iter_data)
495{
496 struct ieee80211_local *local = hw_to_local(hw);
497 struct ieee80211_chanctx *ctx;
498
499 rcu_read_lock();
500 list_for_each_entry_rcu(ctx, &local->chanctx_list, list)
Johannes Berg8a61af62012-12-13 17:42:30 +0100501 if (ctx->driver_present)
502 iter(hw, &ctx->conf, iter_data);
Johannes Berg3448c002012-09-11 17:57:42 +0200503 rcu_read_unlock();
504}
505EXPORT_SYMBOL_GPL(ieee80211_iter_chan_contexts_atomic);