developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From 89cea0c904dfce8fca45a3d721f2871c32402e05 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 070/126] mtk: 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 | |
| 9 | The latest get_hapd_bssid return hapd only if link id is matched. |
| 10 | However,the hostapd_rx_from_unknown_sta does not have link |
| 11 | information so it cannot get hapd. |
| 12 | |
| 13 | Modify get_hapd_bssid to ignore link id when link id is -1. |
| 14 | |
| 15 | Without this patch, wds mode cannot work and the AP would not be |
| 16 | aware that station is using 4 address. |
| 17 | |
| 18 | Transmit correct hapd by i802_bss->ctx to EVENT_RX_FROM_UNKNOWN handler. |
| 19 | Without this patch, AP cannot setup AP_VLAN interface in mlo + legacy case. |
| 20 | In mlo + legacy case, if wds null is sent to legacy AP, it cannot get correct |
| 21 | hapd according drv->ctx because drv->ctx and legacy AP's hapd may not under |
| 22 | the same hostapd_iface. |
| 23 | |
| 24 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 25 | --- |
| 26 | src/ap/drv_callbacks.c | 7 ++++--- |
| 27 | src/ap/ieee802_11.c | 8 ++++++++ |
| 28 | src/ap/sta_info.c | 6 +++++- |
| 29 | src/ap/sta_info.h | 1 + |
| 30 | src/drivers/driver.h | 3 +++ |
| 31 | src/drivers/driver_nl80211.c | 14 ++++++++++++++ |
| 32 | src/drivers/driver_nl80211_event.c | 2 +- |
| 33 | 7 files changed, 36 insertions(+), 5 deletions(-) |
| 34 | |
| 35 | diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c |
| 36 | index 1fa27bf80..1107fd70e 100644 |
| 37 | --- a/src/ap/drv_callbacks.c |
| 38 | +++ b/src/ap/drv_callbacks.c |
| 39 | @@ -1798,6 +1798,7 @@ switch_link_scan(struct hostapd_data *hapd, u64 scan_cookie) |
| 40 | static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 41 | const u8 *bssid, int link_id) |
| 42 | { |
| 43 | + struct hostapd_data *ret = NULL; |
| 44 | size_t i; |
| 45 | |
| 46 | if (bssid == NULL) |
| 47 | @@ -1820,7 +1821,7 @@ static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 48 | if (ether_addr_equal(bssid, hapd->own_addr) || |
| 49 | (hapd->conf->mld_ap && |
| 50 | ether_addr_equal(bssid, hapd->mld->mld_addr) && |
| 51 | - link_id == hapd->mld_link_id)) |
| 52 | + (link_id == hapd->mld_link_id || link_id == -1))) |
| 53 | return hapd; |
| 54 | |
| 55 | if (!hapd->conf->mld_ap) |
| 56 | @@ -1832,13 +1833,13 @@ static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 57 | |
| 58 | if (ether_addr_equal(bssid, p_hapd->own_addr) || |
| 59 | (ether_addr_equal(bssid, p_hapd->mld->mld_addr) && |
| 60 | - link_id == p_hapd->mld_link_id)) |
| 61 | + (link_id == p_hapd->mld_link_id || link_id == -1))) |
| 62 | return p_hapd; |
| 63 | } |
| 64 | #endif /* CONFIG_IEEE80211BE */ |
| 65 | } |
| 66 | |
| 67 | - return NULL; |
| 68 | + return ret; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c |
| 73 | index c6676b754..d26b50031 100644 |
| 74 | --- a/src/ap/ieee802_11.c |
| 75 | +++ b/src/ap/ieee802_11.c |
| 76 | @@ -3183,6 +3183,7 @@ static void handle_auth(struct hostapd_data *hapd, |
| 77 | |
| 78 | ap_sta_set_mld(sta, true); |
| 79 | sta->mld_assoc_link_id = link_id; |
| 80 | + sta->mld_assoc_sta = sta; |
| 81 | |
| 82 | /* |
| 83 | * Set the MLD address as the station address and the |
| 84 | @@ -4572,6 +4573,7 @@ static int ieee80211_ml_process_link(struct hostapd_data *hapd, |
| 85 | |
| 86 | sta->flags |= origin_sta->flags | WLAN_STA_ASSOC_REQ_OK; |
| 87 | sta->mld_assoc_link_id = origin_sta->mld_assoc_link_id; |
| 88 | + sta->mld_assoc_sta = origin_sta; |
| 89 | |
| 90 | status = __check_assoc_ies(hapd, sta, NULL, 0, &elems, reassoc, true); |
| 91 | if (status != WLAN_STATUS_SUCCESS) { |
| 92 | @@ -7037,6 +7039,12 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src, |
| 93 | struct sta_info *sta; |
| 94 | |
| 95 | sta = ap_get_sta(hapd, src); |
| 96 | + |
| 97 | +#ifdef CONFIG_IEEE80211BE |
| 98 | + if (sta && sta->mld_info.mld_sta) |
| 99 | + sta = sta->mld_assoc_sta; |
| 100 | +#endif |
| 101 | + |
| 102 | if (sta && |
| 103 | ((sta->flags & WLAN_STA_ASSOC) || |
| 104 | ((sta->flags & WLAN_STA_ASSOC_REQ_OK) && wds))) { |
| 105 | diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c |
| 106 | index d4f4eb913..ea34d347f 100644 |
| 107 | --- a/src/ap/sta_info.c |
| 108 | +++ b/src/ap/sta_info.c |
| 109 | @@ -74,6 +74,7 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta) |
| 110 | while (s != NULL && os_memcmp(s->addr, sta, 6) != 0) |
| 111 | s = s->hnext; |
| 112 | |
| 113 | +#ifdef CONFIG_IEEE80211BE |
| 114 | if (hapd->conf->mld_ap && !s) { |
| 115 | u8 link_id; |
| 116 | |
| 117 | @@ -84,10 +85,13 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta) |
| 118 | continue; |
| 119 | |
| 120 | for (s = h->sta_list; s; s = s->next) |
| 121 | - if (!os_memcmp(s->setup_link_addr, sta, 6)) |
| 122 | + if ((!os_memcmp(s->setup_link_addr, sta, 6) || |
| 123 | + !os_memcmp(s->addr, sta, 6)) && |
| 124 | + s->flags & WLAN_STA_ASSOC) |
| 125 | return s; |
| 126 | } |
| 127 | } |
| 128 | +#endif |
| 129 | |
| 130 | return s; |
| 131 | } |
| 132 | diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h |
| 133 | index 6b88799e2..67b97671a 100644 |
| 134 | --- a/src/ap/sta_info.h |
| 135 | +++ b/src/ap/sta_info.h |
| 136 | @@ -328,6 +328,7 @@ struct sta_info { |
| 137 | #ifdef CONFIG_IEEE80211BE |
| 138 | struct mld_info mld_info; |
| 139 | u8 mld_assoc_link_id; |
| 140 | + struct sta_info *mld_assoc_sta; |
| 141 | #endif /* CONFIG_IEEE80211BE */ |
| 142 | |
| 143 | u16 max_idle_period; /* if nonzero, the granted BSS max idle period in |
| 144 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
| 145 | index 47f4f56c0..ec00c36e4 100644 |
| 146 | --- a/src/drivers/driver.h |
| 147 | +++ b/src/drivers/driver.h |
| 148 | @@ -5366,6 +5366,9 @@ struct wpa_driver_ops { |
| 149 | * @pp_mode: Value is defined in enum pp_mode |
| 150 | */ |
| 151 | int (*pp_mode_set)(void *priv, const u8 pp_mode); |
| 152 | +#ifdef CONFIG_IEEE80211BE |
| 153 | + int (*get_mld_addr)(void *priv, u8 *addr); |
| 154 | +#endif |
| 155 | }; |
| 156 | |
| 157 | /** |
| 158 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
| 159 | index dec358fba..8f7215d62 100644 |
| 160 | --- a/src/drivers/driver_nl80211.c |
| 161 | +++ b/src/drivers/driver_nl80211.c |
| 162 | @@ -15209,6 +15209,17 @@ fail: |
| 163 | return -ENOBUFS; |
| 164 | } |
| 165 | |
| 166 | +#ifdef CONFIG_IEEE80211BE |
| 167 | +static int nl80211_get_mld_addr(void *priv, u8 *addr) |
| 168 | +{ |
| 169 | + struct i802_bss *bss = priv; |
| 170 | + |
| 171 | + os_memcpy(addr, bss->addr, ETH_ALEN); |
| 172 | + |
| 173 | + return 0; |
| 174 | +} |
| 175 | +#endif |
| 176 | + |
| 177 | const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 178 | .name = "nl80211", |
| 179 | .desc = "Linux nl80211/cfg80211", |
| 180 | @@ -15389,4 +15400,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 181 | .amnt_dump = nl80211_amnt_dump, |
| 182 | .background_radar_mode = nl80211_background_radar_mode, |
| 183 | .pp_mode_set = nl80211_pp_mode_set, |
| 184 | +#ifdef CONFIG_IEEE80211BE |
| 185 | + .get_mld_addr = nl80211_get_mld_addr, |
| 186 | +#endif |
| 187 | }; |
| 188 | diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c |
| 189 | index 7f5a3d892..07af6be77 100644 |
| 190 | --- a/src/drivers/driver_nl80211_event.c |
| 191 | +++ b/src/drivers/driver_nl80211_event.c |
| 192 | @@ -2575,7 +2575,7 @@ static void nl80211_spurious_frame(struct i802_bss *bss, struct nlattr **tb, |
| 193 | event.rx_from_unknown.addr = nla_data(tb[NL80211_ATTR_MAC]); |
| 194 | event.rx_from_unknown.wds = wds; |
| 195 | |
| 196 | - wpa_supplicant_event(drv->ctx, EVENT_RX_FROM_UNKNOWN, &event); |
| 197 | + wpa_supplicant_event(bss->ctx, EVENT_RX_FROM_UNKNOWN, &event); |
| 198 | } |
| 199 | |
| 200 | |
| 201 | -- |
| 202 | 2.18.0 |
| 203 | |