From 243f6925bf818a64f3c996c6a89fec6c8a6ff058 Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Thu, 28 Nov 2024 23:54:17 +0000 Subject: [PATCH] net80211: 11ac: add options to manage VHT STBC Add IEEE80211_FVHT_STBC_(TX|RX) flags to allow userspace to manage if STBC will be allowed for VHT RX/TX. For RX this will only allow us to turn it off but no fine grained control of the number of supported spatial streams. Introduce IEEE80211_FVHT_CHANWIDTH_MASK as a helper to make the spelling out of the IEEE80211_FVHT_MASK more readable. Update ifconfig to allow setting of these flags. Sponsored by: The FreeBSD Foundation MFC atfer: 3 days Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D47838 --- sbin/ifconfig/ifieee80211.c | 8 ++++++++ sys/net80211/ieee80211.c | 4 ++++ sys/net80211/ieee80211_ioctl.c | 20 ++++++++++++++++++++ sys/net80211/ieee80211_var.h | 12 ++++++++++-- sys/net80211/ieee80211_vht.c | 6 ++---- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index c6875785f8f5..25de7fb13632 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -135,6 +135,8 @@ #define IEEE80211_FVHT_USEVHT80 0x000000004 /* CONF: Use VHT80 */ #define IEEE80211_FVHT_USEVHT160 0x000000008 /* CONF: Use VHT160 */ #define IEEE80211_FVHT_USEVHT80P80 0x000000010 /* CONF: Use VHT 80+80 */ +#define IEEE80211_FVHT_STBC_TX 0x00000020 /* CONF: STBC tx enabled */ +#define IEEE80211_FVHT_STBC_RX 0x00000040 /* CONF: STBC rx enabled */ #endif /* Helper macros unified. */ @@ -6038,6 +6040,12 @@ static struct cmd ieee80211_cmds[] = { DEF_CMD("-vht160", -IEEE80211_FVHT_USEVHT160, set80211vhtconf), DEF_CMD("vht80p80", IEEE80211_FVHT_USEVHT80P80, set80211vhtconf), DEF_CMD("-vht80p80", -IEEE80211_FVHT_USEVHT80P80, set80211vhtconf), + DEF_CMD("vhtstbctx", IEEE80211_FVHT_STBC_TX, set80211vhtconf), + DEF_CMD("-vhtstbctx", -IEEE80211_FVHT_STBC_TX, set80211vhtconf), + DEF_CMD("vhtstbcrx", IEEE80211_FVHT_STBC_RX, set80211vhtconf), + DEF_CMD("-vhtstbcrx", -IEEE80211_FVHT_STBC_RX, set80211vhtconf), + DEF_CMD("vhtstbc", (IEEE80211_FVHT_STBC_TX|IEEE80211_FVHT_STBC_RX), set80211vhtconf), + DEF_CMD("-vhtstbc", -(IEEE80211_FVHT_STBC_TX|IEEE80211_FVHT_STBC_RX), set80211vhtconf), DEF_CMD("rifs", 1, set80211rifs), DEF_CMD("-rifs", 0, set80211rifs), DEF_CMD("smps", IEEE80211_HTCAP_SMPS_ENA, set80211smps), diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index ecf87020b066..ccb7efaa4df5 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -744,6 +744,8 @@ ieee80211_vap_attach(struct ieee80211vap *vap, ifm_change_cb_t media_change, ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_USEVHT80); ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_USEVHT160); ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_USEVHT80P80); + ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_STBC_TX); + ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_STBC_RX); IEEE80211_UNLOCK(ic); return 1; @@ -801,6 +803,8 @@ ieee80211_vap_detach(struct ieee80211vap *vap) ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_USEVHT80); ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_USEVHT160); ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_USEVHT80P80); + ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_STBC_TX); + ieee80211_syncflag_vht_locked(ic, IEEE80211_FVHT_STBC_RX); /* NB: this handles the bpfdetach done below */ ieee80211_syncflag_ext_locked(ic, IEEE80211_FEXT_BPF); diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index c0ba19b5db89..3b57e7d8cd8e 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -3506,6 +3506,26 @@ ieee80211_ioctl_set80211(struct ieee80211vap *vap, u_long cmd, struct ieee80211r else ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_USEVHT80P80); + /* Check if we can do STBC TX/RX before changing the setting. */ + if ((ireq->i_val & IEEE80211_FVHT_STBC_TX) && + ((vap->iv_vht_cap.vht_cap_info & IEEE80211_VHTCAP_TXSTBC) == 0)) + return EOPNOTSUPP; + if ((ireq->i_val & IEEE80211_FVHT_STBC_RX) && + ((vap->iv_vht_cap.vht_cap_info & IEEE80211_VHTCAP_RXSTBC_MASK) == 0)) + return EOPNOTSUPP; + + /* TX */ + if (ireq->i_val & IEEE80211_FVHT_STBC_TX) + ieee80211_syncflag_vht(vap, IEEE80211_FVHT_STBC_TX); + else + ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_STBC_TX); + + /* RX */ + if (ireq->i_val & IEEE80211_FVHT_STBC_RX) + ieee80211_syncflag_vht(vap, IEEE80211_FVHT_STBC_RX); + else + ieee80211_syncflag_vht(vap, -IEEE80211_FVHT_STBC_RX); + error = ENETRESET; break; diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 53139a3852b8..94e8a05846e7 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -737,12 +737,20 @@ MALLOC_DECLARE(M_80211_VAP); #define IEEE80211_FVHT_USEVHT80 0x000000004 /* CONF: Use VHT80 */ #define IEEE80211_FVHT_USEVHT160 0x000000008 /* CONF: Use VHT160 */ #define IEEE80211_FVHT_USEVHT80P80 0x000000010 /* CONF: Use VHT 80+80 */ -#define IEEE80211_FVHT_MASK \ +#define IEEE80211_FVHT_STBC_TX 0x00000020 /* CONF: STBC tx enabled */ +#define IEEE80211_FVHT_STBC_RX 0x00000040 /* CONF: STBC rx enabled */ + +#define IEEE80211_FVHT_CHANWIDTH_MASK \ (IEEE80211_FVHT_VHT | IEEE80211_FVHT_USEVHT40 | \ IEEE80211_FVHT_USEVHT80 | IEEE80211_FVHT_USEVHT160 | \ IEEE80211_FVHT_USEVHT80P80) + +#define IEEE80211_FVHT_MASK \ + (IEEE80211_FVHT_CHANWIDTH_MASK | \ + IEEE80211_FVHT_STBC_TX | IEEE80211_FVHT_STBC_RX) + #define IEEE80211_VFHT_BITS \ - "\20\1VHT\2VHT40\3VHT80\4VHT160\5VHT80P80" + "\20\1VHT\2VHT40\3VHT80\4VHT160\5VHT80P80\6STBC_TX\7STBC_RX" #define IEEE80211_COM_DETACHED 0x00000001 /* ieee80211_ifdetach called */ #define IEEE80211_COM_REF_ADD 0x00000002 /* add / remove reference */ diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c index 0839f426e09c..a05beb91216f 100644 --- a/sys/net80211/ieee80211_vht.c +++ b/sys/net80211/ieee80211_vht.c @@ -439,8 +439,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, IEEE80211_VHTCAP_RXSTBC_MASK); } val = MIN(val1, val2); - /* XXX For now, use the 11n config flag */ - if ((vap->iv_flags_ht & IEEE80211_FHT_STBC_TX) == 0) + if ((vap->iv_vht_flags & IEEE80211_FVHT_STBC_TX) == 0) val = 0; new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_TXSTBC); @@ -453,8 +452,7 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, IEEE80211_VHTCAP_TXSTBC); } val = MIN(val1, val2); - /* XXX For now, use the 11n config flag */ - if ((vap->iv_flags_ht & IEEE80211_FHT_STBC_RX) == 0) + if ((vap->iv_vht_flags & IEEE80211_FVHT_STBC_RX) == 0) val = 0; new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_RXSTBC_MASK);