Re: net80211 channel cleanup - IEEE80211_IS_CHAN_DEFINED() / IEEE80211_IS_CHAN_ANYC()

From: Bjoern A. Zeeb <bz_at_freebsd.org>
Date: Tue, 07 Jan 2025 18:01:50 UTC
On Fri, 27 Dec 2024, Adrian Chadd wrote:

> On Thu, 26 Dec 2024 at 22:58, Bjoern A. Zeeb <bz@freebsd.org> wrote:
>
>> On Sat, 21 Dec 2024, Adrian Chadd wrote:
>>
>>> hi!
>>>
>>> i've started on the bare minimum to start cleaning up the way we handle
>>> channels in net80211. The first part - no matter what direction we
>>> eventually DO go - is to try and remove all of the direct pointer
>>> comparisons and dereferences that are going on.
>>>
>>> So along this topic, i've created a diff to demonstrate a couple of those
>>> cases:
>>>
>>> https://reviews.freebsd.org/D48172
>>>
>>> Specifically:
>>>
>>> * IEEE80211_IS_CHAN_DEFINED() returns true if the channel isn't null; and
>>
>> I am sceptical about this one; see further below.
>>
>>
>>> * IEEE80211_IS_CHAN_ANYC() returns true if the channel is the "any
>> channel"
>>> channel (ie IEEE80211_CHAN_ANYC).
>>
>> I would suggest to keep the IEEE80211_CHAN_ prefix and insert the IS
>> after that: IEEE80211_CHAN_IS_ANYC()
>>
>
> ok, why's that? All of the other mcaros are IEEE80211_IS_CHAN_xxx().
> (I don't mind renaming it, I'm just curious why!)

Grml. Yes.  So be it.  The flags are all IEEE80211_CHAN_* and it
would've been nice to have the common prefix for all channel stuff but
history...

>> There are also plain "ANY" (no C) cases which should also be covered but
>> they fit even less into this scheme.
>>
>
> Which ones? I want to make sure those get covered too.

I just grepped and didn't go through them anymore in drivers ...
There seem to be two halfs in this output unintenionally nicely ordered
;-)

sys/dev/bwi/bwiphy.c:   if (chan == IEEE80211_CHAN_ANY)
sys/dev/bwi/bwirf.c:    rf->rf_curchan = IEEE80211_CHAN_ANY;
sys/dev/bwi/bwirf.c:    if (chan == IEEE80211_CHAN_ANY)
sys/dev/bwi/bwirf.c:    if (chan == IEEE80211_CHAN_ANY) {
sys/dev/ral/rt2560.c:   KASSERT(chan != 0 && chan != IEEE80211_CHAN_ANY, ("chan 0x%x", chan));
sys/dev/ral/rt2661.c:   KASSERT(chan != 0 && chan != IEEE80211_CHAN_ANY, ("chan 0x%x", chan));
sys/dev/ral/rt2860.c:   if (chan == 0 || chan == IEEE80211_CHAN_ANY)
sys/dev/usb/wlan/if_rum.c:      if (chan == 0 || chan == IEEE80211_CHAN_ANY)
sys/dev/usb/wlan/if_run.c:      if (chan == 0 || chan == IEEE80211_CHAN_ANY)
sys/dev/usb/wlan/if_upgt.c:     if (channel == 0 || channel == IEEE80211_CHAN_ANY) {
sys/dev/usb/wlan/if_ural.c:     if (chan == 0 || chan == IEEE80211_CHAN_ANY)
sys/dev/usb/wlan/if_zyd.c:      if (chan == 0 || chan == IEEE80211_CHAN_ANY) {


-- 
Bjoern A. Zeeb                                                     r15:7