]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mac80211: allow rate_control_rate_init() for links
authorJohannes Berg <johannes.berg@intel.com>
Mon, 7 Oct 2024 12:00:53 +0000 (15:00 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 23 Oct 2024 14:43:23 +0000 (16:43 +0200)
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 <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20241007144851.c693274a908f.I0376da02e9f5a30eaa1b5d0d01371ff09506d453@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/cfg.c
net/mac80211/ibss.c
net/mac80211/mesh_plink.c
net/mac80211/mlme.c
net/mac80211/ocb.c
net/mac80211/rate.c
net/mac80211/rate.h

index ca4fd217be3eeb5caed9ae4329686f3f79bc87b6..ecc138869b4b0a7687302bbeb69c2eec67b93214 100644 (file)
@@ -1720,7 +1720,7 @@ static int sta_apply_auth_flags(struct ieee80211_local *local,
                 * before drv_sta_state() is called.
                 */
                if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
-                       rate_control_rate_init(sta);
+                       rate_control_rate_init_all_links(sta);
 
                ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
                if (ret)
@@ -2149,7 +2149,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
         */
        if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
            test_sta_flag(sta, WLAN_STA_ASSOC))
-               rate_control_rate_init(sta);
+               rate_control_rate_init_all_links(sta);
 
        return sta_info_insert(sta);
 }
@@ -5063,6 +5063,13 @@ ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
                return ret;
        }
 
+       if (test_sta_flag(sta, WLAN_STA_ASSOC)) {
+               struct link_sta_info *link_sta;
+
+               link_sta = sdata_dereference(sta->link[params->link_id], sdata);
+               rate_control_rate_init(link_sta);
+       }
+
        /* ieee80211_sta_activate_link frees the link upon failure */
        return ieee80211_sta_activate_link(sta, params->link_id);
 }
index 3f74bbceeca5edd89b211f241355996f7d383e05..08fac295ad5b7c3d60a9804a6a8c3c3c05c0feda 100644 (file)
@@ -569,7 +569,7 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta)
        if (!sta->sdata->u.ibss.control_port)
                sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
 
-       rate_control_rate_init(sta);
+       rate_control_rate_init(&sta->deflink);
 
        /* If it fails, maybe we raced another insertion? */
        if (sta_info_insert_rcu(sta))
@@ -1068,7 +1068,7 @@ static void ieee80211_update_sta_info(struct ieee80211_sub_if_data *sdata,
 
                /* Force rx_nss recalculation */
                sta->sta.deflink.rx_nss = 0;
-               rate_control_rate_init(sta);
+               rate_control_rate_init(&sta->deflink);
                if (sta->sta.deflink.rx_nss != rx_nss)
                        changed |= IEEE80211_RC_NSS_CHANGED;
 
index 42286aa3623c995a89bc9a5bea473f0753e3b7db..be0700d645498466abdabb03daefe46774f8bacc 100644 (file)
@@ -487,7 +487,7 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
        }
 
        if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
-               rate_control_rate_init(sta);
+               rate_control_rate_init(&sta->deflink);
        else
                rate_control_rate_update(local, sband, sta, 0, changed);
 out:
index f8fe711e102811d31c43aef17b102cb978022014..714f780cc0f5336bf1987594fd890e24e0f9b911 100644 (file)
@@ -5750,7 +5750,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
        /* links might have changed due to rejected ones, set them again */
        ieee80211_vif_set_links(sdata, valid_links, dormant_links);
 
-       rate_control_rate_init(sta);
+       rate_control_rate_init_all_links(sta);
 
        if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) {
                set_sta_flag(sta, WLAN_STA_MFP);
index f4c51e4a1e29a608aff0af66e318a397334ce1f6..6218abc3e4413fcf48a0b0790e76635895c2fc3d 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright: (c) 2014 Czech Technical University in Prague
  *            (c) 2014 Volkswagen Group Research
- * Copyright (C) 2022 - 2023 Intel Corporation
+ * Copyright (C) 2022 - 2024 Intel Corporation
  * Author:    Rostislav Lisovy <rostislav.lisovy@fel.cvut.cz>
  * Funded by: Volkswagen Group Research
  */
@@ -96,7 +96,7 @@ static struct sta_info *ieee80211_ocb_finish_sta(struct sta_info *sta)
        sta_info_move_state(sta, IEEE80211_STA_ASSOC);
        sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
 
-       rate_control_rate_init(sta);
+       rate_control_rate_init(&sta->deflink);
 
        /* If it fails, maybe we raced another insertion? */
        if (sta_info_insert_rcu(sta))
index 3dc9752188d58f1d45654c90d0d69d1b01397728..23b4f1af37e0f6e110a411d0c1e8b6cda0196b4b 100644 (file)
@@ -28,8 +28,9 @@ module_param(ieee80211_default_rc_algo, charp, 0644);
 MODULE_PARM_DESC(ieee80211_default_rc_algo,
                 "Default rate control algorithm for mac80211 to use");
 
-void rate_control_rate_init(struct sta_info *sta)
+void rate_control_rate_init(struct link_sta_info *link_sta)
 {
+       struct sta_info *sta = link_sta->sta;
        struct ieee80211_local *local = sta->sdata->local;
        struct rate_control_ref *ref = sta->rate_ctrl;
        struct ieee80211_sta *ista = &sta->sta;
@@ -37,11 +38,15 @@ void rate_control_rate_init(struct sta_info *sta)
        struct ieee80211_supported_band *sband;
        struct ieee80211_chanctx_conf *chanctx_conf;
 
-       ieee80211_sta_init_nss(&sta->deflink);
+       ieee80211_sta_init_nss(link_sta);
 
        if (!ref)
                return;
 
+       /* SW rate control isn't supported with MLO right now */
+       if (WARN_ON(ieee80211_vif_is_mld(&sta->sdata->vif)))
+               return;
+
        rcu_read_lock();
 
        chanctx_conf = rcu_dereference(sta->sdata->vif.bss_conf.chanctx_conf);
@@ -67,6 +72,21 @@ void rate_control_rate_init(struct sta_info *sta)
        set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
 }
 
+void rate_control_rate_init_all_links(struct sta_info *sta)
+{
+       int link_id;
+
+       for (link_id = 0; link_id < ARRAY_SIZE(sta->link); link_id++) {
+               struct link_sta_info *link_sta;
+
+               link_sta = sdata_dereference(sta->link[link_id], sta->sdata);
+               if (!link_sta)
+                       continue;
+
+               rate_control_rate_init(link_sta);
+       }
+}
+
 void rate_control_tx_status(struct ieee80211_local *local,
                            struct ieee80211_tx_status *st)
 {
index d6190f10fe7c4751e6d0b1a5d539e81a2c9143b6..8d3c8903b4ae186fe23093b46bbbae9554d1a282 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 2002-2005, Instant802 Networks, Inc.
  * Copyright 2005, Devicescape Software, Inc.
  * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
- * Copyright (C) 2022 Intel Corporation
+ * Copyright (C) 2022, 2024 Intel Corporation
  */
 
 #ifndef IEEE80211_RATE_H
@@ -29,7 +29,8 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
 void rate_control_tx_status(struct ieee80211_local *local,
                            struct ieee80211_tx_status *st);
 
-void rate_control_rate_init(struct sta_info *sta);
+void rate_control_rate_init(struct link_sta_info *link_sta);
+void rate_control_rate_init_all_links(struct sta_info *sta);
 void rate_control_rate_update(struct ieee80211_local *local,
                              struct ieee80211_supported_band *sband,
                              struct sta_info *sta,