wifi: mac80211: Support multi link in ieee80211_recalc_min_chandef()
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Wed, 22 Jun 2022 13:15:56 +0000 (16:15 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 15 Jul 2022 09:43:20 +0000 (11:43 +0200)
Recalculate min channel context for the given or all interface
links, depending on the caller. For a station state change, we
need to recalculate all of them since we don't know which link
(or multiple) it might be on.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ieee80211_i.h
net/mac80211/sta_info.c
net/mac80211/util.c
net/mac80211/vht.c

index 163e62dab0457010ff48f1d2bff55dfbb7687ea3..877f2441b74b576150859b264c9c424b4185e534 100644 (file)
@@ -2335,7 +2335,8 @@ int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
                                 enum ieee80211_smps_mode smps_mode);
 void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata,
                           struct ieee80211_link_data *link);
-void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
+void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata,
+                                 int link_id);
 
 size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
 u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
index 88ff61aadd96c3a6be82f038fcc29d54e6f26b77..f52a7fa6dde58f25d722920263a13b8cb9dd3254 100644 (file)
@@ -780,7 +780,7 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
         * change, this enables driver using the updated channel context right away.
         */
        if (sta->sta_state >= IEEE80211_STA_ASSOC) {
-               ieee80211_recalc_min_chandef(sta->sdata);
+               ieee80211_recalc_min_chandef(sta->sdata, -1);
                if (!sta->sta.support_p2p_ps)
                        ieee80211_recalc_p2p_go_ps_allowed(sta->sdata);
        }
@@ -2136,7 +2136,7 @@ int sta_info_move_state(struct sta_info *sta,
                        set_bit(WLAN_STA_AUTH, &sta->_flags);
                } else if (sta->sta_state == IEEE80211_STA_ASSOC) {
                        clear_bit(WLAN_STA_ASSOC, &sta->_flags);
-                       ieee80211_recalc_min_chandef(sta->sdata);
+                       ieee80211_recalc_min_chandef(sta->sdata, -1);
                        if (!sta->sta.support_p2p_ps)
                                ieee80211_recalc_p2p_go_ps_allowed(sta->sdata);
                }
@@ -2145,7 +2145,7 @@ int sta_info_move_state(struct sta_info *sta,
                if (sta->sta_state == IEEE80211_STA_AUTH) {
                        set_bit(WLAN_STA_ASSOC, &sta->_flags);
                        sta->assoc_at = ktime_get_boottime_ns();
-                       ieee80211_recalc_min_chandef(sta->sdata);
+                       ieee80211_recalc_min_chandef(sta->sdata, -1);
                        if (!sta->sta.support_p2p_ps)
                                ieee80211_recalc_p2p_go_ps_allowed(sta->sdata);
                } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
index 2ff8d1ec564c699d4879f3a9cdee22f70bee6bc6..739c05fdb9bb182683b41b4b620f2137d43ae39e 100644 (file)
@@ -2839,22 +2839,48 @@ void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata,
        mutex_unlock(&local->chanctx_mtx);
 }
 
-void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata)
+void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata,
+                                 int link_id)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_chanctx_conf *chanctx_conf;
        struct ieee80211_chanctx *chanctx;
+       int i;
 
        mutex_lock(&local->chanctx_mtx);
 
-       chanctx_conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf,
-                                                lockdep_is_held(&local->chanctx_mtx));
+       for (i = 0; i < ARRAY_SIZE(sdata->vif.link_conf); i++) {
+               struct ieee80211_bss_conf *bss_conf;
 
-       if (WARN_ON_ONCE(!chanctx_conf))
-               goto unlock;
+               if (link_id >= 0 && link_id != i)
+                       continue;
 
-       chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf);
-       ieee80211_recalc_chanctx_min_def(local, chanctx);
+               rcu_read_lock();
+               bss_conf = rcu_dereference(sdata->vif.link_conf[i]);
+               if (!bss_conf) {
+                       rcu_read_unlock();
+                       continue;
+               }
+
+               chanctx_conf = rcu_dereference_protected(bss_conf->chanctx_conf,
+                                                        lockdep_is_held(&local->chanctx_mtx));
+               /*
+                * Since we hold the chanctx_mtx (checked above)
+                * we can take the chanctx_conf pointer out of the
+                * RCU critical section, it cannot go away without
+                * the mutex. Just the way we reached it could - in
+                * theory - go away, but we don't really care and
+                * it really shouldn't happen anyway.
+                */
+               rcu_read_unlock();
+
+               if (WARN_ON_ONCE(!chanctx_conf))
+                       goto unlock;
+
+               chanctx = container_of(chanctx_conf, struct ieee80211_chanctx,
+                                      conf);
+               ieee80211_recalc_chanctx_min_def(local, chanctx);
+       }
  unlock:
        mutex_unlock(&local->chanctx_mtx);
 }
index c804890dc62332f1bccfb03ae03f28351f481acb..b2b09d421e8b8f0e61333927af21ea6c9787aa8c 100644 (file)
@@ -731,7 +731,7 @@ void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
                                                    opmode, band);
 
        if (changed > 0) {
-               ieee80211_recalc_min_chandef(sdata);
+               ieee80211_recalc_min_chandef(sdata, link_sta->link_id);
                rate_control_rate_update(local, sband, link_sta->sta,
                                         link_sta->link_id, changed);
        }