developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 1 | From 11e9653a0df41e119ff5acad3ffcbd2825690413 Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Tue, 16 Jan 2024 16:22:17 +0800 |
| 4 | Subject: [PATCH 091/104] mtk: wifi: hostapd: add wds mlo support |
| 5 | |
| 6 | 1. Add mld_assoc_sta to get the primary sta_info. |
| 7 | 2. Find hapd according to mld address. |
| 8 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 9 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 10 | --- |
| 11 | src/ap/drv_callbacks.c | 3 ++- |
| 12 | src/ap/ieee802_11.c | 8 ++++++++ |
| 13 | src/ap/sta_info.c | 6 +++++- |
| 14 | src/ap/sta_info.h | 1 + |
| 15 | src/drivers/driver.h | 3 +++ |
| 16 | src/drivers/driver_nl80211.c | 14 ++++++++++++++ |
| 17 | 6 files changed, 33 insertions(+), 2 deletions(-) |
| 18 | |
| 19 | diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c |
| 20 | index 2d946afd6..27c7555a1 100644 |
| 21 | --- a/src/ap/drv_callbacks.c |
| 22 | +++ b/src/ap/drv_callbacks.c |
| 23 | @@ -1762,6 +1762,7 @@ switch_link_hapd(struct hostapd_data *hapd, int link_id) |
| 24 | static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 25 | const u8 *bssid, int link_id) |
| 26 | { |
| 27 | + struct hostapd_data *ret = NULL; |
| 28 | size_t i; |
| 29 | |
| 30 | if (bssid == NULL) |
| 31 | @@ -1797,7 +1798,7 @@ static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 32 | #endif /*CONFIG_IEEE80211BE */ |
| 33 | } |
| 34 | |
| 35 | - return NULL; |
| 36 | + return ret; |
| 37 | } |
| 38 | |
| 39 | |
| 40 | diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c |
| 41 | index fe0a5bce4..688393422 100644 |
| 42 | --- a/src/ap/ieee802_11.c |
| 43 | +++ b/src/ap/ieee802_11.c |
| 44 | @@ -3105,6 +3105,7 @@ static void handle_auth(struct hostapd_data *hapd, |
| 45 | |
| 46 | ap_sta_set_mld(sta, true); |
| 47 | sta->mld_assoc_link_id = link_id; |
| 48 | + sta->mld_assoc_sta = sta; |
| 49 | |
| 50 | /* |
| 51 | * Set the MLD address as the station address and the |
| 52 | @@ -4479,6 +4480,7 @@ static int ieee80211_ml_process_link(struct hostapd_data *hapd, |
| 53 | |
| 54 | sta->flags |= origin_sta->flags | WLAN_STA_ASSOC_REQ_OK; |
| 55 | sta->mld_assoc_link_id = origin_sta->mld_assoc_link_id; |
| 56 | + sta->mld_assoc_sta = origin_sta; |
| 57 | |
| 58 | status = __check_assoc_ies(hapd, sta, NULL, 0, &elems, reassoc, true); |
| 59 | if (status != WLAN_STATUS_SUCCESS) { |
| 60 | @@ -6957,6 +6959,12 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src, |
| 61 | struct sta_info *sta; |
| 62 | |
| 63 | sta = ap_get_sta(hapd, src); |
| 64 | + |
| 65 | +#ifdef CONFIG_IEEE80211BE |
| 66 | + if (sta && sta->mld_info.mld_sta) |
| 67 | + sta = sta->mld_assoc_sta; |
| 68 | +#endif |
| 69 | + |
| 70 | if (sta && |
| 71 | ((sta->flags & WLAN_STA_ASSOC) || |
| 72 | ((sta->flags & WLAN_STA_ASSOC_REQ_OK) && wds))) { |
| 73 | diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c |
| 74 | index e9fa0ed6e..2b8307a27 100644 |
| 75 | --- a/src/ap/sta_info.c |
| 76 | +++ b/src/ap/sta_info.c |
| 77 | @@ -74,6 +74,7 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta) |
| 78 | while (s != NULL && os_memcmp(s->addr, sta, 6) != 0) |
| 79 | s = s->hnext; |
| 80 | |
| 81 | +#ifdef CONFIG_IEEE80211BE |
| 82 | if (hapd->conf->mld_ap && !s) { |
| 83 | u8 link_id; |
| 84 | |
| 85 | @@ -84,10 +85,13 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta) |
| 86 | continue; |
| 87 | |
| 88 | for (s = h->sta_list; s; s = s->next) |
| 89 | - if (!os_memcmp(s->setup_link_addr, sta, 6)) |
| 90 | + if ((!os_memcmp(s->setup_link_addr, sta, 6) || |
| 91 | + !os_memcmp(s->addr, sta, 6)) && |
| 92 | + s->flags & WLAN_STA_ASSOC) |
| 93 | return s; |
| 94 | } |
| 95 | } |
| 96 | +#endif |
| 97 | |
| 98 | return s; |
| 99 | } |
| 100 | diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h |
| 101 | index cd89db6c8..8e500ec9a 100644 |
| 102 | --- a/src/ap/sta_info.h |
| 103 | +++ b/src/ap/sta_info.h |
| 104 | @@ -334,6 +334,7 @@ struct sta_info { |
| 105 | #ifdef CONFIG_IEEE80211BE |
| 106 | struct mld_info mld_info; |
| 107 | u8 mld_assoc_link_id; |
| 108 | + struct sta_info *mld_assoc_sta; |
| 109 | #endif /* CONFIG_IEEE80211BE */ |
| 110 | }; |
| 111 | |
| 112 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
| 113 | index 10ae48729..ba61f5842 100644 |
| 114 | --- a/src/drivers/driver.h |
| 115 | +++ b/src/drivers/driver.h |
| 116 | @@ -5339,6 +5339,9 @@ struct wpa_driver_ops { |
| 117 | * @pp_mode: Value is defined in enum pp_mode |
| 118 | */ |
| 119 | int (*pp_mode_set)(void *priv, const u8 pp_mode); |
| 120 | +#ifdef CONFIG_IEEE80211BE |
| 121 | + int (*get_mld_addr)(void *priv, u8 *addr); |
| 122 | +#endif |
| 123 | }; |
| 124 | |
| 125 | /** |
| 126 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
| 127 | index ad73b4ac1..df4a7ec41 100644 |
| 128 | --- a/src/drivers/driver_nl80211.c |
| 129 | +++ b/src/drivers/driver_nl80211.c |
| 130 | @@ -15181,6 +15181,17 @@ fail: |
| 131 | return -ENOBUFS; |
| 132 | } |
| 133 | |
| 134 | +#ifdef CONFIG_IEEE80211BE |
| 135 | +static int nl80211_get_mld_addr(void *priv, u8 *addr) |
| 136 | +{ |
| 137 | + struct i802_bss *bss = priv; |
| 138 | + |
| 139 | + os_memcpy(addr, bss->addr, ETH_ALEN); |
| 140 | + |
| 141 | + return 0; |
| 142 | +} |
| 143 | +#endif |
| 144 | + |
| 145 | const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 146 | .name = "nl80211", |
| 147 | .desc = "Linux nl80211/cfg80211", |
| 148 | @@ -15361,4 +15372,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 149 | .amnt_dump = nl80211_amnt_dump, |
| 150 | .background_radar_mode = nl80211_background_radar_mode, |
| 151 | .pp_mode_set = nl80211_pp_mode_set, |
| 152 | +#ifdef CONFIG_IEEE80211BE |
| 153 | + .get_mld_addr = nl80211_get_mld_addr, |
| 154 | +#endif |
| 155 | }; |
| 156 | -- |
| 157 | 2.39.2 |
| 158 | |