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