wlan-ap-Telecominfraproject/feeds/qca/hostapd/patches/r00-002-001-hostapd-MLO-add-separate-MLD-level-structure.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

337 lines
8.3 KiB
Diff

From ebf68e793f8e7eb812d81b04a3a8f05141e81062 Mon Sep 17 00:00:00 2001
From: Aditya Kumar Singh <quic_adisi@quicinc.com>
Date: Sat, 25 Nov 2023 14:41:05 +0530
Subject: [PATCH 1/2] hostapd: MLO: add separate MLD level structure
Currently, MLD level info like, MLD address, next link ID, etc are stored
in each BSS. However, only first link BSS assign values to these members
and rest other stores reference to the first BSS. However, if first BSS
is disabled, then the first BSS reference in all BSS should be updated
which is an overhead. Also, this does not seem to scale.
Instead, a separate MLD level structure can be maintained which can store
all these ML related information. All affiliated link BSS can keep reference
to this MLD structure.
This change adds that MLD level structure. However, assigning values to it
and using that instead of BSS level members would be done in subsequent
changes.
Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
---
hostapd/main.c | 25 ++++++++
src/ap/hostapd.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++
src/ap/hostapd.h | 32 ++++++++++
3 files changed, 211 insertions(+)
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -724,6 +724,28 @@ static int gen_uuid(const char *txt_addr
#define HOSTAPD_CLEANUP_INTERVAL 10
#endif /* HOSTAPD_CLEANUP_INTERVAL */
+#ifdef CONFIG_IEEE80211BE
+static void hostapd_global_cleanup_mld(struct hapd_interfaces *interfaces)
+{
+ int i;
+
+ if (!interfaces || !interfaces->mld)
+ return;
+
+ for (i = 0; i < interfaces->mld_count; i++) {
+ if (!interfaces->mld[i])
+ continue;
+
+ os_free(interfaces->mld[i]);
+ interfaces->mld[i] = NULL;
+ }
+
+ os_free(interfaces->mld);
+ interfaces->mld = NULL;
+ interfaces->mld_count = 0;
+}
+#endif /* CONFIG_IEEE80211BE */
+
static int hostapd_periodic_call(struct hostapd_iface *iface, void *ctx)
{
hostapd_periodic_iface(iface);
@@ -1027,6 +1049,10 @@ int main(int argc, char *argv[])
interfaces.iface = NULL;
interfaces.count = 0;
+#ifdef CONFIG_IEEE80211BE
+ hostapd_global_cleanup_mld(&interfaces);
+#endif /* CONFIG_IEEE80211BE */
+
#ifdef CONFIG_DPP
dpp_global_deinit(interfaces.dpp);
#endif /* CONFIG_DPP */
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -2869,6 +2869,69 @@ struct hostapd_iface * hostapd_alloc_ifa
return hapd_iface;
}
+#ifdef CONFIG_IEEE80211BE
+static void hostapd_bss_setup_multi_link(struct hostapd_data *hapd,
+ struct hapd_interfaces *interfaces)
+{
+ struct hostapd_mld *mld, **all_mld;
+ struct hostapd_bss_config *conf;
+ size_t i;
+
+ if (!hapd || !interfaces)
+ return;
+
+ conf = hapd->conf;
+
+ if (!hapd->iconf || !hapd->iconf->ieee80211be || !conf->mld_ap ||
+ conf->disable_11be)
+ return;
+
+ for (i = 0; i < interfaces->mld_count; i++) {
+ mld = interfaces->mld[i];
+
+ if (!(mld && os_strcmp(conf->iface, mld->name) == 0))
+ continue;
+
+ hapd->mld = mld;
+ break;
+ }
+
+ if (hapd->mld)
+ return;
+
+ mld = os_zalloc(sizeof(struct hostapd_mld));
+ if (!mld)
+ goto fail;
+
+ os_strlcpy(mld->name, conf->iface, sizeof(conf->iface));
+ mld->next_link_id = 0;
+ mld->num_links = 0;
+ mld->fbss = NULL;
+ dl_list_init(&mld->links);
+
+ wpa_printf(MSG_DEBUG, "MLD %s created", mld->name);
+
+ hapd->mld = mld;
+
+ all_mld = os_realloc_array(interfaces->mld, interfaces->mld_count + 1,
+ sizeof(struct hostapd_mld *));
+ if (!all_mld)
+ goto fail;
+
+ interfaces->mld = all_mld;
+ interfaces->mld[interfaces->mld_count] = mld;
+ interfaces->mld_count++;
+
+ return;
+fail:
+ if (!mld)
+ return;
+
+ wpa_printf(MSG_DEBUG, "MLD %s: free mld %p", mld->name, mld);
+ os_free(mld);
+ hapd->mld = NULL;
+}
+#endif /* CONFIG_IEEE80211BE */
/**
* hostapd_init - Allocate and initialize per-interface data
@@ -2913,6 +2976,9 @@ struct hostapd_iface * hostapd_init(stru
if (hapd == NULL)
goto fail;
hapd->msg_ctx = hapd;
+#ifdef CONFIG_IEEE80211BE
+ hostapd_bss_setup_multi_link(hapd, interfaces);
+#endif /* CONFIG_IEEE80211BE */
}
return hapd_iface;
@@ -3034,6 +3100,10 @@ hostapd_interface_init_bss(struct hapd_i
iface->conf->last_bss = bss;
iface->bss[iface->num_bss] = hapd;
hapd->msg_ctx = hapd;
+#ifdef CONFIG_IEEE80211BE
+ hostapd_bss_setup_multi_link(hapd, interfaces);
+#endif /* CONFIG_IEEE80211BE */
+
bss_idx = iface->num_bss++;
conf->num_bss--;
@@ -3380,6 +3450,9 @@ static int hostapd_data_alloc(struct hos
return -1;
}
hapd->msg_ctx = hapd;
+#ifdef CONFIG_IEEE80211BE
+ hostapd_bss_setup_multi_link(hapd, hapd_iface->interfaces);
+#endif /* CONFIG_IEEE80211BE */
}
hapd_iface->conf = conf;
@@ -4621,4 +4694,97 @@ u8 hostapd_get_mld_id(struct hostapd_dat
/* TODO MLD ID for MBSS cases */
}
+
+int hostapd_mld_add_link(struct hostapd_data *hapd)
+{
+ struct hostapd_mld *mld = hapd->mld;
+
+ if (!hapd->conf->mld_ap)
+ return 0;
+
+ /* should not happen */
+ if (!mld)
+ return -1;
+
+ dl_list_add_tail(&mld->links, &hapd->link);
+ mld->num_links++;
+
+ wpa_printf(MSG_DEBUG, "MLD %s: Link ID %d added. num_links: %d",
+ mld->name, hapd->mld_link_id, mld->num_links);
+
+ if (mld->fbss)
+ return 0;
+
+ mld->fbss = hapd;
+ wpa_printf(MSG_DEBUG, "MLD %s: First link BSS set to %p",
+ mld->name, mld->fbss);
+ return 0;
+}
+
+int hostapd_mld_remove_link(struct hostapd_data *hapd)
+{
+ struct hostapd_mld *mld = hapd->mld;
+ struct hostapd_data *next_fbss;
+
+ if (!hapd->conf->mld_ap)
+ return 0;
+
+ /* should not happen */
+ if (!mld)
+ return -1;
+
+ dl_list_del(&hapd->link);
+ mld->num_links--;
+
+ wpa_printf(MSG_DEBUG, "MLD %s: Link ID %d removed. num_links: %d",
+ mld->name, hapd->mld_link_id, mld->num_links);
+
+ if (mld->fbss != hapd)
+ return 0;
+
+ /* If len is 0, all links are removed */
+ if (!dl_list_len(&mld->links)) {
+ mld->fbss = NULL;
+ } else {
+ next_fbss = dl_list_entry(mld->links.next, struct hostapd_data,
+ link);
+ mld->fbss = next_fbss;
+ }
+
+ wpa_printf(MSG_DEBUG, "MLD %s: First link BSS set to %p",
+ mld->name, mld->fbss);
+ return 0;
+}
+
+bool hostapd_mld_is_first_bss(struct hostapd_data *hapd)
+{
+ struct hostapd_mld *mld = hapd->mld;
+
+ if (!hapd->conf->mld_ap)
+ return 1;
+
+ /* should not happen */
+ if (!mld)
+ return 0;
+
+ /* if fbss is not set, safe to assume the caller is the first BSS */
+ if (!mld->fbss)
+ return 1;
+
+ return hapd == mld->fbss;
+}
+
+struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd)
+{
+ struct hostapd_mld *mld = hapd->mld;
+
+ if (!hapd->conf->mld_ap)
+ return NULL;
+
+ /* should not happen */
+ if (!mld)
+ return NULL;
+
+ return mld->fbss;
+}
#endif /* CONFIG_IEEE80211BE */
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -45,6 +45,9 @@ struct mesh_conf;
#endif /* CONFIG_CTRL_IFACE_UDP */
struct hostapd_iface;
+#ifdef CONFIG_IEEE80211BE
+struct hostapd_mld;
+#endif /* CONFIG_IEEE80211BE */
struct hapd_interfaces {
int (*reload_config)(struct hostapd_iface *iface, int reconf);
@@ -93,7 +96,10 @@ struct hapd_interfaces {
#ifdef CONFIG_CTRL_IFACE_UDP
unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
#endif /* CONFIG_CTRL_IFACE_UDP */
-
+#ifdef CONFIG_IEEE80211BE
+ struct hostapd_mld **mld;
+ size_t mld_count;
+#endif /* CONFIG_IEEE80211BE */
};
enum hostapd_chan_status {
@@ -493,6 +499,11 @@ struct hostapd_data {
#ifdef CONFIG_CTRL_IFACE_UDP
unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
#endif /* CONFIG_CTRL_IFACE_UDP */
+
+#ifdef CONFIG_IEEE80211BE
+ struct hostapd_mld *mld;
+ struct dl_list link;
+#endif /* CONFIG_IEEE80211BE */
};
@@ -506,6 +517,21 @@ struct hostapd_sta_info {
#endif /* CONFIG_TAXONOMY */
};
+#ifdef CONFIG_IEEE80211BE
+/**
+ * struct hostapd_mld - hostapd per-mld data structure
+ */
+struct hostapd_mld {
+ char name[IFNAMSIZ + 1];
+ u8 mld_addr[ETH_ALEN];
+ u8 next_link_id;
+ u8 num_links;
+
+ struct hostapd_data *fbss;
+ struct dl_list links; /* List HEAD of all affiliated links */
+};
+#endif /* CONFIG_IEEE80211BE */
+
/**
* struct hostapd_iface - hostapd per-interface data structure
*/
@@ -809,4 +835,8 @@ struct hostapd_data * hostapd_mld_get_li
bool hostapd_is_ml_partner(struct hostapd_data *hapd1,
struct hostapd_data *hapd2);
u8 hostapd_get_mld_id(struct hostapd_data *hapd);
+int hostapd_mld_add_link(struct hostapd_data *hapd);
+int hostapd_mld_remove_link(struct hostapd_data *hapd);
+bool hostapd_mld_is_first_bss(struct hostapd_data *hapd);
+struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd);
#endif /* HOSTAPD_H */