diff --git a/sys/net80211/ieee80211_vht.h b/sys/net80211/ieee80211_vht.h --- a/sys/net80211/ieee80211_vht.h +++ b/sys/net80211/ieee80211_vht.h @@ -65,4 +65,8 @@ void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, struct ieee80211_vht_operation *, int); +bool ieee80211_vht_check_tx_vht(const struct ieee80211_node *); +bool ieee80211_vht_check_tx_vht40(const struct ieee80211_node *); +bool ieee80211_vht_check_tx_vht80(const struct ieee80211_node *); + #endif /* _NET80211_IEEE80211_VHT_H_ */ diff --git a/sys/net80211/ieee80211_vht.c b/sys/net80211/ieee80211_vht.c --- a/sys/net80211/ieee80211_vht.c +++ b/sys/net80211/ieee80211_vht.c @@ -873,3 +873,71 @@ { printf("%s: called; TODO!\n", __func__); } + +/* + * Return true if VHT rates can be used for the given node. + */ +bool +ieee80211_vht_check_tx_vht(const struct ieee80211_node *ni) +{ + const struct ieee80211vap *vap; + const struct ieee80211_channel *bss_chan; + + if (ni == NULL || ni->ni_chan == IEEE80211_CHAN_ANYC || + ni->ni_vap == NULL || ni->ni_vap->iv_bss == NULL) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + if (bss_chan == IEEE80211_CHAN_ANYC) + return (false); + + return (IEEE80211_IS_CHAN_VHT(ni->ni_chan)); +} + +/* + * Return true if VHT 40 rates can be transmitted to the given node. + * + * This verifies that the BSS is VHT40 capable and the current + * node channel width is 40MHz. + */ +bool +ieee80211_vht_check_tx_vht40(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + struct ieee80211_channel *bss_chan; + + if (! ieee80211_vht_check_tx_vht(ni)) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + return (IEEE80211_IS_CHAN_VHT40(bss_chan) && + IEEE80211_IS_CHAN_VHT40(ni->ni_chan) && + (ni->ni_chw == IEEE80211_STA_RX_BW_40)); +} + +/* + * Return true if VHT 80 rates can be transmitted to the given node. + * + * This verifies that the BSS is VHT80 capable and the current + * node channel width is 80MHz. + */ +bool +ieee80211_vht_check_tx_vht80(const struct ieee80211_node *ni) +{ + struct ieee80211vap *vap; + struct ieee80211_channel *bss_chan; + + if (! ieee80211_vht_check_tx_vht(ni)) + return (false); + + vap = ni->ni_vap; + bss_chan = vap->iv_bss->ni_chan; + + return (IEEE80211_IS_CHAN_VHT80(bss_chan) && + IEEE80211_IS_CHAN_VHT80(ni->ni_chan) && + (ni->ni_chw == IEEE80211_STA_RX_BW_80)); +}