From 121ccadeb44c5135d035b75691f6c1899f6d3f1b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 22 Dec 2023 20:57:53 +0200 Subject: [PATCH] AP: A helper function for determining whether the AP is an SP AP Get rid of unnecessary code duplication. Signed-off-by: Jouni Malinen --- src/ap/beacon.c | 10 ++-------- src/ap/ieee802_11.c | 10 ++-------- src/common/ieee802_11_defs.h | 6 ++++++ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 04bfffffe..ee1f02792 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -580,20 +580,14 @@ static size_t he_elem_len(struct hostapd_data *hapd) 3 + sizeof(struct ieee80211_he_6ghz_band_cap); /* An additional Transmit Power Envelope element for * subordinate client */ - if (hapd->iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_INDOOR || - hapd->iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP) + if (he_reg_is_sp(hapd->iconf->he_6ghz_reg_pwr_type)) len += 4; /* An additional Transmit Power Envelope element for * default client with unit interpretation of regulatory * client EIRP */ if (hapd->iconf->reg_def_cli_eirp != -1 && - (hapd->iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_SP || - hapd->iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP)) + he_reg_is_sp(hapd->iconf->he_6ghz_reg_pwr_type)) len += 4; } #endif /* CONFIG_IEEE80211AX */ diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 8f61766a7..a939ad35e 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -7077,10 +7077,7 @@ u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid) /* Indoor Access Point must include an additional TPE for * subordinate devices */ - if (iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_INDOOR || - iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP) { + if (he_reg_is_sp(iconf->he_6ghz_reg_pwr_type)) { /* TODO: Extract PSD limits from channel data */ if (hapd->iconf->reg_sub_cli_eirp_psd != -1) tx_pwr = hapd->iconf->reg_sub_cli_eirp_psd; @@ -7093,10 +7090,7 @@ u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid) } if (iconf->reg_def_cli_eirp != -1 && - (iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_SP || - iconf->he_6ghz_reg_pwr_type == - HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP)) + he_reg_is_sp(iconf->he_6ghz_reg_pwr_type)) eid = hostapd_add_tpe_info( eid, tx_pwr_count, REGULATORY_CLIENT_EIRP, REG_DEFAULT_CLIENT, diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index 8ffc199ae..2757ba7f8 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -2461,6 +2461,12 @@ enum he_reg_info_6ghz_ap_type { HE_REG_INFO_6GHZ_AP_TYPE_MAX = HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP, }; +static inline bool he_reg_is_sp(enum he_reg_info_6ghz_ap_type type) +{ + return type == HE_REG_INFO_6GHZ_AP_TYPE_SP || + type == HE_REG_INFO_6GHZ_AP_TYPE_INDOOR_SP; +} + /* Spatial Reuse defines */ #define SPATIAL_REUSE_SRP_DISALLOWED BIT(0) #define SPATIAL_REUSE_NON_SRG_OBSS_PD_SR_DISALLOWED BIT(1)