wifi: iwlwifi: mld: enable OMI bandwidth reduction on 6 GHz
authorJohannes Berg <johannes.berg@intel.com>
Sun, 9 Mar 2025 05:36:47 +0000 (07:36 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 11 Mar 2025 15:29:25 +0000 (16:29 +0100)
Due to the iwl_mld_get_chandef_from_chanctx() logic, even after
the OMI handshake to reduce bandwidth the driver wouldn't apply
that to the PHY context, since it always uses the normal, not
the reduced, configuration on 6 GHz (not strictly always, but
OMI will only apply if the original bandwidth is > 80 MHz.) Fix
this by making that selection contingent on AP mode. Refactor
the code a bit to also make it clearer why the min_def isn't
used in that case (for FILS.)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250309073442.2706cbd0b100.Ic34636b1aee81a140eb690fca8139909a58f8e8b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mld/link.c
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
drivers/net/wireless/intel/iwlwifi/mld/phy.c
drivers/net/wireless/intel/iwlwifi/mld/phy.h
drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c

index f6d482817f1b78fea023dc648a124b4eb9917f9e..1db69aee4e9fa486beb5ea22d409719ca05b9bf6 100644 (file)
@@ -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;
index 27ef41d694796bdc48baf1f1e7873aa89b509970..91e201fde72aa959371503045e093009fcc7a1f5 100644 (file)
@@ -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 |
index c38f101628de3d3695d95c0032fe1030429da889..2fbc8090088bec943a1e6878a7fd28d1b21b9b0b 100644 (file)
@@ -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)
index 357bc9fe962498d95d03789524028dbf2c661ded..2212a89321b7e5678651546247b57b2f293a8bce 100644 (file)
@@ -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__ */
index b6049918b5dba2e5cf79920dd22e1c5a872509d2..6331cd91cdf6e61636afc77540fa73b56fd6ea45 100644 (file)
@@ -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;
 }