* [PATCH wireless-next 00/14] wifi: UHR non-primary channel access
@ 2026-04-28 9:25 Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 01/14] wifi: mac80211: use struct for ieee80211_determine_ap_chan() args Johannes Berg
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless
This series implements UHR NPCA (non-primary channel access) in general
(chandef etc.), for the AP side (just configuration values), and the
client (using it from assoc response.)
A few things to note:
- I know that the 802.11bn draft is likely to change and use an 8-bit
NPCA primary channel field, which changes the parsing. This will need
to be adjusted once that finalizes.
- This change will likely also come together with allowing NPCA to be
used inside the DBE rather than only inside the BSS bandwidth, but
we'll see how this will play out in the spec.
- I have, at least for now, deliberately opted to keep more patches
rather than squashing "don't parse full UHR operation from beacons"
and "separate NPCA validity from chandef validity" as I think it may
be easier to follow, but we can change that. It reflects my thought
process more than anything I guess.
- In addition to this I also have preliminary DBE (dynamic bandwidth
extension) patches, but I've opted to not include them here for now.
- For the AP side, I've only made "fake NPCA" patches that allow
advertising it with specific values in hostapd, rather than handling
the client request to enable it and updating the BSS values. I don't
really know how "real AP" vendors want to handle this, so I'm
deliberately leaving it out.
johannes
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH wireless-next 01/14] wifi: mac80211: use struct for ieee80211_determine_ap_chan() args
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 02/14] wifi: mac80211: move ieee80211_chandef_usable() up Johannes Berg
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
There are too many arguments, and we're going to need another one
for DBE. Collect them into a struct instead.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/mlme.c | 57 ++++++++++++++++++++++++++++++++-------------
1 file changed, 41 insertions(+), 16 deletions(-)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 00b4beff0e43..25c7427e11c4 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -149,20 +149,32 @@ static int ecw2cw(int ecw)
return (1 << ecw) - 1;
}
+struct ieee80211_determine_ap_chan_data {
+ /* input data */
+ struct ieee80211_channel *channel;
+ const struct ieee802_11_elems *elems;
+ const struct ieee80211_conn_settings *conn;
+ u32 vht_cap_info;
+ bool ignore_ht_channel_mismatch;
+
+ /* target chandef is filled in */
+ struct cfg80211_chan_def *chandef;
+};
+
static enum ieee80211_conn_mode
ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
- struct ieee80211_channel *channel,
- u32 vht_cap_info,
- const struct ieee802_11_elems *elems,
- bool ignore_ht_channel_mismatch,
- const struct ieee80211_conn_settings *conn,
- struct cfg80211_chan_def *chandef)
+ struct ieee80211_determine_ap_chan_data *data)
{
+ bool ignore_ht_channel_mismatch = data->ignore_ht_channel_mismatch;
+ const struct ieee802_11_elems *elems = data->elems;
const struct ieee80211_ht_operation *ht_oper = elems->ht_operation;
const struct ieee80211_vht_operation *vht_oper = elems->vht_operation;
const struct ieee80211_he_operation *he_oper = elems->he_operation;
const struct ieee80211_eht_operation *eht_oper = elems->eht_operation;
const struct ieee80211_uhr_operation *uhr_oper = elems->uhr_operation;
+ const struct ieee80211_conn_settings *conn = data->conn;
+ struct ieee80211_channel *channel = data->channel;
+ struct cfg80211_chan_def *chandef = data->chandef;
struct ieee80211_supported_band *sband =
sdata->local->hw.wiphy->bands[channel->band];
struct cfg80211_chan_def vht_chandef;
@@ -288,7 +300,7 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
memcpy(&he_oper_vht_cap, he_oper->optional, 3);
he_oper_vht_cap.basic_mcs_set = cpu_to_le16(0);
- if (!ieee80211_chandef_vht_oper(&sdata->local->hw, vht_cap_info,
+ if (!ieee80211_chandef_vht_oper(&sdata->local->hw, data->vht_cap_info,
&he_oper_vht_cap, ht_oper,
&vht_chandef)) {
sdata_info(sdata,
@@ -303,7 +315,7 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
} else if (sband->band == NL80211_BAND_2GHZ) {
no_vht = true;
} else if (!ieee80211_chandef_vht_oper(&sdata->local->hw,
- vht_cap_info,
+ data->vht_cap_info,
vht_oper, ht_oper,
&vht_chandef)) {
sdata_info(sdata,
@@ -1085,6 +1097,13 @@ ieee80211_determine_chan_mode(struct ieee80211_sub_if_data *sdata,
enum ieee80211_conn_mode ap_mode;
unsigned long unknown_rates_selectors[BITS_TO_LONGS(128)] = {};
unsigned long sta_selectors[BITS_TO_LONGS(128)] = {};
+ struct ieee80211_determine_ap_chan_data ap_chan_data = {
+ .channel = channel,
+ .vht_cap_info = bss->vht_cap_info,
+ .ignore_ht_channel_mismatch = false,
+ .chandef = ap_chandef,
+ .conn = conn,
+ };
int ret;
again:
@@ -1093,8 +1112,8 @@ ieee80211_determine_chan_mode(struct ieee80211_sub_if_data *sdata,
if (!elems)
return ERR_PTR(-ENOMEM);
- ap_mode = ieee80211_determine_ap_chan(sdata, channel, bss->vht_cap_info,
- elems, false, conn, ap_chandef);
+ ap_chan_data.elems = elems;
+ ap_mode = ieee80211_determine_ap_chan(sdata, &ap_chan_data);
/* this should be impossible since parsing depends on our mode */
if (WARN_ON(ap_mode > conn->mode)) {
@@ -1322,12 +1341,19 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,
bool update, u64 *changed, u16 stype)
{
struct ieee80211_channel *channel = link->conf->chanreq.oper.chan;
+ struct cfg80211_chan_def ap_chandef;
+ struct ieee80211_determine_ap_chan_data ap_chan_data = {
+ .channel = channel,
+ .vht_cap_info = 0,
+ .ignore_ht_channel_mismatch = true,
+ .chandef = &ap_chandef,
+ .elems = elems,
+ .conn = &link->u.mgd.conn,
+ };
struct ieee80211_sub_if_data *sdata = link->sdata;
struct ieee80211_chan_req chanreq = {};
- struct cfg80211_chan_def ap_chandef;
enum ieee80211_conn_mode ap_mode;
const char *frame;
- u32 vht_cap_info = 0;
u16 ht_opmode;
int ret;
@@ -1355,11 +1381,10 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,
return 0;
if (elems->vht_cap_elem)
- vht_cap_info = le32_to_cpu(elems->vht_cap_elem->vht_cap_info);
+ ap_chan_data.vht_cap_info =
+ le32_to_cpu(elems->vht_cap_elem->vht_cap_info);
- ap_mode = ieee80211_determine_ap_chan(sdata, channel, vht_cap_info,
- elems, true, &link->u.mgd.conn,
- &ap_chandef);
+ ap_mode = ieee80211_determine_ap_chan(sdata, &ap_chan_data);
if (ap_mode != link->u.mgd.conn.mode) {
link_info(link,
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 02/14] wifi: mac80211: move ieee80211_chandef_usable() up
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 01/14] wifi: mac80211: use struct for ieee80211_determine_ap_chan() args Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 03/14] wifi: mac80211: carry element parsing frame type/from_ap Johannes Berg
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
For UHR DBE this is going to be needed in the AP channel
determination function, move it there.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/mlme.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 25c7427e11c4..0bf51774c155 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -149,6 +149,21 @@ static int ecw2cw(int ecw)
return (1 << ecw) - 1;
}
+static bool ieee80211_chandef_usable(struct ieee80211_sub_if_data *sdata,
+ const struct cfg80211_chan_def *chandef,
+ u32 prohibited_flags)
+{
+ if (!cfg80211_chandef_usable(sdata->local->hw.wiphy,
+ chandef, prohibited_flags))
+ return false;
+
+ if (chandef->punctured &&
+ ieee80211_hw_check(&sdata->local->hw, DISALLOW_PUNCTURING))
+ return false;
+
+ return true;
+}
+
struct ieee80211_determine_ap_chan_data {
/* input data */
struct ieee80211_channel *channel;
@@ -851,21 +866,6 @@ static void ieee80211_get_rates(struct ieee80211_supported_band *sband,
}
}
-static bool ieee80211_chandef_usable(struct ieee80211_sub_if_data *sdata,
- const struct cfg80211_chan_def *chandef,
- u32 prohibited_flags)
-{
- if (!cfg80211_chandef_usable(sdata->local->hw.wiphy,
- chandef, prohibited_flags))
- return false;
-
- if (chandef->punctured &&
- ieee80211_hw_check(&sdata->local->hw, DISALLOW_PUNCTURING))
- return false;
-
- return true;
-}
-
static int ieee80211_chandef_num_subchans(const struct cfg80211_chan_def *c)
{
if (c->width == NL80211_CHAN_WIDTH_80P80)
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 03/14] wifi: mac80211: carry element parsing frame type/from_ap
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 01/14] wifi: mac80211: use struct for ieee80211_determine_ap_chan() args Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 02/14] wifi: mac80211: move ieee80211_chandef_usable() up Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 04/14] wifi: cfg80211: allow representing NPCA in chandef Johannes Berg
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Carry the frame type and from_ap indication in the parse
result, the caller should have it, but we often pass the
resulting data structure around, so this saves passing
more parameters.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/ieee80211_i.h | 2 ++
net/mac80211/parse.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index e23e347f870d..10bad5369e9d 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1790,6 +1790,8 @@ struct ieee802_11_elems {
const u8 *ie_start;
size_t total_len;
u32 crc;
+ u8 frame_type;
+ bool from_ap;
/* pointers to IEs */
const struct ieee80211_tdls_lnkie *lnk_id;
diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c
index 2b3632c6008a..5e61457be0f3 100644
--- a/net/mac80211/parse.c
+++ b/net/mac80211/parse.c
@@ -1053,6 +1053,9 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params)
if (!elems_parse)
return NULL;
+ elems_parse->elems.frame_type = params->type;
+ elems_parse->elems.from_ap = params->from_ap;
+
elems_parse->scratch_len = scratch_len;
elems_parse->scratch_pos = elems_parse->scratch;
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 04/14] wifi: cfg80211: allow representing NPCA in chandef
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (2 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 03/14] wifi: mac80211: carry element parsing frame type/from_ap Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 05/14] wifi: cfg80211: add helper for parsing NPCA to chandef Johannes Berg
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Add the necessary fields to the chandef data structure
to represent NPCA (the NPCA primary channel and NPCA
punctured/disabled subchannels bitmap), and the code
to check these for validity, compatibility, as well as
allowing it to be passed for AP mode for capable
devices.
Compatibility is assumed to only be the case when it's
actually identical, enabling later management of this
in channel contexts in mac80211 for multiple APs, but
requiring userspace to set up the identical chandef on
all AP interfaces that share a channel (and BSS color.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/cfg80211.h | 11 +++-
include/uapi/linux/nl80211.h | 6 ++
net/wireless/chan.c | 59 +++++++++++++++--
net/wireless/nl80211.c | 120 ++++++++++++++++++++++++++++++-----
net/wireless/nl80211.h | 5 +-
net/wireless/pmsr.c | 2 +-
net/wireless/trace.h | 16 ++++-
7 files changed, 189 insertions(+), 30 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index a40ab36b8edb..9e66490dab4f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -844,6 +844,7 @@ struct key_params {
/**
* struct cfg80211_chan_def - channel definition
* @chan: the (control) channel
+ * @npca_chan: the NPCA primary channel
* @width: channel width
* @center_freq1: center frequency of first segment
* @center_freq2: center frequency of second segment
@@ -856,18 +857,22 @@ struct key_params {
* @punctured: mask of the punctured 20 MHz subchannels, with
* bits turned on being disabled (punctured); numbered
* from lower to higher frequency (like in the spec)
+ * @npca_punctured: NPCA puncturing bitmap, like @punctured but for
+ * NPCA transmissions. If NPCA is used (@npca_chan is not %NULL)
+ * this will be a superset of the @punctured bimap.
* @s1g_primary_2mhz: Indicates if the control channel pointed to
* by 'chan' exists as a 1MHz primary subchannel within an
* S1G 2MHz primary channel.
*/
struct cfg80211_chan_def {
struct ieee80211_channel *chan;
+ struct ieee80211_channel *npca_chan;
enum nl80211_chan_width width;
u32 center_freq1;
u32 center_freq2;
struct ieee80211_edmg edmg;
u16 freq1_offset;
- u16 punctured;
+ u16 punctured, npca_punctured;
bool s1g_primary_2mhz;
};
@@ -1014,7 +1019,9 @@ cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
chandef1->freq1_offset == chandef2->freq1_offset &&
chandef1->center_freq2 == chandef2->center_freq2 &&
chandef1->punctured == chandef2->punctured &&
- chandef1->s1g_primary_2mhz == chandef2->s1g_primary_2mhz);
+ chandef1->s1g_primary_2mhz == chandef2->s1g_primary_2mhz &&
+ chandef1->npca_chan == chandef2->npca_chan &&
+ chandef1->npca_punctured == chandef2->npca_punctured);
}
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 072b383d7d3c..2b6957b61b62 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -3142,6 +3142,9 @@ enum nl80211_commands {
* association response etc., since it's abridged in the beacon. Used
* for START_AP etc.
*
+ * @NL80211_ATTR_NPCA_PRIMARY_FREQ: NPCA primary channel (u32)
+ * @NL80211_ATTR_NPCA_PUNCT_BITMAP: NPCA puncturing bitmap (u32)
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3735,6 +3738,9 @@ enum nl80211_attrs {
NL80211_ATTR_NAN_MAX_CHAN_SWITCH_TIME,
NL80211_ATTR_NAN_PEER_MAPS,
+ NL80211_ATTR_NPCA_PRIMARY_FREQ,
+ NL80211_ATTR_NPCA_PUNCT_BITMAP,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 8b94c0de80ad..fae71f2d13ed 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -138,9 +138,10 @@ static const struct cfg80211_per_bw_puncturing_values per_bw_puncturing[] = {
CFG80211_PER_BW_VALID_PUNCTURING_VALUES(320)
};
-static bool valid_puncturing_bitmap(const struct cfg80211_chan_def *chandef)
+static bool valid_puncturing_bitmap(const struct cfg80211_chan_def *chandef,
+ u32 primary_center, u32 punctured)
{
- u32 idx, i, start_freq, primary_center = chandef->chan->center_freq;
+ u32 idx, i, start_freq;
switch (chandef->width) {
case NL80211_CHAN_WIDTH_80:
@@ -156,18 +157,18 @@ static bool valid_puncturing_bitmap(const struct cfg80211_chan_def *chandef)
start_freq = chandef->center_freq1 - 160;
break;
default:
- return chandef->punctured == 0;
+ return punctured == 0;
}
- if (!chandef->punctured)
+ if (!punctured)
return true;
/* check if primary channel is punctured */
- if (chandef->punctured & (u16)BIT((primary_center - start_freq) / 20))
+ if (punctured & (u16)BIT((primary_center - start_freq) / 20))
return false;
for (i = 0; i < per_bw_puncturing[idx].len; i++) {
- if (per_bw_puncturing[idx].valid_values[i] == chandef->punctured)
+ if (per_bw_puncturing[idx].valid_values[i] == punctured)
return true;
}
@@ -458,6 +459,40 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
if (!cfg80211_chandef_valid_control_freq(chandef, control_freq))
return false;
+ if (chandef->npca_chan) {
+ bool pri_upper, npca_upper;
+ u32 cf1;
+
+ switch (chandef->width) {
+ case NL80211_CHAN_WIDTH_80:
+ case NL80211_CHAN_WIDTH_160:
+ case NL80211_CHAN_WIDTH_320:
+ break;
+ default:
+ return false;
+ }
+
+ if (!cfg80211_chandef_valid_control_freq(chandef,
+ chandef->npca_chan->center_freq))
+ return false;
+
+ cf1 = chandef->center_freq1;
+ pri_upper = chandef->chan->center_freq > cf1;
+ npca_upper = chandef->npca_chan->center_freq > cf1;
+
+ if (pri_upper == npca_upper)
+ return false;
+
+ if (!valid_puncturing_bitmap(chandef,
+ chandef->npca_chan->center_freq,
+ chandef->npca_punctured) ||
+ (chandef->punctured & chandef->npca_punctured) !=
+ chandef->punctured)
+ return false;
+ } else if (chandef->npca_punctured) {
+ return false;
+ }
+
if (!cfg80211_valid_center_freq(chandef->center_freq1, chandef->width))
return false;
@@ -477,7 +512,8 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
if (!cfg80211_chandef_is_s1g(chandef) && chandef->s1g_primary_2mhz)
return false;
- return valid_puncturing_bitmap(chandef);
+ return valid_puncturing_bitmap(chandef, control_freq,
+ chandef->punctured);
}
EXPORT_SYMBOL(cfg80211_chandef_valid);
@@ -564,6 +600,15 @@ _cfg80211_chandef_compatible(const struct cfg80211_chan_def *c1,
if (c1->width == c2->width)
return NULL;
+ /*
+ * We need NPCA to be compatible for some scenarios such as
+ * multiple APs, but in this case userspace should configure
+ * identical chandefs including NPCA, even if perhaps one of
+ * the AP interfaces doesn't even advertise it.
+ */
+ if (c1->npca_chan || c2->npca_chan)
+ return NULL;
+
/*
* can't be compatible if one of them is 5/10 MHz or S1G
* but they don't have the same width.
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cf236307cca9..7cb5f39f783d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1076,6 +1076,9 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[NL80211_ATTR_NAN_MAX_CHAN_SWITCH_TIME] = { .type = NLA_U16 },
[NL80211_ATTR_NAN_PEER_MAPS] =
NLA_POLICY_NESTED_ARRAY(nl80211_nan_peer_map_policy),
+ [NL80211_ATTR_NPCA_PRIMARY_FREQ] = { .type = NLA_U32 },
+ [NL80211_ATTR_NPCA_PUNCT_BITMAP] =
+ NLA_POLICY_FULL_RANGE(NLA_U32, &nl80211_punct_bitmap_range),
};
/* policy for the key attributes */
@@ -3772,7 +3775,8 @@ static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev)
static int _nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
struct netlink_ext_ack *extack,
struct nlattr **attrs, bool monitor,
- struct cfg80211_chan_def *chandef)
+ struct cfg80211_chan_def *chandef,
+ bool permit_npca)
{
u32 control_freq;
@@ -3886,6 +3890,34 @@ static int _nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
}
}
+ if (attrs[NL80211_ATTR_NPCA_PRIMARY_FREQ]) {
+ if (!permit_npca) {
+ NL_SET_ERR_MSG_ATTR(extack,
+ attrs[NL80211_ATTR_NPCA_PRIMARY_FREQ],
+ "NPCA not supported");
+ return -EINVAL;
+ }
+
+ chandef->npca_chan =
+ ieee80211_get_channel(&rdev->wiphy,
+ nla_get_u32(attrs[NL80211_ATTR_NPCA_PRIMARY_FREQ]));
+ if (!chandef->npca_chan) {
+ NL_SET_ERR_MSG_ATTR(extack,
+ attrs[NL80211_ATTR_NPCA_PRIMARY_FREQ],
+ "invalid NPCA primary channel");
+ return -EINVAL;
+ }
+
+ chandef->npca_punctured =
+ nla_get_u32_default(attrs[NL80211_ATTR_NPCA_PUNCT_BITMAP],
+ chandef->punctured);
+ } else if (attrs[NL80211_ATTR_NPCA_PUNCT_BITMAP]) {
+ NL_SET_ERR_MSG_ATTR(extack,
+ attrs[NL80211_ATTR_NPCA_PUNCT_BITMAP],
+ "NPCA puncturing only valid with NPCA");
+ return -EINVAL;
+ }
+
if (!cfg80211_chandef_valid(chandef)) {
NL_SET_ERR_MSG_ATTR(extack, attrs[NL80211_ATTR_WIPHY_FREQ],
"invalid channel definition");
@@ -3913,9 +3945,11 @@ static int _nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
struct netlink_ext_ack *extack,
struct nlattr **attrs,
- struct cfg80211_chan_def *chandef)
+ struct cfg80211_chan_def *chandef,
+ bool permit_npca)
{
- return _nl80211_parse_chandef(rdev, extack, attrs, false, chandef);
+ return _nl80211_parse_chandef(rdev, extack, attrs, false, chandef,
+ permit_npca);
}
static int __nl80211_set_channel(struct cfg80211_registered_device *rdev,
@@ -3928,6 +3962,7 @@ static int __nl80211_set_channel(struct cfg80211_registered_device *rdev,
enum nl80211_iftype iftype = NL80211_IFTYPE_MONITOR;
struct wireless_dev *wdev = NULL;
int link_id = _link_id;
+ bool permit_npca;
if (dev)
wdev = dev->ieee80211_ptr;
@@ -3942,9 +3977,13 @@ static int __nl80211_set_channel(struct cfg80211_registered_device *rdev,
link_id = 0;
}
+ /* allow parsing it - will check on start_ap or below */
+ permit_npca = iftype == NL80211_IFTYPE_AP ||
+ iftype == NL80211_IFTYPE_P2P_GO;
+
result = _nl80211_parse_chandef(rdev, info->extack, info->attrs,
iftype == NL80211_IFTYPE_MONITOR,
- &chandef);
+ &chandef, permit_npca);
if (result)
return result;
@@ -3963,6 +4002,9 @@ static int __nl80211_set_channel(struct cfg80211_registered_device *rdev,
return -EBUSY;
/* Only allow dynamic channel width changes */
+ cur_chan = wdev->links[link_id].ap.chandef.npca_chan;
+ if (chandef.npca_chan != cur_chan)
+ return -EBUSY;
cur_chan = wdev->links[link_id].ap.chandef.chan;
if (chandef.chan != cur_chan)
return -EBUSY;
@@ -4447,6 +4489,15 @@ int nl80211_send_chandef(struct sk_buff *msg, const struct cfg80211_chan_def *ch
nla_put_flag(msg, NL80211_ATTR_S1G_PRIMARY_2MHZ))
return -ENOBUFS;
+ if (chandef->npca_chan &&
+ nla_put_u32(msg, NL80211_ATTR_NPCA_PRIMARY_FREQ,
+ chandef->npca_chan->center_freq))
+ return -ENOBUFS;
+ if (chandef->npca_punctured &&
+ nla_put_u32(msg, NL80211_ATTR_NPCA_PUNCT_BITMAP,
+ chandef->npca_punctured))
+ return -ENOBUFS;
+
return 0;
}
EXPORT_SYMBOL(nl80211_send_chandef);
@@ -6949,6 +7000,28 @@ nl80211_parse_s1g_short_beacon(struct cfg80211_registered_device *rdev,
return 0;
}
+static int nl80211_check_npca(struct cfg80211_registered_device *rdev,
+ const struct cfg80211_chan_def *chandef,
+ enum nl80211_iftype iftype,
+ struct netlink_ext_ack *extack)
+{
+ const struct ieee80211_supported_band *sband;
+ const struct ieee80211_sta_uhr_cap *uhr_cap;
+
+ if (!chandef->npca_chan)
+ return 0;
+
+ sband = rdev->wiphy.bands[chandef->chan->band];
+ uhr_cap = ieee80211_get_uhr_iftype_cap(sband, iftype);
+
+ if (uhr_cap &&
+ (uhr_cap->mac.mac_cap[0] & IEEE80211_UHR_MAC_CAP0_NPCA_SUPP))
+ return 0;
+
+ NL_SET_ERR_MSG(extack, "NPCA not supported");
+ return -EINVAL;
+}
+
static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
{
struct cfg80211_registered_device *rdev = info->user_ptr[0];
@@ -7088,7 +7161,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
err = nl80211_parse_chandef(rdev, info->extack, info->attrs,
- ¶ms->chandef);
+ ¶ms->chandef, true);
if (err)
goto out;
} else if (wdev->valid_links) {
@@ -7107,6 +7180,11 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
if (err)
goto out;
+ err = nl80211_check_npca(rdev, ¶ms->chandef, wdev->iftype,
+ info->extack);
+ if (err)
+ goto out;
+
beacon_check.iftype = wdev->iftype;
beacon_check.relax = true;
beacon_check.reg_power =
@@ -11657,7 +11735,8 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
if (dfs_region == NL80211_DFS_UNSET)
return -EINVAL;
- err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef);
+ err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef,
+ false);
if (err)
return err;
@@ -11746,7 +11825,8 @@ static int nl80211_notify_radar_detection(struct sk_buff *skb,
return -EINVAL;
}
- err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef);
+ err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef,
+ false);
if (err) {
GENL_SET_ERR_MSG(info, "Unable to extract chandef info");
return err;
@@ -11829,6 +11909,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
int err;
bool need_new_beacon = false;
bool need_handle_dfs_flag = true;
+ bool permit_npca = false;
u32 cs_count;
if (!rdev->ops->channel_switch ||
@@ -11846,6 +11927,8 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
*/
need_handle_dfs_flag = false;
+ permit_npca = true;
+
/* useless if AP is not running */
if (!wdev->links[link_id].ap.beacon_interval)
return -ENOTCONN;
@@ -11883,7 +11966,12 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
params.count = cs_count;
err = nl80211_parse_chandef(rdev, info->extack, info->attrs,
- ¶ms.chandef);
+ ¶ms.chandef, permit_npca);
+ if (err)
+ goto free;
+
+ err = nl80211_check_npca(rdev, ¶ms.chandef, wdev->iftype,
+ info->extack);
if (err)
goto free;
@@ -13157,7 +13245,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
}
err = nl80211_parse_chandef(rdev, info->extack, info->attrs,
- &ibss.chandef);
+ &ibss.chandef, false);
if (err)
return err;
@@ -14157,7 +14245,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
duration > rdev->wiphy.max_remain_on_channel_duration)
return -EINVAL;
- err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef);
+ err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef,
+ false);
if (err)
return err;
@@ -14376,7 +14465,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
chandef.chan = NULL;
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
err = nl80211_parse_chandef(rdev, info->extack, info->attrs,
- &chandef);
+ &chandef, false);
if (err)
return err;
}
@@ -14779,7 +14868,7 @@ static int nl80211_join_ocb(struct sk_buff *skb, struct genl_info *info)
int err;
err = nl80211_parse_chandef(rdev, info->extack, info->attrs,
- &setup.chandef);
+ &setup.chandef, false);
if (err)
return err;
@@ -14855,7 +14944,7 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info)
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
err = nl80211_parse_chandef(rdev, info->extack, info->attrs,
- &setup.chandef);
+ &setup.chandef, false);
if (err)
return err;
} else {
@@ -16819,7 +16908,7 @@ static int nl80211_parse_nan_channel(struct cfg80211_registered_device *rdev,
return ret;
ret = nl80211_parse_chandef(rdev, info->extack, channel_parsed,
- &chandef);
+ &chandef, false);
if (ret)
return ret;
@@ -17818,7 +17907,8 @@ static int nl80211_tdls_channel_switch(struct sk_buff *skb,
!info->attrs[NL80211_ATTR_OPER_CLASS])
return -EINVAL;
- err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef);
+ err = nl80211_parse_chandef(rdev, info->extack, info->attrs, &chandef,
+ false);
if (err)
return err;
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 048ba92c3e42..bdb065d14054 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Portions of this file
- * Copyright (C) 2018, 2020-2025 Intel Corporation
+ * Copyright (C) 2018, 2020-2026 Intel Corporation
*/
#ifndef __NET_WIRELESS_NL80211_H
#define __NET_WIRELESS_NL80211_H
@@ -25,7 +25,8 @@ static inline u64 wdev_id(struct wireless_dev *wdev)
int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
struct netlink_ext_ack *extack,
struct nlattr **attrs,
- struct cfg80211_chan_def *chandef);
+ struct cfg80211_chan_def *chandef,
+ bool npca_permitted);
int nl80211_parse_random_mac(struct nlattr **attrs,
u8 *mac_addr, u8 *mac_addr_mask);
diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c
index 4c8ea0583f94..93fee1f1aa76 100644
--- a/net/wireless/pmsr.c
+++ b/net/wireless/pmsr.c
@@ -238,7 +238,7 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
return err;
err = nl80211_parse_chandef(rdev, info->extack, info->attrs,
- &out->chandef);
+ &out->chandef, false);
if (err)
return err;
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index eb5bedf9c92a..d03e58c63fd4 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -141,7 +141,9 @@
__field(u32, center_freq1) \
__field(u32, freq1_offset) \
__field(u32, center_freq2) \
- __field(u16, punctured)
+ __field(u16, punctured) \
+ __field(u32, npca_pri_freq) \
+ __field(u16, npca_punctured)
#define CHAN_DEF_ASSIGN(chandef) \
do { \
if ((chandef) && (chandef)->chan) { \
@@ -155,6 +157,11 @@
__entry->freq1_offset = (chandef)->freq1_offset;\
__entry->center_freq2 = (chandef)->center_freq2;\
__entry->punctured = (chandef)->punctured; \
+ __entry->npca_pri_freq = \
+ (chandef)->npca_chan ? \
+ (chandef)->npca_chan->center_freq : 0; \
+ __entry->npca_punctured = \
+ (chandef)->npca_punctured; \
} else { \
__entry->band = 0; \
__entry->control_freq = 0; \
@@ -164,14 +171,17 @@
__entry->freq1_offset = 0; \
__entry->center_freq2 = 0; \
__entry->punctured = 0; \
+ __entry->npca_pri_freq = 0; \
+ __entry->npca_punctured = 0; \
} \
} while (0)
#define CHAN_DEF_PR_FMT \
- "band: %d, control freq: %u.%03u, width: %d, cf1: %u.%03u, cf2: %u, punct: 0x%x"
+ "band: %d, control freq: %u.%03u, width: %d, cf1: %u.%03u, cf2: %u, punct: 0x%x, npca:%u, npca_punct:0x%x"
#define CHAN_DEF_PR_ARG __entry->band, __entry->control_freq, \
__entry->freq_offset, __entry->width, \
__entry->center_freq1, __entry->freq1_offset, \
- __entry->center_freq2, __entry->punctured
+ __entry->center_freq2, __entry->punctured, \
+ __entry->npca_pri_freq, __entry->npca_punctured
#define FILS_AAD_ASSIGN(fa) \
do { \
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 05/14] wifi: cfg80211: add helper for parsing NPCA to chandef
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (3 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 04/14] wifi: cfg80211: allow representing NPCA in chandef Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 06/14] wifi: mac80211: use NPCA in chandef for validation Johannes Berg
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
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.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/cfg80211.h | 13 ++++++++++++
net/wireless/chan.c | 46 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9e66490dab4f..2546567792e2 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1150,6 +1150,19 @@ int cfg80211_chandef_primary(const struct cfg80211_chan_def *chandef,
enum nl80211_chan_width primary_chan_width,
u16 *punctured);
+/**
+ * cfg80211_chandef_add_npca - parse and add NPCA information to chandef
+ * @wiphy: the wiphy this will be used for, for channel pointer lookup
+ * @chandef: the chandef to modify, must be a valid chandef without NPCA
+ * @npca: the NPCA information, can be %NULL
+ *
+ * Returns: 0 if the NPCA information was added and the resulting
+ * chandef is valid, a negative error code on errors
+ */
+int cfg80211_chandef_add_npca(struct wiphy *wiphy,
+ struct cfg80211_chan_def *chandef,
+ const struct ieee80211_uhr_npca_info *npca);
+
/**
* nl80211_send_chandef - sends the channel definition.
* @msg: the msg to send channel definition
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index fae71f2d13ed..70fec444955e 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,
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 06/14] wifi: mac80211: use NPCA in chandef for validation
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (4 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 05/14] wifi: cfg80211: add helper for parsing NPCA to chandef Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 07/14] wifi: mac80211: remove NPCA during chandef downgrade Johannes Berg
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
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.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/mlme.c | 37 +++----------------------------------
1 file changed, 3 insertions(+), 34 deletions(-)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 0bf51774c155..247871c10615 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -402,44 +402,13 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
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;
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 07/14] wifi: mac80211: remove NPCA during chandef downgrade
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (5 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 06/14] wifi: mac80211: use NPCA in chandef for validation Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 08/14] wifi: mac80211: add NPCA to chandef tracing Johannes Berg
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
We can't use NPCA any more if the chandef was downgraded,
for obvious reasons. Clear NPCA during any downgrade.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/util.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 89e82d34ae48..8c816a2a65f2 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -3831,6 +3831,10 @@ void ieee80211_chandef_downgrade(struct cfg80211_chan_def *c,
c->width = new_primary_width;
}
+ /* whatever we do, downgrading removes NPCA */
+ c->npca_chan = NULL;
+ c->npca_punctured = 0;
+
/*
* With an 80 MHz channel, we might have the puncturing in the primary
* 40 Mhz channel, but that's not valid when downgraded to 40 MHz width.
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 08/14] wifi: mac80211: add NPCA to chandef tracing
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (6 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 07/14] wifi: mac80211: remove NPCA during chandef downgrade Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 09/14] wifi: mac80211: allow only AP chanctx sharing with NPCA Johannes Berg
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Add the NPCA parameters (NPCA primary channel and puncturing bitmap)
to the chandef tracing.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/trace.h | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 71cf88039bd4..562a4964afa3 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -44,7 +44,9 @@
__field(u32, n##center_freq1) \
__field(u32, n##freq1_offset) \
__field(u32, n##center_freq2) \
- __field(u16, n##punctured)
+ __field(u16, n##punctured) \
+ __field(u32, n##npca_pri_freq) \
+ __field(u16, n##npca_punctured)
#define __CHANDEF_ASSIGN(n, c) \
__entry->n##control_freq = (c) && (c)->chan ? \
(c)->chan->center_freq : 0; \
@@ -54,14 +56,18 @@
__entry->n##center_freq1 = (c) ? (c)->center_freq1 : 0; \
__entry->n##freq1_offset = (c) ? (c)->freq1_offset : 0; \
__entry->n##center_freq2 = (c) ? (c)->center_freq2 : 0; \
- __entry->n##punctured = (c) ? (c)->punctured : 0;
+ __entry->n##punctured = (c) ? (c)->punctured : 0; \
+ __entry->n##npca_pri_freq = (c) && (c)->npca_chan ? \
+ (c)->npca_chan->center_freq : 0; \
+ __entry->n##npca_punctured = (c) ? (c)->npca_punctured : 0;
#define __CHANDEF_PR_FMT(n) \
- " " #n "(%d.%03d MHz,width:%d,center: %d.%03d/%d MHz, punct:0x%x)"
+ " " #n "(%d.%03d MHz,width:%d,center: %d.%03d/%d MHz, punct:0x%x, npca:%u, npca_punct:0x%x)"
#define __CHANDEF_PR_ARG(n) \
__entry->n##control_freq, __entry->n##freq_offset, \
__entry->n##chan_width, __entry->n##center_freq1, \
__entry->n##freq1_offset, __entry->n##center_freq2, \
- __entry->n##punctured
+ __entry->n##punctured, __entry->n##npca_pri_freq, \
+ __entry->n##npca_punctured
#define CHANDEF_ENTRY __CHANDEF_ENTRY()
#define CHANDEF_ASSIGN(c) __CHANDEF_ASSIGN(, c)
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 09/14] wifi: mac80211: allow only AP chanctx sharing with NPCA
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (7 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 08/14] wifi: mac80211: add NPCA to chandef tracing Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 10/14] wifi: mac80211: mlme: use NPCA chandef if capable Johannes Berg
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
When two interfaces share a channel context, disable NPCA
unless both are AP interfaces that require NPCA. This way,
two AP interfaces can have identical chandefs set up and
share the channel context, but any non-APs cannot share a
chanctx with NPCA (they'd almost certainly have different
BSS color.)
This doesn't mean the chanctx cannot be shared but rather
that NPCA will be disabled on the shared channel context.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/mac80211.h | 7 +++++++
net/mac80211/cfg.c | 15 ++++++++++++---
net/mac80211/chan.c | 34 ++++++++++++++++++++++++++++++----
3 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 02318a4be0e1..62bfa298c67f 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -218,6 +218,8 @@ struct ieee80211_low_level_stats {
* bandwidth) OFDMA settings need to be changed
* @IEEE80211_CHANCTX_CHANGE_PUNCTURING: The punctured channel(s) bitmap
* was changed.
+ * @IEEE80211_CHANCTX_CHANGE_NPCA: NPCA configuration changed
+ * @IEEE80211_CHANCTX_CHANGE_NPCA_PUNCT: NPCA puncturing changed
*/
enum ieee80211_chanctx_change {
IEEE80211_CHANCTX_CHANGE_WIDTH = BIT(0),
@@ -227,6 +229,8 @@ enum ieee80211_chanctx_change {
IEEE80211_CHANCTX_CHANGE_MIN_DEF = BIT(4),
IEEE80211_CHANCTX_CHANGE_AP = BIT(5),
IEEE80211_CHANCTX_CHANGE_PUNCTURING = BIT(6),
+ IEEE80211_CHANCTX_CHANGE_NPCA = BIT(7),
+ IEEE80211_CHANCTX_CHANGE_NPCA_PUNCT = BIT(8),
};
/**
@@ -234,10 +238,13 @@ enum ieee80211_chanctx_change {
* @oper: channel definition to use for operation
* @ap: the channel definition of the AP, if any
* (otherwise the chan member is %NULL)
+ * @require_npca: If NPCA is configured, require it to
+ * remain, this is used by AP interfaces
*/
struct ieee80211_chan_req {
struct cfg80211_chan_def oper;
struct cfg80211_chan_def ap;
+ bool require_npca;
};
/**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 00261bd6674b..8f8d860944a8 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1612,7 +1612,10 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
unsigned int link_id = params->beacon.link_id;
struct ieee80211_link_data *link;
struct ieee80211_bss_conf *link_conf;
- struct ieee80211_chan_req chanreq = { .oper = params->chandef };
+ struct ieee80211_chan_req chanreq = {
+ .oper = params->chandef,
+ .require_npca = true,
+ };
u64 tsf;
lockdep_assert_wiphy(local->hw.wiphy);
@@ -4625,7 +4628,10 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_csa_settings *params)
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- struct ieee80211_chan_req chanreq = { .oper = params->chandef };
+ struct ieee80211_chan_req chanreq = {
+ .oper = params->chandef,
+ .require_npca = true,
+ };
struct ieee80211_local *local = sdata->local;
struct ieee80211_channel_switch ch_switch = {
.link_id = params->link_id,
@@ -5067,7 +5073,10 @@ static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct ieee80211_link_data *link;
- struct ieee80211_chan_req chanreq = { .oper = *chandef };
+ struct ieee80211_chan_req chanreq = {
+ .oper = *chandef,
+ .require_npca = true,
+ };
int ret;
u64 changed = 0;
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 248531051a4e..6c7f5c9de026 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -285,19 +285,41 @@ ieee80211_chanreq_compatible(const struct ieee80211_chan_req *a,
const struct ieee80211_chan_req *b,
struct ieee80211_chan_req *tmp)
{
+ struct ieee80211_chan_req _a = *a, _b = *b;
const struct cfg80211_chan_def *compat;
if (a->ap.chan && b->ap.chan &&
!cfg80211_chandef_identical(&a->ap, &b->ap))
return NULL;
- compat = cfg80211_chandef_compatible(&a->oper, &b->oper);
+ /*
+ * Remove NPCA if it's not required, so that interfaces
+ * sharing a channel context will not use NPCA while the
+ * channel context is shared.
+ * If both sides are AP interfaces requiring NPC, there's
+ * an assumption that userspace will set them up with
+ * identical configurations and the same BSS color
+ * (if the config is not identical, sharing will fail due
+ * to cfg80211_chandef_compatible() failing below.)
+ */
+ if (!_a.require_npca) {
+ _a.oper.npca_chan = NULL;
+ _a.oper.npca_punctured = 0;
+ }
+
+ if (!_b.require_npca) {
+ _b.oper.npca_chan = NULL;
+ _b.oper.npca_punctured = 0;
+ }
+
+ compat = cfg80211_chandef_compatible(&_a.oper, &_b.oper);
if (!compat)
return NULL;
/* Note: later code assumes this always fills & returns tmp if compat */
tmp->oper = *compat;
tmp->ap = a->ap.chan ? a->ap : b->ap;
+ tmp->require_npca = a->require_npca && b->require_npca;
return tmp;
}
@@ -753,7 +775,6 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local,
const struct ieee80211_chan_req *chanreq,
struct ieee80211_link_data *rsvd_for)
{
- const struct cfg80211_chan_def *chandef = &chanreq->oper;
struct ieee80211_chan_req ctx_req = {
.oper = ctx->conf.def,
.ap = ctx->conf.ap,
@@ -761,7 +782,7 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local,
u32 changed = 0;
/* 5/10 MHz not handled here */
- switch (chandef->width) {
+ switch (chanreq->oper.width) {
case NL80211_CHAN_WIDTH_1:
case NL80211_CHAN_WIDTH_2:
case NL80211_CHAN_WIDTH_4:
@@ -806,10 +827,15 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local,
changed |= IEEE80211_CHANCTX_CHANGE_WIDTH;
if (ctx->conf.def.punctured != chanreq->oper.punctured)
changed |= IEEE80211_CHANCTX_CHANGE_PUNCTURING;
+ if (ctx->conf.def.npca_chan != chanreq->oper.npca_chan)
+ changed |= IEEE80211_CHANCTX_CHANGE_NPCA;
+ if (chanreq->oper.npca_chan &&
+ ctx->conf.def.npca_punctured != chanreq->oper.npca_punctured)
+ changed |= IEEE80211_CHANCTX_CHANGE_NPCA_PUNCT;
}
if (!cfg80211_chandef_identical(&ctx->conf.ap, &chanreq->ap))
changed |= IEEE80211_CHANCTX_CHANGE_AP;
- ctx->conf.def = *chandef;
+ ctx->conf.def = chanreq->oper;
ctx->conf.ap = chanreq->ap;
/* check if min chanctx also changed */
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 10/14] wifi: mac80211: mlme: use NPCA chandef if capable
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (8 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 09/14] wifi: mac80211: allow only AP chanctx sharing with NPCA Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 11/14] wifi: mac80211: set AP NPCA parameters in bss_conf Johannes Berg
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
If the device is capable, parse the AP chandef with NPCA.
Also advertise the other NPCA operational parameters to the
underlying driver and track if they change (though not with
BSS critical update etc. yet)
Since NPCA can only be enabled when the chanctx isn't shared,
the channel context code needs to clear/set npca.enabled in
the per-link configuration, except during association since
we can't enable NPCA before having completed association. In
this case, set npca.enabled during the association process.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/mac80211.h | 25 ++++++++++++++
net/mac80211/chan.c | 38 +++++++++++++++++++++
net/mac80211/mlme.c | 77 +++++++++++++++++++++++++++++++++++++++++-
net/mac80211/util.c | 3 ++
4 files changed, 142 insertions(+), 1 deletion(-)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 62bfa298c67f..316554c0a047 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -373,6 +373,7 @@ struct ieee80211_vif_chanctx_switch {
* @BSS_CHANGED_MLD_TTLM: negotiated TID to link mapping was changed
* @BSS_CHANGED_TPE: transmit power envelope changed
* @BSS_CHANGED_NAN_LOCAL_SCHED: NAN local schedule changed (NAN mode only)
+ * @BSS_CHANGED_NPCA: NPCA parameters changed
*/
enum ieee80211_bss_change {
BSS_CHANGED_ASSOC = 1<<0,
@@ -411,6 +412,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_MLD_TTLM = BIT_ULL(34),
BSS_CHANGED_TPE = BIT_ULL(35),
BSS_CHANGED_NAN_LOCAL_SCHED = BIT_ULL(36),
+ BSS_CHANGED_NPCA = BIT_ULL(37),
/* when adding here, make sure to change ieee80211_reconfig */
};
@@ -596,6 +598,26 @@ struct ieee80211_parsed_tpe {
struct ieee80211_parsed_tpe_psd psd_local[2], psd_reg_client[2];
};
+/**
+ * struct ieee80211_bss_npca_params - NPCA parameters
+ * @min_dur_thresh: NPCA minimum duration threshold (512 + 128*n usec)
+ * @switch_delay: NPCA switch delay (units of 4 usec)
+ * @switch_back_delay: NPCA switch back delay (units of 4 usec)
+ * @init_qsrc: initial QSRC value
+ * @moplen: indicates MOPLEN NPCA is permitted in the BSS
+ * @enabled: NPCA is enabled for this link
+ *
+ * Note: the individual values (except @enabled) are in spec representation.
+ */
+struct ieee80211_bss_npca_params {
+ u32 min_dur_thresh:4,
+ switch_delay:6,
+ switch_back_delay:6,
+ init_qsrc:2,
+ moplen:1,
+ enabled:1;
+};
+
/**
* struct ieee80211_bss_conf - holds the BSS's changing parameters
*
@@ -770,6 +792,7 @@ struct ieee80211_parsed_tpe {
* (as opposed to hearing its value from another link's beacon).
* @s1g_long_beacon_period: number of beacon intervals between each long
* beacon transmission.
+ * @npca: NPCA parameters
*/
struct ieee80211_bss_conf {
struct ieee80211_vif *vif;
@@ -873,6 +896,8 @@ struct ieee80211_bss_conf {
u8 bss_param_ch_cnt_link_id;
u8 s1g_long_beacon_period;
+
+ struct ieee80211_bss_npca_params npca;
};
#define IEEE80211_NAN_MAX_CHANNELS 3
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 6c7f5c9de026..d15cb1c22cf4 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -769,6 +769,38 @@ void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
_ieee80211_recalc_chanctx_min_def(local, ctx, NULL, false);
}
+static void
+ieee80211_chanctx_update_npca_links(struct ieee80211_local *local,
+ struct ieee80211_chanctx *ctx,
+ bool enable)
+{
+ struct ieee80211_chanctx_user_iter iter;
+
+ if (!!ctx->conf.def.npca_chan != enable)
+ return;
+
+ for_each_chanctx_user_assigned(local, ctx, &iter) {
+ if (!iter.link)
+ continue;
+ if (!iter.sdata->vif.cfg.assoc)
+ continue;
+
+ if (enable) {
+ if (!iter.link->conf->chanreq.oper.npca_chan)
+ continue;
+ } else {
+ if (!iter.link->conf->npca.enabled)
+ continue;
+ }
+
+ iter.link->conf->npca.enabled = enable;
+ drv_link_info_changed(local, iter.sdata,
+ iter.link->conf,
+ iter.link->link_id,
+ BSS_CHANGED_NPCA);
+ }
+}
+
static void _ieee80211_change_chanctx(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx,
struct ieee80211_chanctx *old_ctx,
@@ -844,10 +876,16 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local,
ieee80211_add_wbrf(local, &ctx->conf.def);
+ /* disable NPCA on the link using it */
+ ieee80211_chanctx_update_npca_links(local, ctx, false);
+
drv_change_chanctx(local, ctx, changed);
/* check if BW is wider */
ieee80211_chan_bw_change(local, old_ctx, false, false);
+
+ /* enable NPCA on the link that requested it */
+ ieee80211_chanctx_update_npca_links(local, ctx, true);
}
static void ieee80211_change_chanctx(struct ieee80211_local *local,
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 247871c10615..0ed3e23c6e60 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -401,6 +401,7 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
elems->uhr_operation_len,
false)) {
struct cfg80211_chan_def npca_chandef = *chandef;
+ const struct ieee80211_sta_uhr_cap *uhr_cap;
const struct ieee80211_uhr_npca_info *npca;
npca = ieee80211_uhr_npca_info(uhr_oper);
@@ -411,6 +412,14 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
"AP UHR NPCA settings invalid, disabling UHR\n");
return IEEE80211_CONN_MODE_EHT;
}
+
+ uhr_cap = ieee80211_get_uhr_iftype_cap_vif(sband, &sdata->vif);
+ /* can't happen since we must have UHR to parse the elems */
+ if (WARN_ON(!uhr_cap))
+ return IEEE80211_CONN_MODE_EHT;
+
+ if (uhr_cap->mac.mac_cap[0] & IEEE80211_UHR_MAC_CAP0_NPCA_SUPP)
+ *chandef = npca_chandef;
}
return IEEE80211_CONN_MODE_UHR;
@@ -1320,6 +1329,7 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,
.conn = &link->u.mgd.conn,
};
struct ieee80211_sub_if_data *sdata = link->sdata;
+ struct ieee80211_chanctx_conf *chanctx_conf;
struct ieee80211_chan_req chanreq = {};
enum ieee80211_conn_mode ap_mode;
const char *frame;
@@ -1403,8 +1413,55 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,
}
}
- if (ieee80211_chanreq_identical(&chanreq, &link->conf->chanreq))
+ /*
+ * Beacons don't have the full information - we need to track
+ * critical updates for NPCA parameters etc. For now only handle
+ * association and link reconfiguration response.
+ */
+ if (stype != IEEE80211_STYPE_BEACON &&
+ chanreq.oper.npca_chan && elems->uhr_operation &&
+ ieee80211_uhr_oper_size_ok((const void *)elems->uhr_operation,
+ elems->uhr_operation_len,
+ false)) {
+ const struct ieee80211_uhr_npca_info *npca;
+ struct ieee80211_bss_npca_params params = {};
+
+ npca = ieee80211_uhr_npca_info(elems->uhr_operation);
+ if (!npca) {
+ chanreq.oper.npca_chan = NULL;
+ chanreq.oper.npca_punctured = 0;
+ } else {
+ params.min_dur_thresh =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_MIN_DUR_THRESH);
+ params.switch_delay =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_SWITCH_DELAY);
+ params.switch_back_delay =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_SWITCH_BACK_DELAY);
+ params.init_qsrc =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_INIT_QSRC);
+ params.moplen =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_MOPLEN);
+ /* don't change the enabled bit yet */
+ params.enabled = link->conf->npca.enabled;
+ }
+
+ if (memcmp(¶ms, &link->conf->npca, sizeof(params)) ||
+ !update) {
+ link->conf->npca = params;
+ *changed |= BSS_CHANGED_NPCA;
+ }
+ }
+
+ if (ieee80211_chanreq_identical(&chanreq, &link->conf->chanreq)) {
+ if (update)
+ goto update_npca;
return 0;
+ }
link_info(link,
"AP %pM changed bandwidth in %s, new used config is %d.%03d MHz, width %d (%d.%03d/%d MHz)\n",
@@ -1451,6 +1508,24 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,
}
cfg80211_schedule_channels_check(&sdata->wdev);
+
+update_npca:
+ chanctx_conf = sdata_dereference(link->conf->chanctx_conf, sdata);
+ /* must be non-NULL when update is true */
+ if (WARN_ON(!chanctx_conf))
+ return -EINVAL;
+
+ /*
+ * If we're not associated yet (i.e. in the process associating)
+ * then the chanctx code won't have enabled NPCA in the link, so
+ * if the channel context was set up with NPCA for us, enable it.
+ */
+ if (chanreq.oper.npca_chan && chanctx_conf->def.npca_chan &&
+ !link->conf->npca.enabled && !sdata->vif.cfg.assoc) {
+ link->conf->npca.enabled = true;
+ *changed |= BSS_CHANGED_NPCA;
+ }
+
return 0;
}
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 8c816a2a65f2..19afa0bdbf25 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2147,6 +2147,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
ieee80211_bss_info_change_notify(sdata,
changed);
} else if (!WARN_ON(!link)) {
+ if (link->conf->npca.enabled)
+ changed |= BSS_CHANGED_NPCA;
+
ieee80211_link_info_change_notify(sdata, link,
changed);
changed = BSS_CHANGED_ASSOC |
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 11/14] wifi: mac80211: set AP NPCA parameters in bss_conf
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (9 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 10/14] wifi: mac80211: mlme: use NPCA chandef if capable Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 12/14] wifi: cfg80211: separate NPCA validity from chandef validity Johannes Berg
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Set the parameters advertised in the beacon in the BSS
configuration as well.
Note this is incomplete since it doesn't track updates.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/cfg.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 8f8d860944a8..9f24a5fa5e75 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1724,10 +1724,42 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
}
if (params->beacon.uhr_oper) {
+ const struct ieee80211_uhr_npca_info *npca;
+ struct ieee80211_bss_npca_params npca_params = {};
+
if (!link_conf->eht_support)
return -EOPNOTSUPP;
link_conf->uhr_support = true;
+
+ npca = ieee80211_uhr_npca_info(params->beacon.uhr_oper);
+ if (!npca) {
+ chanreq.oper.npca_chan = NULL;
+ chanreq.oper.npca_punctured = 0;
+ } else {
+ npca_params.min_dur_thresh =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_MIN_DUR_THRESH);
+ npca_params.switch_delay =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_SWITCH_DELAY);
+ npca_params.switch_back_delay =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_SWITCH_BACK_DELAY);
+ npca_params.init_qsrc =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_INIT_QSRC);
+ npca_params.moplen =
+ le32_get_bits(npca->params,
+ IEEE80211_UHR_NPCA_PARAMS_MOPLEN);
+ npca_params.enabled = true;
+ }
+
+ if (memcmp(&npca_params, &link->conf->npca,
+ sizeof(npca_params))) {
+ link->conf->npca = npca_params;
+ changed |= BSS_CHANGED_NPCA;
+ }
}
if (sdata->vif.type == NL80211_IFTYPE_AP &&
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 12/14] wifi: cfg80211: separate NPCA validity from chandef validity
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (10 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 11/14] wifi: mac80211: set AP NPCA parameters in bss_conf Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 13/14] wifi: mac80211: don't parse full UHR operation from beacons Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 14/14] wifi: mac80211: check AP using NPCA has NPCA capability Johannes Berg
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
When considering both NPCA and DBE, it can appear that the
NPCA configuration is invalid, e.g. for an 80 MHz BSS channel
with DBE to 160 MHz:
| primary channel
| NPCA primary channel
| |
V V
| p | | n | | | | | |
| BSS channel |
| DBE channel |
Now the NPCA primary channel is in the same half as the primary
channel, and the NPCA puncturing bitmap could be completely
invalid as a puncturing bitmap when considering the overall
channel.
Split out the validity checks from cfg80211_chandef_valid() to
a new cfg80211_chandef_npca_valid() function that just checks
the NPCA configuration against the BSS chandef.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/cfg80211.h | 23 ++++++++++++++++
net/mac80211/mlme.c | 5 +++-
net/wireless/chan.c | 59 +++++++++++++++++++++++++++---------------
3 files changed, 65 insertions(+), 22 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 2546567792e2..5176dcb300fa 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -845,6 +845,10 @@ struct key_params {
* struct cfg80211_chan_def - channel definition
* @chan: the (control) channel
* @npca_chan: the NPCA primary channel
+ * Note that if DBE is in use, this channel may appear to be
+ * inside the primary half of the chandef. Implementations
+ * can use the position of this channel to understand how
+ * NPCA is used.
* @width: channel width
* @center_freq1: center frequency of first segment
* @center_freq2: center frequency of second segment
@@ -860,6 +864,8 @@ struct key_params {
* @npca_punctured: NPCA puncturing bitmap, like @punctured but for
* NPCA transmissions. If NPCA is used (@npca_chan is not %NULL)
* this will be a superset of the @punctured bimap.
+ * Note that if DBE is used, this bitmap is also shifted to be in
+ * accordance with the overall chandef bandwidth.
* @s1g_primary_2mhz: Indicates if the control channel pointed to
* by 'chan' exists as a 1MHz primary subchannel within an
* S1G 2MHz primary channel.
@@ -1150,6 +1156,23 @@ int cfg80211_chandef_primary(const struct cfg80211_chan_def *chandef,
enum nl80211_chan_width primary_chan_width,
u16 *punctured);
+/**
+ * cfg80211_chandef_npca_valid - check that NPCA information is valid
+ * @wiphy: the wiphy to check for, for channel pointer lookup
+ * @chandef: the BSS channel chandef to check against
+ * @npca: NPCA information, can be %NULL in which case this
+ * always returns %true
+ *
+ * Note that DBE must not have been configured into the chandef yet
+ * before checking NPCA, i.e. @chandef must represent the BSS channel.
+ *
+ * Returns: %true if the NPCA channel and puncturing bitmap are valid
+ * according to the chandef, %false otherwise
+ */
+bool cfg80211_chandef_npca_valid(struct wiphy *wiphy,
+ const struct cfg80211_chan_def *chandef,
+ const struct ieee80211_uhr_npca_info *npca);
+
/**
* cfg80211_chandef_add_npca - parse and add NPCA information to chandef
* @wiphy: the wiphy this will be used for, for channel pointer lookup
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 0ed3e23c6e60..ccca5219b9e8 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -406,7 +406,10 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
npca = ieee80211_uhr_npca_info(uhr_oper);
- if (cfg80211_chandef_add_npca(sdata->local->hw.wiphy,
+ /* DBE is not considered yet, so this works */
+ if (!cfg80211_chandef_npca_valid(sdata->local->hw.wiphy,
+ &npca_chandef, npca) ||
+ cfg80211_chandef_add_npca(sdata->local->hw.wiphy,
&npca_chandef, npca)) {
sdata_info(sdata,
"AP UHR NPCA settings invalid, disabling UHR\n");
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 70fec444955e..501223d8bb14 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -460,9 +460,6 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
return false;
if (chandef->npca_chan) {
- bool pri_upper, npca_upper;
- u32 cf1;
-
switch (chandef->width) {
case NL80211_CHAN_WIDTH_80:
case NL80211_CHAN_WIDTH_160:
@@ -471,24 +468,6 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
default:
return false;
}
-
- if (!cfg80211_chandef_valid_control_freq(chandef,
- chandef->npca_chan->center_freq))
- return false;
-
- cf1 = chandef->center_freq1;
- pri_upper = chandef->chan->center_freq > cf1;
- npca_upper = chandef->npca_chan->center_freq > cf1;
-
- if (pri_upper == npca_upper)
- return false;
-
- if (!valid_puncturing_bitmap(chandef,
- chandef->npca_chan->center_freq,
- chandef->npca_punctured) ||
- (chandef->punctured & chandef->npca_punctured) !=
- chandef->punctured)
- return false;
} else if (chandef->npca_punctured) {
return false;
}
@@ -556,6 +535,44 @@ int cfg80211_chandef_primary(const struct cfg80211_chan_def *c,
}
EXPORT_SYMBOL(cfg80211_chandef_primary);
+bool cfg80211_chandef_npca_valid(struct wiphy *wiphy,
+ const struct cfg80211_chan_def *chandef,
+ const struct ieee80211_uhr_npca_info *npca)
+{
+ struct cfg80211_chan_def tmp = *chandef;
+ bool pri_upper, npca_upper;
+ u32 cf1;
+
+ if (chandef->npca_chan || chandef->npca_punctured)
+ return false;
+
+ if (!npca)
+ return true;
+
+ if (cfg80211_chandef_add_npca(wiphy, &tmp, npca))
+ return false;
+
+ if (!cfg80211_chandef_valid_control_freq(&tmp,
+ tmp.npca_chan->center_freq))
+ return false;
+
+ cf1 = tmp.center_freq1;
+ pri_upper = tmp.chan->center_freq > cf1;
+ npca_upper = tmp.npca_chan->center_freq > cf1;
+
+ if (pri_upper == npca_upper)
+ return false;
+
+ if (!valid_puncturing_bitmap(&tmp,
+ tmp.npca_chan->center_freq,
+ tmp.npca_punctured) ||
+ (tmp.punctured & tmp.npca_punctured) != tmp.punctured)
+ return false;
+
+ return true;
+}
+EXPORT_SYMBOL(cfg80211_chandef_npca_valid);
+
int cfg80211_chandef_add_npca(struct wiphy *wiphy,
struct cfg80211_chan_def *chandef,
const struct ieee80211_uhr_npca_info *npca)
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 13/14] wifi: mac80211: don't parse full UHR operation from beacons
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (11 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 12/14] wifi: cfg80211: separate NPCA validity from chandef validity Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 14/14] wifi: mac80211: check AP using NPCA has NPCA capability Johannes Berg
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Currently, as noted in the comment, ieee80211_uhr_oper_size_ok()
will reject the element coming from the beacon, since it's too
short. However, this is incorrect in general, since the element
is extensible, and such extensions could be present in a beacon,
and then it might pass muster anyway.
Using the frame type we now have in the element parse result,
check that it's not coming from a beacon. The size was already
checked (according to frame type) during parsing.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/mlme.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index ccca5219b9e8..e23575745c38 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -392,14 +392,7 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
if (conn->mode < IEEE80211_CONN_MODE_UHR || !uhr_oper)
return IEEE80211_CONN_MODE_EHT;
- /*
- * In beacons we don't have all the data - but we know the size was OK,
- * so if the size is valid as a non-beacon case, we have more data and
- * can validate the NPCA parameters.
- */
- if (ieee80211_uhr_oper_size_ok((const void *)uhr_oper,
- elems->uhr_operation_len,
- false)) {
+ if (elems->frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON)) {
struct cfg80211_chan_def npca_chandef = *chandef;
const struct ieee80211_sta_uhr_cap *uhr_cap;
const struct ieee80211_uhr_npca_info *npca;
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH wireless-next 14/14] wifi: mac80211: check AP using NPCA has NPCA capability
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
` (12 preceding siblings ...)
2026-04-28 9:25 ` [PATCH wireless-next 13/14] wifi: mac80211: don't parse full UHR operation from beacons Johannes Berg
@ 2026-04-28 9:25 ` Johannes Berg
13 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-04-28 9:25 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
If an AP advertises NPCA, it should also advertise NPCA
capability. Validate this.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/mlme.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index e23575745c38..f84bf50cb353 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -397,8 +397,19 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
const struct ieee80211_sta_uhr_cap *uhr_cap;
const struct ieee80211_uhr_npca_info *npca;
+ /* frames other than beacons carry UHR capability too */
+ if (!elems->uhr_cap)
+ return IEEE80211_CONN_MODE_EHT;
+
npca = ieee80211_uhr_npca_info(uhr_oper);
+ if (npca && !(elems->uhr_cap->mac.mac_cap[0] &
+ IEEE80211_UHR_MAC_CAP0_NPCA_SUPP)) {
+ sdata_info(sdata,
+ "AP without UHR NPCA capability uses it, disabling UHR\n");
+ return IEEE80211_CONN_MODE_EHT;
+ }
+
/* DBE is not considered yet, so this works */
if (!cfg80211_chandef_npca_valid(sdata->local->hw.wiphy,
&npca_chandef, npca) ||
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-04-28 9:27 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 9:25 [PATCH wireless-next 00/14] wifi: UHR non-primary channel access Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 01/14] wifi: mac80211: use struct for ieee80211_determine_ap_chan() args Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 02/14] wifi: mac80211: move ieee80211_chandef_usable() up Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 03/14] wifi: mac80211: carry element parsing frame type/from_ap Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 04/14] wifi: cfg80211: allow representing NPCA in chandef Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 05/14] wifi: cfg80211: add helper for parsing NPCA to chandef Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 06/14] wifi: mac80211: use NPCA in chandef for validation Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 07/14] wifi: mac80211: remove NPCA during chandef downgrade Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 08/14] wifi: mac80211: add NPCA to chandef tracing Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 09/14] wifi: mac80211: allow only AP chanctx sharing with NPCA Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 10/14] wifi: mac80211: mlme: use NPCA chandef if capable Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 11/14] wifi: mac80211: set AP NPCA parameters in bss_conf Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 12/14] wifi: cfg80211: separate NPCA validity from chandef validity Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 13/14] wifi: mac80211: don't parse full UHR operation from beacons Johannes Berg
2026-04-28 9:25 ` [PATCH wireless-next 14/14] wifi: mac80211: check AP using NPCA has NPCA capability Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox