[PATCH 01/15] common: Move some HE and EHT helpers into the common code

Andrei Otcheretianski andrei.otcheretianski at intel.com
Thu Oct 8 09:05:10 PDT 2026


From: Benjamin Berg <benjamin.berg at intel.com>

These will be used by NAN in the supplicant and are therefore useful
outside of those files.

Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
 src/ap/ieee802_11_eht.c        |  70 --------------------
 src/ap/ieee802_11_he.c         |  42 ------------
 src/common/ieee802_11_common.c | 113 +++++++++++++++++++++++++++++++++
 src/common/ieee802_11_common.h |   7 ++
 4 files changed, 120 insertions(+), 112 deletions(-)

diff --git a/src/ap/ieee802_11_eht.c b/src/ap/ieee802_11_eht.c
index 3463d8db76..3b1eea4574 100644
--- a/src/ap/ieee802_11_eht.c
+++ b/src/ap/ieee802_11_eht.c
@@ -19,76 +19,6 @@
 #include "ieee802_11.h"
 
 
-static u16 ieee80211_eht_ppet_size(u16 ppe_thres_hdr, const u8 *phy_cap_info)
-{
-	u8 ru;
-	u16 sz = 0;
-
-	if ((phy_cap_info[EHT_PHYCAP_PPE_THRESHOLD_PRESENT_IDX] &
-	     EHT_PHYCAP_PPE_THRESHOLD_PRESENT) == 0)
-		return 0;
-
-	ru = (ppe_thres_hdr &
-	      EHT_PPE_THRES_RU_INDEX_MASK) >> EHT_PPE_THRES_RU_INDEX_SHIFT;
-	while (ru) {
-		if (ru & 0x1)
-			sz++;
-		ru >>= 1;
-	}
-
-	sz = sz * (1 + ((ppe_thres_hdr & EHT_PPE_THRES_NSS_MASK) >>
-			EHT_PPE_THRES_NSS_SHIFT));
-	sz = (sz * 6) + 9;
-	if (sz % 8)
-		sz += 8;
-	sz /= 8;
-
-	return sz;
-}
-
-
-static u8 ieee80211_eht_mcs_set_size(enum hostapd_hw_mode mode, u8 opclass,
-				     const u8 *he_phy_cap,
-				     const u8 *eht_phy_cap)
-{
-	u8 sz = EHT_PHYCAP_MCS_NSS_LEN_20MHZ_PLUS;
-	bool band24, band5, band6;
-	u8 cap_chwidth;
-
-	cap_chwidth = he_phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX];
-
-	band24 = mode == HOSTAPD_MODE_IEEE80211B ||
-		mode == HOSTAPD_MODE_IEEE80211G ||
-		mode == NUM_HOSTAPD_MODES;
-	band5 = mode == HOSTAPD_MODE_IEEE80211A ||
-		mode == NUM_HOSTAPD_MODES;
-	band6 = is_6ghz_op_class(opclass);
-
-	if (band24 &&
-	    (cap_chwidth & HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_IN_2G) == 0)
-		return EHT_PHYCAP_MCS_NSS_LEN_20MHZ_ONLY;
-
-	if (band5 &&
-	    (cap_chwidth &
-	     (HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G |
-	      HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G |
-	      HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G)) == 0)
-		return EHT_PHYCAP_MCS_NSS_LEN_20MHZ_ONLY;
-
-	if (band5 &&
-	    (cap_chwidth &
-	     (HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G |
-	      HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G)))
-	    sz += EHT_PHYCAP_MCS_NSS_LEN_20MHZ_PLUS;
-
-	if (band6 &&
-	    (eht_phy_cap[EHT_PHYCAP_320MHZ_IN_6GHZ_SUPPORT_IDX] &
-	     EHT_PHYCAP_320MHZ_IN_6GHZ_SUPPORT_MASK))
-		sz += EHT_PHYCAP_MCS_NSS_LEN_20MHZ_PLUS;
-
-	return sz;
-}
-
 
 size_t hostapd_eid_eht_capab_len(struct hostapd_data *hapd,
 				 enum ieee80211_op_mode opmode)
diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c
index f09f513997..1bc5c7ecf7 100644
--- a/src/ap/ieee802_11_he.c
+++ b/src/ap/ieee802_11_he.c
@@ -21,48 +21,6 @@
 #include "ieee802_11.h"
 #include "dfs.h"
 
-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] &
-	     HE_PHYCAP_PPE_THRESHOLD_PRESENT) == 0)
-		return 0;
-
-	ru = (ppe_thres_hdr >> HE_PPE_THRES_RU_INDEX_BITMASK_SHIFT) &
-		HE_PPE_THRES_RU_INDEX_BITMASK_MASK;
-	/* Count the number of 1 bits in RU Index Bitmask */
-	while (ru) {
-		if (ru & 0x1)
-			sz++;
-		ru >>= 1;
-	}
-
-	/* fixed header of 3 (NSTS) + 4 (RU Index Bitmask) = 7 bits */
-	/* 6 * (NSTS + 1) bits for bit 1 in RU Index Bitmask */
-	sz *= 1 + (ppe_thres_hdr & HE_PPE_THRES_NSS_MASK);
-	sz = (sz * 6) + 7;
-	/* PPE Pad to count the number of needed full octets */
-	sz = (sz + 7) / 8;
-
-	return sz;
-}
-
-
-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)
 {
diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index 0a1e9a67ba..a92c04c0d1 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -4391,3 +4391,116 @@ int ieee80211_get_center_freq(int ctrl_freq, u32 bw)
 		return -1;
 	}
 }
+
+
+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] &
+	     HE_PHYCAP_PPE_THRESHOLD_PRESENT) == 0)
+		return 0;
+
+	ru = (ppe_thres_hdr >> HE_PPE_THRES_RU_INDEX_BITMASK_SHIFT) &
+		HE_PPE_THRES_RU_INDEX_BITMASK_MASK;
+	/* Count the number of 1 bits in RU Index Bitmask */
+	while (ru) {
+		if (ru & 0x1)
+			sz++;
+		ru >>= 1;
+	}
+
+	/* fixed header of 3 (NSTS) + 4 (RU Index Bitmask) = 7 bits */
+	/* 6 * (NSTS + 1) bits for bit 1 in RU Index Bitmask */
+	sz *= 1 + (ppe_thres_hdr & HE_PPE_THRES_NSS_MASK);
+	sz = (sz * 6) + 7;
+	/* PPE Pad to count the number of needed full octets */
+	sz = (sz + 7) / 8;
+
+	return sz;
+}
+
+
+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;
+}
+
+
+u16 ieee80211_eht_ppet_size(u16 ppe_thres_hdr, const u8 *phy_cap_info)
+{
+	u8 ru;
+	u16 sz = 0;
+
+	if ((phy_cap_info[EHT_PHYCAP_PPE_THRESHOLD_PRESENT_IDX] &
+	     EHT_PHYCAP_PPE_THRESHOLD_PRESENT) == 0)
+		return 0;
+
+	ru = (ppe_thres_hdr &
+	      EHT_PPE_THRES_RU_INDEX_MASK) >> EHT_PPE_THRES_RU_INDEX_SHIFT;
+	while (ru) {
+		if (ru & 0x1)
+			sz++;
+		ru >>= 1;
+	}
+
+	sz = sz * (1 + ((ppe_thres_hdr & EHT_PPE_THRES_NSS_MASK) >>
+			EHT_PPE_THRES_NSS_SHIFT));
+	sz = (sz * 6) + 9;
+	if (sz % 8)
+		sz += 8;
+	sz /= 8;
+
+	return sz;
+}
+
+
+u8 ieee80211_eht_mcs_set_size(enum hostapd_hw_mode mode, u8 opclass,
+			      const u8 *he_phy_cap, const u8 *eht_phy_cap)
+{
+	u8 sz = EHT_PHYCAP_MCS_NSS_LEN_20MHZ_PLUS;
+	bool band24, band5, band6;
+	u8 cap_chwidth;
+
+	cap_chwidth = he_phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX];
+
+	band24 = mode == HOSTAPD_MODE_IEEE80211B ||
+		mode == HOSTAPD_MODE_IEEE80211G ||
+		mode == NUM_HOSTAPD_MODES;
+	band5 = mode == HOSTAPD_MODE_IEEE80211A ||
+		mode == NUM_HOSTAPD_MODES;
+	band6 = is_6ghz_op_class(opclass);
+
+	if (band24 &&
+	    (cap_chwidth & HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_IN_2G) == 0)
+		return EHT_PHYCAP_MCS_NSS_LEN_20MHZ_ONLY;
+
+	if (band5 &&
+	    (cap_chwidth &
+	     (HE_PHYCAP_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G |
+	      HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G |
+	      HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G)) == 0)
+		return EHT_PHYCAP_MCS_NSS_LEN_20MHZ_ONLY;
+
+	if (band5 &&
+	    (cap_chwidth &
+	     (HE_PHYCAP_CHANNEL_WIDTH_SET_160MHZ_IN_5G |
+	      HE_PHYCAP_CHANNEL_WIDTH_SET_80PLUS80MHZ_IN_5G)))
+	    sz += EHT_PHYCAP_MCS_NSS_LEN_20MHZ_PLUS;
+
+	if (band6 &&
+	    (eht_phy_cap[EHT_PHYCAP_320MHZ_IN_6GHZ_SUPPORT_IDX] &
+	     EHT_PHYCAP_320MHZ_IN_6GHZ_SUPPORT_MASK))
+		sz += EHT_PHYCAP_MCS_NSS_LEN_20MHZ_PLUS;
+
+	return sz;
+}
diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h
index 8dc38e2151..29eb8ddc93 100644
--- a/src/common/ieee802_11_common.h
+++ b/src/common/ieee802_11_common.h
@@ -477,4 +477,11 @@ enum chan_width get_sta_operation_chan_width(
 	enum chan_width ap_operation_chan_width,
 	struct supported_chan_width sta_supported_width);
 
+u8 ieee80211_he_ppet_size(u8 ppe_thres_hdr, const u8 *phy_cap_info);
+u8 ieee80211_he_mcs_set_size(const u8 *phy_cap_info);
+
+u16 ieee80211_eht_ppet_size(u16 ppe_thres_hdr, const u8 *phy_cap_info);
+u8 ieee80211_eht_mcs_set_size(enum hostapd_hw_mode mode, u8 opclass,
+			      const u8 *he_phy_cap, const u8 *eht_phy_cap);
+
 #endif /* IEEE802_11_COMMON_H */
-- 
2.53.0




More information about the Hostap mailing list