Lines Matching defs:local
15 static int ieee80211_chanctx_num_assigned(struct ieee80211_local *local,
21 lockdep_assert_held(&local->chanctx_mtx);
29 static int ieee80211_chanctx_num_reserved(struct ieee80211_local *local,
35 lockdep_assert_held(&local->chanctx_mtx);
43 int ieee80211_chanctx_refcount(struct ieee80211_local *local,
46 return ieee80211_chanctx_num_assigned(local, ctx) +
47 ieee80211_chanctx_num_reserved(local, ctx);
50 static int ieee80211_num_chanctx(struct ieee80211_local *local)
55 lockdep_assert_held(&local->chanctx_mtx);
57 list_for_each_entry(ctx, &local->chanctx_list, list)
63 static bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local)
65 lockdep_assert_held(&local->chanctx_mtx);
66 return ieee80211_num_chanctx(local) < ieee80211_max_num_channels(local);
72 struct ieee80211_local *local __maybe_unused = link->sdata->local;
76 lockdep_is_held(&local->chanctx_mtx));
84 ieee80211_chanctx_reserved_chandef(struct ieee80211_local *local,
90 lockdep_assert_held(&local->chanctx_mtx);
107 ieee80211_chanctx_non_reserved_chandef(struct ieee80211_local *local,
113 lockdep_assert_held(&local->chanctx_mtx);
135 ieee80211_chanctx_combined_chandef(struct ieee80211_local *local,
139 lockdep_assert_held(&local->chanctx_mtx);
141 compat = ieee80211_chanctx_reserved_chandef(local, ctx, compat);
145 compat = ieee80211_chanctx_non_reserved_chandef(local, ctx, compat);
153 ieee80211_chanctx_can_reserve_chandef(struct ieee80211_local *local,
157 lockdep_assert_held(&local->chanctx_mtx);
159 if (ieee80211_chanctx_combined_chandef(local, ctx, def))
163 ieee80211_chanctx_reserved_chandef(local, ctx, def))
170 ieee80211_find_reservation_chanctx(struct ieee80211_local *local,
176 lockdep_assert_held(&local->chanctx_mtx);
181 list_for_each_entry(ctx, &local->chanctx_list, list) {
188 if (!ieee80211_chanctx_can_reserve_chandef(local, ctx,
248 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
320 ieee80211_get_chanctx_max_required_bw(struct ieee80211_local *local,
328 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
341 sdata = rcu_dereference(local->monitor_sdata);
357 _ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
364 lockdep_assert_held(&local->chanctx_mtx);
379 max_bw = ieee80211_get_chanctx_max_required_bw(local, ctx, rsvd_for);
399 static void ieee80211_chan_bw_change(struct ieee80211_local *local,
405 local->hw.wiphy->bands[ctx->conf.def.chan->band];
408 list_for_each_entry_rcu(sta, &local->sta_list,
444 rate_control_rate_update(local, sband, sta, link_id,
456 void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
460 u32 changed = _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for);
466 ieee80211_chan_bw_change(local, ctx, true);
468 drv_change_chanctx(local, ctx, changed);
471 ieee80211_chan_bw_change(local, ctx, false);
474 static void _ieee80211_change_chanctx(struct ieee80211_local *local,
500 ieee80211_chan_bw_change(local, old_ctx, true);
503 ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for);
513 _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for);
514 drv_change_chanctx(local, ctx, changed);
516 if (!local->use_chanctx) {
517 local->_oper_chandef = *chandef;
518 ieee80211_hw_config(local, 0);
522 ieee80211_chan_bw_change(local, old_ctx, false);
525 static void ieee80211_change_chanctx(struct ieee80211_local *local,
530 _ieee80211_change_chanctx(local, ctx, old_ctx, chandef, NULL);
534 ieee80211_find_chanctx(struct ieee80211_local *local,
540 lockdep_assert_held(&local->chanctx_mtx);
545 list_for_each_entry(ctx, &local->chanctx_list, list) {
558 compat = ieee80211_chanctx_reserved_chandef(local, ctx,
563 ieee80211_change_chanctx(local, ctx, ctx, compat);
571 bool ieee80211_is_radar_required(struct ieee80211_local *local)
575 lockdep_assert_held(&local->mtx);
578 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
598 ieee80211_chanctx_radar_required(struct ieee80211_local *local,
605 lockdep_assert_held(&local->chanctx_mtx);
606 lockdep_assert_held(&local->mtx);
609 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
638 ieee80211_alloc_chanctx(struct ieee80211_local *local,
644 lockdep_assert_held(&local->chanctx_mtx);
646 ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL);
657 _ieee80211_recalc_chanctx_min_def(local, ctx, NULL);
662 static int ieee80211_add_chanctx(struct ieee80211_local *local,
668 lockdep_assert_held(&local->mtx);
669 lockdep_assert_held(&local->chanctx_mtx);
671 if (!local->use_chanctx)
672 local->hw.conf.radar_enabled = ctx->conf.radar_enabled;
675 changed = ieee80211_idle_off(local);
677 ieee80211_hw_config(local, changed);
679 if (!local->use_chanctx) {
680 local->_oper_chandef = ctx->conf.def;
681 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
683 err = drv_add_chanctx(local, ctx);
685 ieee80211_recalc_idle(local);
694 ieee80211_new_chanctx(struct ieee80211_local *local,
701 lockdep_assert_held(&local->mtx);
702 lockdep_assert_held(&local->chanctx_mtx);
704 ctx = ieee80211_alloc_chanctx(local, chandef, mode);
708 err = ieee80211_add_chanctx(local, ctx);
714 list_add_rcu(&ctx->list, &local->chanctx_list);
718 static void ieee80211_del_chanctx(struct ieee80211_local *local,
721 lockdep_assert_held(&local->chanctx_mtx);
723 if (!local->use_chanctx) {
724 struct cfg80211_chan_def *chandef = &local->_oper_chandef;
740 WARN_ON(local->hw.conf.radar_enabled &&
741 !list_empty(&local->chanctx_list));
743 local->hw.conf.radar_enabled = false;
745 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
747 drv_remove_chanctx(local, ctx);
750 ieee80211_recalc_idle(local);
753 static void ieee80211_free_chanctx(struct ieee80211_local *local,
756 lockdep_assert_held(&local->chanctx_mtx);
758 WARN_ON_ONCE(ieee80211_chanctx_refcount(local, ctx) != 0);
761 ieee80211_del_chanctx(local, ctx);
765 void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
773 lockdep_assert_held(&local->chanctx_mtx);
776 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
811 list_for_each_entry_rcu(sta, &local->sta_list, list) {
828 ieee80211_change_chanctx(local, ctx, ctx, compat);
831 static void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
836 lockdep_assert_held(&local->chanctx_mtx);
838 lockdep_assert_held(&local->mtx);
840 radar_enabled = ieee80211_chanctx_radar_required(local, chanctx);
847 if (!local->use_chanctx) {
848 local->hw.conf.radar_enabled = chanctx->conf.radar_enabled;
849 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
852 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RADAR);
859 struct ieee80211_local *local = sdata->local;
868 lockdep_is_held(&local->chanctx_mtx));
873 drv_unassign_vif_chanctx(local, sdata, link->conf, curr_ctx);
880 ieee80211_recalc_chanctx_min_def(local, new_ctx, link);
882 ret = drv_assign_vif_chanctx(local, sdata, link->conf, new_ctx);
896 if (curr_ctx && ieee80211_chanctx_num_assigned(local, curr_ctx) > 0) {
897 ieee80211_recalc_chanctx_chantype(local, curr_ctx);
898 ieee80211_recalc_smps_chanctx(local, curr_ctx);
899 ieee80211_recalc_radar_chanctx(local, curr_ctx);
900 ieee80211_recalc_chanctx_min_def(local, curr_ctx, NULL);
903 if (new_ctx && ieee80211_chanctx_num_assigned(local, new_ctx) > 0) {
905 ieee80211_recalc_chanctx_min_def(local, new_ctx, NULL);
917 void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
923 lockdep_assert_held(&local->chanctx_mtx);
929 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
986 sdata = rcu_dereference(local->monitor_sdata);
989 rx_chains_dynamic = rx_chains_static = local->rx_chains;
993 if (!local->use_chanctx) {
995 local->smps_mode = IEEE80211_SMPS_OFF;
997 local->smps_mode = IEEE80211_SMPS_DYNAMIC;
999 local->smps_mode = IEEE80211_SMPS_STATIC;
1000 ieee80211_hw_config(local, 0);
1009 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS);
1019 struct ieee80211_local *local __maybe_unused = sdata->local;
1026 lockdep_assert_held(&local->mtx);
1035 lockdep_is_held(&local->chanctx_mtx));
1057 struct ieee80211_local *local = link->sdata->local;
1059 mutex_lock(&local->chanctx_mtx);
1063 mutex_unlock(&local->chanctx_mtx);
1071 lockdep_assert_held(&sdata->local->chanctx_mtx);
1079 if (ieee80211_chanctx_refcount(sdata->local, ctx) == 0) {
1095 ieee80211_free_chanctx(sdata->local, ctx);
1108 struct ieee80211_local *local = sdata->local;
1111 lockdep_assert_held(&local->chanctx_mtx);
1114 if (curr_ctx && local->use_chanctx && !local->ops->switch_vif_chanctx)
1117 new_ctx = ieee80211_find_reservation_chanctx(local, chandef, mode);
1119 if (ieee80211_can_create_new_chanctx(local)) {
1120 new_ctx = ieee80211_new_chanctx(local, chandef, mode);
1150 list_for_each_entry(ctx, &local->chanctx_list,
1174 new_ctx = ieee80211_alloc_chanctx(local, chandef, mode);
1186 list_add_rcu(&new_ctx->list, &local->chanctx_list);
1209 ieee80211_queue_work(&sdata->local->hw,
1213 wiphy_delayed_work_queue(sdata->local->hw.wiphy,
1261 struct ieee80211_local *local = sdata->local;
1268 lockdep_assert_held(&local->mtx);
1269 lockdep_assert_held(&local->chanctx_mtx);
1287 chandef = ieee80211_chanctx_non_reserved_chandef(local, new_ctx,
1297 _ieee80211_change_chanctx(local, new_ctx, old_ctx, chandef, link);
1307 err = drv_switch_vif_chanctx(local, vif_chsw, 1,
1310 if (ieee80211_chanctx_refcount(local, new_ctx) == 0)
1311 ieee80211_free_chanctx(local, new_ctx);
1324 if (ieee80211_chanctx_refcount(local, old_ctx) == 0)
1325 ieee80211_free_chanctx(local, old_ctx);
1327 ieee80211_recalc_chanctx_min_def(local, new_ctx, NULL);
1328 ieee80211_recalc_smps_chanctx(local, new_ctx);
1329 ieee80211_recalc_radar_chanctx(local, new_ctx);
1343 struct ieee80211_local *local = sdata->local;
1364 chandef = ieee80211_chanctx_non_reserved_chandef(local, new_ctx,
1369 ieee80211_change_chanctx(local, new_ctx, new_ctx, chandef);
1376 if (ieee80211_chanctx_refcount(local, new_ctx) == 0)
1377 ieee80211_free_chanctx(local, new_ctx);
1393 lockdep_assert_held(&sdata->local->chanctx_mtx);
1413 static int ieee80211_chsw_switch_hwconf(struct ieee80211_local *local,
1418 lockdep_assert_held(&local->mtx);
1419 lockdep_assert_held(&local->chanctx_mtx);
1421 chandef = ieee80211_chanctx_reserved_chandef(local, new_ctx, NULL);
1425 local->hw.conf.radar_enabled = new_ctx->conf.radar_enabled;
1426 local->_oper_chandef = *chandef;
1427 ieee80211_hw_config(local, 0);
1432 static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,
1440 lockdep_assert_held(&local->mtx);
1441 lockdep_assert_held(&local->chanctx_mtx);
1448 list_for_each_entry(ctx, &local->chanctx_list, list) {
1472 err = drv_switch_vif_chanctx(local, vif_chsw, n_vifs,
1480 static int ieee80211_chsw_switch_ctxs(struct ieee80211_local *local)
1485 lockdep_assert_held(&local->mtx);
1486 lockdep_assert_held(&local->chanctx_mtx);
1488 list_for_each_entry(ctx, &local->chanctx_list, list) {
1495 ieee80211_del_chanctx(local, ctx->replace_ctx);
1496 err = ieee80211_add_chanctx(local, ctx);
1504 WARN_ON(ieee80211_add_chanctx(local, ctx));
1505 list_for_each_entry_continue_reverse(ctx, &local->chanctx_list, list) {
1512 ieee80211_del_chanctx(local, ctx);
1513 WARN_ON(ieee80211_add_chanctx(local, ctx->replace_ctx));
1519 static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
1526 lockdep_assert_held(&local->mtx);
1527 lockdep_assert_held(&local->chanctx_mtx);
1545 list_for_each_entry(ctx, &local->chanctx_list, list) {
1556 if (!local->use_chanctx)
1577 wiphy_info(local->hw.wiphy,
1613 WARN_ON(n_ctx > 1 && !local->use_chanctx) ||
1614 WARN_ON(!new_ctx && !local->use_chanctx)) {
1624 if (local->use_chanctx) {
1626 err = ieee80211_chsw_switch_vifs(local, n_vifs_switch);
1632 err = ieee80211_chsw_switch_ctxs(local);
1637 err = ieee80211_chsw_switch_hwconf(local, new_ctx);
1646 list_for_each_entry(ctx, &local->chanctx_list, list) {
1689 ieee80211_recalc_chanctx_chantype(local, ctx);
1690 ieee80211_recalc_smps_chanctx(local, ctx);
1691 ieee80211_recalc_radar_chanctx(local, ctx);
1692 ieee80211_recalc_chanctx_min_def(local, ctx, NULL);
1735 cfg80211_stop_iface(local->hw.wiphy,
1746 list_for_each_entry_safe(ctx, ctx_tmp, &local->chanctx_list, list) {
1761 list_for_each_entry(ctx, &local->chanctx_list, list) {
1781 struct ieee80211_local *local = sdata->local;
1786 lockdep_assert_held(&local->chanctx_mtx);
1789 lockdep_is_held(&local->chanctx_mtx));
1797 ieee80211_chanctx_num_reserved(local, link->reserved_chanctx) > 1)
1804 if (ieee80211_chanctx_refcount(local, ctx) == 0)
1805 ieee80211_free_chanctx(local, ctx);
1811 ieee80211_vif_use_reserved_switch(local);
1819 struct ieee80211_local *local = sdata->local;
1824 lockdep_assert_held(&local->mtx);
1832 mutex_lock(&local->chanctx_mtx);
1834 ret = cfg80211_chandef_dfs_required(local->hw.wiphy,
1851 ctx = ieee80211_find_chanctx(local, chandef, mode);
1853 ctx = ieee80211_new_chanctx(local, chandef, mode);
1864 if (ieee80211_chanctx_refcount(local, ctx) == 0)
1865 ieee80211_free_chanctx(local, ctx);
1869 ieee80211_recalc_smps_chanctx(local, ctx);
1870 ieee80211_recalc_radar_chanctx(local, ctx);
1875 mutex_unlock(&local->chanctx_mtx);
1882 struct ieee80211_local *local = sdata->local;
1887 lockdep_assert_held(&local->mtx);
1888 lockdep_assert_held(&local->chanctx_mtx);
1926 err = ieee80211_vif_use_reserved_switch(local);
1932 wiphy_info(local->hw.wiphy,
1947 struct ieee80211_local *local = sdata->local;
1953 if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
1957 mutex_lock(&local->chanctx_mtx);
1970 lockdep_is_held(&local->chanctx_mtx));
1986 if (!ieee80211_chanctx_reserved_chandef(local, ctx, compat)) {
2006 ieee80211_recalc_chanctx_chantype(local, ctx);
2011 mutex_unlock(&local->chanctx_mtx);
2019 mutex_lock(&sdata->local->chanctx_mtx);
2021 lockdep_assert_held(&sdata->local->mtx);
2024 mutex_unlock(&sdata->local->chanctx_mtx);
2033 struct ieee80211_local *local = sdata->local;
2042 mutex_lock(&local->chanctx_mtx);
2047 lockdep_is_held(&local->chanctx_mtx));
2050 mutex_unlock(&local->chanctx_mtx);
2060 struct ieee80211_local *local = hw_to_local(hw);
2064 list_for_each_entry_rcu(ctx, &local->chanctx_list, list)