Skip to content

Commit f828deb

Browse files
committed
wifi: mac80211: allow rate_control_rate_init() for links
Andrei previously fixed an issue in the client where the NSS for links other than the primary/assoc/deflink isn't set. The same issue appears to exist on the AP side, because there's only a call to rate_control_rate_init() for the deflink, and not any other links. Rework the code a bit to do rate_control_rate_init() for links, even if it really doesn't work with software rate control yet, it does other things as well. Also add rate_control_rate_init_all_links() to actually do it properly when moving to ASSOC state in cfg80211. Change the explicit call to ieee80211_sta_init_nss() to instead be rate_control_rate_init() now in the client code, but also add a call to rate_control_rate_init() when a link is added in AP mode and the STA is already associated. This should fix the NSS initialization issue, and perhaps pave the way for actual software rate scaling a bit, in case anyone cares in the future, but that of course needs a lot more than just the init call. We still need to fix the rate control _update_ as well, and the sta_rc_update() driver method especially, but that will be in a different patch. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://patch.msgid.link/20241007144851.c693274a908f.I0376da02e9f5a30eaa1b5d0d01371ff09506d453@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent c4382d5 commit f828deb

File tree

7 files changed

+40
-12
lines changed

7 files changed

+40
-12
lines changed

net/mac80211/cfg.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ static int sta_apply_auth_flags(struct ieee80211_local *local,
17201720
* before drv_sta_state() is called.
17211721
*/
17221722
if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1723-
rate_control_rate_init(sta);
1723+
rate_control_rate_init_all_links(sta);
17241724

17251725
ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
17261726
if (ret)
@@ -2149,7 +2149,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
21492149
*/
21502150
if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
21512151
test_sta_flag(sta, WLAN_STA_ASSOC))
2152-
rate_control_rate_init(sta);
2152+
rate_control_rate_init_all_links(sta);
21532153

21542154
return sta_info_insert(sta);
21552155
}
@@ -5063,6 +5063,13 @@ ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
50635063
return ret;
50645064
}
50655065

5066+
if (test_sta_flag(sta, WLAN_STA_ASSOC)) {
5067+
struct link_sta_info *link_sta;
5068+
5069+
link_sta = sdata_dereference(sta->link[params->link_id], sdata);
5070+
rate_control_rate_init(link_sta);
5071+
}
5072+
50665073
/* ieee80211_sta_activate_link frees the link upon failure */
50675074
return ieee80211_sta_activate_link(sta, params->link_id);
50685075
}

net/mac80211/ibss.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta)
569569
if (!sta->sdata->u.ibss.control_port)
570570
sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
571571

572-
rate_control_rate_init(sta);
572+
rate_control_rate_init(&sta->deflink);
573573

574574
/* If it fails, maybe we raced another insertion? */
575575
if (sta_info_insert_rcu(sta))
@@ -1068,7 +1068,7 @@ static void ieee80211_update_sta_info(struct ieee80211_sub_if_data *sdata,
10681068

10691069
/* Force rx_nss recalculation */
10701070
sta->sta.deflink.rx_nss = 0;
1071-
rate_control_rate_init(sta);
1071+
rate_control_rate_init(&sta->deflink);
10721072
if (sta->sta.deflink.rx_nss != rx_nss)
10731073
changed |= IEEE80211_RC_NSS_CHANGED;
10741074

net/mac80211/mesh_plink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
487487
}
488488

489489
if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
490-
rate_control_rate_init(sta);
490+
rate_control_rate_init(&sta->deflink);
491491
else
492492
rate_control_rate_update(local, sband, sta, 0, changed);
493493
out:

net/mac80211/mlme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5750,7 +5750,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
57505750
/* links might have changed due to rejected ones, set them again */
57515751
ieee80211_vif_set_links(sdata, valid_links, dormant_links);
57525752

5753-
rate_control_rate_init(sta);
5753+
rate_control_rate_init_all_links(sta);
57545754

57555755
if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) {
57565756
set_sta_flag(sta, WLAN_STA_MFP);

net/mac80211/ocb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright: (c) 2014 Czech Technical University in Prague
66
* (c) 2014 Volkswagen Group Research
7-
* Copyright (C) 2022 - 2023 Intel Corporation
7+
* Copyright (C) 2022 - 2024 Intel Corporation
88
* Author: Rostislav Lisovy <[email protected]>
99
* Funded by: Volkswagen Group Research
1010
*/
@@ -96,7 +96,7 @@ static struct sta_info *ieee80211_ocb_finish_sta(struct sta_info *sta)
9696
sta_info_move_state(sta, IEEE80211_STA_ASSOC);
9797
sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
9898

99-
rate_control_rate_init(sta);
99+
rate_control_rate_init(&sta->deflink);
100100

101101
/* If it fails, maybe we raced another insertion? */
102102
if (sta_info_insert_rcu(sta))

net/mac80211/rate.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,25 @@ module_param(ieee80211_default_rc_algo, charp, 0644);
2828
MODULE_PARM_DESC(ieee80211_default_rc_algo,
2929
"Default rate control algorithm for mac80211 to use");
3030

31-
void rate_control_rate_init(struct sta_info *sta)
31+
void rate_control_rate_init(struct link_sta_info *link_sta)
3232
{
33+
struct sta_info *sta = link_sta->sta;
3334
struct ieee80211_local *local = sta->sdata->local;
3435
struct rate_control_ref *ref = sta->rate_ctrl;
3536
struct ieee80211_sta *ista = &sta->sta;
3637
void *priv_sta = sta->rate_ctrl_priv;
3738
struct ieee80211_supported_band *sband;
3839
struct ieee80211_chanctx_conf *chanctx_conf;
3940

40-
ieee80211_sta_init_nss(&sta->deflink);
41+
ieee80211_sta_init_nss(link_sta);
4142

4243
if (!ref)
4344
return;
4445

46+
/* SW rate control isn't supported with MLO right now */
47+
if (WARN_ON(ieee80211_vif_is_mld(&sta->sdata->vif)))
48+
return;
49+
4550
rcu_read_lock();
4651

4752
chanctx_conf = rcu_dereference(sta->sdata->vif.bss_conf.chanctx_conf);
@@ -67,6 +72,21 @@ void rate_control_rate_init(struct sta_info *sta)
6772
set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
6873
}
6974

75+
void rate_control_rate_init_all_links(struct sta_info *sta)
76+
{
77+
int link_id;
78+
79+
for (link_id = 0; link_id < ARRAY_SIZE(sta->link); link_id++) {
80+
struct link_sta_info *link_sta;
81+
82+
link_sta = sdata_dereference(sta->link[link_id], sta->sdata);
83+
if (!link_sta)
84+
continue;
85+
86+
rate_control_rate_init(link_sta);
87+
}
88+
}
89+
7090
void rate_control_tx_status(struct ieee80211_local *local,
7191
struct ieee80211_tx_status *st)
7292
{

net/mac80211/rate.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright 2002-2005, Instant802 Networks, Inc.
44
* Copyright 2005, Devicescape Software, Inc.
55
* Copyright (c) 2006 Jiri Benc <[email protected]>
6-
* Copyright (C) 2022 Intel Corporation
6+
* Copyright (C) 2022, 2024 Intel Corporation
77
*/
88

99
#ifndef IEEE80211_RATE_H
@@ -29,7 +29,8 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
2929
void rate_control_tx_status(struct ieee80211_local *local,
3030
struct ieee80211_tx_status *st);
3131

32-
void rate_control_rate_init(struct sta_info *sta);
32+
void rate_control_rate_init(struct link_sta_info *link_sta);
33+
void rate_control_rate_init_all_links(struct sta_info *sta);
3334
void rate_control_rate_update(struct ieee80211_local *local,
3435
struct ieee80211_supported_band *sband,
3536
struct sta_info *sta,

0 commit comments

Comments
 (0)