@@ -67,7 +67,7 @@ static void iwl_mld_fill_rates(struct iwl_mld *mld,
__le32 *cck_rates, __le32 *ofdm_rates)
{
struct cfg80211_chan_def *chandef =
- iwl_mld_get_chandef_from_chanctx(chan_ctx);
+ iwl_mld_get_chandef_from_chanctx(mld, chan_ctx);
struct ieee80211_supported_band *sband =
mld->hw->wiphy->bands[chandef->chan->band];
unsigned long basic = link->basic_rates;
@@ -840,7 +840,7 @@ int iwl_mld_add_chanctx(struct ieee80211_hw *hw,
phy->mld = mld;
phy->fw_id = fw_id;
- phy->chandef = *iwl_mld_get_chandef_from_chanctx(ctx);
+ phy->chandef = *iwl_mld_get_chandef_from_chanctx(mld, ctx);
ret = iwl_mld_phy_fw_action(mld, ctx, FW_CTXT_ACTION_ADD);
if (ret) {
@@ -872,7 +872,7 @@ void iwl_mld_change_chanctx(struct ieee80211_hw *hw,
struct iwl_mld *mld = IWL_MAC80211_GET_MLD(hw);
struct iwl_mld_phy *phy = iwl_mld_phy_from_mac80211(ctx);
struct cfg80211_chan_def *chandef =
- iwl_mld_get_chandef_from_chanctx(ctx);
+ iwl_mld_get_chandef_from_chanctx(mld, ctx);
/* We don't care about these */
if (!(changed & ~(IEEE80211_CHANCTX_CHANGE_RX_CHAINS |
@@ -22,16 +22,55 @@ int iwl_mld_allocate_fw_phy_id(struct iwl_mld *mld)
}
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mld_allocate_fw_phy_id);
-struct cfg80211_chan_def *
-iwl_mld_get_chandef_from_chanctx(struct ieee80211_chanctx_conf *ctx)
+struct iwl_mld_chanctx_usage_data {
+ struct iwl_mld *mld;
+ struct ieee80211_chanctx_conf *ctx;
+ bool use_def;
+};
+
+static bool iwl_mld_chanctx_fils_enabled(struct ieee80211_vif *vif,
+ struct ieee80211_chanctx_conf *ctx)
{
- bool use_def = cfg80211_channel_is_psc(ctx->def.chan) ||
+ if (vif->type != NL80211_IFTYPE_AP)
+ return false;
+
+ return cfg80211_channel_is_psc(ctx->def.chan) ||
(ctx->def.chan->band == NL80211_BAND_6GHZ &&
ctx->def.width >= NL80211_CHAN_WIDTH_80);
+}
+
+static void iwl_mld_chanctx_usage_iter(void *_data, u8 *mac,
+ struct ieee80211_vif *vif)
+{
+ struct iwl_mld_chanctx_usage_data *data = _data;
+ struct ieee80211_bss_conf *link_conf;
+ int link_id;
+
+ for_each_vif_active_link(vif, link_conf, link_id) {
+ if (rcu_access_pointer(link_conf->chanctx_conf) != data->ctx)
+ continue;
+
+ if (iwl_mld_chanctx_fils_enabled(vif, data->ctx))
+ data->use_def = true;
+ }
+}
+
+struct cfg80211_chan_def *
+iwl_mld_get_chandef_from_chanctx(struct iwl_mld *mld,
+ struct ieee80211_chanctx_conf *ctx)
+{
+ struct iwl_mld_chanctx_usage_data data = {
+ .mld = mld,
+ .ctx = ctx,
+ };
+
+ ieee80211_iterate_active_interfaces_mtx(mld->hw,
+ IEEE80211_IFACE_ITER_NORMAL,
+ iwl_mld_chanctx_usage_iter,
+ &data);
- return use_def ? &ctx->def : &ctx->min_def;
+ return data.use_def ? &ctx->def : &ctx->min_def;
}
-EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mld_get_chandef_from_chanctx);
static u8
iwl_mld_nl80211_width_to_fw(enum nl80211_chan_width width)
@@ -48,7 +48,8 @@ int iwl_mld_allocate_fw_phy_id(struct iwl_mld *mld);
int iwl_mld_phy_fw_action(struct iwl_mld *mld,
struct ieee80211_chanctx_conf *ctx, u32 action);
struct cfg80211_chan_def *
-iwl_mld_get_chandef_from_chanctx(struct ieee80211_chanctx_conf *ctx);
+iwl_mld_get_chandef_from_chanctx(struct iwl_mld *mld,
+ struct ieee80211_chanctx_conf *ctx);
u8 iwl_mld_get_fw_ctrl_pos(const struct cfg80211_chan_def *chandef);
#endif /* __iwl_mld_phy_h__ */
@@ -169,7 +169,7 @@ iwlmld_kunit_add_chanctx_from_def(struct cfg80211_chan_def *def)
phy->fw_id = fw_id;
phy->mld = mld;
- phy->chandef = *iwl_mld_get_chandef_from_chanctx(ctx);
+ phy->chandef = *def;
return ctx;
}