From c47c9c66e37ecff2519ce17f22db1b542ec4436c Mon Sep 17 00:00:00 2001 From: Pradeep Kumar Chitrapu Date: Wed, 9 Mar 2022 09:47:40 -0800 Subject: [PATCH] hostapd: workaround to match EHT client Current AP code is using IEEE P802.11be/D1.4 whereas client devices are designed as per IEEE P802.11be/D1.3. Roll-back the AP code to match client temporarily. Signed-off-by: Pradeep Kumar Chitrapu Signed-off-by: Aloka Dixit --- src/ap/ieee802_11_eht.c | 33 +++++++++++++++++---------------- src/common/ieee802_11_defs.h | 17 ++++++++++++----- 2 files changed, 29 insertions(+), 21 deletions(-) --- a/src/ap/ieee802_11_eht.c +++ b/src/ap/ieee802_11_eht.c @@ -170,7 +170,7 @@ u8 * hostapd_eid_eht_operation(struct ho { struct hostapd_hw_modes *mode; struct ieee80211_eht_operation *oper; - u8 *pos = eid, *length_pos, chwidth, seg0 = 0; + u8 *pos = eid, oper_size = 0, chwidth; mode = hapd->iface->current_mode; if (!mode) @@ -179,45 +179,49 @@ u8 * hostapd_eid_eht_operation(struct ho if (!mode->eht_capab[opmode].eht_supported) return eid; + oper_size = sizeof(struct ieee80211_eht_operation); *pos++ = WLAN_EID_EXTENSION; - length_pos = pos++; + *pos++ = 1 + oper_size; *pos++ = WLAN_EID_EXT_EHT_OPERATION; oper = (struct ieee80211_eht_operation *) pos; os_memset(oper, 0, sizeof(*oper)); + oper->ccfs = hostapd_get_oper_centr_freq_seg0_idx(hapd->iconf); + if (!oper->ccfs) + oper->ccfs = hapd->iconf->channel; + if (is_6ghz_op_class(hapd->iconf->op_class)) chwidth = op_class_to_ch_width(hapd->iconf->op_class); else chwidth = hapd->iconf->eht_oper_chwidth; - seg0 = hostapd_get_oper_centr_freq_seg0_idx(hapd->iconf); - switch (chwidth) { case CHANWIDTH_320MHZ: - *pos++ = EHT_OPERATION_CHANNEL_WIDTH_320MHZ; + oper->width = EHT_OPERATION_CHANNEL_WIDTH_320MHZ; break; case CHANWIDTH_160MHZ: - *pos++ = EHT_OPERATION_CHANNEL_WIDTH_160MHZ; + oper->width = EHT_OPERATION_CHANNEL_WIDTH_160MHZ; break; case CHANWIDTH_80MHZ: - *pos++ = EHT_OPERATION_CHANNEL_WIDTH_80MHZ; + oper->width = EHT_OPERATION_CHANNEL_WIDTH_80MHZ; break; case CHANWIDTH_USE_HT: - if (seg0) - *pos++ = EHT_OPERATION_CHANNEL_WIDTH_40MHZ; + if ((is_6ghz_op_class(hapd->iconf->op_class) && + op_class_to_bandwidth(hapd->iconf->op_class) == 40) || + hapd->iconf->secondary_channel) + oper->width = EHT_OPERATION_CHANNEL_WIDTH_40MHZ; else - pos++; + oper->width = EHT_OPERATION_CHANNEL_WIDTH_20MHZ; + break; default: - return eid; + oper->width = EHT_OPERATION_CHANNEL_WIDTH_20MHZ; + break; } - if (!seg0) - seg0 = hapd->iconf->channel; - *pos++ = seg0; + pos += oper_size; - *length_pos = pos - (eid + 2); return pos; } @@ -295,6 +299,7 @@ static int ieee80211_invalid_eht_cap_siz const u8 *he_phy_cap; size_t cap_len; + return 0; he_phy_cap = ((struct ieee80211_he_capabilities *)he_cap)->he_phy_capab_info; cap = (struct ieee80211_eht_capabilities *) eht_cap; cap_len = sizeof(*cap); --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -2458,6 +2458,7 @@ struct ieee80211_eht_capabilities { u8 optional[71]; } STRUCT_PACKED; +#define EHT_OPERATION_CCFS_SHIFT 4 /* * struct ieee80211_eht_operation - eht operation element * @@ -2469,13 +2470,17 @@ struct ieee80211_eht_capabilities { * structure (Figure 9-1002a) at all ... */ struct ieee80211_eht_operation { - u8 chan_width; + u8 width:3, + reserved:5; u8 ccfs; - u8 present_bm; - /* contains disabled subchannel bitmap */ - u8 optional[]; + u8 disable_sub_chan_bitmap_present:1, + reserved2:7; + le16 disabled_subchannel_bitmap; + + /* Add puncture pattern here when supported */ } STRUCT_PACKED; +#define EHT_OPERATION_CHANNEL_WIDTH_20MHZ 0 #define EHT_OPERATION_CHANNEL_WIDTH_40MHZ 1 #define EHT_OPERATION_CHANNEL_WIDTH_80MHZ 2 #define EHT_OPERATION_CHANNEL_WIDTH_160MHZ 3