blob: 1ce57ff4b92343bd5aada9829d91790f09af6996 [file] [log] [blame]
From 11e9653a0df41e119ff5acad3ffcbd2825690413 Mon Sep 17 00:00:00 2001
From: Peter Chiu <chui-hao.chiu@mediatek.com>
Date: Tue, 16 Jan 2024 16:22:17 +0800
Subject: [PATCH 091/104] mtk: wifi: hostapd: add wds mlo support
1. Add mld_assoc_sta to get the primary sta_info.
2. Find hapd according to mld address.
CR-Id: WCNCR00240772
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Change-Id: Ic2d67c0623299dfc00021925296c54e25fe86959
---
src/ap/drv_callbacks.c | 3 ++-
src/ap/ieee802_11.c | 8 ++++++++
src/ap/sta_info.c | 6 +++++-
src/ap/sta_info.h | 1 +
src/drivers/driver.h | 3 +++
src/drivers/driver_nl80211.c | 14 ++++++++++++++
6 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index 2d946afd6..27c7555a1 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -1762,6 +1762,7 @@ switch_link_hapd(struct hostapd_data *hapd, int link_id)
static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface,
const u8 *bssid, int link_id)
{
+ struct hostapd_data *ret = NULL;
size_t i;
if (bssid == NULL)
@@ -1797,7 +1798,7 @@ static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface,
#endif /*CONFIG_IEEE80211BE */
}
- return NULL;
+ return ret;
}
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index fe0a5bce4..688393422 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -3105,6 +3105,7 @@ static void handle_auth(struct hostapd_data *hapd,
ap_sta_set_mld(sta, true);
sta->mld_assoc_link_id = link_id;
+ sta->mld_assoc_sta = sta;
/*
* Set the MLD address as the station address and the
@@ -4479,6 +4480,7 @@ static int ieee80211_ml_process_link(struct hostapd_data *hapd,
sta->flags |= origin_sta->flags | WLAN_STA_ASSOC_REQ_OK;
sta->mld_assoc_link_id = origin_sta->mld_assoc_link_id;
+ sta->mld_assoc_sta = origin_sta;
status = __check_assoc_ies(hapd, sta, NULL, 0, &elems, reassoc, true);
if (status != WLAN_STATUS_SUCCESS) {
@@ -6957,6 +6959,12 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
struct sta_info *sta;
sta = ap_get_sta(hapd, src);
+
+#ifdef CONFIG_IEEE80211BE
+ if (sta && sta->mld_info.mld_sta)
+ sta = sta->mld_assoc_sta;
+#endif
+
if (sta &&
((sta->flags & WLAN_STA_ASSOC) ||
((sta->flags & WLAN_STA_ASSOC_REQ_OK) && wds))) {
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index e9fa0ed6e..2b8307a27 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -74,6 +74,7 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
s = s->hnext;
+#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && !s) {
u8 link_id;
@@ -84,10 +85,13 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
continue;
for (s = h->sta_list; s; s = s->next)
- if (!os_memcmp(s->setup_link_addr, sta, 6))
+ if ((!os_memcmp(s->setup_link_addr, sta, 6) ||
+ !os_memcmp(s->addr, sta, 6)) &&
+ s->flags & WLAN_STA_ASSOC)
return s;
}
}
+#endif
return s;
}
diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h
index cd89db6c8..8e500ec9a 100644
--- a/src/ap/sta_info.h
+++ b/src/ap/sta_info.h
@@ -334,6 +334,7 @@ struct sta_info {
#ifdef CONFIG_IEEE80211BE
struct mld_info mld_info;
u8 mld_assoc_link_id;
+ struct sta_info *mld_assoc_sta;
#endif /* CONFIG_IEEE80211BE */
};
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 10ae48729..ba61f5842 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -5339,6 +5339,9 @@ struct wpa_driver_ops {
* @pp_mode: Value is defined in enum pp_mode
*/
int (*pp_mode_set)(void *priv, const u8 pp_mode);
+#ifdef CONFIG_IEEE80211BE
+ int (*get_mld_addr)(void *priv, u8 *addr);
+#endif
};
/**
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index ad73b4ac1..df4a7ec41 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -15181,6 +15181,17 @@ fail:
return -ENOBUFS;
}
+#ifdef CONFIG_IEEE80211BE
+static int nl80211_get_mld_addr(void *priv, u8 *addr)
+{
+ struct i802_bss *bss = priv;
+
+ os_memcpy(addr, bss->addr, ETH_ALEN);
+
+ return 0;
+}
+#endif
+
const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.name = "nl80211",
.desc = "Linux nl80211/cfg80211",
@@ -15361,4 +15372,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.amnt_dump = nl80211_amnt_dump,
.background_radar_mode = nl80211_background_radar_mode,
.pp_mode_set = nl80211_pp_mode_set,
+#ifdef CONFIG_IEEE80211BE
+ .get_mld_addr = nl80211_get_mld_addr,
+#endif
};
--
2.39.2