Lines Matching defs:local
13 static int ieee80211_chanctx_num_assigned(struct ieee80211_local *local,
19 lockdep_assert_held(&local->chanctx_mtx);
27 static int ieee80211_chanctx_num_reserved(struct ieee80211_local *local,
33 lockdep_assert_held(&local->chanctx_mtx);
41 int ieee80211_chanctx_refcount(struct ieee80211_local *local,
44 return ieee80211_chanctx_num_assigned(local, ctx) +
45 ieee80211_chanctx_num_reserved(local, ctx);
48 static int ieee80211_num_chanctx(struct ieee80211_local *local)
53 lockdep_assert_held(&local->chanctx_mtx);
55 list_for_each_entry(ctx, &local->chanctx_list, list)
61 static bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local)
63 lockdep_assert_held(&local->chanctx_mtx);
64 return ieee80211_num_chanctx(local) < ieee80211_max_num_channels(local);
70 struct ieee80211_local *local __maybe_unused = sdata->local;
74 lockdep_is_held(&local->chanctx_mtx));
82 ieee80211_chanctx_reserved_chandef(struct ieee80211_local *local,
88 lockdep_assert_held(&local->chanctx_mtx);
105 ieee80211_chanctx_non_reserved_chandef(struct ieee80211_local *local,
111 lockdep_assert_held(&local->chanctx_mtx);
131 ieee80211_chanctx_combined_chandef(struct ieee80211_local *local,
135 lockdep_assert_held(&local->chanctx_mtx);
137 compat = ieee80211_chanctx_reserved_chandef(local, ctx, compat);
141 compat = ieee80211_chanctx_non_reserved_chandef(local, ctx, compat);
149 ieee80211_chanctx_can_reserve_chandef(struct ieee80211_local *local,
153 lockdep_assert_held(&local->chanctx_mtx);
155 if (ieee80211_chanctx_combined_chandef(local, ctx, def))
159 ieee80211_chanctx_reserved_chandef(local, ctx, def))
166 ieee80211_find_reservation_chanctx(struct ieee80211_local *local,
172 lockdep_assert_held(&local->chanctx_mtx);
177 list_for_each_entry(ctx, &local->chanctx_list, list) {
184 if (!ieee80211_chanctx_can_reserve_chandef(local, ctx,
230 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
243 ieee80211_get_chanctx_max_required_bw(struct ieee80211_local *local,
250 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
294 sdata = rcu_dereference(local->monitor_sdata);
308 void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
314 lockdep_assert_held(&local->chanctx_mtx);
329 max_bw = ieee80211_get_chanctx_max_required_bw(local, &ctx->conf);
343 drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_MIN_WIDTH);
346 static void ieee80211_change_chanctx(struct ieee80211_local *local,
351 ieee80211_recalc_chanctx_min_def(local, ctx);
358 drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_WIDTH);
359 ieee80211_recalc_chanctx_min_def(local, ctx);
361 if (!local->use_chanctx) {
362 local->_oper_chandef = *chandef;
363 ieee80211_hw_config(local, 0);
368 ieee80211_find_chanctx(struct ieee80211_local *local,
374 lockdep_assert_held(&local->chanctx_mtx);
379 list_for_each_entry(ctx, &local->chanctx_list, list) {
392 compat = ieee80211_chanctx_reserved_chandef(local, ctx,
397 ieee80211_change_chanctx(local, ctx, compat);
405 bool ieee80211_is_radar_required(struct ieee80211_local *local)
409 lockdep_assert_held(&local->mtx);
412 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
424 ieee80211_chanctx_radar_required(struct ieee80211_local *local,
431 lockdep_assert_held(&local->chanctx_mtx);
432 lockdep_assert_held(&local->mtx);
435 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
452 ieee80211_alloc_chanctx(struct ieee80211_local *local,
458 lockdep_assert_held(&local->chanctx_mtx);
460 ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL);
471 ieee80211_recalc_chanctx_min_def(local, ctx);
476 static int ieee80211_add_chanctx(struct ieee80211_local *local,
482 lockdep_assert_held(&local->mtx);
483 lockdep_assert_held(&local->chanctx_mtx);
485 if (!local->use_chanctx)
486 local->hw.conf.radar_enabled = ctx->conf.radar_enabled;
489 changed = ieee80211_idle_off(local);
491 ieee80211_hw_config(local, changed);
493 if (!local->use_chanctx) {
494 local->_oper_chandef = ctx->conf.def;
495 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
497 err = drv_add_chanctx(local, ctx);
499 ieee80211_recalc_idle(local);
508 ieee80211_new_chanctx(struct ieee80211_local *local,
515 lockdep_assert_held(&local->mtx);
516 lockdep_assert_held(&local->chanctx_mtx);
518 ctx = ieee80211_alloc_chanctx(local, chandef, mode);
522 err = ieee80211_add_chanctx(local, ctx);
528 list_add_rcu(&ctx->list, &local->chanctx_list);
532 static void ieee80211_del_chanctx(struct ieee80211_local *local,
535 lockdep_assert_held(&local->chanctx_mtx);
537 if (!local->use_chanctx) {
538 struct cfg80211_chan_def *chandef = &local->_oper_chandef;
554 WARN_ON(local->hw.conf.radar_enabled &&
555 !list_empty(&local->chanctx_list));
557 local->hw.conf.radar_enabled = false;
559 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
561 drv_remove_chanctx(local, ctx);
564 ieee80211_recalc_idle(local);
567 static void ieee80211_free_chanctx(struct ieee80211_local *local,
570 lockdep_assert_held(&local->chanctx_mtx);
572 WARN_ON_ONCE(ieee80211_chanctx_refcount(local, ctx) != 0);
575 ieee80211_del_chanctx(local, ctx);
579 void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
587 lockdep_assert_held(&local->chanctx_mtx);
590 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
609 list_for_each_entry_rcu(sta, &local->sta_list, list) {
626 ieee80211_change_chanctx(local, ctx, compat);
629 static void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
634 lockdep_assert_held(&local->chanctx_mtx);
636 lockdep_assert_held(&local->mtx);
638 radar_enabled = ieee80211_chanctx_radar_required(local, chanctx);
645 if (!local->use_chanctx) {
646 local->hw.conf.radar_enabled = chanctx->conf.radar_enabled;
647 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
650 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RADAR);
656 struct ieee80211_local *local = sdata->local;
665 lockdep_is_held(&local->chanctx_mtx));
670 drv_unassign_vif_chanctx(local, sdata, curr_ctx);
676 ret = drv_assign_vif_chanctx(local, sdata, new_ctx);
690 if (curr_ctx && ieee80211_chanctx_num_assigned(local, curr_ctx) > 0) {
691 ieee80211_recalc_chanctx_chantype(local, curr_ctx);
692 ieee80211_recalc_smps_chanctx(local, curr_ctx);
693 ieee80211_recalc_radar_chanctx(local, curr_ctx);
694 ieee80211_recalc_chanctx_min_def(local, curr_ctx);
697 if (new_ctx && ieee80211_chanctx_num_assigned(local, new_ctx) > 0) {
699 ieee80211_recalc_chanctx_min_def(local, new_ctx);
712 void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
718 lockdep_assert_held(&local->chanctx_mtx);
724 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
778 sdata = rcu_dereference(local->monitor_sdata);
781 rx_chains_dynamic = rx_chains_static = local->rx_chains;
785 if (!local->use_chanctx) {
787 local->smps_mode = IEEE80211_SMPS_OFF;
789 local->smps_mode = IEEE80211_SMPS_DYNAMIC;
791 local->smps_mode = IEEE80211_SMPS_STATIC;
792 ieee80211_hw_config(local, 0);
801 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS);
808 struct ieee80211_local *local __maybe_unused = sdata->local;
815 lockdep_assert_held(&local->mtx);
824 lockdep_is_held(&local->chanctx_mtx));
837 struct ieee80211_local *local = sdata->local;
839 mutex_lock(&local->chanctx_mtx);
843 mutex_unlock(&local->chanctx_mtx);
850 lockdep_assert_held(&sdata->local->chanctx_mtx);
858 if (ieee80211_chanctx_refcount(sdata->local, ctx) == 0) {
874 ieee80211_free_chanctx(sdata->local, ctx);
886 struct ieee80211_local *local = sdata->local;
889 lockdep_assert_held(&local->chanctx_mtx);
892 if (curr_ctx && local->use_chanctx && !local->ops->switch_vif_chanctx)
895 new_ctx = ieee80211_find_reservation_chanctx(local, chandef, mode);
897 if (ieee80211_can_create_new_chanctx(local)) {
898 new_ctx = ieee80211_new_chanctx(local, chandef, mode);
928 list_for_each_entry(ctx, &local->chanctx_list,
952 new_ctx = ieee80211_alloc_chanctx(local, chandef, mode);
964 list_add_rcu(&new_ctx->list, &local->chanctx_list);
985 ieee80211_queue_work(&sdata->local->hw,
989 ieee80211_queue_work(&sdata->local->hw,
1024 struct ieee80211_local *local = sdata->local;
1031 lockdep_assert_held(&local->mtx);
1032 lockdep_assert_held(&local->chanctx_mtx);
1050 chandef = ieee80211_chanctx_non_reserved_chandef(local, new_ctx,
1055 ieee80211_change_chanctx(local, new_ctx, chandef);
1064 err = drv_switch_vif_chanctx(local, vif_chsw, 1,
1067 if (ieee80211_chanctx_refcount(local, new_ctx) == 0)
1068 ieee80211_free_chanctx(local, new_ctx);
1081 if (ieee80211_chanctx_refcount(local, old_ctx) == 0)
1082 ieee80211_free_chanctx(local, old_ctx);
1089 ieee80211_recalc_smps_chanctx(local, new_ctx);
1090 ieee80211_recalc_radar_chanctx(local, new_ctx);
1091 ieee80211_recalc_chanctx_min_def(local, new_ctx);
1104 struct ieee80211_local *local = sdata->local;
1125 chandef = ieee80211_chanctx_non_reserved_chandef(local, new_ctx,
1130 ieee80211_change_chanctx(local, new_ctx, chandef);
1137 if (ieee80211_chanctx_refcount(local, new_ctx) == 0)
1138 ieee80211_free_chanctx(local, new_ctx);
1153 lockdep_assert_held(&sdata->local->chanctx_mtx);
1173 static int ieee80211_chsw_switch_hwconf(struct ieee80211_local *local,
1178 lockdep_assert_held(&local->mtx);
1179 lockdep_assert_held(&local->chanctx_mtx);
1181 chandef = ieee80211_chanctx_reserved_chandef(local, new_ctx, NULL);
1185 local->hw.conf.radar_enabled = new_ctx->conf.radar_enabled;
1186 local->_oper_chandef = *chandef;
1187 ieee80211_hw_config(local, 0);
1192 static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,
1200 lockdep_assert_held(&local->mtx);
1201 lockdep_assert_held(&local->chanctx_mtx);
1208 list_for_each_entry(ctx, &local->chanctx_list, list) {
1232 err = drv_switch_vif_chanctx(local, vif_chsw, n_vifs,
1240 static int ieee80211_chsw_switch_ctxs(struct ieee80211_local *local)
1245 lockdep_assert_held(&local->mtx);
1246 lockdep_assert_held(&local->chanctx_mtx);
1248 list_for_each_entry(ctx, &local->chanctx_list, list) {
1255 ieee80211_del_chanctx(local, ctx->replace_ctx);
1256 err = ieee80211_add_chanctx(local, ctx);
1264 WARN_ON(ieee80211_add_chanctx(local, ctx));
1265 list_for_each_entry_continue_reverse(ctx, &local->chanctx_list, list) {
1272 ieee80211_del_chanctx(local, ctx);
1273 WARN_ON(ieee80211_add_chanctx(local, ctx->replace_ctx));
1279 static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
1287 lockdep_assert_held(&local->mtx);
1288 lockdep_assert_held(&local->chanctx_mtx);
1306 list_for_each_entry(ctx, &local->chanctx_list, list) {
1315 if (!local->use_chanctx)
1336 wiphy_info(local->hw.wiphy,
1372 WARN_ON(n_ctx > 1 && !local->use_chanctx) ||
1373 WARN_ON(!new_ctx && !local->use_chanctx)) {
1383 if (local->use_chanctx) {
1385 err = ieee80211_chsw_switch_vifs(local, n_vifs_switch);
1391 err = ieee80211_chsw_switch_ctxs(local);
1396 err = ieee80211_chsw_switch_hwconf(local, new_ctx);
1405 list_for_each_entry(ctx, &local->chanctx_list, list) {
1443 ieee80211_recalc_chanctx_chantype(local, ctx);
1444 ieee80211_recalc_smps_chanctx(local, ctx);
1445 ieee80211_recalc_radar_chanctx(local, ctx);
1446 ieee80211_recalc_chanctx_min_def(local, ctx);
1491 cfg80211_stop_iface(local->hw.wiphy,
1502 list_for_each_entry_safe(ctx, ctx_tmp, &local->chanctx_list, list) {
1517 list_for_each_entry(ctx, &local->chanctx_list, list) {
1533 struct ieee80211_local *local = sdata->local;
1538 lockdep_assert_held(&local->chanctx_mtx);
1541 lockdep_is_held(&local->chanctx_mtx));
1550 ieee80211_chanctx_num_reserved(local,
1558 if (ieee80211_chanctx_refcount(local, ctx) == 0)
1559 ieee80211_free_chanctx(local, ctx);
1565 ieee80211_vif_use_reserved_switch(local);
1572 struct ieee80211_local *local = sdata->local;
1577 lockdep_assert_held(&local->mtx);
1581 mutex_lock(&local->chanctx_mtx);
1583 ret = cfg80211_chandef_dfs_required(local->hw.wiphy,
1600 ctx = ieee80211_find_chanctx(local, chandef, mode);
1602 ctx = ieee80211_new_chanctx(local, chandef, mode);
1613 if (ieee80211_chanctx_refcount(local, ctx) == 0)
1614 ieee80211_free_chanctx(local, ctx);
1618 ieee80211_recalc_smps_chanctx(local, ctx);
1619 ieee80211_recalc_radar_chanctx(local, ctx);
1624 mutex_unlock(&local->chanctx_mtx);
1630 struct ieee80211_local *local = sdata->local;
1635 lockdep_assert_held(&local->mtx);
1636 lockdep_assert_held(&local->chanctx_mtx);
1674 err = ieee80211_vif_use_reserved_switch(local);
1680 wiphy_info(local->hw.wiphy,
1693 struct ieee80211_local *local = sdata->local;
1699 if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
1703 mutex_lock(&local->chanctx_mtx);
1716 lockdep_is_held(&local->chanctx_mtx));
1732 if (!ieee80211_chanctx_reserved_chandef(local, ctx, compat)) {
1752 ieee80211_recalc_chanctx_chantype(local, ctx);
1757 mutex_unlock(&local->chanctx_mtx);
1765 lockdep_assert_held(&sdata->local->mtx);
1767 mutex_lock(&sdata->local->chanctx_mtx);
1769 mutex_unlock(&sdata->local->chanctx_mtx);
1774 struct ieee80211_local *local = sdata->local;
1783 mutex_lock(&local->chanctx_mtx);
1786 lockdep_is_held(&local->chanctx_mtx));
1788 mutex_unlock(&local->chanctx_mtx);
1798 struct ieee80211_local *local = hw_to_local(hw);
1802 list_for_each_entry_rcu(ctx, &local->chanctx_list, list)