From: Johannes Berg <johannes@sipsolutions.net>
To: Felix Fietkau <nbd@nbd.name>, linux-wireless@vger.kernel.org
Cc: quic_adisi@quicinc.com, quic_periyasa@quicinc.com,
ath12k@lists.infradead.org
Subject: Re: [RFC v3 8/8] wifi: mac80211: add wiphy radio assignment and validation
Date: Fri, 07 Jun 2024 11:44:00 +0200 [thread overview]
Message-ID: <a1cff51f789c21b2b307c58ee4d743a62874cec6.camel@sipsolutions.net> (raw)
In-Reply-To: <9b331a61b8d53284b044bc594cf9952c60164e5f.1717696995.git-series.nbd@nbd.name>
On Thu, 2024-06-06 at 20:07 +0200, Felix Fietkau wrote:
>
> +static bool
> +ieee80211_radio_freq_match(const struct wiphy_radio *radio,
> + const struct ieee80211_chan_req *chanreq)
> +{
> + const struct wiphy_radio_freq_range *r;
> + u32 freq;
> + int i;
> +
> + freq = ieee80211_channel_to_khz(chanreq->oper.chan);
> + for (i = 0; i < radio->n_freq_range; i++) {
> + r = &radio->freq_range[i];
> + if (freq >= r->start_freq && freq <= r->end_freq)
> + return true;
IMHO should be inclusive only on one side of the range. Can always make
it work since channels are at least a few MHz apart, but the purist in
me says it's easier to grok if the end is not inclusive :)
Maybe this should be a cfg80211 helper like
struct wiphy_radio *wiphy_get_radio(struct wiphy *wiphy, ... *chandef);
which could also check that the _whole_ chandef fits (though that should
probably also be handled elsewhere, like chandef_valid), and you can use
it to get the radio pointer and then check for == below.
The point would be to have a single place with this kind of range logic.
This is only going to get done by mac80211 now, but it'd really be
awkward if some other driver had some other logic later.
> if (!curr_ctx || (curr_ctx->replace_state ==
> IEEE80211_CHANCTX_WILL_BE_REPLACED) ||
> @@ -1096,6 +1117,12 @@ ieee80211_replace_chanctx(struct ieee80211_local *local,
> if (!list_empty(&ctx->reserved_links))
> continue;
>
> + if (ctx->conf.radio_idx >= 0) {
> + radio = &wiphy->radio[ctx->conf.radio_idx];
> + if (!ieee80211_radio_freq_match(radio, chanreq))
> + continue;
> + }
something happened to indentation here :)
> +static bool
> +ieee80211_find_available_radio(struct ieee80211_local *local,
> + const struct ieee80211_chan_req *chanreq,
> + int *radio_idx)
> +{
> + struct wiphy *wiphy = local->hw.wiphy;
> + const struct wiphy_radio *radio;
> + int i;
> +
> + *radio_idx = -1;
> + if (!wiphy->n_radio)
> + return true;
> +
> + for (i = 0; i < wiphy->n_radio; i++) {
> + radio = &wiphy->radio[i];
> + if (!ieee80211_radio_freq_match(radio, chanreq))
> + continue;
> +
> + if (!ieee80211_can_create_new_chanctx(local, i))
> + continue;
> +
> + *radio_idx = i;
> + return true;
> + }
> +
> + return false;
> +}
which would also get used here to find the radio first, though would
have to differentiate n_radio still, of course.
johannes
next prev parent reply other threads:[~2024-06-07 9:44 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 18:07 [RFC v3 0/8] cfg80211/mac80211: support defining multiple radios per wiphy Felix Fietkau
2024-06-06 18:07 ` [RFC v3 1/8] wifi: nl80211: split helper function from nl80211_put_iface_combinations Felix Fietkau
2024-06-06 18:07 ` [RFC v3 2/8] wifi: cfg80211: add support for advertising multiple radios belonging to a wiphy Felix Fietkau
2024-06-07 9:24 ` Johannes Berg
2024-06-07 10:00 ` Felix Fietkau
2024-06-06 18:07 ` [RFC v3 3/8] wifi: cfg80211: extend interface combination check for multi-radio Felix Fietkau
2024-06-07 9:32 ` Johannes Berg
2024-06-07 12:36 ` Felix Fietkau
2024-06-06 18:07 ` [RFC v3 4/8] wifi: mac80211: add support for DFS with multiple radios Felix Fietkau
2024-06-07 4:25 ` Karthikeyan Periyasamy
2024-06-07 4:35 ` Felix Fietkau
2024-06-07 4:54 ` Karthikeyan Periyasamy
2024-06-07 5:03 ` Felix Fietkau
2024-06-07 6:45 ` Karthikeyan Periyasamy
2024-06-07 8:16 ` Felix Fietkau
2024-06-07 8:54 ` Karthikeyan Periyasamy
2024-06-07 9:00 ` Felix Fietkau
2024-06-12 14:23 ` Karthikeyan Periyasamy
2024-06-12 14:29 ` Felix Fietkau
2024-06-06 18:07 ` [RFC v3 5/8] wifi: mac80211: add radio index to ieee80211_chanctx_conf Felix Fietkau
2024-06-06 18:07 ` [RFC v3 6/8] wifi: mac80211: extend ifcomb check functions for multi-radio Felix Fietkau
2024-06-07 4:45 ` Karthikeyan Periyasamy
2024-06-07 4:49 ` Felix Fietkau
2024-06-07 9:22 ` Karthikeyan Periyasamy
2024-06-07 10:07 ` Karthikeyan Periyasamy
2024-06-07 10:22 ` Felix Fietkau
2024-06-07 10:53 ` Karthikeyan Periyasamy
2024-06-07 11:04 ` Felix Fietkau
2024-06-12 12:05 ` Johannes Berg
2024-06-12 12:21 ` Felix Fietkau
2024-06-06 18:07 ` [RFC v3 7/8] wifi: mac80211: move code in ieee80211_link_reserve_chanctx to a helper Felix Fietkau
2024-06-06 18:07 ` [RFC v3 8/8] wifi: mac80211: add wiphy radio assignment and validation Felix Fietkau
2024-06-07 9:44 ` Johannes Berg [this message]
2024-06-07 9:53 ` Felix Fietkau
2024-06-07 10:12 ` Johannes Berg
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=a1cff51f789c21b2b307c58ee4d743a62874cec6.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=ath12k@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@nbd.name \
--cc=quic_adisi@quicinc.com \
--cc=quic_periyasa@quicinc.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox