[PATCH v2 01/15] common: Combine definitions for Multi-Link and per STA profile control

Andrei Otcheretianski andrei.otcheretianski at intel.com
Wed Nov 30 05:09:25 PST 2022


The control fields are 16 bit wide. Combine the per byte definitions to
make it more convenient.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 src/common/ieee802_11_defs.h       | 32 ++++++++++++++----------------
 src/drivers/driver_nl80211_event.c | 16 ++++++++++-----
 2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index 310b7660e2..427b284b85 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -2539,28 +2539,26 @@ struct ieee80211_eht_capabilities {
 /* IEEE P802.11be/D2.2, 9.4.2.312.2 - Basic Multi-Link element */
 
 /* Figure 9-1002g: Presence Bitmap subfield of the Basic Multi-Link element */
-#define BASIC_MULTI_LINK_CTRL0_PRES_LINK_ID		0x10
-#define BASIC_MULTI_LINK_CTRL0_PRES_BSS_PARAM_CH_COUNT	0x20
-#define BASIC_MULTI_LINK_CTRL0_PRES_MSD_INFO		0x40
-#define BASIC_MULTI_LINK_CTRL0_PRES_EML_CAPA		0x80
-
-#define BASIC_MULTI_LINK_CTRL1_PRES_MLD_CAPA		0x01
-#define BASIC_MULTI_LINK_CTRL1_PRES_AP_MLD_ID		0x02
+#define BASIC_MULTI_LINK_CTRL_PRES_LINK_ID		0x0010
+#define BASIC_MULTI_LINK_CTRL_PRES_BSS_PARAM_CH_COUNT	0x0020
+#define BASIC_MULTI_LINK_CTRL_PRES_MSD_INFO		0x0040
+#define BASIC_MULTI_LINK_CTRL_PRES_EML_CAPA		0x0080
+#define BASIC_MULTI_LINK_CTRL_PRES_MLD_CAPA		0x0100
+#define BASIC_MULTI_LINK_CTRL_PRES_AP_MLD_ID		0x0200
 
 /*
  * STA Control field definitions of Per-STA Profile subelement in Basic
  * Multi-Link element as described in Figure 9-1002n: STA Control field format.
  */
-#define BASIC_MLE_STA_CTRL0_LINK_ID_SHIFT		0
-#define BASIC_MLE_STA_CTRL0_LINK_ID_MASK		0x0F
-#define BASIC_MLE_STA_CTRL0_COMPLETE_PROFILE		0x10
-#define BASIC_MLE_STA_CTRL0_PRES_STA_MAC		0x20
-#define BASIC_MLE_STA_CTRL0_PRES_BEACON_INT		0x40
-#define BASIC_MLE_STA_CTRL0_PRES_TSF_OFFSET		0x80
-#define BASIC_MLE_STA_CTRL1_PRES_DTIM_INFO		0x01
-#define BASIC_MLE_STA_CTRL1_PRES_NSTR_LINK_PAIR		0x02
-#define BASIC_MLE_STA_CTRL1_NSTR_BITMAP			0x04
-#define BASIC_MLE_STA_CTRL1_PRES_BSS_PARAM_COUNT	0x08
+#define BASIC_MLE_STA_CTRL_LINK_ID_MASK			0x000F
+#define BASIC_MLE_STA_CTRL_COMPLETE_PROFILE		0x0010
+#define BASIC_MLE_STA_CTRL_PRES_STA_MAC			0x0020
+#define BASIC_MLE_STA_CTRL_PRES_BEACON_INT		0x0040
+#define BASIC_MLE_STA_CTRL_PRES_TSF_OFFSET		0x0080
+#define BASIC_MLE_STA_CTRL_PRES_DTIM_INFO		0x0100
+#define BASIC_MLE_STA_CTRL_PRES_NSTR_LINK_PAIR		0x0200
+#define BASIC_MLE_STA_CTRL_NSTR_BITMAP			0x0400
+#define BASIC_MLE_STA_CTRL_PRES_BSS_PARAM_COUNT		0x0800
 
 #define BASIC_MLE_STA_PROF_STA_MAC_IDX			3
 
diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
index c10c31a376..c7ea565870 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -536,18 +536,18 @@ static void nl80211_get_basic_mle_links_info(const u8 *mle, size_t mle_len,
 		if (pos[0] == MULTI_LINK_SUB_ELEM_ID_PER_STA_PROFILE) {
 			u8 link_id;
 			const u8 *sta_profile;
+			u16 sta_ctrl;
 
 			if (pos[1] < BASIC_MLE_STA_PROF_STA_MAC_IDX + ETH_ALEN)
 				goto next_subelem;
 
 			sta_profile = &pos[2];
-			link_id = sta_profile[0] &
-				BASIC_MLE_STA_CTRL0_LINK_ID_MASK;
+			sta_ctrl = WPA_GET_LE16(sta_profile);
+			link_id = sta_ctrl & BASIC_MLE_STA_CTRL_LINK_ID_MASK;
 			if (link_id >= MAX_NUM_MLD_LINKS)
 				goto next_subelem;
 
-			if (!(sta_profile[0] &
-			      BASIC_MLE_STA_CTRL0_PRES_STA_MAC))
+			if (!(sta_ctrl & BASIC_MLE_STA_CTRL_PRES_STA_MAC))
 				goto next_subelem;
 
 			info->non_assoc_links |= BIT(link_id);
@@ -640,7 +640,13 @@ static int nl80211_update_rejected_links_info(struct driver_sta_mlo_info *mlo,
 
 static int nl80211_get_assoc_link_id(const u8 *data, u8 len)
 {
-	if (!(data[0] & BASIC_MULTI_LINK_CTRL0_PRES_LINK_ID))
+	u16 control;
+
+	if (len < 2)
+		return -1;
+
+	control = WPA_GET_LE16(data);
+	if (!(control & BASIC_MULTI_LINK_CTRL_PRES_LINK_ID))
 		return -1;
 
 #define BASIC_ML_IE_COMMON_INFO_LINK_ID_IDX \
-- 
2.25.1




More information about the Hostap mailing list