net80211: fix VHT160/80P80/80 chanwidth selection in the "40-" case

Depending on the base channel ni_vht_chan2 - ni_vht_chan1 can be
negative.  Apply abs() as indicated in the comments right above
	| CCFS1 - CCFS0 | = 8  or > 16
in order to fix the channel width selection.

Sponsored by:	The FreeBSD Foundation
PR:		293645
Fixes:		4bf049bfee
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D55717

(cherry picked from commit 6cfd2b93e68061c7831016b91c2e308d01658764)
(cherry picked from commit 68fcf0b94c)
This commit is contained in:
Bjoern A. Zeeb 2026-03-08 00:57:33 +00:00 • committed by Franco Fichtner
parent a30ec3bb9f
commit b3d03b18e3

View file

@ -38,6 +38,7 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/libkern.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/endian.h>
@ -2028,11 +2029,11 @@ do { \
}
/* CCFS1 > 0 and | CCFS1 - CCFS0 | = 8 */
if (ni->ni_vht_chan2 > 0 && (ni->ni_vht_chan2 - ni->ni_vht_chan1) == 8)
if (ni->ni_vht_chan2 > 0 && abs(ni->ni_vht_chan2 - ni->ni_vht_chan1) == 8)
can_vht160 = can_vht80 = true;
/* CCFS1 > 0 and | CCFS1 - CCFS0 | > 16 */
if (ni->ni_vht_chan2 > 0 && (ni->ni_vht_chan2 - ni->ni_vht_chan1) > 16)
if (ni->ni_vht_chan2 > 0 && abs(ni->ni_vht_chan2 - ni->ni_vht_chan1) > 16)
can_vht80p80 = can_vht80 = true;
/* CFFS1 == 0 */