git: fbba0d6b6364 - main - net80211: combine iv_vhtcaps and iv_vht_mcsinfo

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 03 Nov 2023 21:08:27 UTC
The branch main has been updated by bz:

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

commit fbba0d6b636492505dc5878b9ed2c1bbdcd88b91
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-10-27 18:33:22 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-11-03 21:08:04 +0000

    net80211: combine iv_vhtcaps and iv_vht_mcsinfo
    
    The iv_vhtcaps and iv_vht_mcsinfo fields together form
    struct ieee80211_vht_cap so combine them into one field in the VAP
    and keep the information together.
    
    While the structure layout changes no other functional changes intended.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
    Reviewed by:    adrian, cc
    Differential Revision: https://reviews.freebsd.org/D42420
---
 sys/net80211/ieee80211.c     |  2 +-
 sys/net80211/ieee80211_ddb.c |  2 +-
 sys/net80211/ieee80211_ht.c  |  4 ++--
 sys/net80211/ieee80211_var.h |  3 +--
 sys/net80211/ieee80211_vht.c | 50 ++++++++++++++++++++++----------------------
 5 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index 41b743c988f4..dcd61e8de43a 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -553,7 +553,7 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
 	vap->iv_htextcaps = ic->ic_htextcaps;
 
 	/* 11ac capabilities - XXX methodize */
-	vap->iv_vhtcaps = ic->ic_vhtcaps;
+	vap->iv_vht_cap.vht_cap_info = ic->ic_vhtcaps;
 	vap->iv_vhtextcaps = ic->ic_vhtextcaps;
 
 	vap->iv_opmode = opmode;
diff --git a/sys/net80211/ieee80211_ddb.c b/sys/net80211/ieee80211_ddb.c
index e4a09a58049b..e3f70fbe3f29 100644
--- a/sys/net80211/ieee80211_ddb.c
+++ b/sys/net80211/ieee80211_ddb.c
@@ -490,7 +490,7 @@ _db_show_vap(const struct ieee80211vap *vap, int showmesh, int showprocs)
 	db_printf("\tflags_ven=%b\n", vap->iv_flags_ven, IEEE80211_FVEN_BITS);
 	db_printf("\tcaps=%b\n", vap->iv_caps, IEEE80211_C_BITS);
 	db_printf("\thtcaps=%b\n", vap->iv_htcaps, IEEE80211_C_HTCAP_BITS);
-	db_printf("\tvhtcaps=%b\n", vap->iv_vhtcaps, IEEE80211_VHTCAP_BITS);
+	db_printf("\tvhtcap=%b\n", vap->iv_vht_cap.vht_cap_info, IEEE80211_VHTCAP_BITS);
 
 	_db_show_stats(&vap->iv_stats);
 
diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c
index 34d330f0dd09..61c57b87c5d7 100644
--- a/sys/net80211/ieee80211_ht.c
+++ b/sys/net80211/ieee80211_ht.c
@@ -1938,7 +1938,7 @@ ieee80211_vht_get_vhtflags(struct ieee80211_node *ni, uint32_t htflags)
 	if (ni->ni_flags & IEEE80211_NODE_VHT && vap->iv_vht_flags & IEEE80211_FVHT_VHT) {
 		if ((ni->ni_vht_chanwidth == IEEE80211_VHT_CHANWIDTH_160MHZ) &&
 		    /* XXX 2 means "160MHz and 80+80MHz", 1 means "160MHz" */
-		    (_IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+		    (_IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 		     IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) >= 1) &&
 		    (vap->iv_vht_flags & IEEE80211_FVHT_USEVHT160)) {
 			vhtflags = IEEE80211_CHAN_VHT160;
@@ -1950,7 +1950,7 @@ ieee80211_vht_get_vhtflags(struct ieee80211_node *ni, uint32_t htflags)
 			}
 		} else if ((ni->ni_vht_chanwidth == IEEE80211_VHT_CHANWIDTH_80P80MHZ) &&
 		    /* XXX 2 means "160MHz and 80+80MHz" */
-		    (_IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+		    (_IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 		     IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) == 2) &&
 		    (vap->iv_vht_flags & IEEE80211_FVHT_USEVHT80P80)) {
 			vhtflags = IEEE80211_CHAN_VHT80P80;
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 1208a8b3ab4e..08812c5eb27c 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -424,9 +424,8 @@ struct ieee80211vap {
 
 	/* VHT flags */
 	uint32_t		iv_vht_flags;	/* VHT state flags */
-	uint32_t		iv_vhtcaps;	/* VHT capabilities */
+	struct ieee80211_vht_cap iv_vht_cap;	/* VHT capabilities + MCS info */
 	uint32_t		iv_vhtextcaps;	/* VHT extended capabilities (TODO) */
-	struct ieee80211_vht_mcs_info	iv_vht_mcsinfo;
 	uint32_t		iv_vht_spare[4];
 
 	int			iv_des_nssid;	/* # desired ssids */
diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c
index 9f8b104db10c..49d5fa18b448 100644
--- a/sys/net80211/ieee80211_vht.c
+++ b/sys/net80211/ieee80211_vht.c
@@ -144,7 +144,7 @@ ieee80211_vht_vattach(struct ieee80211vap *vap)
 	if (! IEEE80211_CONF_VHT(ic))
 		return;
 
-	vap->iv_vhtcaps = ic->ic_vhtcaps;
+	vap->iv_vht_cap.vht_cap_info = ic->ic_vhtcaps;
 	vap->iv_vhtextcaps = ic->ic_vhtextcaps;
 
 	/* XXX assume VHT80 support; should really check vhtcaps */
@@ -152,12 +152,12 @@ ieee80211_vht_vattach(struct ieee80211vap *vap)
 	    IEEE80211_FVHT_VHT
 	    | IEEE80211_FVHT_USEVHT40
 	    | IEEE80211_FVHT_USEVHT80;
-	if (IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_IS_160MHZ(vap->iv_vhtcaps))
+	if (IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_IS_160MHZ(vap->iv_vht_cap.vht_cap_info))
 		vap->iv_vht_flags |= IEEE80211_FVHT_USEVHT160;
-	if (IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_IS_160_80P80MHZ(vap->iv_vhtcaps))
+	if (IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_IS_160_80P80MHZ(vap->iv_vht_cap.vht_cap_info))
 		vap->iv_vht_flags |= IEEE80211_FVHT_USEVHT80P80;
 
-	memcpy(&vap->iv_vht_mcsinfo, &ic->ic_vht_mcsinfo,
+	memcpy(&vap->iv_vht_cap.supp_mcs, &ic->ic_vht_mcsinfo,
 	    sizeof(struct ieee80211_vht_mcs_info));
 }
 
@@ -366,7 +366,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 */
 
 	/* Limit MPDU size to the smaller of the two */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_MAX_MPDU_MASK);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -376,7 +376,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_MAX_MPDU_MASK);
 
 	/* Limit supp channel config */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -393,7 +393,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	     IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK);
 
 	/* RX LDPC */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_RXLDPC);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -403,7 +403,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_RXLDPC);
 
 	/* Short-GI 80 */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_SHORT_GI_80);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -413,7 +413,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_SHORT_GI_80);
 
 	/* Short-GI 160 */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_SHORT_GI_160);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -438,7 +438,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 */
 
 	/* TX STBC */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_TXSTBC);
 	if (opmode == 1) {
 		/* STA mode - enable it only if node RXSTBC is non-zero */
@@ -452,7 +452,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_TXSTBC);
 
 	/* RX STBC1..4 */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_RXSTBC_MASK);
 	if (opmode == 1) {
 		/* STA mode - enable it only if node TXSTBC is non-zero */
@@ -483,7 +483,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 */
 
 	/* SU Beamformer capable */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -494,7 +494,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	    IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE);
 
 	/* SU Beamformee capable */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -505,7 +505,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	    IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE);
 
 	/* Beamformee STS capability - only if SU beamformee capable */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK);
 	if (opmode == 1) {
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -518,7 +518,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	    IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK);
 
 	/* Sounding dimensions - only if SU beamformer capable */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_MASK);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -533,7 +533,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 * MU Beamformer capable - only if SU BFF capable, MU BFF capable
 	 * and STA (not AP)
 	 */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_MU_BEAMFORMER_CAPABLE);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -550,7 +550,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 * MU Beamformee capable - only if SU BFE capable, MU BFE capable
 	 * and AP (not STA)
 	 */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_MU_BEAMFORMEE_CAPABLE);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -564,7 +564,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	   IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE);
 
 	/* VHT TXOP PS */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_VHT_TXOP_PS);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -573,7 +573,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_VHT_TXOP_PS);
 
 	/* HTC_VHT */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_HTC_VHT);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -583,7 +583,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 
 	/* A-MPDU length max */
 	/* XXX TODO: we need a userland config knob for this */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -596,7 +596,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 * Link adaptation is only valid if HTC-VHT capable is 1.
 	 * Otherwise, always set it to 0.
 	 */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MASK);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -613,7 +613,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 */
 
 	/* RX antenna pattern */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_RX_ANTENNA_PATTERN);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -623,7 +623,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	    IEEE80211_VHTCAP_RX_ANTENNA_PATTERN);
 
 	/* TX antenna pattern */
-	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps,
+	val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vht_cap.vht_cap_info,
 	    IEEE80211_VHTCAP_TX_ANTENNA_PATTERN);
 	if (opmode == 1)
 		val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap,
@@ -639,9 +639,9 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
 	 */
 
 	/* MCS set - start with whatever the device supports */
-	vhtcap->supp_mcs.rx_mcs_map = vap->iv_vht_mcsinfo.rx_mcs_map;
+	vhtcap->supp_mcs.rx_mcs_map = vap->iv_vht_cap.supp_mcs.rx_mcs_map;
 	vhtcap->supp_mcs.rx_highest = 0;
-	vhtcap->supp_mcs.tx_mcs_map = vap->iv_vht_mcsinfo.tx_mcs_map;
+	vhtcap->supp_mcs.tx_mcs_map = vap->iv_vht_cap.supp_mcs.tx_mcs_map;
 	vhtcap->supp_mcs.tx_highest = 0;
 
 	vhtcap->vht_cap_info = new_vhtcap;