wifi: mac80211: mlme: unify CSA handling
authorJohannes Berg <johannes.berg@intel.com>
Wed, 28 Feb 2024 08:55:46 +0000 (09:55 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 4 Mar 2024 13:34:01 +0000 (14:34 +0100)
Unify all the CSA handling, including handling of a beacon
after the CSA, into ieee80211_sta_process_chanswitch().

The CRC of the beacon will change due to changes in the
CSA/ECSA elements, so there's really no need to have the
'beacon after CSA' handling before the CRC processing or
to change the beacon_crc_valid value here.

Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240228095719.e269c0e02905.I9dc68ff1e84d51349822bc7d3b33b578fcf8e360@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/mlme.c

index 3d5cc3dd923887b9cfa672e0df97b809b0570110..2180b1ba0e4205d69fed0e9a77d6d43e3d1fb6e1 100644 (file)
@@ -1934,11 +1934,6 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link)
 
        link->conf->csa_active = false;
        link->u.mgd.csa_waiting_bcn = false;
-       /*
-        * If the CSA IE is still present on the beacon after the switch,
-        * we need to consider it as a new CSA (possibly to self).
-        */
-       link->u.mgd.beacon_crc_valid = false;
 
        ret = drv_post_channel_switch(link);
        if (ret) {
@@ -2053,18 +2048,32 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
        if (res < 0)
                goto drop_connection;
 
-       if (beacon && link->conf->csa_active &&
-           !link->u.mgd.csa_waiting_bcn) {
-               if (res)
+       if (link->conf->csa_active) {
+               /* already processing - disregard action frames */
+               if (!beacon)
+                       return;
+
+               if (link->u.mgd.csa_waiting_bcn) {
+                       ieee80211_chswitch_post_beacon(link);
+                       /*
+                        * If the CSA IE is still present in the beacon after
+                        * the switch, we need to consider it as a new CSA
+                        * (possibly to self) - this happens by not returning
+                        * here so we'll get to the check below.
+                        */
+               } else if (res) {
                        ieee80211_sta_abort_chanswitch(link);
-               else
+                       return;
+               } else {
                        drv_channel_switch_rx_beacon(sdata, &ch_switch);
-               return;
-       } else if (link->conf->csa_active || res) {
-               /* disregard subsequent announcements if already processing */
-               return;
+                       return;
+               }
        }
 
+       /* nothing to do at all - no active CSA nor a new one */
+       if (res)
+               return;
+
        if (link->conf->chanreq.oper.chan->band !=
            csa_ie.chanreq.oper.chan->band) {
                sdata_info(sdata,
@@ -6293,9 +6302,6 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
                }
        }
 
-       if (link->u.mgd.csa_waiting_bcn)
-               ieee80211_chswitch_post_beacon(link);
-
        /*
         * Update beacon timing and dtim count on every beacon appearance. This
         * will allow the driver to use the most updated values. Do it before