>From 358854163b8f4a30058f4d4c21065c7d426a1c6f Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 9 Dec 2015 12:20:33 -0800 Subject: [PATCH 2/3] hostapd: Take configured antenna set into consideration If user has configured TX antennas to be less than what hardware advertises, the MCS reported by hardware will be too large. So, remove MCS sets accordingly. Signed-off-by: Ben Greear --- src/ap/ieee802_11_ht.c | 25 +++++++++++++++++++++++++ src/ap/ieee802_11_vht.c | 23 +++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/ap/ieee802_11_ht.c b/src/ap/ieee802_11_ht.c index 5eb1060..e75bda4 100644 --- a/src/ap/ieee802_11_ht.c +++ b/src/ap/ieee802_11_ht.c @@ -25,6 +25,7 @@ u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid) { struct ieee80211_ht_capabilities *cap; u8 *pos = eid; + int i; if (!hapd->iconf->ieee80211n || !hapd->iface->current_mode || hapd->conf->disable_11n) @@ -40,6 +41,30 @@ u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid) os_memcpy(cap->supported_mcs_set, hapd->iface->current_mode->mcs_set, 16); + /* + * Disable all MCS rates that are out of the configured nss (antenna) + * range. + */ + if (hapd->iface->current_mode->conf_tx_ant && + hapd->iface->current_mode->conf_rx_ant) { + int msk; + + msk = hapd->iface->current_mode->conf_tx_ant & + hapd->iface->current_mode->conf_rx_ant; + for (i = 7; i >= 0; i--) { + if (msk & BIT(i)) + break; + if (!cap->supported_mcs_set[i]) + continue; + wpa_printf(MSG_DEBUG, + "Decreasing MCS set due to configured antennas: conf-tx-ant: 0x%x conf-rx-ant: 0x%x mcs-set for nss: %d", + hapd->iface->current_mode->conf_tx_ant, + hapd->iface->current_mode->conf_rx_ant, + i + 1); + cap->supported_mcs_set[i] = 0; + } + } + /* TODO: ht_extended_capabilities (now fully disabled) */ /* TODO: tx_bf_capability_info (now fully disabled) */ /* TODO: asel_capabilities (now fully disabled) */ diff --git a/src/ap/ieee802_11_vht.c b/src/ap/ieee802_11_vht.c index 3236016..99787e9 100644 --- a/src/ap/ieee802_11_vht.c +++ b/src/ap/ieee802_11_vht.c @@ -25,14 +25,13 @@ u8 * hostapd_eid_vht_capabilities(struct hostapd_data *hapd, u8 *eid) struct ieee80211_vht_capabilities *cap; struct hostapd_hw_modes *mode = hapd->iface->current_mode; u8 *pos = eid; + int i; if (!mode) return eid; if (mode->mode == HOSTAPD_MODE_IEEE80211G && hapd->conf->vendor_vht && mode->vht_capab == 0 && hapd->iface->hw_features) { - int i; - for (i = 0; i < hapd->iface->num_hw_features; i++) { if (hapd->iface->hw_features[i].mode == HOSTAPD_MODE_IEEE80211A) { @@ -53,6 +52,26 @@ u8 * hostapd_eid_vht_capabilities(struct hostapd_data *hapd, u8 *eid) /* Supported MCS set comes from hw */ os_memcpy(&cap->vht_supported_mcs_set, mode->vht_mcs_set, 8); + /* + * Disable all MCS rates that are out of the configured nss (antenna) + * range. + */ + if (mode->conf_tx_ant) { + for (i = 7; i > 0; i--) { + if (mode->conf_tx_ant & BIT(i - 1)) + break; + cap->vht_supported_mcs_set.tx_map |= (0x3 << i); + } + } + + if (mode->conf_rx_ant) { + for (i = 7; i > 0; i--) { + if (mode->conf_rx_ant & BIT(i - 1)) + break; + cap->vht_supported_mcs_set.rx_map |= (0x3 << i); + } + } + pos += sizeof(*cap); return pos; -- 1.9.1