]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mac80211: refactor link STA bandwidth update
authorJohannes Berg <johannes.berg@intel.com>
Fri, 29 May 2026 08:25:06 +0000 (10:25 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 3 Jun 2026 12:11:58 +0000 (14:11 +0200)
There's similar code in two places in HT and HE, and we need to add
the same again for UHR. Rename ieee80211_link_sta_rc_update_omi()
to ieee80211_link_sta_update_rc_bw() and move it to sta_info.c and
update existing code that can use it to do so.

Link: https://patch.msgid.link/20260529102644.577c2f304d33.I09df4fce83c4e3e6deddfecbea74ffdbeedb4927@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/he.c
net/mac80211/ht.c
net/mac80211/sta_info.c
net/mac80211/sta_info.h

index b7d9e4cb6ba6eeafee51b198e140e67985042d12..5acf482c177a7e412255260c183b7c3800e3b7b7 100644 (file)
@@ -262,27 +262,6 @@ ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif,
        }
 }
 
-static void ieee80211_link_sta_rc_update_omi(struct ieee80211_link_data *link,
-                                            struct link_sta_info *link_sta)
-{
-       struct ieee80211_sub_if_data *sdata = link->sdata;
-       struct ieee80211_supported_band *sband;
-       enum ieee80211_sta_rx_bandwidth new_bw;
-       enum nl80211_band band;
-
-       band = link->conf->chanreq.oper.chan->band;
-       sband = sdata->local->hw.wiphy->bands[band];
-
-       new_bw = ieee80211_sta_current_bw(link_sta, &link->conf->chanreq.oper,
-                                         IEEE80211_STA_BW_TX_TO_STA);
-       if (link_sta->pub->bandwidth == new_bw)
-               return;
-
-       link_sta->pub->bandwidth = new_bw;
-       rate_control_rate_update(sdata->local, sband, link_sta,
-                                IEEE80211_RC_BW_CHANGED);
-}
-
 bool ieee80211_prepare_rx_omi_bw(struct ieee80211_link_sta *pub_link_sta,
                                 enum ieee80211_sta_rx_bandwidth bw)
 {
@@ -323,7 +302,7 @@ bool ieee80211_prepare_rx_omi_bw(struct ieee80211_link_sta *pub_link_sta,
 
        if (bw < link_sta->rx_omi_bw_staging) {
                link_sta->rx_omi_bw_tx = bw;
-               ieee80211_link_sta_rc_update_omi(link, link_sta);
+               ieee80211_link_sta_update_rc_bw(link, link_sta);
        } else {
                link_sta->rx_omi_bw_rx = bw;
                ieee80211_recalc_chanctx_min_def(local, chanctx);
@@ -365,7 +344,7 @@ void ieee80211_finalize_rx_omi_bw(struct ieee80211_link_sta *pub_link_sta)
                /* rate control in finalize only when widening bandwidth */
                WARN_ON(link_sta->rx_omi_bw_tx > link_sta->rx_omi_bw_staging);
                link_sta->rx_omi_bw_tx = link_sta->rx_omi_bw_staging;
-               ieee80211_link_sta_rc_update_omi(link, link_sta);
+               ieee80211_link_sta_update_rc_bw(link, link_sta);
        }
 
        if (link_sta->rx_omi_bw_rx != link_sta->rx_omi_bw_staging) {
index 6285ac15c16c4ca75cc05ed8d44ca8df84357e12..e1e1b7f82f3feadb1397931ebe79d73773d260e4 100644 (file)
@@ -584,9 +584,10 @@ void ieee80211_ht_handle_chanwidth_notif(struct ieee80211_local *local,
                                         struct link_sta_info *link_sta,
                                         u8 chanwidth, enum nl80211_band band)
 {
-       enum ieee80211_sta_rx_bandwidth max_bw, new_bw;
-       struct ieee80211_supported_band *sband;
-       struct sta_opmode_info sta_opmode = {};
+       enum ieee80211_sta_rx_bandwidth max_bw;
+       struct sta_opmode_info sta_opmode = {
+               .changed = STA_OPMODE_MAX_BW_CHANGED,
+       };
        struct ieee80211_link_data *link;
 
        lockdep_assert_wiphy(local->hw.wiphy);
@@ -602,21 +603,12 @@ void ieee80211_ht_handle_chanwidth_notif(struct ieee80211_local *local,
 
        /* set op_mode_bw and recalc sta bw */
        link_sta->op_mode_bw = max_bw;
-       new_bw = ieee80211_sta_current_bw(link_sta, &link->conf->chanreq.oper,
-                                         IEEE80211_STA_BW_TX_TO_STA);
 
-       if (link_sta->pub->bandwidth == new_bw)
+       if (!ieee80211_link_sta_update_rc_bw(link, link_sta))
                return;
 
-       link_sta->pub->bandwidth = new_bw;
-       sband = local->hw.wiphy->bands[band];
-       sta_opmode.bw = ieee80211_sta_rx_bw_to_chan_width(new_bw);
-       sta_opmode.changed = STA_OPMODE_MAX_BW_CHANGED;
-
-       rate_control_rate_update(local, sband, link_sta,
-                                IEEE80211_RC_BW_CHANGED);
-       cfg80211_sta_opmode_change_notify(sdata->dev,
-                                         sta->addr,
-                                         &sta_opmode,
-                                         GFP_KERNEL);
+       sta_opmode.bw = ieee80211_sta_rx_bw_to_chan_width(link_sta->pub->bandwidth);
+
+       cfg80211_sta_opmode_change_notify(sdata->dev, sta->addr,
+                                         &sta_opmode, GFP_KERNEL);
 }
index 857c7d3355c7289e1372a10cffef97eda3ad6bbc..205e8d5c0c72975da6ce2826f0b1e3d500d029e8 100644 (file)
@@ -3775,3 +3775,26 @@ ieee80211_sta_current_bw(struct link_sta_info *link_sta,
        /* unreachable */
        return IEEE80211_STA_RX_BW_20;
 }
+
+bool ieee80211_link_sta_update_rc_bw(struct ieee80211_link_data *link,
+                                    struct link_sta_info *link_sta)
+{
+       struct ieee80211_sub_if_data *sdata = link->sdata;
+       struct ieee80211_supported_band *sband;
+       enum ieee80211_sta_rx_bandwidth new_bw;
+       enum nl80211_band band;
+
+       band = link->conf->chanreq.oper.chan->band;
+       sband = sdata->local->hw.wiphy->bands[band];
+
+       new_bw = ieee80211_sta_current_bw(link_sta, &link->conf->chanreq.oper,
+                                         IEEE80211_STA_BW_TX_TO_STA);
+       if (link_sta->pub->bandwidth == new_bw)
+               return false;
+
+       link_sta->pub->bandwidth = new_bw;
+       rate_control_rate_update(sdata->local, sband, link_sta,
+                                IEEE80211_RC_BW_CHANGED);
+
+       return true;
+}
index e1837e986837f89e56802e78d35d68731865f5a6..3abac031d01cfb8e3379970f1038b92fca20b536 100644 (file)
@@ -1015,6 +1015,9 @@ ieee80211_sta_current_bw(struct link_sta_info *link_sta,
                         struct cfg80211_chan_def *chandef,
                         enum ieee80211_sta_bw_direction direction);
 
+bool ieee80211_link_sta_update_rc_bw(struct ieee80211_link_data *link,
+                                    struct link_sta_info *link_sta);
+
 enum sta_stats_type {
        STA_STATS_RATE_TYPE_INVALID = 0,
        STA_STATS_RATE_TYPE_LEGACY,