From: Felix Fietkau <nbd@nbd.name>
To: Johannes Berg <johannes@sipsolutions.net>,
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, 7 Jun 2024 11:53:15 +0200 [thread overview]
Message-ID: <c5abf1ae-bdda-42b2-95c0-9b1c39659bbd@nbd.name> (raw)
In-Reply-To: <a1cff51f789c21b2b307c58ee4d743a62874cec6.camel@sipsolutions.net>
On 07.06.24 11:44, Johannes Berg wrote:
> 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 :)
Sure, no problem.
> Maybe this should be a cfg80211 helper like
>
> struct wiphy_radio *wiphy_get_radio(struct wiphy *wiphy, ... *chandef);
I didn't add such a helper, in case we get hardware where multiple
radios support the same band. That's why ieee80211_find_available_radio
loops over all radios until it finds one that matches both the freq
range and the ifcomb constraints.
> 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.
I will move a variation of the freq range match helper to cfg80211.
>> 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 :)
Will fix :)
>> +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.
See above
- Felix
next prev parent reply other threads:[~2024-06-07 9:53 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
2024-06-07 9:53 ` Felix Fietkau [this message]
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=c5abf1ae-bdda-42b2-95c0-9b1c39659bbd@nbd.name \
--to=nbd@nbd.name \
--cc=ath12k@lists.infradead.org \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--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