diff mbox series

[01/22] hostapd: MLO: fix for_each_mld_link macro

Message ID 20240328181652.2956122-2-quic_adisi@quicinc.com
State Accepted
Headers show
Series [01/22] hostapd: MLO: fix for_each_mld_link macro | expand

Commit Message

Aditya Kumar Singh March 28, 2024, 6:16 p.m. UTC
Currently for_each_mld_link macro uses 3 nested for loops. Since now the
affliated links are linked together via linked list, the logic can
be improvised by using dl_list_for_each macro instead which uses one for
loop.

Modify for_each_mld_link macro to use dl_list_for_each instead.

Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
---
 src/ap/beacon.c   | 10 +---------
 src/ap/hostapd.h  | 17 +++--------------
 src/ap/sta_info.c |  4 +---
 3 files changed, 5 insertions(+), 26 deletions(-)
diff mbox series

Patch

diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 32865f667ea4..195c7bbd9972 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -945,7 +945,6 @@  static void hostapd_fill_probe_resp_ml_params(struct hostapd_data *hapd,
 {
 	struct probe_resp_params sta_info_params;
 	struct hostapd_data *link;
-	unsigned int probed_mld_id, i, j;
 
 	params->mld_ap = NULL;
 	params->mld_info = os_zalloc(sizeof(*params->mld_info));
@@ -956,14 +955,7 @@  static void hostapd_fill_probe_resp_ml_params(struct hostapd_data *hapd,
 		   "MLD: Got ML probe request with AP MLD ID %d for links %04x",
 		   mld_id, links);
 
-	/*
-	 * We want to include the AP MLD ID in the response if it was
-	 * included in the request.
-	 */
-	probed_mld_id = mld_id != -1 ? mld_id : hostapd_get_mld_id(hapd);
-
-	for_each_mld_link(link, i, j, hapd->iface->interfaces,
-			  probed_mld_id) {
+	for_each_mld_link(link, hapd) {
 		struct mld_link_info *link_info;
 		size_t buflen;
 		u8 mld_link_id = link->mld_link_id;
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index affe4f604fe5..d12efb104f81 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -817,19 +817,8 @@  struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd);
 
 bool hostapd_mld_is_first_bss(struct hostapd_data *hapd);
 
-#define for_each_mld_link(_link, _bss_idx, _iface_idx, _ifaces, _mld_id) \
-	for (_iface_idx = 0;						\
-	     _iface_idx < (_ifaces)->count;				\
-	     _iface_idx++)						\
-		for (_bss_idx = 0;					\
-		     _bss_idx <						\
-			(_ifaces)->iface[_iface_idx]->num_bss;		\
-		     _bss_idx++)					\
-			for (_link =					\
-			     (_ifaces)->iface[_iface_idx]->bss[_bss_idx]; \
-			    _link && _link->conf->mld_ap &&		\
-				hostapd_get_mld_id(_link) == _mld_id;	\
-			    _link = NULL)
+#define for_each_mld_link(partner, self) \
+	dl_list_for_each(partner, &self->mld->links, struct hostapd_data, link)
 
 #else /* CONFIG_IEEE80211BE */
 
@@ -838,7 +827,7 @@  static inline bool hostapd_mld_is_first_bss(struct hostapd_data *hapd)
 	return true;
 }
 
-#define for_each_mld_link(_link, _bss_idx, _iface_idx, _ifaces, _mld_id) \
+#define for_each_mld_link(partner, self) \
 	if (false)
 
 #endif /* CONFIG_IEEE80211BE */
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index 122880a3d87b..2423ff1896e4 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -1761,10 +1761,8 @@  static void ap_sta_remove_link_sta(struct hostapd_data *hapd,
 				   struct sta_info *sta)
 {
 	struct hostapd_data *tmp_hapd;
-	unsigned int i, j;
 
-	for_each_mld_link(tmp_hapd, i, j, hapd->iface->interfaces,
-			  hostapd_get_mld_id(hapd)) {
+	for_each_mld_link(tmp_hapd, hapd) {
 		struct sta_info *tmp_sta;
 
 		if (hapd == tmp_hapd)