All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Lachlan Hodges <lachlan.hodges@morsemicro.com>
Cc: linux-wireless@vger.kernel.org, benjamin.berg@intel.com,
	 arien.judge@morsemicro.com
Subject: Re: [PATCH RFC wireless-next] wifi: mac80211: correct rx freq handling for S1G
Date: Tue, 06 Oct 2026 09:44:28 +0200	[thread overview]
Message-ID: <da737a625b8ee416ffcaea37ab9c84e705634c4c.camel@sipsolutions.net> (raw)
In-Reply-To: <20261002072954.1168872-1-lachlan.hodges@morsemicro.com> (sfid-20261002_093135_409872_DAA7268A)

On Fri, 2026-10-02 at 17:29 +1000, Lachlan Hodges wrote:
> 
> +++ b/include/net/mac80211.h
> @@ -1741,6 +1741,8 @@ enum mac80211_rx_encoding {
>   * @freq: frequency the radio was tuned to when receiving this frame, in MHz
>   *	This field must be set for management frames, but isn't strictly needed
>   *	for data (other) frames - for those it only affects radiotap reporting.
> + *	For S1G, when operating on a 2MHz primary channel, this may be the
> + *	center frequency of the 2MHz primary rather than the 1MHz primary.

Should it really say "may be"? Vs. something more specific about being
1/2 MHz center depending on how it was transmitted/received?

> -static bool ieee80211_rx_valid_freq(int freq, struct ieee80211_link_data *link)
> +bool __ieee80211_rx_valid_freq(struct wiphy *wiphy,
> +			       struct ieee80211_rx_status *status,
> +			       const struct cfg80211_chan_def *chandef)
> +{
> +	u32 pri_khz = ieee80211_channel_to_khz(chandef->chan);
> +	u32 rx_khz = ieee80211_rx_status_to_khz(status);
> +	struct ieee80211_channel *sibling;
> +
> +	if (rx_khz == pri_khz)
> +		return true;

This is also in the original, but now it's called more I think, might
make sense to check them before conversion to kHz? But not sure what the
compiler would do here for the *1000.

> +	/* Any non-S1G case from here is not a valid freq */
> +	if (!cfg80211_chandef_is_s1g(chandef))
> +		return false;
> +
> +	if (!chandef->s1g_primary_2mhz)
> +		return false;
> +
> +	/*
> +	 * Find the sibling 1MHz channel of the 2MHz primary to calculate
> +	 * the 2MHz primary center frequency.
> +	 */
> +	sibling = cfg80211_s1g_get_primary_sibling(wiphy, chandef);
> +	if (!sibling)
> +		return false;
> +
> +	return rx_khz == (pri_khz + ieee80211_channel_to_khz(sibling)) / 2;


All of this gets really complex, IMHO.

Maybe here's another thought: we have

	u16 freq: 13, freq_offset: 1;

What if we make that

	u16 freq: 13, freq_offset: 1,
	    s1g_width_2mhz: 1;

(or something, handwaving about the name) and ask that the driver puts
the 1 MHz center frequency into freq/_offset (so mac80211's comparison
on RX is just ==), but we can still get back the right frequency to
report further out (scan, radiotap) again? Or use two bits (above/below)
then we don't even need to have the sibling channel lookup (we'd just
believe the driver).

I don't know, I'm just thinking out loud, but I feel like maybe that'd
make it more likely we don't break it (again) when we have HT/VHT/etc.
in mind?

johannes

      parent reply	other threads:[~2026-10-06  7:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02  7:29 [PATCH RFC wireless-next] wifi: mac80211: correct rx freq handling for S1G Lachlan Hodges
2026-10-02  7:58 ` Johannes Berg
2026-10-02  8:11   ` Johannes Berg
2026-10-02  9:54   ` Lachlan Hodges
2026-10-05 13:53     ` Johannes Berg
2026-10-06  6:06       ` Lachlan Hodges
2026-10-06  7:44 ` Johannes Berg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da737a625b8ee416ffcaea37ab9c84e705634c4c.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=arien.judge@morsemicro.com \
    --cc=benjamin.berg@intel.com \
    --cc=lachlan.hodges@morsemicro.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.