]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mac80211: use NPCA in chandef for validation
authorJohannes Berg <johannes.berg@intel.com>
Tue, 28 Apr 2026 09:25:34 +0000 (11:25 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 5 May 2026 12:49:03 +0000 (14:49 +0200)
Put the NPCA parameters into a chandef when parsing data from
the AP to validate them using the cfg80211 code, rather than
implementing that in mac80211 directly.

Note that the parameters are not applied yet, since mac80211
doesn't yet have NPCA support.

Link: https://patch.msgid.link/20260428112708.418e86f9444c.I54430f3018e39a26b4252d71000d7bb7dd744331@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/mlme.c

index f8ed8a8ce0b142e8195a33ca5c52d7f1cec59c58..5be390de67564143c38d68ad8e1d3b61284daca6 100644 (file)
@@ -402,44 +402,13 @@ check_uhr:
                                       false)) {
                struct cfg80211_chan_def npca_chandef = *chandef;
                const struct ieee80211_uhr_npca_info *npca;
-               const __le16 *dis_subch_bmap;
-               u16 punct = chandef->punctured, npca_punct;
 
                npca = ieee80211_uhr_npca_info(uhr_oper);
-               if (npca) {
-                       int width = cfg80211_chandef_get_width(chandef);
-                       u8 offs = le32_get_bits(npca->params,
-                                               IEEE80211_UHR_NPCA_PARAMS_PRIMARY_CHAN_OFFS);
-                       u32 cf1 = chandef->center_freq1;
-                       bool pri_upper, npca_upper;
-
-                       pri_upper = chandef->chan->center_freq > cf1;
-                       npca_upper = 20 * offs >= width / 2;
-
-                       if (20 * offs >= cfg80211_chandef_get_width(chandef) ||
-                           pri_upper == npca_upper) {
-                               sdata_info(sdata,
-                                          "AP UHR NPCA primary channel invalid, disabling UHR\n");
-                               return IEEE80211_CONN_MODE_EHT;
-                       }
-               }
-
-               dis_subch_bmap = ieee80211_uhr_npca_dis_subch_bitmap(uhr_oper);
 
-               if (dis_subch_bmap) {
-                       npca_punct = get_unaligned_le16(dis_subch_bmap);
-                       npca_chandef.punctured = npca_punct;
-               }
-
-               /*
-                * must be a valid puncturing pattern for this channel as
-                * well as puncturing all subchannels that are already in
-                * the disabled subchannel bitmap on the primary channel
-                */
-               if (!cfg80211_chandef_valid(&npca_chandef) ||
-                   ((punct & npca_punct) != punct)) {
+               if (cfg80211_chandef_add_npca(sdata->local->hw.wiphy,
+                                             &npca_chandef, npca)) {
                        sdata_info(sdata,
-                                  "AP UHR NPCA disabled subchannel bitmap invalid, disabling UHR\n");
+                                  "AP UHR NPCA settings invalid, disabling UHR\n");
                        return IEEE80211_CONN_MODE_EHT;
                }
        }