From bafe35df0351cd42323cf0b9d24d90db87cadd60 Mon Sep 17 00:00:00 2001 From: Aleti Nageshwar Reddy Date: Fri, 13 May 2022 21:47:40 +0530 Subject: [PATCH] Move CHANWIDTH_* definitions from ieee80211_defs.h to defs.h Move most of CHANWIDTH_* definitions from ieee80211_defs.h to defs.h as the definitions are getting used mostly for internal purpose only. Also change prefix of the definitions to CONF_OPER_CHWIDTH_* and update in all the files accordingly. Leave the couple of VHT-specific exceptions to use the old defines (the reason why they were originally added as VHT values), to avoid use of clearly marked configuration values in information elements. In addition, use the defines instead of magic values where appropriate. Signed-off-by: Aleti Nageshwar Reddy --- hostapd/hostapd.conf | 4 +- src/ap/acs.c | 16 ++--- src/ap/ap_config.h | 12 ++-- src/ap/ap_drv_ops.c | 9 +-- src/ap/beacon.c | 10 ++-- src/ap/dfs.c | 29 ++++----- src/ap/drv_callbacks.c | 26 +++++---- src/ap/hostapd.c | 31 +++++----- src/ap/hw_features.c | 2 +- src/ap/ieee802_11.c | 8 +-- src/ap/ieee802_11_eht.c | 15 +++-- src/ap/ieee802_11_he.c | 14 +++-- src/ap/ieee802_11_shared.c | 2 +- src/ap/ieee802_11_vht.c | 9 +-- src/ap/neighbor_db.c | 12 ++-- src/common/defs.h | 15 +++++ src/common/hw_features_common.c | 47 +++++++++------ src/common/hw_features_common.h | 3 +- src/common/ieee802_11_common.c | 100 ++++++++++++++++---------------- src/common/ieee802_11_common.h | 9 +-- src/common/ieee802_11_defs.h | 7 +-- wpa_supplicant/ap.c | 30 +++++----- wpa_supplicant/config.c | 4 +- wpa_supplicant/config_ssid.h | 2 +- wpa_supplicant/ctrl_iface.c | 14 ++--- wpa_supplicant/mesh.c | 10 ++-- wpa_supplicant/op_classes.c | 5 +- wpa_supplicant/p2p_supplicant.c | 16 ++--- wpa_supplicant/rrm.c | 18 +++--- wpa_supplicant/wnm_sta.c | 3 +- wpa_supplicant/wpa_supplicant.c | 20 +++---- 31 files changed, 275 insertions(+), 227 deletions(-) diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index f37d5634b..6b4223fff 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -871,7 +871,7 @@ wmm_ac_vo_acm=0 # he_oper_chwidth is ignored, and the channel width is derived from the # configured operating class or center frequency indexes (see # IEEE P802.11ax/D6.1 Annex E, Table E-4). -#he_oper_chwidth +#he_oper_chwidth (see vht_oper_chwidth) #he_oper_centr_freq_seg0_idx #he_oper_centr_freq_seg1_idx @@ -1021,7 +1021,7 @@ wmm_ac_vo_acm=0 # In the 6 GHz band, eht_oper_chwidth is ignored and the channel width is # derived from the configured operating class (IEEE P802.11be/D1.5, # Annex E.1 - Country information and operating classes). -#eht_oper_chwidth +#eht_oper_chwidth (see vht_oper_chwidth) #eht_oper_centr_freq_seg0_idx ##### IEEE 802.1X-2004 related configuration ################################## diff --git a/src/ap/acs.c b/src/ap/acs.c index faaedbfdb..7708bc283 100644 --- a/src/ap/acs.c +++ b/src/ap/acs.c @@ -710,7 +710,7 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface, if (mode->mode == HOSTAPD_MODE_IEEE80211A && (iface->conf->ieee80211ac || iface->conf->ieee80211ax)) { if (hostapd_get_oper_chwidth(iface->conf) == - CHANWIDTH_80MHZ && + CONF_OPER_CHWIDTH_80MHZ && !acs_usable_bw80_chan(chan)) { wpa_printf(MSG_DEBUG, "ACS: Channel %d: not allowed as primary channel for 80 MHz bandwidth", @@ -719,7 +719,7 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface, } if (hostapd_get_oper_chwidth(iface->conf) == - CHANWIDTH_160MHZ && + CONF_OPER_CHWIDTH_160MHZ && !acs_usable_bw160_chan(chan)) { wpa_printf(MSG_DEBUG, "ACS: Channel %d: not allowed as primary channel for 160 MHz bandwidth", @@ -873,12 +873,14 @@ acs_find_ideal_chan(struct hostapd_iface *iface) if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) { switch (hostapd_get_oper_chwidth(iface->conf)) { - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: n_chans = 4; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: n_chans = 8; break; + default: + break; } } @@ -915,13 +917,13 @@ static void acs_adjust_center_freq(struct hostapd_iface *iface) wpa_printf(MSG_DEBUG, "ACS: Adjusting VHT center frequency"); switch (hostapd_get_oper_chwidth(iface->conf)) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: offset = 2 * iface->conf->secondary_channel; break; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: offset = 6; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: offset = 14; break; default: diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 805ea93df..876a1bbd9 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -1048,7 +1048,7 @@ struct hostapd_config { u32 vht_capab; int ieee80211ac; int require_vht; - u8 vht_oper_chwidth; + enum oper_chan_width vht_oper_chwidth; u8 vht_oper_centr_freq_seg0_idx; u8 vht_oper_centr_freq_seg1_idx; u8 ht40_plus_minus_allowed; @@ -1092,7 +1092,7 @@ struct hostapd_config { struct he_operation he_op; struct ieee80211_he_mu_edca_parameter_set he_mu_edca; struct spatial_reuse spr; - u8 he_oper_chwidth; + enum oper_chan_width he_oper_chwidth; u8 he_oper_centr_freq_seg0_idx; u8 he_oper_centr_freq_seg1_idx; u8 he_6ghz_max_mpdu; @@ -1130,7 +1130,7 @@ struct hostapd_config { int ieee80211be; #ifdef CONFIG_IEEE80211BE - u8 eht_oper_chwidth; + enum oper_chan_width eht_oper_chwidth; u8 eht_oper_centr_freq_seg0_idx; struct eht_phy_capabilities_info eht_phy_capab; #endif /* CONFIG_IEEE80211BE */ @@ -1142,7 +1142,8 @@ struct hostapd_config { }; -static inline u8 hostapd_get_oper_chwidth(struct hostapd_config *conf) +static inline enum oper_chan_width +hostapd_get_oper_chwidth(struct hostapd_config *conf) { #ifdef CONFIG_IEEE80211BE if (conf->ieee80211be) @@ -1156,7 +1157,8 @@ static inline u8 hostapd_get_oper_chwidth(struct hostapd_config *conf) } static inline void -hostapd_set_oper_chwidth(struct hostapd_config *conf, u8 oper_chwidth) +hostapd_set_oper_chwidth(struct hostapd_config *conf, + enum oper_chan_width oper_chwidth) { #ifdef CONFIG_IEEE80211BE if (conf->ieee80211be) diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index 8af7a0e25..a7079f6ab 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -978,12 +978,13 @@ int hostapd_drv_do_acs(struct hostapd_data *hapd) hapd->iface->conf->ieee80211ax || hapd->iface->conf->ieee80211ac) && params.ht40_enabled) { - u8 oper_chwidth = hostapd_get_oper_chwidth(hapd->iface->conf); + enum oper_chan_width oper_chwidth; - if (oper_chwidth == CHANWIDTH_80MHZ) + oper_chwidth = hostapd_get_oper_chwidth(hapd->iface->conf); + if (oper_chwidth == CONF_OPER_CHWIDTH_80MHZ) params.ch_width = 80; - else if (oper_chwidth == CHANWIDTH_160MHZ || - oper_chwidth == CHANWIDTH_80P80MHZ) + else if (oper_chwidth == CONF_OPER_CHWIDTH_160MHZ || + oper_chwidth == CONF_OPER_CHWIDTH_80P80MHZ) params.ch_width = 160; } diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 58872bfda..86765705a 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -1280,22 +1280,24 @@ static u16 hostapd_fils_discovery_cap(struct hostapd_data *hapd) } } else { switch (hostapd_get_oper_chwidth(hapd->iconf)) { - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: mcs_nss_size += 4; /* fallthrough */ - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: mcs_nss_size += 4; chwidth = FD_CAP_BSS_CHWIDTH_160_80_80; break; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: chwidth = FD_CAP_BSS_CHWIDTH_80; break; - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: if (hapd->iconf->secondary_channel) chwidth = FD_CAP_BSS_CHWIDTH_40; else chwidth = FD_CAP_BSS_CHWIDTH_20; break; + default: + break; } #ifdef CONFIG_IEEE80211AX diff --git a/src/ap/dfs.c b/src/ap/dfs.c index e46dd7ede..146dd1ada 100644 --- a/src/ap/dfs.c +++ b/src/ap/dfs.c @@ -50,15 +50,15 @@ static int dfs_get_used_n_chans(struct hostapd_iface *iface, int *seg1) if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) { switch (hostapd_get_oper_chwidth(iface->conf)) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: break; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: n_chans = 4; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: n_chans = 8; break; - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: n_chans = 4; *seg1 = 4; break; @@ -311,7 +311,7 @@ static void dfs_adjust_center_freq(struct hostapd_iface *iface, *oper_centr_freq_seg1_idx = 0; switch (hostapd_get_oper_chwidth(iface->conf)) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: if (secondary_channel == 1) *oper_centr_freq_seg0_idx = chan->chan + 2; else if (secondary_channel == -1) @@ -319,13 +319,13 @@ static void dfs_adjust_center_freq(struct hostapd_iface *iface, else *oper_centr_freq_seg0_idx = chan->chan; break; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: *oper_centr_freq_seg0_idx = chan->chan + 6; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: *oper_centr_freq_seg0_idx = chan->chan + 14; break; - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: *oper_centr_freq_seg0_idx = chan->chan + 6; *oper_centr_freq_seg1_idx = sec_chan_idx_80p80 + 6; break; @@ -361,17 +361,17 @@ static int dfs_get_start_chan_idx(struct hostapd_iface *iface, int *seg1_start) /* VHT/HE */ if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) { switch (hostapd_get_oper_chwidth(iface->conf)) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: break; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: channel_no = hostapd_get_oper_centr_freq_seg0_idx( iface->conf) - 6; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: channel_no = hostapd_get_oper_centr_freq_seg0_idx( iface->conf) - 14; break; - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: channel_no = hostapd_get_oper_centr_freq_seg0_idx( iface->conf) - 6; chan_seg1 = hostapd_get_oper_centr_freq_seg1_idx( @@ -555,7 +555,8 @@ dfs_get_valid_channel(struct hostapd_iface *iface, *secondary_channel = 0; /* Get secondary channel for HT80P80 */ - if (hostapd_get_oper_chwidth(iface->conf) == CHANWIDTH_80P80MHZ) { + if (hostapd_get_oper_chwidth(iface->conf) == + CONF_OPER_CHWIDTH_80P80MHZ) { if (num_available_chandefs <= 1) { wpa_printf(MSG_ERROR, "only 1 valid chan, can't support 80+80"); @@ -1220,7 +1221,7 @@ dfs_downgrade_bandwidth(struct hostapd_iface *iface, int *secondary_channel, int oper_chwidth; oper_chwidth = hostapd_get_oper_chwidth(iface->conf); - if (oper_chwidth == CHANWIDTH_USE_HT) + if (oper_chwidth == CONF_OPER_CHWIDTH_USE_HT) break; *channel_type = DFS_AVAILABLE; hostapd_set_oper_chwidth(iface->conf, oper_chwidth - 1); diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index fff8bb3e5..4b321a9b9 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -891,19 +891,19 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, switch (width) { case CHAN_WIDTH_80: - chwidth = CHANWIDTH_80MHZ; + chwidth = CONF_OPER_CHWIDTH_80MHZ; break; case CHAN_WIDTH_80P80: - chwidth = CHANWIDTH_80P80MHZ; + chwidth = CONF_OPER_CHWIDTH_80P80MHZ; break; case CHAN_WIDTH_160: - chwidth = CHANWIDTH_160MHZ; + chwidth = CONF_OPER_CHWIDTH_160MHZ; break; case CHAN_WIDTH_20_NOHT: case CHAN_WIDTH_20: case CHAN_WIDTH_40: default: - chwidth = CHANWIDTH_USE_HT; + chwidth = CONF_OPER_CHWIDTH_USE_HT; break; } @@ -979,10 +979,10 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, seg1_idx); if (hapd->iconf->ieee80211ac) { hapd->iconf->vht_capab &= ~VHT_CAP_SUPP_CHAN_WIDTH_MASK; - if (chwidth == CHANWIDTH_160MHZ) + if (chwidth == CONF_OPER_CHWIDTH_160MHZ) hapd->iconf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; - else if (chwidth == CHANWIDTH_80P80MHZ) + else if (chwidth == CONF_OPER_CHWIDTH_80P80MHZ) hapd->iconf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; } @@ -1145,7 +1145,7 @@ void hostapd_acs_channel_selected(struct hostapd_data *hapd, /* set defaults for backwards compatibility */ hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, 0); hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, 0); - hostapd_set_oper_chwidth(hapd->iconf, CHANWIDTH_USE_HT); + hostapd_set_oper_chwidth(hapd->iconf, CONF_OPER_CHWIDTH_USE_HT); if (acs_res->ch_width == 40) { if (is_6ghz_freq(acs_res->pri_freq)) hostapd_set_oper_centr_freq_seg0_idx( @@ -1155,17 +1155,19 @@ void hostapd_acs_channel_selected(struct hostapd_data *hapd, hostapd_set_oper_centr_freq_seg0_idx( hapd->iconf, acs_res->vht_seg0_center_ch); if (acs_res->vht_seg1_center_ch == 0) { - hostapd_set_oper_chwidth(hapd->iconf, - CHANWIDTH_80MHZ); + hostapd_set_oper_chwidth( + hapd->iconf, CONF_OPER_CHWIDTH_80MHZ); } else { - hostapd_set_oper_chwidth(hapd->iconf, - CHANWIDTH_80P80MHZ); + hostapd_set_oper_chwidth( + hapd->iconf, + CONF_OPER_CHWIDTH_80P80MHZ); hostapd_set_oper_centr_freq_seg1_idx( hapd->iconf, acs_res->vht_seg1_center_ch); } } else if (acs_res->ch_width == 160) { - hostapd_set_oper_chwidth(hapd->iconf, CHANWIDTH_160MHZ); + hostapd_set_oper_chwidth(hapd->iconf, + CONF_OPER_CHWIDTH_160MHZ); hostapd_set_oper_centr_freq_seg0_idx( hapd->iconf, acs_res->vht_seg1_center_ch); } diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index f6fe8a8a0..f6e45274b 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -1718,7 +1718,7 @@ static int setup_interface2(struct hostapd_iface *iface) goto fail; if (iface->conf->op_class) { - int ch_width; + enum oper_chan_width ch_width; ch_width = op_class_to_ch_width(iface->conf->op_class); hostapd_set_oper_chwidth(iface->conf, ch_width); @@ -3503,16 +3503,18 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd, case 0: case 20: case 40: - hostapd_set_oper_chwidth(conf, CHANWIDTH_USE_HT); + hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_USE_HT); break; case 80: if (params->center_freq2) - hostapd_set_oper_chwidth(conf, CHANWIDTH_80P80MHZ); + hostapd_set_oper_chwidth(conf, + CONF_OPER_CHWIDTH_80P80MHZ); else - hostapd_set_oper_chwidth(conf, CHANWIDTH_80MHZ); + hostapd_set_oper_chwidth(conf, + CONF_OPER_CHWIDTH_80MHZ); break; case 160: - hostapd_set_oper_chwidth(conf, CHANWIDTH_160MHZ); + hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_160MHZ); break; default: return -1; @@ -3550,15 +3552,15 @@ static int hostapd_fill_csa_settings(struct hostapd_data *hapd, switch (settings->freq_params.bandwidth) { case 80: if (settings->freq_params.center_freq2) - bandwidth = CHANWIDTH_80P80MHZ; + bandwidth = CONF_OPER_CHWIDTH_80P80MHZ; else - bandwidth = CHANWIDTH_80MHZ; + bandwidth = CONF_OPER_CHWIDTH_80MHZ; break; case 160: - bandwidth = CHANWIDTH_160MHZ; + bandwidth = CONF_OPER_CHWIDTH_160MHZ; break; default: - bandwidth = CHANWIDTH_USE_HT; + bandwidth = CONF_OPER_CHWIDTH_USE_HT; break; } @@ -3688,7 +3690,8 @@ void hostapd_switch_channel_fallback(struct hostapd_iface *iface, const struct hostapd_freq_params *freq_params) { - int seg0_idx = 0, seg1_idx = 0, bw = CHANWIDTH_USE_HT; + int seg0_idx = 0, seg1_idx = 0; + enum oper_chan_width bw = CONF_OPER_CHWIDTH_USE_HT; wpa_printf(MSG_DEBUG, "Restarting all CSA-related BSSes"); @@ -3701,16 +3704,16 @@ hostapd_switch_channel_fallback(struct hostapd_iface *iface, case 0: case 20: case 40: - bw = CHANWIDTH_USE_HT; + bw = CONF_OPER_CHWIDTH_USE_HT; break; case 80: if (freq_params->center_freq2) - bw = CHANWIDTH_80P80MHZ; + bw = CONF_OPER_CHWIDTH_80P80MHZ; else - bw = CHANWIDTH_80MHZ; + bw = CONF_OPER_CHWIDTH_80MHZ; break; case 160: - bw = CHANWIDTH_160MHZ; + bw = CONF_OPER_CHWIDTH_160MHZ; break; default: wpa_printf(MSG_WARNING, "Unknown CSA bandwidth: %d", diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index 4b66b02f4..cbd659219 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -371,7 +371,7 @@ static void ieee80211n_check_scan(struct hostapd_iface *iface) iface->conf->secondary_channel = 0; hostapd_set_oper_centr_freq_seg0_idx(iface->conf, 0); hostapd_set_oper_centr_freq_seg1_idx(iface->conf, 0); - hostapd_set_oper_chwidth(iface->conf, CHANWIDTH_USE_HT); + hostapd_set_oper_chwidth(iface->conf, CONF_OPER_CHWIDTH_USE_HT); res = 1; wpa_printf(MSG_INFO, "Fallback to 20 MHz"); } diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index aa26ad4ef..8806a585a 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -7033,7 +7033,7 @@ u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid) #endif /* CONFIG_IEEE80211AX */ switch (hostapd_get_oper_chwidth(iconf)) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: if (iconf->secondary_channel == 0) { /* Max Transmit Power count = 0 (20 MHz) */ tx_pwr_count = 0; @@ -7042,12 +7042,12 @@ u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid) tx_pwr_count = 1; } break; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: /* Max Transmit Power count = 2 (20, 40, and 80 MHz) */ tx_pwr_count = 2; break; - case CHANWIDTH_80P80MHZ: - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_160MHZ: /* Max Transmit Power count = 3 (20, 40, 80, 160/80+80 MHz) */ tx_pwr_count = 3; break; diff --git a/src/ap/ieee802_11_eht.c b/src/ap/ieee802_11_eht.c index 0b7454f3e..547ccd329 100644 --- a/src/ap/ieee802_11_eht.c +++ b/src/ap/ieee802_11_eht.c @@ -176,7 +176,8 @@ u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid) { struct hostapd_config *conf = hapd->iconf; struct ieee80211_eht_operation *oper; - u8 *pos = eid, chwidth, seg0 = 0, seg1 = 0; + u8 *pos = eid, seg0 = 0, seg1 = 0; + enum oper_chan_width chwidth; if (!hapd->iface->current_mode) return eid; @@ -207,7 +208,7 @@ u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid) seg0 += 16; break; #endif - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: oper->oper_info.control |= EHT_OPER_CHANNEL_WIDTH_160MHZ; seg1 = seg0; if (hapd->iconf->channel < seg0) @@ -215,10 +216,10 @@ u8 * hostapd_eid_eht_operation(struct hostapd_data *hapd, u8 *eid) else seg0 += 8; break; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: oper->oper_info.control |= EHT_OPER_CHANNEL_WIDTH_80MHZ; break; - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: if (seg0) oper->oper_info.control |= EHT_OPER_CHANNEL_WIDTH_40MHZ; break; @@ -286,10 +287,12 @@ static bool check_valid_eht_mcs(struct hostapd_data *hapd, switch (hapd->iface->conf->eht_oper_chwidth) { /* TODO: CHANWIDTH_320MHZ */ - case CHANWIDTH_80P80MHZ: - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_160MHZ: mcs_count = 2; break; + default: + break; } return check_valid_eht_mcs_nss(hapd, ap_mcs, sta_mcs, mcs_count, diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c index 1e74c5845..e9be2d3ed 100644 --- a/src/ap/ieee802_11_he.c +++ b/src/ap/ieee802_11_he.c @@ -102,20 +102,22 @@ u8 * hostapd_eid_he_capab(struct hostapd_data *hapd, u8 *eid, mode->he_capab[opmode].phy_cap); switch (hapd->iface->conf->he_oper_chwidth) { - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: he_oper_chwidth |= HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G; mcs_nss_size += 4; /* fall through */ - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: he_oper_chwidth |= HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G; mcs_nss_size += 4; /* fall through */ - case CHANWIDTH_80MHZ: - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_USE_HT: he_oper_chwidth |= HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_IN_2G | HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G; break; + default: + break; } ie_size += mcs_nss_size + ppet_size; @@ -430,10 +432,10 @@ static int check_valid_he_mcs(struct hostapd_data *hapd, const u8 *sta_he_capab, * band/stream cases. */ switch (hapd->iface->conf->he_oper_chwidth) { - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: mcs_count = 3; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: mcs_count = 2; break; default: diff --git a/src/ap/ieee802_11_shared.c b/src/ap/ieee802_11_shared.c index 615489511..4e7c33eea 100644 --- a/src/ap/ieee802_11_shared.c +++ b/src/ap/ieee802_11_shared.c @@ -998,7 +998,7 @@ int get_tx_parameters(struct sta_info *sta, int ap_max_chanwidth, * If a VHT Operation element was present, use it to determine * the supported channel bandwidth. */ - if (oper->vht_op_info_chwidth == 0) { + if (oper->vht_op_info_chwidth == CHANWIDTH_USE_HT) { requested_bw = ht_40mhz ? 40 : 20; } else if (oper->vht_op_info_chan_center_freq_seg1_idx == 0) { requested_bw = 80; diff --git a/src/ap/ieee802_11_vht.c b/src/ap/ieee802_11_vht.c index 828f0abb5..681b6d78f 100644 --- a/src/ap/ieee802_11_vht.c +++ b/src/ap/ieee802_11_vht.c @@ -96,12 +96,12 @@ u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid) hapd->iconf->vht_oper_centr_freq_seg1_idx; oper->vht_op_info_chwidth = hapd->iconf->vht_oper_chwidth; - if (hapd->iconf->vht_oper_chwidth == 2) { + if (hapd->iconf->vht_oper_chwidth == CONF_OPER_CHWIDTH_160MHZ) { /* * Convert 160 MHz channel width to new style as interop * workaround. */ - oper->vht_op_info_chwidth = 1; + oper->vht_op_info_chwidth = CHANWIDTH_80MHZ; oper->vht_op_info_chan_center_freq_seg1_idx = oper->vht_op_info_chan_center_freq_seg0_idx; if (hapd->iconf->channel < @@ -109,12 +109,13 @@ u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid) oper->vht_op_info_chan_center_freq_seg0_idx -= 8; else oper->vht_op_info_chan_center_freq_seg0_idx += 8; - } else if (hapd->iconf->vht_oper_chwidth == 3) { + } else if (hapd->iconf->vht_oper_chwidth == + CONF_OPER_CHWIDTH_80P80MHZ) { /* * Convert 80+80 MHz channel width to new style as interop * workaround. */ - oper->vht_op_info_chwidth = 1; + oper->vht_op_info_chwidth = CHANWIDTH_80MHZ; } /* VHT Basic MCS set comes from hw */ diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c index e37324f3d..52f25eb7a 100644 --- a/src/ap/neighbor_db.c +++ b/src/ap/neighbor_db.c @@ -199,19 +199,21 @@ void hostapd_free_neighbor_db(struct hostapd_data *hapd) static enum nr_chan_width hostapd_get_nr_chan_width(struct hostapd_data *hapd, int ht, int vht, int he) { - u8 oper_chwidth = hostapd_get_oper_chwidth(hapd->iconf); + enum oper_chan_width oper_chwidth; + + oper_chwidth = hostapd_get_oper_chwidth(hapd->iconf); if (!ht && !vht && !he) return NR_CHAN_WIDTH_20; if (!hapd->iconf->secondary_channel) return NR_CHAN_WIDTH_20; - if ((!vht && !he) || oper_chwidth == CHANWIDTH_USE_HT) + if ((!vht && !he) || oper_chwidth == CONF_OPER_CHWIDTH_USE_HT) return NR_CHAN_WIDTH_40; - if (oper_chwidth == CHANWIDTH_80MHZ) + if (oper_chwidth == CONF_OPER_CHWIDTH_80MHZ) return NR_CHAN_WIDTH_80; - if (oper_chwidth == CHANWIDTH_160MHZ) + if (oper_chwidth == CONF_OPER_CHWIDTH_160MHZ) return NR_CHAN_WIDTH_160; - if (oper_chwidth == CHANWIDTH_80P80MHZ) + if (oper_chwidth == CONF_OPER_CHWIDTH_80P80MHZ) return NR_CHAN_WIDTH_80P80; return NR_CHAN_WIDTH_20; } diff --git a/src/common/defs.h b/src/common/defs.h index 07065695d..ce7487988 100644 --- a/src/common/defs.h +++ b/src/common/defs.h @@ -432,6 +432,21 @@ enum chan_width { CHAN_WIDTH_UNKNOWN }; +/* VHT/EDMG/etc. channel widths + * Note: The first four values are used in hostapd.conf and as such, must + * maintain their defined values. Other values are used internally. */ +enum oper_chan_width { + CONF_OPER_CHWIDTH_USE_HT = 0, + CONF_OPER_CHWIDTH_80MHZ = 1, + CONF_OPER_CHWIDTH_160MHZ = 2, + CONF_OPER_CHWIDTH_80P80MHZ = 3, + CONF_OPER_CHWIDTH_2160MHZ, + CONF_OPER_CHWIDTH_4320MHZ, + CONF_OPER_CHWIDTH_6480MHZ, + CONF_OPER_CHWIDTH_8640MHZ, + CONF_OPER_CHWIDTH_40MHZ_6GHZ, +}; + enum key_flag { KEY_FLAG_MODIFY = BIT(0), KEY_FLAG_DEFAULT = BIT(1), diff --git a/src/common/hw_features_common.c b/src/common/hw_features_common.c index 2e10e7386..e2bf3afc6 100644 --- a/src/common/hw_features_common.c +++ b/src/common/hw_features_common.c @@ -384,7 +384,8 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, u8 edmg_channel, int ht_enabled, int vht_enabled, int he_enabled, bool eht_enabled, int sec_channel_offset, - int oper_chwidth, int center_segment0, + enum oper_chan_width oper_chwidth, + int center_segment0, int center_segment1, u32 vht_caps, struct he_capabilities *he_cap, struct eht_capabilities *eht_cap) @@ -402,10 +403,10 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, data->sec_channel_offset = sec_channel_offset; data->center_freq1 = freq + sec_channel_offset * 10; data->center_freq2 = 0; - if (oper_chwidth == CHANWIDTH_80MHZ) + if (oper_chwidth == CONF_OPER_CHWIDTH_80MHZ) data->bandwidth = 80; - else if (oper_chwidth == CHANWIDTH_160MHZ || - oper_chwidth == CHANWIDTH_80P80MHZ) + else if (oper_chwidth == CONF_OPER_CHWIDTH_160MHZ || + oper_chwidth == CONF_OPER_CHWIDTH_80P80MHZ) data->bandwidth = 160; else if (sec_channel_offset) data->bandwidth = 40; @@ -496,7 +497,7 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, #endif if (data->he_enabled || data->eht_enabled) switch (oper_chwidth) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: if (sec_channel_offset == 0) break; @@ -511,7 +512,7 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, break; } /* fall through */ - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: if (mode == HOSTAPD_MODE_IEEE80211A) { if (he_cap && !(he_cap->phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] & @@ -522,7 +523,7 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, } } break; - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: if (he_cap && !(he_cap->phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] & HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G)) { @@ -531,7 +532,7 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, return -1; } break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: if (he_cap && !(he_cap->phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] & HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G)) { @@ -540,19 +541,21 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, return -1; } break; - } else if (data->vht_enabled) switch (oper_chwidth) { - case CHANWIDTH_USE_HT: + default: break; - case CHANWIDTH_80P80MHZ: + } else if (data->vht_enabled) switch (oper_chwidth) { + case CONF_OPER_CHWIDTH_USE_HT: + break; + case CONF_OPER_CHWIDTH_80P80MHZ: if (!(vht_caps & VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)) { wpa_printf(MSG_ERROR, "80+80 channel width is not supported!"); return -1; } /* fall through */ - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: if (!(vht_caps & (VHT_CAP_SUPP_CHAN_WIDTH_160MHZ | VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ))) { wpa_printf(MSG_ERROR, @@ -560,11 +563,13 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, return -1; } break; + default: + break; } if (data->eht_enabled || data->he_enabled || data->vht_enabled) switch (oper_chwidth) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: if (center_segment1 || (center_segment0 != 0 && 5000 + center_segment0 * 5 != data->center_freq1 && @@ -575,7 +580,7 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, return -1; } break; - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: if (center_segment1 == center_segment0 + 4 || center_segment1 == center_segment0 - 4) { wpa_printf(MSG_ERROR, @@ -584,19 +589,21 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, } data->center_freq2 = 5000 + center_segment1 * 5; /* fall through */ - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: data->bandwidth = 80; if (!sec_channel_offset) { wpa_printf(MSG_ERROR, "80/80+80 MHz: no second channel offset"); return -1; } - if (oper_chwidth == CHANWIDTH_80MHZ && center_segment1) { + if (oper_chwidth == CONF_OPER_CHWIDTH_80MHZ && + center_segment1) { wpa_printf(MSG_ERROR, "80 MHz: center segment 1 configured"); return -1; } - if (oper_chwidth == CHANWIDTH_80P80MHZ && !center_segment1) { + if (oper_chwidth == CONF_OPER_CHWIDTH_80P80MHZ && + !center_segment1) { wpa_printf(MSG_ERROR, "80+80 MHz: center segment 1 not configured"); return -1; @@ -635,7 +642,7 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, } } break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: data->bandwidth = 160; if (center_segment1) { wpa_printf(MSG_ERROR, @@ -666,6 +673,8 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, return -1; } break; + default: + break; } return 0; diff --git a/src/common/hw_features_common.h b/src/common/hw_features_common.h index d87a2caff..d8ca16867 100644 --- a/src/common/hw_features_common.h +++ b/src/common/hw_features_common.h @@ -41,7 +41,8 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, int ht_enabled, int vht_enabled, int he_enabled, bool eht_enabled, int sec_channel_offset, - int oper_chwidth, int center_segment0, + enum oper_chan_width oper_chwidth, + int center_segment0, int center_segment1, u32 vht_caps, struct he_capabilities *he_caps, struct eht_capabilities *eht_cap); diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 9e348a21c..dfc035df7 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -880,7 +880,7 @@ enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel) { u8 op_class; - return ieee80211_freq_to_channel_ext(freq, 0, CHANWIDTH_USE_HT, + return ieee80211_freq_to_channel_ext(freq, 0, CONF_OPER_CHWIDTH_USE_HT, &op_class, channel); } @@ -890,15 +890,15 @@ enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel) * for HT40, VHT, and HE. DFS channels are not covered. * @freq: Frequency (MHz) to convert * @sec_channel: 0 = non-HT40, 1 = sec. channel above, -1 = sec. channel below - * @chanwidth: VHT/EDMG channel width (CHANWIDTH_*) + * @chanwidth: VHT/EDMG/etc. channel width * @op_class: Buffer for returning operating class * @channel: Buffer for returning channel number * Returns: hw_mode on success, NUM_HOSTAPD_MODES on failure */ -enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, - int sec_channel, - int chanwidth, - u8 *op_class, u8 *channel) +enum hostapd_hw_mode +ieee80211_freq_to_channel_ext(unsigned int freq, int sec_channel, + enum oper_chan_width chanwidth, + u8 *op_class, u8 *channel) { u8 vht_opclass; @@ -946,13 +946,13 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, } switch (chanwidth) { - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: vht_opclass = 128; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: vht_opclass = 129; break; - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: vht_opclass = 130; break; default: @@ -1051,13 +1051,13 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, return NUM_HOSTAPD_MODES; switch (chanwidth) { - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: *op_class = 133; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: *op_class = 134; break; - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: *op_class = 135; break; default: @@ -1084,12 +1084,12 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, return NUM_HOSTAPD_MODES; switch (chanwidth) { - case CHANWIDTH_USE_HT: - case CHANWIDTH_2160MHZ: + case CONF_OPER_CHWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_2160MHZ: *channel = (freq - 56160) / 2160; *op_class = 180; break; - case CHANWIDTH_4320MHZ: + case CONF_OPER_CHWIDTH_4320MHZ: /* EDMG channels 9 - 13 */ if (freq > 56160 + 2160 * 5) return NUM_HOSTAPD_MODES; @@ -1097,7 +1097,7 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, *channel = (freq - 56160) / 2160 + 8; *op_class = 181; break; - case CHANWIDTH_6480MHZ: + case CONF_OPER_CHWIDTH_6480MHZ: /* EDMG channels 17 - 20 */ if (freq > 56160 + 2160 * 4) return NUM_HOSTAPD_MODES; @@ -1105,7 +1105,7 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, *channel = (freq - 56160) / 2160 + 16; *op_class = 182; break; - case CHANWIDTH_8640MHZ: + case CONF_OPER_CHWIDTH_8640MHZ: /* EDMG channels 25 - 27 */ if (freq > 56160 + 2160 * 3) return NUM_HOSTAPD_MODES; @@ -1134,28 +1134,28 @@ int ieee80211_chaninfo_to_channel(unsigned int freq, enum chan_width chanwidth, case CHAN_WIDTH_20_NOHT: case CHAN_WIDTH_20: case CHAN_WIDTH_40: - cw = CHANWIDTH_USE_HT; + cw = CONF_OPER_CHWIDTH_USE_HT; break; case CHAN_WIDTH_80: - cw = CHANWIDTH_80MHZ; + cw = CONF_OPER_CHWIDTH_80MHZ; break; case CHAN_WIDTH_80P80: - cw = CHANWIDTH_80P80MHZ; + cw = CONF_OPER_CHWIDTH_80P80MHZ; break; case CHAN_WIDTH_160: - cw = CHANWIDTH_160MHZ; + cw = CONF_OPER_CHWIDTH_160MHZ; break; case CHAN_WIDTH_2160: - cw = CHANWIDTH_2160MHZ; + cw = CONF_OPER_CHWIDTH_2160MHZ; break; case CHAN_WIDTH_4320: - cw = CHANWIDTH_4320MHZ; + cw = CONF_OPER_CHWIDTH_4320MHZ; break; case CHAN_WIDTH_6480: - cw = CHANWIDTH_6480MHZ; + cw = CONF_OPER_CHWIDTH_6480MHZ; break; case CHAN_WIDTH_8640: - cw = CHANWIDTH_8640MHZ; + cw = CONF_OPER_CHWIDTH_8640MHZ; break; } @@ -2607,64 +2607,64 @@ int op_class_to_bandwidth(u8 op_class) } -int op_class_to_ch_width(u8 op_class) +enum oper_chan_width op_class_to_ch_width(u8 op_class) { switch (op_class) { case 81: case 82: - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 83: /* channels 1..9; 40 MHz */ case 84: /* channels 5..13; 40 MHz */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 115: /* channels 36,40,44,48; indoor only */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 116: /* channels 36,44; 40 MHz; indoor only */ case 117: /* channels 40,48; 40 MHz; indoor only */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 118: /* channels 52,56,60,64; dfs */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 119: /* channels 52,60; 40 MHz; dfs */ case 120: /* channels 56,64; 40 MHz; dfs */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 121: /* channels 100-140 */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 122: /* channels 100-142; 40 MHz */ case 123: /* channels 104-136; 40 MHz */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 124: /* channels 149,153,157,161 */ case 125: /* channels 149,153,157,161,165,169,171 */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 126: /* channels 149,157,165, 173; 40 MHz */ case 127: /* channels 153,161,169,177; 40 MHz */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 128: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80 MHz */ - return CHANWIDTH_80MHZ; + return CONF_OPER_CHWIDTH_80MHZ; case 129: /* center freqs 50, 114, 163; 160 MHz */ - return CHANWIDTH_160MHZ; + return CONF_OPER_CHWIDTH_160MHZ; case 130: /* center freqs 42, 58, 106, 122, 138, 155, 171; 80+80 MHz */ - return CHANWIDTH_80P80MHZ; + return CONF_OPER_CHWIDTH_80P80MHZ; case 131: /* UHB channels, 20 MHz: 1, 5, 9.. */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 132: /* UHB channels, 40 MHz: 3, 11, 19.. */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 133: /* UHB channels, 80 MHz: 7, 23, 39.. */ - return CHANWIDTH_80MHZ; + return CONF_OPER_CHWIDTH_80MHZ; case 134: /* UHB channels, 160 MHz: 15, 47, 79.. */ - return CHANWIDTH_160MHZ; + return CONF_OPER_CHWIDTH_160MHZ; case 135: /* UHB channels, 80+80 MHz: 7, 23, 39.. */ - return CHANWIDTH_80P80MHZ; + return CONF_OPER_CHWIDTH_80P80MHZ; case 136: /* UHB channels, 20 MHz: 2 */ - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 180: /* 60 GHz band, channels 1..8 */ - return CHANWIDTH_2160MHZ; + return CONF_OPER_CHWIDTH_2160MHZ; case 181: /* 60 GHz band, EDMG CB2, channels 9..15 */ - return CHANWIDTH_4320MHZ; + return CONF_OPER_CHWIDTH_4320MHZ; case 182: /* 60 GHz band, EDMG CB3, channels 17..22 */ - return CHANWIDTH_6480MHZ; + return CONF_OPER_CHWIDTH_6480MHZ; case 183: /* 60 GHz band, EDMG CB4, channel 25..29 */ - return CHANWIDTH_8640MHZ; + return CONF_OPER_CHWIDTH_8640MHZ; } - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; } diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index 743c5a03c..94e1d7b8b 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -215,9 +215,10 @@ int hostapd_config_tx_queue(struct hostapd_tx_queue_params queue[], const char *name, const char *val); enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel); int ieee80211_chan_to_freq(const char *country, u8 op_class, u8 chan); -enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, - int sec_channel, int vht, - u8 *op_class, u8 *channel); +enum hostapd_hw_mode +ieee80211_freq_to_channel_ext(unsigned int freq, int sec_channel, + enum oper_chan_width chanwidth, + u8 *op_class, u8 *channel); int ieee80211_chaninfo_to_channel(unsigned int freq, enum chan_width chanwidth, int sec_channel, u8 *op_class, u8 *channel); int ieee80211_is_dfs(int freq, const struct hostapd_hw_modes *modes, @@ -279,7 +280,7 @@ bool ieee802_11_rsnx_capab_len(const u8 *rsnxe, size_t rsnxe_len, unsigned int capab); bool ieee802_11_rsnx_capab(const u8 *rsnxe, unsigned int capab); int op_class_to_bandwidth(u8 op_class); -int op_class_to_ch_width(u8 op_class); +enum oper_chan_width op_class_to_ch_width(u8 op_class); /* element iteration helpers */ #define for_each_element(_elem, _data, _datalen) \ diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index ffa93f320..1bd57afe5 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -1334,16 +1334,11 @@ struct ieee80211_ampe_ie { #define VHT_RX_NSS_MAX_STREAMS 8 -/* VHT/EDMG channel widths */ +/* VHT operation information - channel widths */ #define CHANWIDTH_USE_HT 0 #define CHANWIDTH_80MHZ 1 #define CHANWIDTH_160MHZ 2 #define CHANWIDTH_80P80MHZ 3 -#define CHANWIDTH_2160MHZ 4 -#define CHANWIDTH_4320MHZ 5 -#define CHANWIDTH_6480MHZ 6 -#define CHANWIDTH_8640MHZ 7 -#define CHANWIDTH_40MHZ_6GHZ 8 #define HE_NSS_MAX_STREAMS 8 diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 52b537e62..7de924945 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -90,7 +90,7 @@ static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s, &conf->op_class, &conf->channel); - if (hostapd_get_oper_chwidth(conf) == CHANWIDTH_80P80MHZ) { + if (hostapd_get_oper_chwidth(conf) == CONF_OPER_CHWIDTH_80P80MHZ) { ieee80211_freq_to_chan(ssid->vht_center_freq2, &freq_seg_idx); hostapd_set_oper_centr_freq_seg1_idx(conf, freq_seg_idx); @@ -112,15 +112,15 @@ static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s, #ifdef CONFIG_P2P switch (hostapd_get_oper_chwidth(conf)) { - case CHANWIDTH_80MHZ: - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: center_chan = wpas_p2p_get_vht80_center(wpa_s, mode, channel, conf->op_class); wpa_printf(MSG_DEBUG, "VHT center channel %u for 80 or 80+80 MHz bandwidth", center_chan); break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel, conf->op_class); wpa_printf(MSG_DEBUG, @@ -133,7 +133,7 @@ static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s, * try oper_cwidth 160 MHz first then VHT 80 MHz, if 160 MHz is * not supported. */ - hostapd_set_oper_chwidth(conf, CHANWIDTH_160MHZ); + hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_160MHZ); ieee80211_freq_to_channel_ext(ssid->frequency, 0, conf->vht_oper_chwidth, &conf->op_class, @@ -145,7 +145,7 @@ static void wpas_conf_ap_vht(struct wpa_supplicant *wpa_s, "VHT center channel %u for auto-selected 160 MHz bandwidth", center_chan); } else { - hostapd_set_oper_chwidth(conf, CHANWIDTH_80MHZ); + hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_80MHZ); ieee80211_freq_to_channel_ext(ssid->frequency, 0, conf->vht_oper_chwidth, &conf->op_class, @@ -174,7 +174,7 @@ no_vht: conf->channel); hostapd_set_oper_centr_freq_seg0_idx( conf, conf->channel + conf->secondary_channel * 2); - hostapd_set_oper_chwidth(conf, CHANWIDTH_USE_HT); + hostapd_set_oper_chwidth(conf, CONF_OPER_CHWIDTH_USE_HT); } @@ -201,14 +201,14 @@ wpa_supplicant_find_hw_mode(struct wpa_supplicant *wpa_s, static int get_max_oper_chwidth_6ghz(int chwidth) { switch (chwidth) { - case CHANWIDTH_USE_HT: + case CONF_OPER_CHWIDTH_USE_HT: return 20; - case CHANWIDTH_40MHZ_6GHZ: + case CONF_OPER_CHWIDTH_40MHZ_6GHZ: return 40; - case CHANWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: return 80; - case CHANWIDTH_80P80MHZ: - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_160MHZ: return 160; default: return 0; @@ -249,8 +249,8 @@ static void wpas_conf_ap_he_6ghz(struct wpa_supplicant *wpa_s, wpa_printf(MSG_DEBUG, "Secondary channel offset %d for P2P group", conf->secondary_channel); - if (ssid->max_oper_chwidth == CHANWIDTH_40MHZ_6GHZ) - ssid->max_oper_chwidth = CHANWIDTH_USE_HT; + if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_40MHZ_6GHZ) + ssid->max_oper_chwidth = CONF_OPER_CHWIDTH_USE_HT; } if ((is_chanwidth_40_80 || is_chanwidth_160) && ssid->p2p_group && @@ -266,7 +266,7 @@ int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s, struct hostapd_config *conf) { conf->hw_mode = ieee80211_freq_to_channel_ext(ssid->frequency, 0, - CHANWIDTH_USE_HT, + CONF_OPER_CHWIDTH_USE_HT, &conf->op_class, &conf->channel); if (conf->hw_mode == NUM_HOSTAPD_MODES) { diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index bfbc46000..92525d7c6 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2434,8 +2434,8 @@ static const struct parse_data ssid_fields[] = { { INT_RANGE(ht, 0, 1) }, { INT_RANGE(vht, 0, 1) }, { INT_RANGE(ht40, -1, 1) }, - { INT_RANGE(max_oper_chwidth, CHANWIDTH_USE_HT, - CHANWIDTH_80P80MHZ) }, + { INT_RANGE(max_oper_chwidth, CONF_OPER_CHWIDTH_USE_HT, + CONF_OPER_CHWIDTH_80P80MHZ) }, { INT(vht_center_freq1) }, { INT(vht_center_freq2) }, #ifdef IEEE8021X_EAPOL diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h index 9b17c3b14..767f659c8 100644 --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -561,7 +561,7 @@ struct wpa_ssid { int he; - int max_oper_chwidth; + enum oper_chan_width max_oper_chwidth; unsigned int vht_center_freq1; unsigned int vht_center_freq2; diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 499e6d3dd..2bbbaab20 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -5978,17 +5978,17 @@ static int parse_freq(int chwidth, int freq2) if (freq2 < 0) return -1; if (freq2) - return CHANWIDTH_80P80MHZ; + return CONF_OPER_CHWIDTH_80P80MHZ; switch (chwidth) { case 0: case 20: case 40: - return CHANWIDTH_USE_HT; + return CONF_OPER_CHWIDTH_USE_HT; case 80: - return CHANWIDTH_80MHZ; + return CONF_OPER_CHWIDTH_80MHZ; case 160: - return CHANWIDTH_160MHZ; + return CONF_OPER_CHWIDTH_160MHZ; default: wpa_printf(MSG_DEBUG, "Unknown max oper bandwidth: %d", chwidth); @@ -6095,7 +6095,7 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, return -1; if (allow_6ghz && chwidth == 40) - max_oper_chwidth = CHANWIDTH_40MHZ_6GHZ; + max_oper_chwidth = CONF_OPER_CHWIDTH_40MHZ_6GHZ; pos2 = os_strstr(pos, " ssid="); if (pos2) { @@ -6751,7 +6751,7 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd) allow_6ghz = os_strstr(cmd, " allow_6ghz") != NULL; if (allow_6ghz && chwidth == 40) - max_oper_chwidth = CHANWIDTH_40MHZ_6GHZ; + max_oper_chwidth = CONF_OPER_CHWIDTH_40MHZ_6GHZ; return wpas_p2p_invite(wpa_s, _peer, ssid, NULL, freq, freq2, ht40, vht, max_oper_chwidth, pref_freq, he, edmg, @@ -6897,7 +6897,7 @@ static int p2p_ctrl_group_add(struct wpa_supplicant *wpa_s, char *cmd) return -1; if (allow_6ghz && chwidth == 40) - max_oper_chwidth = CHANWIDTH_40MHZ_6GHZ; + max_oper_chwidth = CONF_OPER_CHWIDTH_40MHZ_6GHZ; /* Allow DFS to be used for Autonomous GO */ wpa_s->p2p_go_allow_dfs = !!(wpa_s->drv_flags & diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c index b67396d5a..16530fb74 100644 --- a/wpa_supplicant/mesh.c +++ b/wpa_supplicant/mesh.c @@ -643,18 +643,20 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s, switch (params->freq.bandwidth) { case 80: if (params->freq.center_freq2) { - ssid->max_oper_chwidth = CHANWIDTH_80P80MHZ; + ssid->max_oper_chwidth = + CONF_OPER_CHWIDTH_80P80MHZ; ssid->vht_center_freq2 = params->freq.center_freq2; } else { - ssid->max_oper_chwidth = CHANWIDTH_80MHZ; + ssid->max_oper_chwidth = + CONF_OPER_CHWIDTH_80MHZ; } break; case 160: - ssid->max_oper_chwidth = CHANWIDTH_160MHZ; + ssid->max_oper_chwidth = CONF_OPER_CHWIDTH_160MHZ; break; default: - ssid->max_oper_chwidth = CHANWIDTH_USE_HT; + ssid->max_oper_chwidth = CONF_OPER_CHWIDTH_USE_HT; break; } } diff --git a/wpa_supplicant/op_classes.c b/wpa_supplicant/op_classes.c index bd53c5cec..5dca8f723 100644 --- a/wpa_supplicant/op_classes.c +++ b/wpa_supplicant/op_classes.c @@ -470,8 +470,9 @@ size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s, * or used. */ if (wpas_sta_secondary_channel_offset(bss, ¤t, &chan) < 0 && - ieee80211_freq_to_channel_ext(bss->freq, 0, CHANWIDTH_USE_HT, - ¤t, &chan) == NUM_HOSTAPD_MODES) + ieee80211_freq_to_channel_ext(bss->freq, 0, + CONF_OPER_CHWIDTH_USE_HT, ¤t, + &chan) == NUM_HOSTAPD_MODES) return 0; /* diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 6a23dd998..ed2ccc9ca 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -6674,8 +6674,8 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s, if (!is_6ghz && ieee80211_freq_to_channel_ext( - cand, -1, CHANWIDTH_USE_HT, &op_class, - &chan) != NUM_HOSTAPD_MODES && + cand, -1, CONF_OPER_CHWIDTH_USE_HT, + &op_class, &chan) != NUM_HOSTAPD_MODES && wpas_p2p_verify_channel( wpa_s, hwmode, op_class, chan, BW40MINUS) == ALLOWED) @@ -6683,8 +6683,8 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s, if (!supported && !is_6ghz && ieee80211_freq_to_channel_ext( - cand, 1, CHANWIDTH_USE_HT, &op_class, - &chan) != NUM_HOSTAPD_MODES && + cand, 1, CONF_OPER_CHWIDTH_USE_HT, + &op_class, &chan) != NUM_HOSTAPD_MODES && wpas_p2p_verify_channel( wpa_s, hwmode, op_class, chan, BW40PLUS) == ALLOWED) @@ -9717,13 +9717,15 @@ static int wpas_p2p_move_go_csa(struct wpa_supplicant *wpa_s) csa_settings.freq_params.center_freq2 = freq2; switch (conf->vht_oper_chwidth) { - case CHANWIDTH_80MHZ: - case CHANWIDTH_80P80MHZ: + case CONF_OPER_CHWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: csa_settings.freq_params.bandwidth = 80; break; - case CHANWIDTH_160MHZ: + case CONF_OPER_CHWIDTH_160MHZ: csa_settings.freq_params.bandwidth = 160; break; + default: + break; } } diff --git a/wpa_supplicant/rrm.c b/wpa_supplicant/rrm.c index 4457b6c3d..238fe68da 100644 --- a/wpa_supplicant/rrm.c +++ b/wpa_supplicant/rrm.c @@ -731,24 +731,24 @@ int wpas_get_op_chan_phy(int freq, const u8 *ies, size_t ies_len, vht_oper = (struct ieee80211_vht_operation *) (ie + 2); switch (vht_oper->vht_op_info_chwidth) { - case 1: + case CHANWIDTH_80MHZ: seg0 = vht_oper->vht_op_info_chan_center_freq_seg0_idx; seg1 = vht_oper->vht_op_info_chan_center_freq_seg1_idx; if (seg1 && abs(seg1 - seg0) == 8) - vht = CHANWIDTH_160MHZ; + vht = CONF_OPER_CHWIDTH_160MHZ; else if (seg1) - vht = CHANWIDTH_80P80MHZ; + vht = CONF_OPER_CHWIDTH_80P80MHZ; else - vht = CHANWIDTH_80MHZ; + vht = CONF_OPER_CHWIDTH_80MHZ; break; - case 2: - vht = CHANWIDTH_160MHZ; + case CHANWIDTH_160MHZ: + vht = CONF_OPER_CHWIDTH_160MHZ; break; - case 3: - vht = CHANWIDTH_80P80MHZ; + case CHANWIDTH_80P80MHZ: + vht = CONF_OPER_CHWIDTH_80P80MHZ; break; default: - vht = CHANWIDTH_USE_HT; + vht = CONF_OPER_CHWIDTH_USE_HT; break; } } diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 0a4b9d474..a00a2c538 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -921,7 +921,8 @@ static int wnm_nei_rep_add_bss(struct wpa_supplicant *wpa_s, { const u8 *ie; u8 op_class, chan; - int sec_chan = 0, vht = 0; + int sec_chan = 0; + enum oper_chan_width vht = CONF_OPER_CHWIDTH_USE_HT; enum phy_type phy_type; u32 info; struct ieee80211_ht_operation *ht_oper = NULL; diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index c2ce2c934..5111297dc 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2686,7 +2686,7 @@ skip_to_6ghz: if (!ibss_mesh_is_80mhz_avail(channel, mode)) return; - chwidth = CHANWIDTH_80MHZ; + chwidth = CONF_OPER_CHWIDTH_80MHZ; seg0 = channel + 6; seg1 = 0; @@ -2702,14 +2702,14 @@ skip_to_6ghz: for (j = 0; j < ARRAY_SIZE(bw160); j++) { if (freq->freq == bw160[j]) { - chwidth = CHANWIDTH_160MHZ; + chwidth = CONF_OPER_CHWIDTH_160MHZ; seg0 = channel + 14; break; } } } - if (ssid->max_oper_chwidth == CHANWIDTH_80P80MHZ) { + if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_80P80MHZ) { /* setup center_freq2, bandwidth */ for (k = 0; k < ARRAY_SIZE(bw80); k++) { /* Only accept 80 MHz segments separated by a gap */ @@ -2733,28 +2733,28 @@ skip_to_6ghz: continue; /* Found a suitable second segment for 80+80 */ - chwidth = CHANWIDTH_80P80MHZ; + chwidth = CONF_OPER_CHWIDTH_80P80MHZ; if (!is_6ghz) vht_caps |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; seg1 = channel + 6; } - if (chwidth == CHANWIDTH_80P80MHZ) + if (chwidth == CONF_OPER_CHWIDTH_80P80MHZ) break; } - } else if (ssid->max_oper_chwidth == CHANWIDTH_160MHZ) { + } else if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_160MHZ) { if (freq->freq == 5180) { - chwidth = CHANWIDTH_160MHZ; + chwidth = CONF_OPER_CHWIDTH_160MHZ; vht_caps |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; seg0 = 50; } else if (freq->freq == 5520) { - chwidth = CHANWIDTH_160MHZ; + chwidth = CONF_OPER_CHWIDTH_160MHZ; vht_caps |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; seg0 = 114; } - } else if (ssid->max_oper_chwidth == CHANWIDTH_USE_HT) { - chwidth = CHANWIDTH_USE_HT; + } else if (ssid->max_oper_chwidth == CONF_OPER_CHWIDTH_USE_HT) { + chwidth = CONF_OPER_CHWIDTH_USE_HT; seg0 = channel + 2; #ifdef CONFIG_HT_OVERRIDES if (ssid->disable_ht40)