2016-10-25 19:23:24 +02:00
|
|
|
/*
|
|
|
|
* hostapd / IEEE 802.11ax HE
|
|
|
|
* Copyright (c) 2016-2017, Qualcomm Atheros, Inc.
|
2019-05-20 09:55:05 +02:00
|
|
|
* Copyright (c) 2019 John Crispin <john@phrozen.org>
|
2016-10-25 19:23:24 +02:00
|
|
|
*
|
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "utils/includes.h"
|
|
|
|
|
|
|
|
#include "utils/common.h"
|
|
|
|
#include "common/ieee802_11_defs.h"
|
2019-06-19 14:49:13 +02:00
|
|
|
#include "common/ieee802_11_common.h"
|
2016-10-25 19:23:24 +02:00
|
|
|
#include "hostapd.h"
|
|
|
|
#include "ap_config.h"
|
|
|
|
#include "beacon.h"
|
2019-05-20 09:55:05 +02:00
|
|
|
#include "sta_info.h"
|
2016-10-25 19:23:24 +02:00
|
|
|
#include "ieee802_11.h"
|
|
|
|
#include "dfs.h"
|
|
|
|
|
2019-05-20 09:55:10 +02:00
|
|
|
static u8 ieee80211_he_ppet_size(u8 ppe_thres_hdr, const u8 *phy_cap_info)
|
|
|
|
{
|
|
|
|
u8 sz = 0, ru;
|
|
|
|
|
|
|
|
if ((phy_cap_info[HE_PHYCAP_PPE_THRESHOLD_PRESENT_IDX] &
|
2019-06-13 01:10:07 +02:00
|
|
|
HE_PHYCAP_PPE_THRESHOLD_PRESENT) == 0)
|
2019-05-20 09:55:10 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
ru = (ppe_thres_hdr >> HE_PPE_THRES_RU_INDEX_BITMASK_SHIFT) &
|
|
|
|
HE_PPE_THRES_RU_INDEX_BITMASK_MASK;
|
2022-02-04 18:43:30 +01:00
|
|
|
/* Count the number of 1 bits in RU Index Bitmask */
|
2019-05-20 09:55:10 +02:00
|
|
|
while (ru) {
|
|
|
|
if (ru & 0x1)
|
|
|
|
sz++;
|
|
|
|
ru >>= 1;
|
|
|
|
}
|
|
|
|
|
2022-02-04 18:43:30 +01:00
|
|
|
/* fixed header of 3 (NSTS) + 4 (RU Index Bitmask) = 7 bits */
|
|
|
|
/* 6 * (NSTS + 1) bits for bit 1 in RU Index Bitmask */
|
2019-05-20 09:55:10 +02:00
|
|
|
sz *= 1 + (ppe_thres_hdr & HE_PPE_THRES_NSS_MASK);
|
|
|
|
sz = (sz * 6) + 7;
|
2022-02-04 18:43:30 +01:00
|
|
|
/* PPE Pad to count the number of needed full octets */
|
|
|
|
sz = (sz + 7) / 8;
|
2019-05-20 09:55:10 +02:00
|
|
|
|
|
|
|
return sz;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-13 15:10:46 +02:00
|
|
|
static u8 ieee80211_he_mcs_set_size(const u8 *phy_cap_info)
|
|
|
|
{
|
|
|
|
u8 sz = 4;
|
|
|
|
|
|
|
|
if (phy_cap_info[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] &
|
|
|
|
HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G)
|
|
|
|
sz += 4;
|
|
|
|
if (phy_cap_info[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] &
|
|
|
|
HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G)
|
|
|
|
sz += 4;
|
|
|
|
|
|
|
|
return sz;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ieee80211_invalid_he_cap_size(const u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
struct ieee80211_he_capabilities *cap;
|
|
|
|
size_t cap_len;
|
2022-03-03 00:24:02 +01:00
|
|
|
u8 ppe_thres_hdr;
|
2019-08-13 15:10:46 +02:00
|
|
|
|
|
|
|
cap = (struct ieee80211_he_capabilities *) buf;
|
|
|
|
cap_len = sizeof(*cap) - sizeof(cap->optional);
|
|
|
|
if (len < cap_len)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
cap_len += ieee80211_he_mcs_set_size(cap->he_phy_capab_info);
|
|
|
|
if (len < cap_len)
|
|
|
|
return 1;
|
|
|
|
|
2022-03-03 00:24:02 +01:00
|
|
|
ppe_thres_hdr = len > cap_len ? buf[cap_len] : 0xff;
|
|
|
|
cap_len += ieee80211_he_ppet_size(ppe_thres_hdr,
|
|
|
|
cap->he_phy_capab_info);
|
2019-08-13 15:10:46 +02:00
|
|
|
|
2022-03-03 00:24:02 +01:00
|
|
|
return len < cap_len;
|
2019-08-13 15:10:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-14 16:49:20 +02:00
|
|
|
u8 * hostapd_eid_he_capab(struct hostapd_data *hapd, u8 *eid,
|
|
|
|
enum ieee80211_op_mode opmode)
|
2016-10-25 19:23:24 +02:00
|
|
|
{
|
|
|
|
struct ieee80211_he_capabilities *cap;
|
2019-04-16 14:34:00 +02:00
|
|
|
struct hostapd_hw_modes *mode = hapd->iface->current_mode;
|
2019-05-20 09:55:10 +02:00
|
|
|
u8 he_oper_chwidth = ~HE_PHYCAP_CHANNEL_WIDTH_MASK;
|
2016-10-25 19:23:24 +02:00
|
|
|
u8 *pos = eid;
|
2019-07-01 15:27:09 +02:00
|
|
|
u8 ie_size = 0, mcs_nss_size = 4, ppet_size = 0;
|
2016-10-25 19:23:24 +02:00
|
|
|
|
2019-04-16 14:34:00 +02:00
|
|
|
if (!mode)
|
2016-10-25 19:23:24 +02:00
|
|
|
return eid;
|
|
|
|
|
2019-08-13 15:10:46 +02:00
|
|
|
ie_size = sizeof(*cap) - sizeof(cap->optional);
|
2019-06-14 16:49:20 +02:00
|
|
|
ppet_size = ieee80211_he_ppet_size(mode->he_capab[opmode].ppet[0],
|
|
|
|
mode->he_capab[opmode].phy_cap);
|
2019-05-20 09:55:10 +02:00
|
|
|
|
|
|
|
switch (hapd->iface->conf->he_oper_chwidth) {
|
2022-05-13 18:17:40 +02:00
|
|
|
case CONF_OPER_CHWIDTH_80P80MHZ:
|
2019-05-20 09:55:10 +02:00
|
|
|
he_oper_chwidth |=
|
|
|
|
HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G;
|
|
|
|
mcs_nss_size += 4;
|
|
|
|
/* fall through */
|
2022-05-13 18:17:40 +02:00
|
|
|
case CONF_OPER_CHWIDTH_160MHZ:
|
2019-05-20 09:55:10 +02:00
|
|
|
he_oper_chwidth |= HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
|
|
|
|
mcs_nss_size += 4;
|
|
|
|
/* fall through */
|
2022-05-13 18:17:40 +02:00
|
|
|
case CONF_OPER_CHWIDTH_80MHZ:
|
|
|
|
case CONF_OPER_CHWIDTH_USE_HT:
|
2019-05-20 09:55:10 +02:00
|
|
|
he_oper_chwidth |= HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_IN_2G |
|
|
|
|
HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G;
|
|
|
|
break;
|
2022-05-13 18:17:40 +02:00
|
|
|
default:
|
|
|
|
break;
|
2019-05-20 09:55:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ie_size += mcs_nss_size + ppet_size;
|
|
|
|
|
2017-09-30 01:32:44 +02:00
|
|
|
*pos++ = WLAN_EID_EXTENSION;
|
2019-05-20 09:55:10 +02:00
|
|
|
*pos++ = 1 + ie_size;
|
2017-09-30 01:32:44 +02:00
|
|
|
*pos++ = WLAN_EID_EXT_HE_CAPABILITIES;
|
|
|
|
|
2016-10-25 19:23:24 +02:00
|
|
|
cap = (struct ieee80211_he_capabilities *) pos;
|
|
|
|
os_memset(cap, 0, sizeof(*cap));
|
|
|
|
|
2019-06-14 16:49:20 +02:00
|
|
|
os_memcpy(cap->he_mac_capab_info, mode->he_capab[opmode].mac_cap,
|
2019-04-16 14:34:00 +02:00
|
|
|
HE_MAX_MAC_CAPAB_SIZE);
|
2019-06-14 16:49:20 +02:00
|
|
|
os_memcpy(cap->he_phy_capab_info, mode->he_capab[opmode].phy_cap,
|
2019-04-16 14:34:00 +02:00
|
|
|
HE_MAX_PHY_CAPAB_SIZE);
|
2019-06-14 16:49:20 +02:00
|
|
|
os_memcpy(cap->optional, mode->he_capab[opmode].mcs, mcs_nss_size);
|
2019-05-20 09:55:10 +02:00
|
|
|
if (ppet_size)
|
2019-06-14 16:49:20 +02:00
|
|
|
os_memcpy(&cap->optional[mcs_nss_size],
|
|
|
|
mode->he_capab[opmode].ppet, ppet_size);
|
2019-04-16 14:34:00 +02:00
|
|
|
|
2016-10-25 19:23:24 +02:00
|
|
|
if (hapd->iface->conf->he_phy_capab.he_su_beamformer)
|
|
|
|
cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMER_CAPAB_IDX] |=
|
|
|
|
HE_PHYCAP_SU_BEAMFORMER_CAPAB;
|
2019-05-20 09:55:11 +02:00
|
|
|
else
|
|
|
|
cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMER_CAPAB_IDX] &=
|
|
|
|
~HE_PHYCAP_SU_BEAMFORMER_CAPAB;
|
2016-10-25 19:23:24 +02:00
|
|
|
|
|
|
|
if (hapd->iface->conf->he_phy_capab.he_su_beamformee)
|
|
|
|
cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMEE_CAPAB_IDX] |=
|
|
|
|
HE_PHYCAP_SU_BEAMFORMEE_CAPAB;
|
2019-05-20 09:55:11 +02:00
|
|
|
else
|
|
|
|
cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMEE_CAPAB_IDX] &=
|
|
|
|
~HE_PHYCAP_SU_BEAMFORMEE_CAPAB;
|
2016-10-25 19:23:24 +02:00
|
|
|
|
|
|
|
if (hapd->iface->conf->he_phy_capab.he_mu_beamformer)
|
|
|
|
cap->he_phy_capab_info[HE_PHYCAP_MU_BEAMFORMER_CAPAB_IDX] |=
|
|
|
|
HE_PHYCAP_MU_BEAMFORMER_CAPAB;
|
2019-05-20 09:55:11 +02:00
|
|
|
else
|
|
|
|
cap->he_phy_capab_info[HE_PHYCAP_MU_BEAMFORMER_CAPAB_IDX] &=
|
|
|
|
~HE_PHYCAP_MU_BEAMFORMER_CAPAB;
|
2016-10-25 19:23:24 +02:00
|
|
|
|
2019-05-20 09:55:10 +02:00
|
|
|
cap->he_phy_capab_info[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] &=
|
|
|
|
he_oper_chwidth;
|
|
|
|
|
|
|
|
pos += ie_size;
|
2016-10-25 19:23:24 +02:00
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-30 01:32:44 +02:00
|
|
|
u8 * hostapd_eid_he_operation(struct hostapd_data *hapd, u8 *eid)
|
2016-10-25 19:23:24 +02:00
|
|
|
{
|
|
|
|
struct ieee80211_he_operation *oper;
|
|
|
|
u8 *pos = eid;
|
2019-04-25 16:57:48 +02:00
|
|
|
int oper_size = 6;
|
2019-04-25 22:57:47 +02:00
|
|
|
u32 params = 0;
|
2016-10-25 19:23:24 +02:00
|
|
|
|
|
|
|
if (!hapd->iface->current_mode)
|
|
|
|
return eid;
|
|
|
|
|
2019-06-19 14:49:13 +02:00
|
|
|
if (is_6ghz_op_class(hapd->iconf->op_class))
|
|
|
|
oper_size += 5;
|
|
|
|
|
2017-09-30 01:32:44 +02:00
|
|
|
*pos++ = WLAN_EID_EXTENSION;
|
2019-04-25 16:57:48 +02:00
|
|
|
*pos++ = 1 + oper_size;
|
2017-09-30 01:32:44 +02:00
|
|
|
*pos++ = WLAN_EID_EXT_HE_OPERATION;
|
|
|
|
|
2016-10-25 19:23:24 +02:00
|
|
|
oper = (struct ieee80211_he_operation *) pos;
|
|
|
|
os_memset(oper, 0, sizeof(*oper));
|
|
|
|
|
|
|
|
if (hapd->iface->conf->he_op.he_default_pe_duration)
|
2019-04-25 22:57:47 +02:00
|
|
|
params |= (hapd->iface->conf->he_op.he_default_pe_duration <<
|
|
|
|
HE_OPERATION_DFLT_PE_DURATION_OFFSET);
|
2016-10-25 19:23:24 +02:00
|
|
|
|
|
|
|
if (hapd->iface->conf->he_op.he_twt_required)
|
2019-04-25 22:57:47 +02:00
|
|
|
params |= HE_OPERATION_TWT_REQUIRED;
|
2016-10-25 19:23:24 +02:00
|
|
|
|
|
|
|
if (hapd->iface->conf->he_op.he_rts_threshold)
|
2019-04-25 22:57:47 +02:00
|
|
|
params |= (hapd->iface->conf->he_op.he_rts_threshold <<
|
|
|
|
HE_OPERATION_RTS_THRESHOLD_OFFSET);
|
2016-10-25 19:23:24 +02:00
|
|
|
|
2021-07-21 07:46:26 +02:00
|
|
|
if (hapd->iface->conf->he_op.he_er_su_disable)
|
|
|
|
params |= HE_OPERATION_ER_SU_DISABLE;
|
|
|
|
|
2022-03-21 12:10:32 +01:00
|
|
|
if (hapd->iface->conf->he_op.he_bss_color_disabled ||
|
|
|
|
hapd->cca_in_progress)
|
2020-02-04 09:04:54 +01:00
|
|
|
params |= HE_OPERATION_BSS_COLOR_DISABLED;
|
|
|
|
if (hapd->iface->conf->he_op.he_bss_color_partial)
|
|
|
|
params |= HE_OPERATION_BSS_COLOR_PARTIAL;
|
|
|
|
params |= hapd->iface->conf->he_op.he_bss_color <<
|
|
|
|
HE_OPERATION_BSS_COLOR_OFFSET;
|
2019-04-16 14:33:59 +02:00
|
|
|
|
2019-05-20 09:55:04 +02:00
|
|
|
/* HE minimum required basic MCS and NSS for STAs */
|
|
|
|
oper->he_mcs_nss_set =
|
|
|
|
host_to_le16(hapd->iface->conf->he_op.he_basic_mcs_nss_set);
|
|
|
|
|
2017-09-30 01:32:44 +02:00
|
|
|
/* TODO: conditional MaxBSSID Indicator subfield */
|
|
|
|
|
2019-06-19 14:49:13 +02:00
|
|
|
pos += 6; /* skip the fixed part */
|
|
|
|
|
|
|
|
if (is_6ghz_op_class(hapd->iconf->op_class)) {
|
2023-03-14 05:59:17 +01:00
|
|
|
enum oper_chan_width oper_chwidth =
|
|
|
|
hostapd_get_oper_chwidth(hapd->iconf);
|
2022-05-13 18:17:41 +02:00
|
|
|
u8 seg0 = hapd->iconf->he_oper_centr_freq_seg0_idx;
|
2019-12-24 13:02:29 +01:00
|
|
|
u8 seg1 = hostapd_get_oper_centr_freq_seg1_idx(hapd->iconf);
|
2022-04-08 01:56:52 +02:00
|
|
|
u8 control;
|
2019-06-19 14:49:13 +02:00
|
|
|
|
2023-03-14 05:59:17 +01:00
|
|
|
#ifdef CONFIG_IEEE80211BE
|
|
|
|
if (hapd->iconf->punct_bitmap) {
|
|
|
|
punct_update_legacy_bw(hapd->iconf->punct_bitmap,
|
|
|
|
hapd->iconf->channel,
|
|
|
|
&oper_chwidth, &seg0, &seg1);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_IEEE80211BE */
|
|
|
|
|
2019-06-19 14:49:13 +02:00
|
|
|
if (!seg0)
|
|
|
|
seg0 = hapd->iconf->channel;
|
2019-04-25 22:57:47 +02:00
|
|
|
|
2019-06-19 14:49:13 +02:00
|
|
|
params |= HE_OPERATION_6GHZ_OPER_INFO;
|
2019-12-24 13:02:29 +01:00
|
|
|
|
2021-04-05 07:45:26 +02:00
|
|
|
/* 6 GHz Operation Information field
|
2022-04-08 18:36:22 +02:00
|
|
|
* IEEE Std 802.11ax-2021, 9.4.2.249 HE Operation element,
|
2021-04-05 07:45:26 +02:00
|
|
|
* Figure 9-788k
|
|
|
|
*/
|
2019-06-19 14:49:13 +02:00
|
|
|
*pos++ = hapd->iconf->channel; /* Primary Channel */
|
2019-12-24 13:02:29 +01:00
|
|
|
|
2022-04-08 01:56:52 +02:00
|
|
|
/* Control:
|
|
|
|
* bits 0-1: Channel Width
|
|
|
|
* bit 2: Duplicate Beacon
|
|
|
|
* bits 3-5: Regulatory Info
|
|
|
|
*/
|
|
|
|
/* Channel Width */
|
2019-12-24 13:02:29 +01:00
|
|
|
if (seg1)
|
2022-04-08 01:56:52 +02:00
|
|
|
control = 3;
|
|
|
|
else
|
|
|
|
control = center_idx_to_bw_6ghz(seg0);
|
2023-12-22 10:04:17 +01:00
|
|
|
|
|
|
|
control |= hapd->iconf->he_6ghz_reg_pwr_type <<
|
|
|
|
HE_6GHZ_OPER_INFO_CTRL_REG_INFO_SHIFT;
|
|
|
|
|
2022-04-08 01:56:52 +02:00
|
|
|
*pos++ = control;
|
2019-12-24 13:02:29 +01:00
|
|
|
|
|
|
|
/* Channel Center Freq Seg0/Seg1 */
|
2023-11-15 09:48:05 +01:00
|
|
|
if (oper_chwidth == CONF_OPER_CHWIDTH_160MHZ ||
|
|
|
|
oper_chwidth == CONF_OPER_CHWIDTH_320MHZ) {
|
2021-04-05 07:45:26 +02:00
|
|
|
/*
|
|
|
|
* Seg 0 indicates the channel center frequency index of
|
|
|
|
* the 160 MHz channel.
|
|
|
|
*/
|
|
|
|
seg1 = seg0;
|
|
|
|
if (hapd->iconf->channel < seg0)
|
|
|
|
seg0 -= 8;
|
|
|
|
else
|
|
|
|
seg0 += 8;
|
|
|
|
}
|
|
|
|
|
2019-06-19 14:49:13 +02:00
|
|
|
*pos++ = seg0;
|
2019-12-24 13:02:29 +01:00
|
|
|
*pos++ = seg1;
|
2019-06-19 14:49:13 +02:00
|
|
|
/* Minimum Rate */
|
|
|
|
*pos++ = 6; /* TODO: what should be set here? */
|
|
|
|
}
|
|
|
|
|
|
|
|
oper->he_oper_params = host_to_le32(params);
|
2016-10-25 19:23:24 +02:00
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
2019-01-07 10:26:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
u8 * hostapd_eid_he_mu_edca_parameter_set(struct hostapd_data *hapd, u8 *eid)
|
|
|
|
{
|
|
|
|
struct ieee80211_he_mu_edca_parameter_set *edca;
|
|
|
|
u8 *pos;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
pos = (u8 *) &hapd->iface->conf->he_mu_edca;
|
|
|
|
for (i = 0; i < sizeof(*edca); i++) {
|
|
|
|
if (pos[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == sizeof(*edca))
|
|
|
|
return eid; /* no MU EDCA Parameters configured */
|
|
|
|
|
|
|
|
pos = eid;
|
|
|
|
*pos++ = WLAN_EID_EXTENSION;
|
|
|
|
*pos++ = 1 + sizeof(*edca);
|
|
|
|
*pos++ = WLAN_EID_EXT_HE_MU_EDCA_PARAMS;
|
|
|
|
|
|
|
|
edca = (struct ieee80211_he_mu_edca_parameter_set *) pos;
|
|
|
|
os_memcpy(edca, &hapd->iface->conf->he_mu_edca, sizeof(*edca));
|
|
|
|
|
|
|
|
wpa_hexdump(MSG_DEBUG, "HE: MU EDCA Parameter Set element",
|
|
|
|
pos, sizeof(*edca));
|
|
|
|
|
|
|
|
pos += sizeof(*edca);
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
2019-04-16 14:34:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
u8 * hostapd_eid_spatial_reuse(struct hostapd_data *hapd, u8 *eid)
|
|
|
|
{
|
|
|
|
struct ieee80211_spatial_reuse *spr;
|
|
|
|
u8 *pos = eid, *spr_param;
|
|
|
|
u8 sz = 1;
|
|
|
|
|
2019-05-03 15:13:46 +02:00
|
|
|
if (!hapd->iface->conf->spr.sr_control)
|
|
|
|
return eid;
|
|
|
|
|
2019-04-16 14:34:01 +02:00
|
|
|
if (hapd->iface->conf->spr.sr_control &
|
|
|
|
SPATIAL_REUSE_NON_SRG_OFFSET_PRESENT)
|
|
|
|
sz++;
|
|
|
|
|
|
|
|
if (hapd->iface->conf->spr.sr_control &
|
|
|
|
SPATIAL_REUSE_SRG_INFORMATION_PRESENT)
|
|
|
|
sz += 18;
|
|
|
|
|
|
|
|
*pos++ = WLAN_EID_EXTENSION;
|
|
|
|
*pos++ = 1 + sz;
|
|
|
|
*pos++ = WLAN_EID_EXT_SPATIAL_REUSE;
|
|
|
|
|
|
|
|
spr = (struct ieee80211_spatial_reuse *) pos;
|
|
|
|
os_memset(spr, 0, sizeof(*spr));
|
|
|
|
|
|
|
|
spr->sr_ctrl = hapd->iface->conf->spr.sr_control;
|
|
|
|
pos++;
|
|
|
|
spr_param = spr->params;
|
|
|
|
if (spr->sr_ctrl & SPATIAL_REUSE_NON_SRG_OFFSET_PRESENT) {
|
|
|
|
*spr_param++ =
|
|
|
|
hapd->iface->conf->spr.non_srg_obss_pd_max_offset;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
if (spr->sr_ctrl & SPATIAL_REUSE_SRG_INFORMATION_PRESENT) {
|
|
|
|
*spr_param++ = hapd->iface->conf->spr.srg_obss_pd_min_offset;
|
|
|
|
*spr_param++ = hapd->iface->conf->spr.srg_obss_pd_max_offset;
|
2020-10-03 11:31:16 +02:00
|
|
|
os_memcpy(spr_param,
|
|
|
|
hapd->iface->conf->spr.srg_bss_color_bitmap, 8);
|
|
|
|
spr_param += 8;
|
|
|
|
os_memcpy(spr_param,
|
|
|
|
hapd->iface->conf->spr.srg_partial_bssid_bitmap, 8);
|
2019-04-16 14:34:01 +02:00
|
|
|
pos += 18;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
2019-05-20 09:55:05 +02:00
|
|
|
|
|
|
|
|
2020-04-25 00:45:37 +02:00
|
|
|
u8 * hostapd_eid_he_6ghz_band_cap(struct hostapd_data *hapd, u8 *eid)
|
|
|
|
{
|
2020-10-03 08:34:16 +02:00
|
|
|
struct hostapd_config *conf = hapd->iface->conf;
|
2020-04-25 00:45:37 +02:00
|
|
|
struct hostapd_hw_modes *mode = hapd->iface->current_mode;
|
2020-06-02 08:14:25 +02:00
|
|
|
struct he_capabilities *he_cap;
|
2020-04-25 00:45:37 +02:00
|
|
|
struct ieee80211_he_6ghz_band_cap *cap;
|
2020-06-02 08:14:25 +02:00
|
|
|
u16 capab;
|
2020-04-25 00:45:37 +02:00
|
|
|
u8 *pos;
|
|
|
|
|
2020-06-02 08:14:25 +02:00
|
|
|
if (!mode || !is_6ghz_op_class(hapd->iconf->op_class) ||
|
|
|
|
!is_6ghz_freq(hapd->iface->freq))
|
2020-04-25 00:45:37 +02:00
|
|
|
return eid;
|
|
|
|
|
2020-06-02 08:14:25 +02:00
|
|
|
he_cap = &mode->he_capab[IEEE80211_MODE_AP];
|
2020-10-03 08:34:16 +02:00
|
|
|
capab = he_cap->he_6ghz_capa & HE_6GHZ_BAND_CAP_MIN_MPDU_START;
|
|
|
|
capab |= (conf->he_6ghz_max_ampdu_len_exp <<
|
|
|
|
HE_6GHZ_BAND_CAP_MAX_AMPDU_LEN_EXP_SHIFT) &
|
|
|
|
HE_6GHZ_BAND_CAP_MAX_AMPDU_LEN_EXP_MASK;
|
|
|
|
capab |= (conf->he_6ghz_max_mpdu <<
|
|
|
|
HE_6GHZ_BAND_CAP_MAX_MPDU_LEN_SHIFT) &
|
|
|
|
HE_6GHZ_BAND_CAP_MAX_MPDU_LEN_MASK;
|
2020-06-02 08:14:25 +02:00
|
|
|
capab |= HE_6GHZ_BAND_CAP_SMPS_DISABLED;
|
2020-10-03 08:34:16 +02:00
|
|
|
if (conf->he_6ghz_rx_ant_pat)
|
|
|
|
capab |= HE_6GHZ_BAND_CAP_RX_ANTPAT_CONS;
|
|
|
|
if (conf->he_6ghz_tx_ant_pat)
|
|
|
|
capab |= HE_6GHZ_BAND_CAP_TX_ANTPAT_CONS;
|
2020-04-25 00:45:37 +02:00
|
|
|
|
|
|
|
pos = eid;
|
|
|
|
*pos++ = WLAN_EID_EXTENSION;
|
|
|
|
*pos++ = 1 + sizeof(*cap);
|
|
|
|
*pos++ = WLAN_EID_EXT_HE_6GHZ_BAND_CAP;
|
|
|
|
|
|
|
|
cap = (struct ieee80211_he_6ghz_band_cap *) pos;
|
2020-06-02 08:14:25 +02:00
|
|
|
cap->capab = host_to_le16(capab);
|
2020-04-25 00:45:37 +02:00
|
|
|
pos += sizeof(*cap);
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-20 09:55:05 +02:00
|
|
|
void hostapd_get_he_capab(struct hostapd_data *hapd,
|
|
|
|
const struct ieee80211_he_capabilities *he_cap,
|
|
|
|
struct ieee80211_he_capabilities *neg_he_cap,
|
|
|
|
size_t he_capab_len)
|
|
|
|
{
|
|
|
|
if (!he_cap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (he_capab_len > sizeof(*neg_he_cap))
|
|
|
|
he_capab_len = sizeof(*neg_he_cap);
|
|
|
|
/* TODO: mask out unsupported features */
|
|
|
|
|
|
|
|
os_memcpy(neg_he_cap, he_cap, he_capab_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-14 16:49:20 +02:00
|
|
|
static int check_valid_he_mcs(struct hostapd_data *hapd, const u8 *sta_he_capab,
|
|
|
|
enum ieee80211_op_mode opmode)
|
2019-05-20 09:55:05 +02:00
|
|
|
{
|
|
|
|
u16 sta_rx_mcs_set, ap_tx_mcs_set;
|
|
|
|
u8 mcs_count = 0;
|
|
|
|
const u16 *ap_mcs_set, *sta_mcs_set;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!hapd->iface->current_mode)
|
|
|
|
return 1;
|
2019-06-14 16:49:20 +02:00
|
|
|
ap_mcs_set = (u16 *) hapd->iface->current_mode->he_capab[opmode].mcs;
|
2019-05-20 09:55:05 +02:00
|
|
|
sta_mcs_set = (u16 *) ((const struct ieee80211_he_capabilities *)
|
|
|
|
sta_he_capab)->optional;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable HE capabilities for STAs for which there is not even a single
|
|
|
|
* allowed MCS in any supported number of streams, i.e., STA is
|
|
|
|
* advertising 3 (not supported) as HE MCS rates for all supported
|
|
|
|
* band/stream cases.
|
|
|
|
*/
|
|
|
|
switch (hapd->iface->conf->he_oper_chwidth) {
|
2022-05-13 18:17:40 +02:00
|
|
|
case CONF_OPER_CHWIDTH_80P80MHZ:
|
2019-05-20 09:55:05 +02:00
|
|
|
mcs_count = 3;
|
|
|
|
break;
|
2022-05-13 18:17:40 +02:00
|
|
|
case CONF_OPER_CHWIDTH_160MHZ:
|
2019-05-20 09:55:05 +02:00
|
|
|
mcs_count = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mcs_count = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < mcs_count; i++) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
/* AP Tx MCS map vs. STA Rx MCS map */
|
|
|
|
sta_rx_mcs_set = WPA_GET_LE16((const u8 *) &sta_mcs_set[i * 2]);
|
|
|
|
ap_tx_mcs_set = WPA_GET_LE16((const u8 *)
|
|
|
|
&ap_mcs_set[(i * 2) + 1]);
|
|
|
|
|
|
|
|
for (j = 0; j < HE_NSS_MAX_STREAMS; j++) {
|
|
|
|
if (((ap_tx_mcs_set >> (j * 2)) & 0x3) == 3)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((sta_rx_mcs_set >> (j * 2)) & 0x3) == 3)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"No matching HE MCS found between AP TX and STA RX");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u16 copy_sta_he_capab(struct hostapd_data *hapd, struct sta_info *sta,
|
2019-06-14 16:49:20 +02:00
|
|
|
enum ieee80211_op_mode opmode, const u8 *he_capab,
|
|
|
|
size_t he_capab_len)
|
2019-05-20 09:55:05 +02:00
|
|
|
{
|
2021-04-01 19:25:39 +02:00
|
|
|
if (!he_capab || !(sta->flags & WLAN_STA_WMM) ||
|
|
|
|
!hapd->iconf->ieee80211ax || hapd->conf->disable_11ax ||
|
2019-06-14 16:49:20 +02:00
|
|
|
!check_valid_he_mcs(hapd, he_capab, opmode) ||
|
2019-08-13 15:10:46 +02:00
|
|
|
ieee80211_invalid_he_cap_size(he_capab, he_capab_len) ||
|
2019-05-20 09:55:05 +02:00
|
|
|
he_capab_len > sizeof(struct ieee80211_he_capabilities)) {
|
|
|
|
sta->flags &= ~WLAN_STA_HE;
|
|
|
|
os_free(sta->he_capab);
|
|
|
|
sta->he_capab = NULL;
|
|
|
|
return WLAN_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sta->he_capab) {
|
|
|
|
sta->he_capab =
|
|
|
|
os_zalloc(sizeof(struct ieee80211_he_capabilities));
|
|
|
|
if (!sta->he_capab)
|
|
|
|
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta->flags |= WLAN_STA_HE;
|
|
|
|
os_memset(sta->he_capab, 0, sizeof(struct ieee80211_he_capabilities));
|
|
|
|
os_memcpy(sta->he_capab, he_capab, he_capab_len);
|
|
|
|
sta->he_capab_len = he_capab_len;
|
|
|
|
|
|
|
|
return WLAN_STATUS_SUCCESS;
|
|
|
|
}
|
2020-02-04 09:05:40 +01:00
|
|
|
|
|
|
|
|
2020-04-25 00:45:41 +02:00
|
|
|
u16 copy_sta_he_6ghz_capab(struct hostapd_data *hapd, struct sta_info *sta,
|
|
|
|
const u8 *he_6ghz_capab)
|
|
|
|
{
|
|
|
|
if (!he_6ghz_capab || !hapd->iconf->ieee80211ax ||
|
2020-06-30 16:23:46 +02:00
|
|
|
hapd->conf->disable_11ax ||
|
2020-04-25 00:45:41 +02:00
|
|
|
!is_6ghz_op_class(hapd->iconf->op_class)) {
|
|
|
|
sta->flags &= ~WLAN_STA_6GHZ;
|
|
|
|
os_free(sta->he_6ghz_capab);
|
|
|
|
sta->he_6ghz_capab = NULL;
|
|
|
|
return WLAN_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sta->he_6ghz_capab) {
|
|
|
|
sta->he_6ghz_capab =
|
|
|
|
os_zalloc(sizeof(struct ieee80211_he_6ghz_band_cap));
|
|
|
|
if (!sta->he_6ghz_capab)
|
|
|
|
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta->flags |= WLAN_STA_6GHZ;
|
|
|
|
os_memcpy(sta->he_6ghz_capab, he_6ghz_capab,
|
|
|
|
sizeof(struct ieee80211_he_6ghz_band_cap));
|
|
|
|
|
|
|
|
return WLAN_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-04 09:05:40 +01:00
|
|
|
int hostapd_get_he_twt_responder(struct hostapd_data *hapd,
|
|
|
|
enum ieee80211_op_mode mode)
|
|
|
|
{
|
|
|
|
u8 *mac_cap;
|
|
|
|
|
|
|
|
if (!hapd->iface->current_mode ||
|
2022-07-06 15:57:59 +02:00
|
|
|
!hapd->iface->current_mode->he_capab[mode].he_supported ||
|
|
|
|
!hapd->iconf->ieee80211ax || hapd->conf->disable_11ax)
|
2020-02-04 09:05:40 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
mac_cap = hapd->iface->current_mode->he_capab[mode].mac_cap;
|
|
|
|
|
2021-05-28 06:17:38 +02:00
|
|
|
return !!(mac_cap[HE_MAC_CAPAB_0] & HE_MACCAP_TWT_RESPONDER) &&
|
|
|
|
hapd->iface->conf->he_op.he_twt_responder;
|
2020-02-04 09:05:40 +01:00
|
|
|
}
|
2022-03-21 12:10:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
u8 * hostapd_eid_cca(struct hostapd_data *hapd, u8 *eid)
|
|
|
|
{
|
|
|
|
if (!hapd->cca_in_progress)
|
|
|
|
return eid;
|
|
|
|
|
|
|
|
/* BSS Color Change Announcement element */
|
|
|
|
*eid++ = WLAN_EID_EXTENSION;
|
|
|
|
*eid++ = 3;
|
|
|
|
*eid++ = WLAN_EID_EXT_COLOR_CHANGE_ANNOUNCEMENT;
|
|
|
|
*eid++ = hapd->cca_count; /* Color Switch Countdown */
|
|
|
|
*eid++ = hapd->cca_color; /* New BSS Color Information */
|
|
|
|
|
|
|
|
return eid;
|
|
|
|
}
|