summaryrefslogtreecommitdiff
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2026-04-28 11:25:33 +0200
committerJohannes Berg <johannes.berg@intel.com>2026-05-05 14:49:03 +0200
commit3ca884399be1bcb04baec264a75133cf7a422b52 (patch)
treebcd4146c8633a895e3b276a0a44bf64d6e3fb63f /net/wireless
parent1cf1d06e956dfbb05a7f69f64ab3c8938117eabe (diff)
wifi: cfg80211: add helper for parsing NPCA to chandef
Add a cfg80211_chandef_add_npca() helper function that takes an existing chandef without NPCA and sets the NPCA information from the format used in UHR operation and UHR Parameters Update. Link: https://patch.msgid.link/20260428112708.5cdc4e69a306.I95d396ac671da438f340b1afb735ebfe33164894@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/chan.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 38b83b44b5dc..5289a4ddacd6 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -556,6 +556,52 @@ int cfg80211_chandef_primary(const struct cfg80211_chan_def *c,
}
EXPORT_SYMBOL(cfg80211_chandef_primary);
+int cfg80211_chandef_add_npca(struct wiphy *wiphy,
+ struct cfg80211_chan_def *chandef,
+ const struct ieee80211_uhr_npca_info *npca)
+{
+ struct cfg80211_chan_def new_chandef = *chandef;
+ u32 width, npca_freq;
+ u8 offs;
+
+ if (chandef->npca_chan || chandef->npca_punctured)
+ return -EINVAL;
+
+ if (WARN_ON(!cfg80211_chandef_valid(chandef)))
+ return -EINVAL;
+
+ if (!npca)
+ return 0;
+
+ switch (chandef->width) {
+ case NL80211_CHAN_WIDTH_80:
+ case NL80211_CHAN_WIDTH_160:
+ case NL80211_CHAN_WIDTH_320:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ offs = le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_PRIMARY_CHAN_OFFS);
+
+ width = cfg80211_chandef_get_width(chandef);
+ npca_freq = chandef->center_freq1 - width / 2 + 10 + 20 * offs;
+ new_chandef.npca_chan = ieee80211_get_channel(wiphy, npca_freq);
+ if (!new_chandef.npca_chan)
+ return -EINVAL;
+
+ if (npca->params & cpu_to_le32(IEEE80211_UHR_NPCA_PARAMS_DIS_SUBCH_BMAP_PRES))
+ new_chandef.npca_punctured = le16_to_cpu(npca->dis_subch_bmap[0]);
+
+ if (!cfg80211_chandef_valid(&new_chandef))
+ return -EINVAL;
+
+ *chandef = new_chandef;
+ return 0;
+}
+EXPORT_SYMBOL(cfg80211_chandef_add_npca);
+
static const struct cfg80211_chan_def *
check_chandef_primary_compat(const struct cfg80211_chan_def *c1,
const struct cfg80211_chan_def *c2,