* [PATCH wireless] wifi: cfg80211: return center freq for 1Mhz S1G chan start/end
@ 2025-10-21 11:07 Lachlan Hodges
2025-10-21 12:20 ` Johannes Berg
0 siblings, 1 reply; 3+ messages in thread
From: Lachlan Hodges @ 2025-10-21 11:07 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, arien.judge, Lachlan Hodges
The frequencies returned by cfg80211_s1g_get_{start/end}_freq_khz()
for 1MHz chandefs are off by +-1000KHz. This prevents some 1MHz
channels from being used as the range returned is larger leading to
adjacent 1MHz channels being included in the validation process.
Channels on the band edge may be prevented from being used if any
of those extra channels are disabled / no primary etc. To fix return
the center frequency as 1MHz channels don't contain any subchannels.
Fixes: d0688dc2b172 ("wifi: cfg80211: correctly implement and validate S1G chandef")
Signed-off-by: Lachlan Hodges <lachlan.hodges@morsemicro.com>
---
include/net/cfg80211.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 781624f5913a..a1e362e0054d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -10194,7 +10194,8 @@ cfg80211_s1g_get_start_freq_khz(const struct cfg80211_chan_def *chandef)
u32 bw_mhz = cfg80211_chandef_get_width(chandef);
u32 center_khz =
MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
- return center_khz - bw_mhz * 500 + 500;
+
+ return (bw_mhz == 1) ? center_khz : center_khz - bw_mhz * 500 + 500;
}
/**
@@ -10209,7 +10210,8 @@ cfg80211_s1g_get_end_freq_khz(const struct cfg80211_chan_def *chandef)
u32 bw_mhz = cfg80211_chandef_get_width(chandef);
u32 center_khz =
MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
- return center_khz + bw_mhz * 500 - 500;
+
+ return (bw_mhz == 1) ? center_khz : center_khz + bw_mhz * 500 - 500;
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH wireless] wifi: cfg80211: return center freq for 1Mhz S1G chan start/end
2025-10-21 11:07 [PATCH wireless] wifi: cfg80211: return center freq for 1Mhz S1G chan start/end Lachlan Hodges
@ 2025-10-21 12:20 ` Johannes Berg
2025-10-21 12:30 ` Lachlan Hodges
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2025-10-21 12:20 UTC (permalink / raw)
To: Lachlan Hodges; +Cc: linux-wireless, arien.judge
^^ should be MHz in the subject
On Tue, 2025-10-21 at 22:07 +1100, Lachlan Hodges wrote:
> The frequencies returned by cfg80211_s1g_get_{start/end}_freq_khz()
> for 1MHz chandefs are off by +-1000KHz.
Hmm. I'm confused.
> +++ b/include/net/cfg80211.h
> @@ -10194,7 +10194,8 @@ cfg80211_s1g_get_start_freq_khz(const struct cfg80211_chan_def *chandef)
> u32 bw_mhz = cfg80211_chandef_get_width(chandef);
> u32 center_khz =
> MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
> - return center_khz - bw_mhz * 500 + 500;
> +
> + return (bw_mhz == 1) ? center_khz : center_khz - bw_mhz * 500 + 500;
> }
I don't see how this changes anything - if "bw_mhz == 1" then
center_freq - bw_mhz * 500 + 500
== center_freq - 1 * 500 + 500
== center_freq - 500 + 500
== center_freq
so this makes no difference?
>
> /**
> @@ -10209,7 +10210,8 @@ cfg80211_s1g_get_end_freq_khz(const struct cfg80211_chan_def *chandef)
> u32 bw_mhz = cfg80211_chandef_get_width(chandef);
> u32 center_khz =
> MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
> - return center_khz + bw_mhz * 500 - 500;
> +
> + return (bw_mhz == 1) ? center_khz : center_khz + bw_mhz * 500 - 500;
Same here with the sign inverted?
What am I missing?
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH wireless] wifi: cfg80211: return center freq for 1Mhz S1G chan start/end
2025-10-21 12:20 ` Johannes Berg
@ 2025-10-21 12:30 ` Lachlan Hodges
0 siblings, 0 replies; 3+ messages in thread
From: Lachlan Hodges @ 2025-10-21 12:30 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, arien.judge
On Tue, Oct 21, 2025 at 02:20:45PM +0200, Johannes Berg wrote:
> ^^ should be MHz in the subject
>
> On Tue, 2025-10-21 at 22:07 +1100, Lachlan Hodges wrote:
> > The frequencies returned by cfg80211_s1g_get_{start/end}_freq_khz()
> > for 1MHz chandefs are off by +-1000KHz.
>
> Hmm. I'm confused.
>
> > +++ b/include/net/cfg80211.h
> > @@ -10194,7 +10194,8 @@ cfg80211_s1g_get_start_freq_khz(const struct cfg80211_chan_def *chandef)
> > u32 bw_mhz = cfg80211_chandef_get_width(chandef);
> > u32 center_khz =
> > MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
> > - return center_khz - bw_mhz * 500 + 500;
> > +
> > + return (bw_mhz == 1) ? center_khz : center_khz - bw_mhz * 500 + 500;
> > }
>
> I don't see how this changes anything - if "bw_mhz == 1" then
>
> center_freq - bw_mhz * 500 + 500
> == center_freq - 1 * 500 + 500
> == center_freq - 500 + 500
> == center_freq
>
> so this makes no difference?
Is there a way to remove this patch from the internet forever? heh ^.^. Sorry -
I have clearly forgotten basic arithmetic, though I'm now questioning why I
thought I needed to write this in the first place..
lachlan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-21 12:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 11:07 [PATCH wireless] wifi: cfg80211: return center freq for 1Mhz S1G chan start/end Lachlan Hodges
2025-10-21 12:20 ` Johannes Berg
2025-10-21 12:30 ` Lachlan Hodges
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox