From a1d4da59739c2054eb46cf634320c8bd323a8069 Mon Sep 17 00:00:00 2001 From: Maharaja Kennadyrajan Date: Tue, 12 Jan 2021 18:12:37 +0530 Subject: [PATCH] hostapd: Add support for beacon tx mode User can configure the beacon tx mode while bring-up the AP via hostapd configuration and while bring-up MESH via wpa_supplicant configuration. Use the below configuration in the hostapd/wpa_supplicant to configure the beacon tx mode. "beacon_tx_mode=N", where N = 1 for STAGGERED beacon mode and N = 2 for BURST beacon mode. Signed-off-by: Maharaja Kennadyrajan --- hostapd/config_file.c | 9 +++++++++ src/ap/ap_config.c | 2 ++ src/ap/ap_config.h | 1 + src/ap/beacon.c | 2 ++ src/ap/ctrl_iface_ap.c | 6 ++++-- src/drivers/driver.h | 5 +++++ src/drivers/driver_nl80211.c | 16 +++++++++++++++- src/drivers/nl80211_copy.h | 4 ++++ 8 files changed, 42 insertions(+), 3 deletions(-) --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -4595,6 +4595,15 @@ static int hostapd_config_fill(struct ho bss->disable_11ac = !!atoi(pos); } else if (os_strcmp(buf, "disable_11ax") == 0) { bss->disable_11ax = !!atoi(pos); + } else if (os_strcmp(buf, "beacon_tx_mode") == 0) { + int val = atoi(pos); + + if (val < 0 || val > 2) { + wpa_printf(MSG_ERROR, "Line %d: invalid beacon_tx_mode %d", + line, val); + return 1; + } + bss->beacon_tx_mode = val; #ifdef CONFIG_PASN #ifdef CONFIG_TESTING_OPTIONS } else if (os_strcmp(buf, "force_kdk_derivation") == 0) { --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -903,6 +903,7 @@ struct hostapd_bss_config { u8 ext_capa[EXT_CAPA_MAX_LEN]; u8 rnr; + int beacon_tx_mode; }; /** --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -1777,6 +1777,8 @@ int ieee802_11_build_ap_params(struct ho } } + params->beacon_tx_mode = hapd->conf->beacon_tx_mode; + return 0; } --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1214,6 +1214,12 @@ struct wpa_driver_associate_params { * Disable HE40MHz coexistence scan */ int disable_40mhz_scan; + /** + * Beacon Tx mode - To configure STAGGERED or BURST mode + * 1 = STAGGERED beacon tx mode + * 2 = BURST beacon tx mode + */ + int beacon_tx_mode; }; enum hide_ssid { @@ -1593,6 +1599,13 @@ struct wpa_driver_ap_params { * Unsolicited broadcast Probe Response template length */ size_t unsol_bcast_probe_resp_tmpl_len; + + /** + * Beacon Tx mode - To configure STAGGERED or BURST mode + * 1 = STAGGERED beacon tx mode + * 2 = BURST beacon tx mode + */ + int beacon_tx_mode; }; struct wpa_driver_mesh_bss_params { @@ -1631,6 +1644,7 @@ struct wpa_driver_mesh_join_params { #define WPA_DRIVER_MESH_FLAG_AMPE 0x00000008 unsigned int flags; bool handle_dfs; + int beacon_tx_mode; }; struct wpa_driver_set_key_params { --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -4572,6 +4572,7 @@ static int wpa_driver_nl80211_set_ap(voi wpa_printf(MSG_DEBUG, "nl80211: beacon_rate=%u", params->beacon_rate); wpa_printf(MSG_DEBUG, "nl80211: rate_type=%d", params->rate_type); wpa_printf(MSG_DEBUG, "nl80211: dtim_period=%d", params->dtim_period); + wpa_printf(MSG_DEBUG, "nl80211: beacon_tx_mode=%d", params->beacon_tx_mode); wpa_printf(MSG_DEBUG, "nl80211: ssid=%s", wpa_ssid_txt(params->ssid, params->ssid_len)); if (!(msg = nl80211_bss_msg(bss, 0, cmd)) || @@ -4583,7 +4584,9 @@ static int wpa_driver_nl80211_set_ap(voi 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)) + nla_put(msg, NL80211_ATTR_SSID, params->ssid_len, params->ssid) || + (params->beacon_tx_mode && + nla_put_u32(msg, NL80211_ATTR_BEACON_TX_MODE, params->beacon_tx_mode))) goto fail; if (params->proberesp && params->proberesp_len) { wpa_hexdump(MSG_DEBUG, "nl80211: proberesp (offload)", @@ -10647,7 +10650,9 @@ static int nl80211_join_mesh(struct i802 nl80211_put_basic_rates(msg, params->basic_rates) || nl80211_put_mesh_id(msg, params->meshid, params->meshid_len) || nl80211_put_beacon_int(msg, params->beacon_int) || - nl80211_put_dtim_period(msg, params->dtim_period)) + nl80211_put_dtim_period(msg, params->dtim_period) || + (params->beacon_tx_mode && + nla_put_u32(msg, NL80211_ATTR_BEACON_TX_MODE, params->beacon_tx_mode))) goto fail; wpa_printf(MSG_DEBUG, " * flags=%08X", params->flags); --- a/src/drivers/nl80211_copy.h +++ b/src/drivers/nl80211_copy.h @@ -2579,6 +2579,10 @@ enum nl80211_commands { * @NL80211_ATTR_HE_MUEDCA_PARAMS: MU-EDCA AC parameters for the NL80211_CMD_UPDATE_HE_MUEDCA_PARAMS command. * + * @NL80211_ATTR_BEACON_TX_MODE: used to configure the beacon tx mode as + * staggered mode or burst mode in %NL80211_CMD_START_AP from + * user-space. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3087,6 +3091,8 @@ enum nl80211_attrs { NL80211_ATTR_MBSSID_CONFIG, NL80211_ATTR_MBSSID_ELEMS, + NL80211_ATTR_BEACON_TX_MODE, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -7333,4 +7339,13 @@ enum nl80211_sar_specs_attrs { NL80211_SAR_ATTR_SPECS_MAX = __NL80211_SAR_ATTR_SPECS_LAST - 1, }; + +/** + * enum nl80211_beacon_tx_mode - Beacon Tx Mode enum. + * Used to configure beacon staggered mode or beacon burst mode. + */ +enum nl80211_beacon_tx_mode { + NL80211_BEACON_STAGGERED_MODE = 1, + NL80211_BEACON_BURST_MODE = 2, +}; #endif /* __LINUX_NL80211_H */ --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -254,6 +254,9 @@ rts_threshold=-1 # it. fragm_threshold=-1 +# Beacon Tx mode; 1 = STAGGERED beacon tx mode; 2 = BURST beacon tx mode. +beacon_tx_mode=1 + # Rate configuration # Default is to enable all rates supported by the hardware. This configuration # item allows this list be filtered so that only the listed rates will be left --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2806,6 +2806,7 @@ static const struct parse_data ssid_fiel { INT_RANGE(transition_disable, 0, 255) }, { INT_RANGE(sae_pk, 0, 2) }, { INT_RANGE(disable_40mhz_scan, 0, 1)}, + { INT_RANGE(beacon_tx_mode, 1, 2)}, }; #undef OFFSET @@ -3321,6 +3322,7 @@ void wpa_config_set_network_defaults(str #endif /* CONFIG_MACSEC */ ssid->mac_addr = -1; ssid->max_oper_chwidth = DEFAULT_MAX_OPER_CHWIDTH; + ssid->beacon_tx_mode = DEFAULT_BEACON_TX_MODE; } --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -888,6 +888,7 @@ static void wpa_config_write_network(FIL INT(disable_he); #endif /* CONFIG_HE_OVERRIDES */ INT(disable_40mhz_scan); + INT(beacon_tx_mode); #undef STR #undef INT #undef INT_DEF --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -45,6 +45,7 @@ #define DEFAULT_AMPDU_DENSITY -1 /* no change */ #define DEFAULT_USER_SELECTED_SIM 1 #define DEFAULT_MAX_OPER_CHWIDTH -1 +#define DEFAULT_BEACON_TX_MODE 0 /* Consider global sae_pwe for SAE mechanism for PWE derivation */ #define DEFAULT_SAE_PWE 4 @@ -1191,6 +1192,13 @@ struct wpa_ssid { * disable_40mhz_scan - Disable 40MHz coex scan */ int disable_40mhz_scan; + + /** + * beacon_tx_mode - Beacon Tx mode + * 1 = STAGGERED MODE + * 2 = BURST MODE + */ + int beacon_tx_mode; }; #endif /* CONFIG_SSID_H */ --- a/wpa_supplicant/mesh.c +++ b/wpa_supplicant/mesh.c @@ -690,6 +690,7 @@ int wpa_supplicant_join_mesh(struct wpa_ params->dtim_period = ssid->dtim_period; else if (wpa_s->conf->dtim_period > 0) params->dtim_period = wpa_s->conf->dtim_period; + params->beacon_tx_mode = ssid->beacon_tx_mode; params->conf.max_peer_links = wpa_s->conf->max_peer_links; if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) { params->conf.rssi_threshold = ssid->mesh_rssi_threshold; --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -1485,6 +1485,7 @@ static const char *network_fields[] = { #endif /* CONFIG_HS20 */ "mac_addr", "pbss", "wps_disabled", "disable_40mhz_scan", + "beacon_tx_mode", };