wlan-ap-Telecominfraproject/feeds/qca/hostapd/patches/r04-003-hostapd-add-bandwidth-indication-IE-support.patch
John Crispin 008ca9618d
Some checks failed
Build OpenWrt/uCentral images / build (cig_wf186h) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf186w) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf188n) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf189) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf196) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cybertan_eww631-a1) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cybertan_eww631-b1) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap101) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap102) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap104) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap105) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap111) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap112) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101-6e) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101e) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101e-6e) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x_2) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x_3) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x_w) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4xe) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4xi) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4xi_w) (push) Has been cancelled
Build OpenWrt/uCentral images / build (indio_um-305ax) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sercomm_ap72tip) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sonicfi_rap630c-311g) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sonicfi_rap630w-211g) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sonicfi_rap630w-311g) (push) Has been cancelled
Build OpenWrt/uCentral images / build (udaya_a6-id2) (push) Has been cancelled
Build OpenWrt/uCentral images / build (udaya_a6-od2) (push) Has been cancelled
Build OpenWrt/uCentral images / build (wallys_dr5018) (push) Has been cancelled
Build OpenWrt/uCentral images / build (wallys_dr6018) (push) Has been cancelled
Build OpenWrt/uCentral images / build (wallys_dr6018-v4) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_ax820) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_ax840) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_fap640) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_fap650) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_fap655) (push) Has been cancelled
Build OpenWrt/uCentral images / trigger-testing (push) Has been cancelled
Build OpenWrt/uCentral images / create-x64_vm-ami (push) Has been cancelled
ipq95xx: import ath12.4-cs kernel and drivers
Signed-off-by: John Crispin <john@phrozen.org>
2024-10-20 09:25:13 +02:00

289 lines
9.6 KiB
Diff

From b4e5b5e0db999e76f656db35307be0fa4f3a53fc Mon Sep 17 00:00:00 2001
From: Yuvarani V <quic_yuvarani@quicinc.com>
Date: Thu, 23 Nov 2023 11:50:33 +0530
Subject: [PATCH] hostapd: add bandwidth indication IE support
Bandwidth Indication subelement is present for an EHT STA when channel
switching or extended channel switching to an EHT BSS operating channel
width wider than 160 MHz or to an EHT BSS operating channel width including
at least one punctured 20 MHz subchannel.
In Beacon frame, Bandwidth Indication subelement is added within channel
switch wrapper.
Signed-off-by: Karthik M <quic_karm@quicinc.com>
Signed-off-by: Yuvarani V <quic_yuvarani@quicinc.com>
---
src/ap/beacon.c | 4 +-
src/ap/ieee802_11.c | 150 ++++++++++++++++++++++++++++++-----
src/ap/ieee802_11.h | 6 +-
src/common/ieee802_11_defs.h | 36 +++++++++
4 files changed, 174 insertions(+), 22 deletions(-)
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -1118,7 +1118,7 @@ static u8 * hostapd_gen_probe_resp(struc
if ((hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) ||
(hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) ||
(hapd->iconf->ieee80211be && !hapd->conf->disable_11be))
- pos = hostapd_eid_wb_chsw_wrapper(hapd, pos);
+ pos = hostapd_eid_chsw_wrapper(hapd, pos);
pos = hostapd_eid_rnr(hapd, pos, WLAN_FC_STYPE_PROBE_RESP, true);
pos = hostapd_eid_fils_indic(hapd, pos, 0);
@@ -2338,7 +2338,7 @@ int ieee802_11_build_ap_params(struct ho
if ((hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) ||
(hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) ||
(hapd->iconf->ieee80211be && !hapd->conf->disable_11be))
- tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos);
+ tailpos = hostapd_eid_chsw_wrapper(hapd, tailpos);
tailpos = hostapd_eid_rnr(hapd, tailpos, WLAN_FC_STYPE_BEACON, true);
tailpos = hostapd_eid_fils_indic(hapd, tailpos, 0);
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -7176,16 +7176,12 @@ u8 * hostapd_eid_txpower_envelope(struct
}
-u8 * hostapd_eid_wb_chsw_wrapper(struct hostapd_data *hapd, u8 *eid)
+u8 *hostapd_eid_wide_bw_chan_switch(struct hostapd_data *hapd,
+ u8 *eid, u8 ccfs0, u8 ccfs1)
{
- u8 bw, chan1, chan2 = 0;
- int freq1;
- if (!hapd->cs_freq_params.channel ||
- (!hapd->cs_freq_params.vht_enabled &&
- !hapd->cs_freq_params.he_enabled &&
- !hapd->cs_freq_params.eht_enabled))
- return eid;
+ struct ieee80211_wb_chsw_element *wb_chsw_elem;
+ u8 bw;
/* bandwidth: 0: 40, 1: 80, 2: 160, 3: 80+80, 4: 320 */
switch (hapd->cs_freq_params.bandwidth) {
@@ -7210,27 +7206,143 @@ u8 * hostapd_eid_wb_chsw_wrapper(struct
return eid;
}
- freq1 = hapd->cs_freq_params.center_freq1 ?
+ *eid++ = WLAN_EID_WIDE_BW_CHSWITCH;
+ /* Length of Wide Bandwidth Channel Switch element */
+ *eid++ = sizeof(struct ieee80211_wb_chsw_element);
+ wb_chsw_elem = (struct ieee80211_wb_chsw_element *) eid;
+ eid += sizeof(struct ieee80211_wb_chsw_element);
+
+ /* New Channel Width */
+ wb_chsw_elem->new_channel_width = bw;
+ /* New Channel Center Frequency Segment 0 */
+ wb_chsw_elem->new_ccfs0 = ccfs0;
+ /* New Channel Center Frequency Segment 1 */
+ wb_chsw_elem->new_ccfs1 = ccfs1;
+
+ return eid;
+}
+
+u8 *hostapd_eid_bw_indication(struct hostapd_data *hapd, u8 *eid, u8 ccfs0, u8 ccfs1)
+{
+ u8 *pos = eid, *length_pos;
+ struct ieee80211_bw_ind_element *bw_ind_elem;
+ int bw_ind_status = false;
+ size_t fixed_eid_len;
+
+ if (hapd->cs_freq_params.bandwidth > 160 ||
+ hapd->cs_freq_params.ru_punct_bitmap)
+ bw_ind_status = true;
+
+ if (!bw_ind_status)
+ return eid;
+
+ if (!hapd->cs_freq_params.channel || !hapd->cs_freq_params.eht_enabled)
+ return eid;
+
+ *pos++ = WLAN_EID_EXTENSION;
+ length_pos = pos++;
+ *pos++ = WLAN_EID_EXT_BW_IND;
+
+ fixed_eid_len = (sizeof(struct ieee80211_bw_ind_element) -
+ DISABLED_SUBCHANNEL_BITMAP_BYTES_SIZE);
+
+ bw_ind_elem = (struct ieee80211_bw_ind_element *) pos;
+ os_memset(bw_ind_elem, 0, sizeof(struct ieee80211_bw_ind_element));
+
+ if (hapd->cs_freq_params.ru_punct_bitmap) {
+ bw_ind_elem->bw_ind_params |=
+ BW_IND_PARAMETER_DISABLED_SUBCHAN_BITMAP_PRESENT;
+ bw_ind_elem->bw_ind_info.disabled_chan_bitmap =
+ host_to_le16(hapd->cs_freq_params.ru_punct_bitmap);
+ pos += DISABLED_SUBCHANNEL_BITMAP_BYTES_SIZE;
+ } else {
+ bw_ind_elem->bw_ind_params &=
+ ~BW_IND_PARAMETER_DISABLED_SUBCHAN_BITMAP_PRESENT;
+ }
+
+ switch (hapd->cs_freq_params.bandwidth) {
+ case 320:
+ bw_ind_elem->bw_ind_info.control |=
+ BW_IND_CHANNEL_WIDTH_320MHZ;
+ ccfs1 = ccfs0;
+ if (hapd->cs_freq_params.channel < ccfs0)
+ ccfs0 -= 16;
+ else
+ ccfs0 += 16;
+ break;
+ case 160:
+ bw_ind_elem->bw_ind_info.control |=
+ BW_IND_CHANNEL_WIDTH_160MHZ;
+ ccfs1 = ccfs0;
+ if (hapd->cs_freq_params.channel < ccfs0)
+ ccfs0 -= 8;
+ else
+ ccfs0 += 8;
+ break;
+ case 80:
+ bw_ind_elem->bw_ind_info.control |=
+ BW_IND_CHANNEL_WIDTH_80MHZ;
+ break;
+ case 40:
+ if (hapd->cs_freq_params.sec_channel_offset == 1)
+ bw_ind_elem->bw_ind_info.control |=
+ BW_IND_CHANNEL_WIDTH_40MHZ;
+ else
+ bw_ind_elem->bw_ind_info.control |=
+ BW_IND_CHANNEL_WIDTH_20MHZ;
+ break;
+ default:
+ bw_ind_elem->bw_ind_info.control |=
+ BW_IND_CHANNEL_WIDTH_20MHZ;
+ break;
+ }
+
+ bw_ind_elem->bw_ind_info.ccfs0 = ccfs0;
+ bw_ind_elem->bw_ind_info.ccfs1 = ccfs1;
+
+ pos += fixed_eid_len;
+ *length_pos = pos - (eid + 2);
+
+ return pos;
+}
+
+u8 *hostapd_eid_chsw_wrapper(struct hostapd_data *hapd, u8 *eid)
+{
+ u8 *pos = eid, *length_pos;
+ u8 ccfs0, ccfs1;
+ int freq;
+
+ if (!hapd->cs_freq_params.channel ||
+ (!hapd->cs_freq_params.vht_enabled &&
+ !hapd->cs_freq_params.he_enabled &&
+ !hapd->cs_freq_params.eht_enabled))
+ return eid;
+
+ freq = hapd->cs_freq_params.center_freq1 ?
hapd->cs_freq_params.center_freq1 :
hapd->cs_freq_params.freq;
- if (ieee80211_freq_to_chan(freq1, &chan1) !=
+ if (ieee80211_freq_to_chan(freq, &ccfs0) !=
HOSTAPD_MODE_IEEE80211A)
return eid;
if (hapd->cs_freq_params.center_freq2 &&
ieee80211_freq_to_chan(hapd->cs_freq_params.center_freq2,
- &chan2) != HOSTAPD_MODE_IEEE80211A)
+ &ccfs1) != HOSTAPD_MODE_IEEE80211A)
return eid;
- *eid++ = WLAN_EID_CHANNEL_SWITCH_WRAPPER;
- *eid++ = 5; /* Length of Channel Switch Wrapper */
- *eid++ = WLAN_EID_WIDE_BW_CHSWITCH;
- *eid++ = 3; /* Length of Wide Bandwidth Channel Switch element */
- *eid++ = bw; /* New Channel Width */
- *eid++ = chan1; /* New Channel Center Frequency Segment 0 */
- *eid++ = chan2; /* New Channel Center Frequency Segment 1 */
+ *pos++ = WLAN_EID_CHANNEL_SWITCH_WRAPPER;
+ /* Length of Channel Switch Wrapper */
+ length_pos = pos++;
+
+ pos = hostapd_eid_wide_bw_chan_switch(hapd, pos, ccfs0, ccfs1);
+
+#ifdef CONFIG_IEEE80211BE
+ if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be)
+ pos = hostapd_eid_bw_indication(hapd, pos, ccfs0, ccfs1);
+#endif /*CONFIG_IEEE80211BE */
- return eid;
+ *length_pos = pos - (eid + 2);
+ return pos;
}
int hostapd_config_read_maclist(const char *fname,
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -70,7 +70,11 @@ u8 * hostapd_eid_ht_operation(struct hos
u8 * hostapd_eid_vht_capabilities(struct hostapd_data *hapd, u8 *eid, u32 nsts);
u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid);
u8 * hostapd_eid_vendor_vht(struct hostapd_data *hapd, u8 *eid);
-u8 * hostapd_eid_wb_chsw_wrapper(struct hostapd_data *hapd, u8 *eid);
+u8 *hostapd_eid_chsw_wrapper(struct hostapd_data *hapd, u8 *eid);
+u8 *hostapd_eid_wide_bw_chan_switch(struct hostapd_data *hapd, u8 *eid,
+ u8 ccfs0, u8 ccfs1);
+u8 *hostapd_eid_bw_indication(struct hostapd_data *hapd, u8 *eid,
+ u8 ccfs0, u8 ccfs1);
u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid);
u8 * hostapd_eid_he_capab(struct hostapd_data *hapd, u8 *eid,
enum ieee80211_op_mode opmode);
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -503,6 +503,7 @@
#define WLAN_EID_EXT_TID_TO_LINK_MAPPING 109
#define WLAN_EID_EXT_MULTI_LINK_TRAFFIC_INDICATION 110
#define WLAN_EID_EXT_AKM_SUITE_SELECTOR 114
+#define WLAN_EID_EXT_BW_IND 135
/* Extended Capabilities field */
#define WLAN_EXT_CAPAB_20_40_COEX 0
@@ -2923,6 +2924,42 @@ enum dscp_policy_request_type {
#define WFA_CAPA_QM_DSCP_POLICY BIT(0)
#define WFA_CAPA_QM_UNSOLIC_DSCP BIT(1)
+/* IEEE P802.11be/D3.0,9.4.2.160 - Wide Bandwidth Channel Switch element */
+struct ieee80211_wb_chsw_element {
+ u8 new_channel_width;
+ u8 new_ccfs0;
+ u8 new_ccfs1;
+};
+
+/* IEEE P802.11be/D3.0, 9.4.2.319 - Bandwidth Indication element */
+
+/* Figure 9-1002ba: Bandwidth Indication Parameters field subfields */
+#define BW_IND_PARAMETER_RESERVED BIT(0)
+#define BW_IND_PARAMETER_DISABLED_SUBCHAN_BITMAP_PRESENT BIT(1)
+
+/* Table 9-467: Control subfield: Channel Width subfield; */
+#define BW_IND_CHANNEL_WIDTH_20MHZ 0
+#define BW_IND_CHANNEL_WIDTH_40MHZ 1
+#define BW_IND_CHANNEL_WIDTH_80MHZ 2
+#define BW_IND_CHANNEL_WIDTH_160MHZ 3
+#define BW_IND_CHANNEL_WIDTH_320MHZ 4
+
+/* Figure 9-1002c: Bandwidth Indication information
+ * field format similar to EHT Operation Information field format
+ */
+struct ieee80211_bw_ind_info {
+ u8 control; /* B0..B2: Channel Width */
+ u8 ccfs0;
+ u8 ccfs1;
+ le16 disabled_chan_bitmap; /* 0 or 2 octets */
+} STRUCT_PACKED;
+
+/* Figure 9-1002ba—Bandwidth Indication element format */
+struct ieee80211_bw_ind_element {
+ u8 bw_ind_params; /* Bandwidth Indication Parameters */
+ struct ieee80211_bw_ind_info bw_ind_info; /* 3 or 5 octets */
+} STRUCT_PACKED;
+
struct ieee80211_neighbor_ap_info {
u8 tbtt_info_hdr;
u8 tbtt_info_len;