summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2026-05-29 11:25:06 +0300
committerJohannes Berg <johannes.berg@intel.com>2026-06-03 15:11:58 +0300
commitece981f88e930b2071ab045eb248b5e2292c9327 (patch)
tree70b8973851726bda4ec8a76b7c0aa64bbacb1376
parentf576db12f1f0adafd8fd1c395e377b7b37a77b7b (diff)
downloadlinux-ece981f88e930b2071ab045eb248b5e2292c9327.tar.xz
wifi: mac80211: refactor link STA bandwidth update
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>
-rw-r--r--net/mac80211/he.c25
-rw-r--r--net/mac80211/ht.c26
-rw-r--r--net/mac80211/sta_info.c23
-rw-r--r--net/mac80211/sta_info.h3
4 files changed, 37 insertions, 40 deletions
diff --git a/net/mac80211/he.c b/net/mac80211/he.c
index b7d9e4cb6ba6..5acf482c177a 100644
--- a/net/mac80211/he.c
+++ b/net/mac80211/he.c
@@ -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) {
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index 6285ac15c16c..e1e1b7f82f3f 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -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);
}
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 857c7d3355c7..205e8d5c0c72 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -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;
+}
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index e1837e986837..3abac031d01c 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -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,