From 9f9d3d36254a7f732bd99883736540fb0a9df621 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Sat, 3 Oct 2020 02:31:15 -0700 Subject: [PATCH] Allow HE MCS rate selection for Beacon frames Allow HE MCS rate to be used for beacon transmission when the driver advertises the support. The rate is specified with a new beacon_rate option "he:" in hostapd configuration. Signed-off-by: Rajkumar Manoharan --- hostapd/config_file.c | 10 ++++++++++ hostapd/hostapd.conf | 2 ++ src/common/defs.h | 3 ++- src/drivers/driver.h | 10 ++++++---- src/drivers/driver_nl80211.c | 23 +++++++++++++++++++++-- src/drivers/driver_nl80211_capa.c | 4 ++++ 6 files changed, 45 insertions(+), 7 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index fe8fcd728..ac66d8bd4 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -3263,6 +3263,16 @@ static int hostapd_config_fill(struct hostapd_config *conf, } conf->rate_type = BEACON_RATE_VHT; conf->beacon_rate = val; + } else if (os_strncmp(pos, "he:", 3) == 0) { + val = atoi(pos + 3); + if (val < 0 || val > 11) { + wpa_printf(MSG_ERROR, + "Line %d: invalid beacon_rate HE-MCS %d", + line, val); + return 1; + } + conf->rate_type = BEACON_RATE_HE; + conf->beacon_rate = val; } else { val = atoi(pos); if (val < 10 || val > 10000) { diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index c4482c13c..8553338fd 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -279,6 +279,8 @@ fragm_threshold=-1 # beacon_rate=ht: # VHT: # beacon_rate=vht: +# HE: +# beacon_rate=he: # # For example, beacon_rate=10 for 1 Mbps or beacon_rate=60 for 6 Mbps (OFDM). #beacon_rate=10 diff --git a/src/common/defs.h b/src/common/defs.h index a58eff5f7..f43bdb5d1 100644 --- a/src/common/defs.h +++ b/src/common/defs.h @@ -405,7 +405,8 @@ enum wpa_radio_work_band { enum beacon_rate_type { BEACON_RATE_LEGACY, BEACON_RATE_HT, - BEACON_RATE_VHT + BEACON_RATE_VHT, + BEACON_RATE_HE }; enum eap_proxy_sim_state { diff --git a/src/drivers/driver.h b/src/drivers/driver.h index f737aecae..1e1f11372 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1264,14 +1264,14 @@ struct wpa_driver_ap_params { * * This parameter can be used to set a specific Beacon frame data rate * for the BSS. The interpretation of this value depends on the - * rate_type (legacy: in 100 kbps units, HT: HT-MCS, VHT: VHT-MCS). If - * beacon_rate == 0 and rate_type == 0 (BEACON_RATE_LEGACY), the default - * Beacon frame data rate is used. + * rate_type (legacy: in 100 kbps units, HT: HT-MCS, VHT: VHT-MCS, + * HE: HE-MCS). If beacon_rate == 0 and rate_type == 0 + * (BEACON_RATE_LEGACY), the default Beacon frame data rate is used. */ unsigned int beacon_rate; /** - * beacon_rate_type: Beacon data rate type (legacy/HT/VHT) + * beacon_rate_type: Beacon data rate type (legacy/HT/VHT/HE) */ enum beacon_rate_type rate_type; @@ -1959,6 +1959,8 @@ struct wpa_driver_capa { * frames */ #define WPA_DRIVER_FLAGS2_PROT_RANGE_NEG 0x0000000000000010ULL +/** Driver supports Beacon frame TX rate configuration (HE rates) */ +#define WPA_DRIVER_FLAGS2_BEACON_RATE_HE 0x0000000000000020ULL u64 flags2; #define FULL_AP_CLIENT_STATE_SUPP(drv_flags) \ diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index aa0e10bd2..9e5ee5441 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -4198,11 +4198,12 @@ static int nl80211_set_mesh_config(void *priv, #endif /* CONFIG_MESH */ -static int nl80211_put_beacon_rate(struct nl_msg *msg, const u64 flags, +static int nl80211_put_beacon_rate(struct nl_msg *msg, u64 flags, u64 flags2, struct wpa_driver_ap_params *params) { struct nlattr *bands, *band; struct nl80211_txrate_vht vht_rate; + struct nl80211_txrate_he he_rate; if (!params->freq || (params->beacon_rate == 0 && @@ -4235,6 +4236,7 @@ static int nl80211_put_beacon_rate(struct nl_msg *msg, const u64 flags, return -1; os_memset(&vht_rate, 0, sizeof(vht_rate)); + os_memset(&he_rate, 0, sizeof(he_rate)); switch (params->rate_type) { case BEACON_RATE_LEGACY: @@ -4287,6 +4289,22 @@ static int nl80211_put_beacon_rate(struct nl_msg *msg, const u64 flags, wpa_printf(MSG_DEBUG, " * beacon_rate = VHT-MCS %u", params->beacon_rate); break; + case BEACON_RATE_HE: + if (!(flags2 & WPA_DRIVER_FLAGS2_BEACON_RATE_HE)) { + wpa_printf(MSG_INFO, + "nl80211: Driver does not support setting Beacon frame rate (HE)"); + return -1; + } + he_rate.mcs[0] = BIT(params->beacon_rate); + if (nla_put(msg, NL80211_TXRATE_LEGACY, 0, NULL) || + nla_put(msg, NL80211_TXRATE_HT, 0, NULL) || + nla_put(msg, NL80211_TXRATE_VHT, sizeof(vht_rate), + &vht_rate) || + nla_put(msg, NL80211_TXRATE_HE, sizeof(he_rate), &he_rate)) + return -1; + wpa_printf(MSG_DEBUG, " * beacon_rate = HE-MCS %u", + params->beacon_rate); + break; } nla_nest_end(msg, band); @@ -4409,7 +4427,8 @@ static int wpa_driver_nl80211_set_ap(void *priv, nla_put(msg, NL80211_ATTR_BEACON_TAIL, params->tail_len, params->tail) || nl80211_put_beacon_int(msg, params->beacon_int) || - nl80211_put_beacon_rate(msg, drv->capa.flags, params) || + nl80211_put_beacon_rate(msg, drv->capa.flags, drv->capa.flags2, + params) || nl80211_put_dtim_period(msg, params->dtim_period) || nla_put(msg, NL80211_ATTR_SSID, params->ssid_len, params->ssid)) goto fail; diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index 6c2ab515e..6dea42f90 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -558,6 +558,10 @@ static void wiphy_info_ext_feature_flags(struct wiphy_info_data *info, NL80211_EXT_FEATURE_BEACON_RATE_VHT)) capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_VHT; + if (ext_feature_isset(ext_features, len, + NL80211_EXT_FEATURE_BEACON_RATE_HE)) + capa->flags2 |= WPA_DRIVER_FLAGS2_BEACON_RATE_HE; + if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_SET_SCAN_DWELL)) capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_SET_SCAN_DWELL;