From: Johannes Berg 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. Signed-off-by: Johannes Berg --- net/mac80211/he.c | 25 ++----------------------- net/mac80211/ht.c | 24 ++++++++---------------- net/mac80211/sta_info.c | 23 +++++++++++++++++++++++ net/mac80211/sta_info.h | 3 +++ 4 files changed, 36 insertions(+), 39 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; + sta_opmode.bw = ieee80211_sta_rx_bw_to_chan_width(link_sta->pub->bandwidth); - 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); + 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 0ea37016cd4f..85e0b6c5ff00 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -3765,3 +3765,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 39608a0abbb5..1da074dfffb4 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, -- 2.53.0