git: dc32c7133921 - main - net80211: VHT correct check/option in ieee80211_vht_adjust_channel()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 29 Jul 2022 15:15:14 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=dc32c7133921a34f3144a4b5fc4f7c1f6cddbd1f

commit dc32c7133921a34f3144a4b5fc4f7c1f6cddbd1f
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-07-29 00:12:34 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-07-29 15:10:45 +0000

    net80211: VHT correct check/option in ieee80211_vht_adjust_channel()
    
    In ieee80211_vht_adjust_channel() we have to check for all possible
    IEEE80211_FVHT_VHT* options using the mask rather than just checking
    for IEEE80211_FVHT_VHT;  ieee80211_vhtchanflags() (contrary to its
    HT counterpart) only returns the "highest" flag nor or-ing them together
    with the base flag.  For the moment this seems to make sense as with
    more width options we'd add a pyramid.
    
    Later on, in the same function when we get VHT160 actually go and look
    for VHT160 and not VHT80.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Reviewed by:    adrian
    Differential Revision: https://reviews.freebsd.org/D35977
---
 sys/net80211/ieee80211_vht.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c
index b023c6de6e95..b4eb901f0f13 100644
--- a/sys/net80211/ieee80211_vht.c
+++ b/sys/net80211/ieee80211_vht.c
@@ -797,7 +797,7 @@ ieee80211_vht_adjust_channel(struct ieee80211com *ic,
 	struct ieee80211_channel *c;
 
 	/* First case - handle channel demotion - if VHT isn't set */
-	if ((flags & IEEE80211_FVHT_VHT) == 0) {
+	if ((flags & IEEE80211_FVHT_MASK) == 0) {
 #if 0
 		printf("%s: demoting channel %d/0x%08x\n", __func__,
 		    chan->ic_ieee, chan->ic_flags);
@@ -819,10 +819,9 @@ ieee80211_vht_adjust_channel(struct ieee80211com *ic,
 	 * Note: we don't clear the HT flags, these are the hints
 	 * for HT40U/HT40D when selecting VHT40 or larger channels.
 	 */
-	/* Start with VHT80 */
 	c = NULL;
 	if ((c == NULL) && (flags & IEEE80211_FVHT_USEVHT160))
-		c = findvhtchan(ic, chan, IEEE80211_CHAN_VHT80);
+		c = findvhtchan(ic, chan, IEEE80211_CHAN_VHT160);
 
 	if ((c == NULL) && (flags & IEEE80211_FVHT_USEVHT80P80))
 		c = findvhtchan(ic, chan, IEEE80211_CHAN_VHT80P80);