Skip to contentSkip to conversation

wifi: misc S1G channel fixups/additions

PATCH In review Lachlan Hodges 3 participants 8 messages Nov 25, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover wifi: misc S1G channel fixups/additions

Some additional information specifically regarding the channel context implementation can be found in [1]. For now it's very basic, we only support sharing an identical channel context.

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#m4cefcd7c644175261f540900defbc7127b3a6364

Lachlan Hodges (3):
wifi: cfg80211: include s1g_primary_2mhz when sending chandef
wifi: cfg80211: include s1g_primary_2mhz when comparing chandefs
wifi: mac80211: allow sharing identical chanctx for S1G interfaces

 include/net/cfg80211.h |  3 ++-
 net/mac80211/chan.c    | 14 +++++++++++++-
 net/mac80211/mlme.c    |  9 +++++++--
 net/wireless/nl80211.c |  3 +++
 4 files changed, 25 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 wifi: cfg80211: include s1g_primary_2mhz when sending chandef

The chandef now includes a flag denoting the use of a 2MHz primary channel for S1G interfaces, include this when sending the chandef.

---
 net/wireless/nl80211.c | 3 +++
 1 file changed, 3 insertions(+)
net/wireless/nl80211.c +3 -0
index 2187e148389d..c2bb0f8f480b 100644
@@ -4178,6 +4178,9 @@ int nl80211_send_chandef(struct sk_buff *msg, const struct cfg80211_chan_def *ch
 	if (chandef->punctured &&
 	    nla_put_u32(msg, NL80211_ATTR_PUNCT_BITMAP, chandef->punctured))
 		return -ENOBUFS;
+	if (chandef->s1g_primary_2mhz &&
+	    nla_put_flag(msg, NL80211_ATTR_S1G_PRIMARY_2MHZ))
+		return -ENOBUFS;
 
 	return 0;
 }
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 wifi: cfg80211: include s1g_primary_2mhz when comparing chandefs

In reply to Lachlan Hodges

When comparing chandefs, ensure we include s1g_primary_2mhz.

---
 include/net/cfg80211.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/net/cfg80211.h +2 -1
index 53490eb04e87..d513a70fad07 100644
@@ -975,7 +975,8 @@ cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
 		chandef1->center_freq1 == chandef2->center_freq1 &&
 		chandef1->freq1_offset == chandef2->freq1_offset &&
 		chandef1->center_freq2 == chandef2->center_freq2 &&
-		chandef1->punctured == chandef2->punctured);
+		chandef1->punctured == chandef2->punctured &&
+		chandef1->s1g_primary_2mhz == chandef2->s1g_primary_2mhz);
 }
 
 /**
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 wifi: mac80211: allow sharing identical chanctx for S1G interfaces

In reply to Lachlan Hodges

Introduce support for sharing identical channel contexts for S1G interfaces. Additionally, do not downgrade channel requests for S1G interfaces.

---

I've kept the WARN_ON(1) here, though it only *should* be hit if an S1G driver advertises num_different_channels > 1 and starts a non-identical interface, otherwise the connection will be rejected earlier when verifying the iface combinations assuming num_different_channels = 1 (should be every S1G driver at this point).

---
 net/mac80211/chan.c | 14 +++++++++++++-
 net/mac80211/mlme.c |  9 +++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)
net/mac80211/chan.c +13 -1
index 57065714cf8c..f73973096097 100644
@@ -530,8 +530,20 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local,
 	};
 	u32 changed = 0;
 
-	/* expected to handle only 20/40/80/160/320 channel widths */
+	/* 5/10 MHz not handled here */
 	switch (chandef->width) {
+	case NL80211_CHAN_WIDTH_1:
+	case NL80211_CHAN_WIDTH_2:
+	case NL80211_CHAN_WIDTH_4:
+	case NL80211_CHAN_WIDTH_8:
+	case NL80211_CHAN_WIDTH_16:
+		/*
+		 * mac80211 currently only supports sharing identical
+		 * chanctx's for S1G interfaces.
+		 */
+		if (ieee80211_chanreq_identical(&ctx_req, chanreq))
+			return;
+		WARN_ON(1);
 	case NL80211_CHAN_WIDTH_20_NOHT:
 	case NL80211_CHAN_WIDTH_20:
 	case NL80211_CHAN_WIDTH_40:
net/mac80211/mlme.c +7 -2
index 025210d50405..e4814cb1c181 100644
@@ -6122,9 +6122,14 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
 	ret = ieee80211_link_use_channel(link, &chanreq,
 					 IEEE80211_CHANCTX_SHARED);
 
-	/* don't downgrade for 5 and 10 MHz channels, though. */
+	/* don't downgrade for 5/10/S1G MHz channels, though. */
 	if (chanreq.oper.width == NL80211_CHAN_WIDTH_5 ||
-	    chanreq.oper.width == NL80211_CHAN_WIDTH_10)
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_10 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_1 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_2 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_4 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_8 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_16)
 		return ret;
 
 	while (ret && chanreq.oper.width != NL80211_CHAN_WIDTH_20_NOHT) {
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH wireless-next 3/3] wifi: mac80211: allow sharing identical chanctx for S1G interfaces

net/mac80211/chan.c static void _ieee80211_change_chanctx(struct ieee80211_local *local, · line 546

Quoted 13 lines
net/mac80211/chan.c +12 -0
 	switch (chandef->width) {
+	case NL80211_CHAN_WIDTH_1:
+	case NL80211_CHAN_WIDTH_2:
+	case NL80211_CHAN_WIDTH_4:
+	case NL80211_CHAN_WIDTH_8:
+	case NL80211_CHAN_WIDTH_16:
+		/*
+		 * mac80211 currently only supports sharing identical
+		 * chanctx's for S1G interfaces.
+		 */
+		if (ieee80211_chanreq_identical(&ctx_req, chanreq))
+			return;
+		WARN_ON(1);

The robot not happy with this as I forgot a break / fallthrough..

	if (ieee80211_chanreq_identical(&ctx_req, chanreq))
		return;
	WARN_ON(1);
	return;

The above looks a bit ugly.. did you have a preference here before I send a v2?

lachlan

maintainer
#5 lore raw

Re: [PATCH wireless-next 3/3] wifi: mac80211: allow sharing identical chanctx for S1G interfaces

Quoted 16 lines · Lachlan Hodges

net/mac80211/chan.c static void _ieee80211_change_chanctx(struct ieee80211_local *local, · line 546

Quoted 13 lines

  switch (chandef->width) {

net/mac80211/chan.c +12 -0
+	case NL80211_CHAN_WIDTH_1:
+	case NL80211_CHAN_WIDTH_2:
+	case NL80211_CHAN_WIDTH_4:
+	case NL80211_CHAN_WIDTH_8:
+	case NL80211_CHAN_WIDTH_16:
+		/*
+		 * mac80211 currently only supports sharing identical
+		 * chanctx's for S1G interfaces.
+		 */
+		if (ieee80211_chanreq_identical(&ctx_req, chanreq))
+			return;
+		WARN_ON(1);

The robot not happy with this as I forgot a break / fallthrough..

Quoted 7 lines
	if (ieee80211_chanreq_identical(&ctx_req, chanreq))
		return;
	WARN_ON(1);
	return;

The above looks a bit ugly.. did you have a preference here before I send a v2?

I guess I'd prefer just

	WARN_ON(!ieee80211_chanreq_identical(&ctx_req, chanreq));
	return;

?

johannes

maintainer
#6 lore raw

Re: [PATCH wireless-next 3/3] wifi: mac80211: allow sharing identical chanctx for S1G interfaces

In reply to Lachlan Hodges

FWIW, I applied patches 1 and 2.

net/mac80211/mlme.c static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata, · line 6133

Quoted 11 lines
net/mac80211/mlme.c +7 -2
-	/* don't downgrade for 5 and 10 MHz channels, though. */
+	/* don't downgrade for 5/10/S1G MHz channels, though. */
 	if (chanreq.oper.width == NL80211_CHAN_WIDTH_5 ||
-	    chanreq.oper.width == NL80211_CHAN_WIDTH_10)
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_10 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_1 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_2 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_4 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_8 ||
+	    chanreq.oper.width == NL80211_CHAN_WIDTH_16)
 		return ret;

Maybe that'd also be nicer to write as

	if (width == 5 ||
	    width == 10 ||
	    cfg80211_chandef_is_s1g(&chanreq.oper))

?

johannes

#7 lore raw

Re: [PATCH wireless-next 3/3] wifi: mac80211: allow sharing identical chanctx for S1G interfaces

In reply to Lachlan Hodges
kernel test robot noticed the following build warnings:

Hi Lachlan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.18-rc7 next-20251125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lachlan-Hodges/wifi-cfg80211-include-s1g_primary_2mhz-when-sending-chandef/20251125-110125
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20251125025927.245280-4-lachlan.hodges%40morsemicro.com
patch subject: [PATCH wireless-next 3/3] wifi: mac80211: allow sharing identical chanctx for S1G interfaces
config: arm-randconfig-001-20251126 (https://download.01.org/0day-ci/archive/20251126/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9e9fe08b16ea2c4d9867fb4974edf2a3776d6ece)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251126/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> net/mac80211/chan.c:671:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
     671 |         case NL80211_CHAN_WIDTH_20_NOHT:
         |         ^
   net/mac80211/chan.c:671:2: note: insert 'break;' to avoid fall-through
     671 |         case NL80211_CHAN_WIDTH_20_NOHT:
         |         ^
         |         break; 

1 warning generated.

vim +671 net/mac80211/chan.c

52363af3a9c989 Johannes Berg       2025-11-05  643  
b72a455a2409fd Johannes Berg       2023-05-04  644  static void _ieee80211_change_chanctx(struct ieee80211_local *local,
d6c375095ade4e Mordechay Goodstein 2021-06-18  645  				      struct ieee80211_chanctx *ctx,
d6c375095ade4e Mordechay Goodstein 2021-06-18  646  				      struct ieee80211_chanctx *old_ctx,
6092077ad09ce8 Johannes Berg       2024-01-29  647  				      const struct ieee80211_chan_req *chanreq,
b72a455a2409fd Johannes Berg       2023-05-04  648  				      struct ieee80211_link_data *rsvd_for)
d6c375095ade4e Mordechay Goodstein 2021-06-18  649  {
6092077ad09ce8 Johannes Berg       2024-01-29  650  	const struct cfg80211_chan_def *chandef = &chanreq->oper;
761748f001800d Johannes Berg       2024-01-29  651  	struct ieee80211_chan_req ctx_req = {
761748f001800d Johannes Berg       2024-01-29  652  		.oper = ctx->conf.def,
761748f001800d Johannes Berg       2024-01-29  653  		.ap = ctx->conf.ap,
761748f001800d Johannes Berg       2024-01-29  654  	};
761748f001800d Johannes Berg       2024-01-29  655  	u32 changed = 0;
44b72ca8163b8c Ilan Peer           2020-12-06  656  
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  657  	/* 5/10 MHz not handled here */
44b72ca8163b8c Ilan Peer           2020-12-06  658  	switch (chandef->width) {
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  659  	case NL80211_CHAN_WIDTH_1:
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  660  	case NL80211_CHAN_WIDTH_2:
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  661  	case NL80211_CHAN_WIDTH_4:
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  662  	case NL80211_CHAN_WIDTH_8:
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  663  	case NL80211_CHAN_WIDTH_16:
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  664  		/*
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  665  		 * mac80211 currently only supports sharing identical
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  666  		 * chanctx's for S1G interfaces.
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  667  		 */
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  668  		if (ieee80211_chanreq_identical(&ctx_req, chanreq))
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  669  			return;
ffaa1f7cd953b4 Lachlan Hodges      2025-11-25  670  		WARN_ON(1);
44b72ca8163b8c Ilan Peer           2020-12-06 @671  	case NL80211_CHAN_WIDTH_20_NOHT:
44b72ca8163b8c Ilan Peer           2020-12-06  672  	case NL80211_CHAN_WIDTH_20:
44b72ca8163b8c Ilan Peer           2020-12-06  673  	case NL80211_CHAN_WIDTH_40:
44b72ca8163b8c Ilan Peer           2020-12-06  674  	case NL80211_CHAN_WIDTH_80:
44b72ca8163b8c Ilan Peer           2020-12-06  675  	case NL80211_CHAN_WIDTH_80P80:
44b72ca8163b8c Ilan Peer           2020-12-06  676  	case NL80211_CHAN_WIDTH_160:
5dca295dd76756 Ilan Peer           2022-02-14  677  	case NL80211_CHAN_WIDTH_320:
44b72ca8163b8c Ilan Peer           2020-12-06  678  		break;
44b72ca8163b8c Ilan Peer           2020-12-06  679  	default:
44b72ca8163b8c Ilan Peer           2020-12-06  680  		WARN_ON(1);
44b72ca8163b8c Ilan Peer           2020-12-06  681  	}
44b72ca8163b8c Ilan Peer           2020-12-06  682  
d6c375095ade4e Mordechay Goodstein 2021-06-18  683  	/* Check maybe BW narrowed - we do this _before_ calling recalc_chanctx_min_def
d6c375095ade4e Mordechay Goodstein 2021-06-18  684  	 * due to maybe not returning from it, e.g in case new context was added
d6c375095ade4e Mordechay Goodstein 2021-06-18  685  	 * first time with all parameters up to date.
d6c375095ade4e Mordechay Goodstein 2021-06-18  686  	 */
b27512368591fc Johannes Berg       2024-06-12  687  	ieee80211_chan_bw_change(local, old_ctx, false, true);
44b72ca8163b8c Ilan Peer           2020-12-06  688  
761748f001800d Johannes Berg       2024-01-29  689  	if (ieee80211_chanreq_identical(&ctx_req, chanreq)) {
52363af3a9c989 Johannes Berg       2025-11-05  690  		_ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for, false);
d6c375095ade4e Mordechay Goodstein 2021-06-18  691  		return;
d6c375095ade4e Mordechay Goodstein 2021-06-18  692  	}
d6c375095ade4e Mordechay Goodstein 2021-06-18  693  
761748f001800d Johannes Berg       2024-01-29  694  	WARN_ON(ieee80211_chanctx_refcount(local, ctx) > 1 &&
761748f001800d Johannes Berg       2024-01-29  695  		!cfg80211_chandef_compatible(&ctx->conf.def, &chanreq->oper));
d6c375095ade4e Mordechay Goodstein 2021-06-18  696  
d34be4310cbe3a Evan Quan           2023-12-11  697  	ieee80211_remove_wbrf(local, &ctx->conf.def);
d34be4310cbe3a Evan Quan           2023-12-11  698  
b82730bf57b548 Johannes Berg       2024-01-29  699  	if (!cfg80211_chandef_identical(&ctx->conf.def, &chanreq->oper)) {
b82730bf57b548 Johannes Berg       2024-01-29  700  		if (ctx->conf.def.width != chanreq->oper.width)
761748f001800d Johannes Berg       2024-01-29  701  			changed |= IEEE80211_CHANCTX_CHANGE_WIDTH;
b82730bf57b548 Johannes Berg       2024-01-29  702  		if (ctx->conf.def.punctured != chanreq->oper.punctured)
b82730bf57b548 Johannes Berg       2024-01-29  703  			changed |= IEEE80211_CHANCTX_CHANGE_PUNCTURING;
b82730bf57b548 Johannes Berg       2024-01-29  704  	}
761748f001800d Johannes Berg       2024-01-29  705  	if (!cfg80211_chandef_identical(&ctx->conf.ap, &chanreq->ap))
761748f001800d Johannes Berg       2024-01-29  706  		changed |= IEEE80211_CHANCTX_CHANGE_AP;
d6c375095ade4e Mordechay Goodstein 2021-06-18  707  	ctx->conf.def = *chandef;
761748f001800d Johannes Berg       2024-01-29  708  	ctx->conf.ap = chanreq->ap;
d6c375095ade4e Mordechay Goodstein 2021-06-18  709  
d6c375095ade4e Mordechay Goodstein 2021-06-18  710  	/* check if min chanctx also changed */
52363af3a9c989 Johannes Berg       2025-11-05  711  	changed |= __ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for,
52363af3a9c989 Johannes Berg       2025-11-05  712  						      false);
d34be4310cbe3a Evan Quan           2023-12-11  713  
d34be4310cbe3a Evan Quan           2023-12-11  714  	ieee80211_add_wbrf(local, &ctx->conf.def);
d34be4310cbe3a Evan Quan           2023-12-11  715  
d6c375095ade4e Mordechay Goodstein 2021-06-18  716  	drv_change_chanctx(local, ctx, changed);
55de908ab292c0 Johannes Berg       2012-07-26  717  
761748f001800d Johannes Berg       2024-01-29  718  	/* check if BW is wider */
b27512368591fc Johannes Berg       2024-06-12  719  	ieee80211_chan_bw_change(local, old_ctx, false, false);
0aaffa9b969989 Johannes Berg       2010-05-05  720  }
d01a1e658606a0 Michal Kazior       2012-06-26  721  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki