blob: 8024874ba95d5d154f9f3e44686947b352a8695b [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) {
Karl Beldan675a0b02013-03-25 16:26:57 +010025 local->_oper_chandef = *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) {
Karl Beldan675a0b02013-03-25 16:26:57 +010080 local->_oper_chandef = *chandef;
Johannes Berg55de9082012-07-26 17:24:39 +020081 ieee80211_hw_config(local, 0);
82 } else {
83 err = drv_add_chanctx(local, ctx);
84 if (err) {
85 kfree(ctx);
86 return ERR_PTR(err);
87 }
Michal Kazior35f2fce2012-06-26 14:37:20 +020088 }
89
Johannes Berg3448c002012-09-11 17:57:42 +020090 list_add_rcu(&ctx->list, &local->chanctx_list);
Michal Kaziord01a1e62012-06-26 14:37:16 +020091
Johannes Bergfd0f9792013-02-07 00:14:51 +010092 mutex_lock(&local->mtx);
93 ieee80211_recalc_idle(local);
94 mutex_unlock(&local->mtx);
95
Michal Kaziord01a1e62012-06-26 14:37:16 +020096 return ctx;
97}
98
99static void ieee80211_free_chanctx(struct ieee80211_local *local,
100 struct ieee80211_chanctx *ctx)
101{
102 lockdep_assert_held(&local->chanctx_mtx);
103
104 WARN_ON_ONCE(ctx->refcount != 0);
105
Johannes Berg55de9082012-07-26 17:24:39 +0200106 if (!local->use_chanctx) {
Karl Beldan675a0b02013-03-25 16:26:57 +0100107 struct cfg80211_chan_def *chandef = &local->_oper_chandef;
108 chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
109 chandef->center_freq1 = chandef->chan->center_freq;
110 chandef->center_freq2 = 0;
Johannes Berg55de9082012-07-26 17:24:39 +0200111 ieee80211_hw_config(local, 0);
112 } else {
113 drv_remove_chanctx(local, ctx);
114 }
Michal Kazior35f2fce2012-06-26 14:37:20 +0200115
Johannes Berg3448c002012-09-11 17:57:42 +0200116 list_del_rcu(&ctx->list);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200117 kfree_rcu(ctx, rcu_head);
Johannes Bergfd0f9792013-02-07 00:14:51 +0100118
119 mutex_lock(&local->mtx);
120 ieee80211_recalc_idle(local);
121 mutex_unlock(&local->mtx);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200122}
123
124static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
125 struct ieee80211_chanctx *ctx)
126{
Michal Kazior35f2fce2012-06-26 14:37:20 +0200127 struct ieee80211_local *local = sdata->local;
128 int ret;
Michal Kaziord01a1e62012-06-26 14:37:16 +0200129
130 lockdep_assert_held(&local->chanctx_mtx);
131
Michal Kazior35f2fce2012-06-26 14:37:20 +0200132 ret = drv_assign_vif_chanctx(local, sdata, ctx);
133 if (ret)
134 return ret;
135
Michal Kaziord01a1e62012-06-26 14:37:16 +0200136 rcu_assign_pointer(sdata->vif.chanctx_conf, &ctx->conf);
137 ctx->refcount++;
138
Johannes Berg1ea6f9c2012-10-24 10:59:25 +0200139 ieee80211_recalc_txpower(sdata);
Johannes Bergfd0f9792013-02-07 00:14:51 +0100140 sdata->vif.bss_conf.idle = false;
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100141
142 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
143 sdata->vif.type != NL80211_IFTYPE_MONITOR)
144 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IDLE);
Johannes Berg1ea6f9c2012-10-24 10:59:25 +0200145
Michal Kaziord01a1e62012-06-26 14:37:16 +0200146 return 0;
147}
148
Johannes Berg4bf88532012-11-09 11:39:59 +0100149static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
150 struct ieee80211_chanctx *ctx)
Michal Kaziore89a96f2012-06-26 14:37:22 +0200151{
152 struct ieee80211_chanctx_conf *conf = &ctx->conf;
153 struct ieee80211_sub_if_data *sdata;
Johannes Berg4bf88532012-11-09 11:39:59 +0100154 const struct cfg80211_chan_def *compat = NULL;
Michal Kaziore89a96f2012-06-26 14:37:22 +0200155
156 lockdep_assert_held(&local->chanctx_mtx);
157
158 rcu_read_lock();
159 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
Johannes Berg4bf88532012-11-09 11:39:59 +0100160
Michal Kaziore89a96f2012-06-26 14:37:22 +0200161 if (!ieee80211_sdata_running(sdata))
162 continue;
163 if (rcu_access_pointer(sdata->vif.chanctx_conf) != conf)
164 continue;
165
Johannes Berg4bf88532012-11-09 11:39:59 +0100166 if (!compat)
167 compat = &sdata->vif.bss_conf.chandef;
168
169 compat = cfg80211_chandef_compatible(
170 &sdata->vif.bss_conf.chandef, compat);
171 if (!compat)
172 break;
Michal Kaziore89a96f2012-06-26 14:37:22 +0200173 }
174 rcu_read_unlock();
175
Johannes Berg4bf88532012-11-09 11:39:59 +0100176 if (WARN_ON_ONCE(!compat))
177 return;
Michal Kaziore89a96f2012-06-26 14:37:22 +0200178
Johannes Berg18942d32013-02-07 21:30:37 +0100179 ieee80211_change_chanctx(local, ctx, compat);
Michal Kaziore89a96f2012-06-26 14:37:22 +0200180}
181
Michal Kaziord01a1e62012-06-26 14:37:16 +0200182static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
183 struct ieee80211_chanctx *ctx)
184{
Michal Kazior35f2fce2012-06-26 14:37:20 +0200185 struct ieee80211_local *local = sdata->local;
Michal Kaziord01a1e62012-06-26 14:37:16 +0200186
187 lockdep_assert_held(&local->chanctx_mtx);
188
189 ctx->refcount--;
190 rcu_assign_pointer(sdata->vif.chanctx_conf, NULL);
Michal Kazior35f2fce2012-06-26 14:37:20 +0200191
Johannes Bergfd0f9792013-02-07 00:14:51 +0100192 sdata->vif.bss_conf.idle = true;
Johannes Berg5bbe754d2013-02-13 13:50:51 +0100193
194 if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
195 sdata->vif.type != NL80211_IFTYPE_MONITOR)
196 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IDLE);
Johannes Bergfd0f9792013-02-07 00:14:51 +0100197
Michal Kazior35f2fce2012-06-26 14:37:20 +0200198 drv_unassign_vif_chanctx(local, sdata, ctx);
Michal Kaziore89a96f2012-06-26 14:37:22 +0200199
Johannes Berg04ecd252012-09-11 14:34:12 +0200200 if (ctx->refcount > 0) {
Michal Kaziore89a96f2012-06-26 14:37:22 +0200201 ieee80211_recalc_chanctx_chantype(sdata->local, ctx);
Johannes Berg04ecd252012-09-11 14:34:12 +0200202 ieee80211_recalc_smps_chanctx(local, ctx);
Simon Wunderlich164eb022013-02-08 18:16:20 +0100203 ieee80211_recalc_radar_chanctx(local, ctx);
Johannes Berg04ecd252012-09-11 14:34:12 +0200204 }
Michal Kaziord01a1e62012-06-26 14:37:16 +0200205}
206
207static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
208{
209 struct ieee80211_local *local = sdata->local;
210 struct ieee80211_chanctx_conf *conf;
211 struct ieee80211_chanctx *ctx;
212
213 lockdep_assert_held(&local->chanctx_mtx);
214
215 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
216 lockdep_is_held(&local->chanctx_mtx));
217 if (!conf)
218 return;
219
220 ctx = container_of(conf, struct ieee80211_chanctx, conf);
221
222 ieee80211_unassign_vif_chanctx(sdata, ctx);
223 if (ctx->refcount == 0)
224 ieee80211_free_chanctx(local, ctx);
225}
226
Simon Wunderlich164eb022013-02-08 18:16:20 +0100227void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
228 struct ieee80211_chanctx *chanctx)
229{
230 struct ieee80211_sub_if_data *sdata;
231 bool radar_enabled = false;
232
233 lockdep_assert_held(&local->chanctx_mtx);
234
235 rcu_read_lock();
236 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
237 if (sdata->radar_required) {
238 radar_enabled = true;
239 break;
240 }
241 }
242 rcu_read_unlock();
243
244 if (radar_enabled == chanctx->conf.radar_enabled)
245 return;
246
247 chanctx->conf.radar_enabled = radar_enabled;
248 local->radar_detect_enabled = chanctx->conf.radar_enabled;
249
250 if (!local->use_chanctx) {
251 local->hw.conf.radar_enabled = chanctx->conf.radar_enabled;
252 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
253 }
254
255 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RADAR);
256}
257
Johannes Berg04ecd252012-09-11 14:34:12 +0200258void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
259 struct ieee80211_chanctx *chanctx)
260{
261 struct ieee80211_sub_if_data *sdata;
262 u8 rx_chains_static, rx_chains_dynamic;
263
264 lockdep_assert_held(&local->chanctx_mtx);
265
266 rx_chains_static = 1;
267 rx_chains_dynamic = 1;
268
269 rcu_read_lock();
270 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
271 u8 needed_static, needed_dynamic;
272
273 if (!ieee80211_sdata_running(sdata))
274 continue;
275
276 if (rcu_access_pointer(sdata->vif.chanctx_conf) !=
277 &chanctx->conf)
278 continue;
279
280 switch (sdata->vif.type) {
281 case NL80211_IFTYPE_P2P_DEVICE:
282 continue;
283 case NL80211_IFTYPE_STATION:
284 if (!sdata->u.mgd.associated)
285 continue;
286 break;
287 case NL80211_IFTYPE_AP_VLAN:
288 continue;
289 case NL80211_IFTYPE_AP:
290 case NL80211_IFTYPE_ADHOC:
291 case NL80211_IFTYPE_WDS:
292 case NL80211_IFTYPE_MESH_POINT:
293 break;
294 default:
295 WARN_ON_ONCE(1);
296 }
297
298 switch (sdata->smps_mode) {
299 default:
300 WARN_ONCE(1, "Invalid SMPS mode %d\n",
301 sdata->smps_mode);
302 /* fall through */
303 case IEEE80211_SMPS_OFF:
304 needed_static = sdata->needed_rx_chains;
305 needed_dynamic = sdata->needed_rx_chains;
306 break;
307 case IEEE80211_SMPS_DYNAMIC:
308 needed_static = 1;
309 needed_dynamic = sdata->needed_rx_chains;
310 break;
311 case IEEE80211_SMPS_STATIC:
312 needed_static = 1;
313 needed_dynamic = 1;
314 break;
315 }
316
317 rx_chains_static = max(rx_chains_static, needed_static);
318 rx_chains_dynamic = max(rx_chains_dynamic, needed_dynamic);
319 }
320 rcu_read_unlock();
321
322 if (!local->use_chanctx) {
323 if (rx_chains_static > 1)
324 local->smps_mode = IEEE80211_SMPS_OFF;
325 else if (rx_chains_dynamic > 1)
326 local->smps_mode = IEEE80211_SMPS_DYNAMIC;
327 else
328 local->smps_mode = IEEE80211_SMPS_STATIC;
329 ieee80211_hw_config(local, 0);
330 }
331
332 if (rx_chains_static == chanctx->conf.rx_chains_static &&
333 rx_chains_dynamic == chanctx->conf.rx_chains_dynamic)
334 return;
335
336 chanctx->conf.rx_chains_static = rx_chains_static;
337 chanctx->conf.rx_chains_dynamic = rx_chains_dynamic;
338 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS);
339}
340
Michal Kaziord01a1e62012-06-26 14:37:16 +0200341int ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
Johannes Berg4bf88532012-11-09 11:39:59 +0100342 const struct cfg80211_chan_def *chandef,
Michal Kaziord01a1e62012-06-26 14:37:16 +0200343 enum ieee80211_chanctx_mode mode)
344{
345 struct ieee80211_local *local = sdata->local;
346 struct ieee80211_chanctx *ctx;
347 int ret;
348
Johannes Berg55de9082012-07-26 17:24:39 +0200349 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
350
Michal Kaziord01a1e62012-06-26 14:37:16 +0200351 mutex_lock(&local->chanctx_mtx);
352 __ieee80211_vif_release_channel(sdata);
353
Johannes Berg4bf88532012-11-09 11:39:59 +0100354 ctx = ieee80211_find_chanctx(local, chandef, mode);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200355 if (!ctx)
Johannes Berg4bf88532012-11-09 11:39:59 +0100356 ctx = ieee80211_new_chanctx(local, chandef, mode);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200357 if (IS_ERR(ctx)) {
358 ret = PTR_ERR(ctx);
359 goto out;
360 }
361
Johannes Berg4bf88532012-11-09 11:39:59 +0100362 sdata->vif.bss_conf.chandef = *chandef;
Johannes Berg55de9082012-07-26 17:24:39 +0200363
Michal Kaziord01a1e62012-06-26 14:37:16 +0200364 ret = ieee80211_assign_vif_chanctx(sdata, ctx);
365 if (ret) {
366 /* if assign fails refcount stays the same */
367 if (ctx->refcount == 0)
368 ieee80211_free_chanctx(local, ctx);
369 goto out;
370 }
371
Johannes Berg04ecd252012-09-11 14:34:12 +0200372 ieee80211_recalc_smps_chanctx(local, ctx);
Simon Wunderlich164eb022013-02-08 18:16:20 +0100373 ieee80211_recalc_radar_chanctx(local, ctx);
Michal Kaziord01a1e62012-06-26 14:37:16 +0200374 out:
375 mutex_unlock(&local->chanctx_mtx);
376 return ret;
377}
378
Johannes Berg2c9b7352013-02-07 21:37:29 +0100379int ieee80211_vif_change_bandwidth(struct ieee80211_sub_if_data *sdata,
380 const struct cfg80211_chan_def *chandef,
381 u32 *changed)
382{
383 struct ieee80211_local *local = sdata->local;
384 struct ieee80211_chanctx_conf *conf;
385 struct ieee80211_chanctx *ctx;
386 int ret;
387
388 if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
389 IEEE80211_CHAN_DISABLED))
390 return -EINVAL;
391
392 mutex_lock(&local->chanctx_mtx);
393 if (cfg80211_chandef_identical(chandef, &sdata->vif.bss_conf.chandef)) {
394 ret = 0;
395 goto out;
396 }
397
398 if (chandef->width == NL80211_CHAN_WIDTH_20_NOHT ||
399 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) {
400 ret = -EINVAL;
401 goto out;
402 }
403
404 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
405 lockdep_is_held(&local->chanctx_mtx));
406 if (!conf) {
407 ret = -EINVAL;
408 goto out;
409 }
410
411 ctx = container_of(conf, struct ieee80211_chanctx, conf);
412 if (!cfg80211_chandef_compatible(&conf->def, chandef)) {
413 ret = -EINVAL;
414 goto out;
415 }
416
417 sdata->vif.bss_conf.chandef = *chandef;
418
419 ieee80211_recalc_chanctx_chantype(local, ctx);
420
421 *changed |= BSS_CHANGED_BANDWIDTH;
422 ret = 0;
423 out:
424 mutex_unlock(&local->chanctx_mtx);
425 return ret;
426}
427
Michal Kaziord01a1e62012-06-26 14:37:16 +0200428void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
429{
Johannes Berg55de9082012-07-26 17:24:39 +0200430 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
431
Michal Kaziord01a1e62012-06-26 14:37:16 +0200432 mutex_lock(&sdata->local->chanctx_mtx);
433 __ieee80211_vif_release_channel(sdata);
434 mutex_unlock(&sdata->local->chanctx_mtx);
435}
Johannes Berg3448c002012-09-11 17:57:42 +0200436
Johannes Berg4d76d212012-12-11 20:38:41 +0100437void ieee80211_vif_vlan_copy_chanctx(struct ieee80211_sub_if_data *sdata)
438{
439 struct ieee80211_local *local = sdata->local;
440 struct ieee80211_sub_if_data *ap;
441 struct ieee80211_chanctx_conf *conf;
442
443 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->bss))
444 return;
445
446 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap);
447
448 mutex_lock(&local->chanctx_mtx);
449
450 conf = rcu_dereference_protected(ap->vif.chanctx_conf,
451 lockdep_is_held(&local->chanctx_mtx));
452 rcu_assign_pointer(sdata->vif.chanctx_conf, conf);
453 mutex_unlock(&local->chanctx_mtx);
454}
455
Johannes Berg1f4ac5a2013-02-08 12:07:44 +0100456void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
457 bool clear)
458{
459 struct ieee80211_local *local = sdata->local;
460 struct ieee80211_sub_if_data *vlan;
461 struct ieee80211_chanctx_conf *conf;
462
463 ASSERT_RTNL();
464
465 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP))
466 return;
467
468 mutex_lock(&local->chanctx_mtx);
469
470 /*
471 * Check that conf exists, even when clearing this function
472 * must be called with the AP's channel context still there
473 * as it would otherwise cause VLANs to have an invalid
474 * channel context pointer for a while, possibly pointing
475 * to a channel context that has already been freed.
476 */
477 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
478 lockdep_is_held(&local->chanctx_mtx));
479 WARN_ON(!conf);
480
481 if (clear)
482 conf = NULL;
483
484 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
485 rcu_assign_pointer(vlan->vif.chanctx_conf, conf);
486
487 mutex_unlock(&local->chanctx_mtx);
488}
489
Johannes Berg3448c002012-09-11 17:57:42 +0200490void ieee80211_iter_chan_contexts_atomic(
491 struct ieee80211_hw *hw,
492 void (*iter)(struct ieee80211_hw *hw,
493 struct ieee80211_chanctx_conf *chanctx_conf,
494 void *data),
495 void *iter_data)
496{
497 struct ieee80211_local *local = hw_to_local(hw);
498 struct ieee80211_chanctx *ctx;
499
500 rcu_read_lock();
501 list_for_each_entry_rcu(ctx, &local->chanctx_list, list)
Johannes Berg8a61af62012-12-13 17:42:30 +0100502 if (ctx->driver_present)
503 iter(hw, &ctx->conf, iter_data);
Johannes Berg3448c002012-09-11 17:57:42 +0200504 rcu_read_unlock();
505}
506EXPORT_SYMBOL_GPL(ieee80211_iter_chan_contexts_atomic);