developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From 4bae58d6ded6d2b08975054e1c4097dcedb6b333 Mon Sep 17 00:00:00 2001 |
| 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 28 Jun 2024 14:06:20 +0800 |
| 4 | Subject: [PATCH 117/126] mtk: hostapd: handle 5G link setup after DFS bootup |
| 5 | CAC as link reconfig |
| 6 | |
| 7 | Consider the setup of 5G link after bootup CAC as a link adding |
| 8 | process via link reconfiguration. |
| 9 | |
| 10 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 11 | --- |
| 12 | src/ap/dfs.c | 38 +++++++++++++++++++++++++++++++++++--- |
| 13 | src/ap/hostapd.c | 2 ++ |
| 14 | src/ap/hostapd.h | 1 + |
| 15 | src/ap/ieee802_11.c | 7 +++++-- |
| 16 | src/ap/ieee802_11_eht.c | 13 +++++++++++-- |
| 17 | 5 files changed, 54 insertions(+), 7 deletions(-) |
| 18 | |
| 19 | diff --git a/src/ap/dfs.c b/src/ap/dfs.c |
| 20 | index 5a3112d40..31e37a2ab 100644 |
| 21 | --- a/src/ap/dfs.c |
| 22 | +++ b/src/ap/dfs.c |
| 23 | @@ -1034,6 +1034,22 @@ int hostapd_handle_dfs(struct hostapd_iface *iface) |
| 24 | return -1; |
| 25 | } |
| 26 | |
| 27 | + /* Remove the CAC link from the active links of AP MLD temporarily to avoid |
| 28 | + * it being reported in the RNR of the affiliated APs of the same AP MLD |
| 29 | + */ |
| 30 | + if (iface->cac_started) { |
| 31 | + int i; |
| 32 | + |
| 33 | + for (i = 0; i < iface->num_bss; i++) { |
| 34 | + struct hostapd_data *hapd = iface->bss[i]; |
| 35 | + |
| 36 | + if (!hapd->conf->mld_ap || !hapd->mld) |
| 37 | + continue; |
| 38 | + |
| 39 | + hapd->mld->active_links &= ~BIT(hapd->mld_link_id); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | @@ -1310,6 +1326,8 @@ int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq, |
| 47 | int ht_enabled, int chan_offset, int chan_width, |
| 48 | int cf1, int cf2) |
| 49 | { |
| 50 | + int i; |
| 51 | + |
| 52 | wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_COMPLETED |
| 53 | "success=%d freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d radar_detected=%d", |
| 54 | success, freq, ht_enabled, chan_offset, chan_width, cf1, cf2, |
| 55 | @@ -1364,10 +1382,26 @@ int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq, |
| 56 | * sure the configured channel is available because this |
| 57 | * CAC completion event could have been propagated from |
| 58 | * another radio. |
| 59 | + * For a AP MLD, the setup of a DFS link after bootup CAC is |
| 60 | + * considered as link adding process via link reconfiguration. |
| 61 | */ |
| 62 | if (iface->state != HAPD_IFACE_ENABLED && |
| 63 | - hostapd_is_dfs_chan_available(iface)) |
| 64 | + hostapd_is_dfs_chan_available(iface)) { |
| 65 | + for (i = 0; i < iface->num_bss; i++) { |
| 66 | + struct hostapd_data *h, *hapd = iface->bss[i]; |
| 67 | + |
| 68 | + if (!hapd->conf->mld_ap || !hapd->mld) |
| 69 | + continue; |
| 70 | + |
| 71 | + hapd->mld->active_links |= BIT(hapd->mld_link_id); |
| 72 | + for_each_mld_link(h, hapd) |
| 73 | + h->mld->link_reconf_in_progress |= |
| 74 | + BIT(h->mld_link_id); |
| 75 | + hapd->mld->link_reconf_in_progress &= |
| 76 | + ~BIT(hapd->mld_link_id); |
| 77 | + } |
| 78 | hostapd_setup_interface_complete(iface, 0); |
| 79 | + } |
| 80 | |
| 81 | iface->cac_started = 0; |
| 82 | |
| 83 | @@ -1386,8 +1420,6 @@ int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq, |
| 84 | iface->radar_background.expand_ch = 0; |
| 85 | hostapd_dfs_update_background_chain(iface); |
| 86 | } else if (iface->state == HAPD_IFACE_ENABLED) { |
| 87 | - int i; |
| 88 | - |
| 89 | iface->cac_started = 0; |
| 90 | /* Clear all CSA flags once channel switch to DFS channel fails */ |
| 91 | for (i = 0; i < iface->num_bss; i++) |
| 92 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
| 93 | index a89628fe7..7518a8b53 100644 |
| 94 | --- a/src/ap/hostapd.c |
| 95 | +++ b/src/ap/hostapd.c |
| 96 | @@ -5109,6 +5109,7 @@ int hostapd_mld_add_link(struct hostapd_data *hapd) |
| 97 | |
| 98 | dl_list_add_tail(&mld->links, &hapd->link); |
| 99 | mld->num_links++; |
| 100 | + mld->active_links |= BIT(hapd->mld_link_id); |
| 101 | |
| 102 | wpa_printf(MSG_DEBUG, "AP MLD %s: Link ID %d added. num_links: %d", |
| 103 | mld->name, hapd->mld_link_id, mld->num_links); |
| 104 | @@ -5137,6 +5138,7 @@ int hostapd_mld_remove_link(struct hostapd_data *hapd) |
| 105 | |
| 106 | dl_list_del(&hapd->link); |
| 107 | mld->num_links--; |
| 108 | + mld->active_links &= ~BIT(hapd->mld_link_id); |
| 109 | |
| 110 | wpa_printf(MSG_DEBUG, "AP MLD %s: Link ID %d removed. num_links: %d", |
| 111 | mld->name, hapd->mld_link_id, mld->num_links); |
| 112 | diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h |
| 113 | index 52875cca1..668f1c44d 100644 |
| 114 | --- a/src/ap/hostapd.h |
| 115 | +++ b/src/ap/hostapd.h |
| 116 | @@ -550,6 +550,7 @@ struct hostapd_mld { |
| 117 | u8 refcount; |
| 118 | bool started; |
| 119 | u16 link_reconf_in_progress; |
| 120 | + u16 active_links; |
| 121 | |
| 122 | struct hostapd_data *fbss; |
| 123 | struct dl_list links; /* List head of all affiliated links */ |
| 124 | diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c |
| 125 | index 93bd8255c..2861c09d7 100644 |
| 126 | --- a/src/ap/ieee802_11.c |
| 127 | +++ b/src/ap/ieee802_11.c |
| 128 | @@ -989,6 +989,8 @@ void sae_accept_sta(struct hostapd_data *hapd, struct sta_info *sta) |
| 129 | sta->sae->peer_commit_scalar = NULL; |
| 130 | if (hostapd_is_mld_ap(hapd)) { |
| 131 | for_each_mld_link(link, hapd) { |
| 132 | + if (!(hapd->mld->active_links & BIT(link->mld_link_id))) |
| 133 | + continue; |
| 134 | wpa_auth_pmksa_add_sae(link->wpa_auth, sta->addr, |
| 135 | sta->sae->pmk, sta->sae->pmk_len, |
| 136 | sta->sae->pmkid, sta->sae->akmp); |
| 137 | @@ -8108,7 +8110,7 @@ u8 * hostapd_eid_rnr_mlo(struct hostapd_data *hapd, u32 type, |
| 138 | struct hostapd_iface *iface; |
| 139 | size_t i; |
| 140 | |
| 141 | - if (!hapd->iface || !hapd->iface->interfaces || !hapd->conf->mld_ap) |
| 142 | + if (!hapd->iface || !hapd->iface->interfaces || !hapd->conf->mld_ap || !hapd->mld) |
| 143 | return eid; |
| 144 | |
| 145 | /* TODO: Allow for FILS/Action as well */ |
| 146 | @@ -8119,7 +8121,8 @@ u8 * hostapd_eid_rnr_mlo(struct hostapd_data *hapd, u32 type, |
| 147 | iface = hapd->iface->interfaces->iface[i]; |
| 148 | |
| 149 | if (!iface || iface == hapd->iface || |
| 150 | - hapd->iface->freq == iface->freq) |
| 151 | + hapd->iface->freq == iface->freq || |
| 152 | + !(hapd->mld->active_links & BIT(hapd->mld_link_id))) |
| 153 | continue; |
| 154 | |
| 155 | eid = hostapd_eid_rnr_iface(iface->bss[0], hapd, eid, |
| 156 | diff --git a/src/ap/ieee802_11_eht.c b/src/ap/ieee802_11_eht.c |
| 157 | index 63713bc39..cad0d8437 100644 |
| 158 | --- a/src/ap/ieee802_11_eht.c |
| 159 | +++ b/src/ap/ieee802_11_eht.c |
| 160 | @@ -514,7 +514,13 @@ static u8 * hostapd_eid_eht_basic_ml_common(struct hostapd_data *hapd, |
| 161 | u8 link_id; |
| 162 | u8 common_info_len; |
| 163 | u16 mld_cap; |
| 164 | - u8 max_simul_links, active_links; |
| 165 | + u8 max_simul_links, active_links = 0; |
| 166 | + |
| 167 | + if (hapd->mld && !(hapd->mld->active_links & BIT(hapd->mld_link_id))) { |
| 168 | + wpa_printf(MSG_ERROR, "MLD: Current link %d is not active for %s", |
| 169 | + hapd->mld_link_id, hapd->mld->name); |
| 170 | + return pos; |
| 171 | + } |
| 172 | |
| 173 | /* |
| 174 | * As the Multi-Link element can exceed the size of 255 bytes need to |
| 175 | @@ -573,7 +579,10 @@ static u8 * hostapd_eid_eht_basic_ml_common(struct hostapd_data *hapd, |
| 176 | |
| 177 | mld_cap = hapd->iface->mld_mld_capa; |
| 178 | max_simul_links = mld_cap & EHT_ML_MLD_CAPA_MAX_NUM_SIM_LINKS_MASK; |
| 179 | - active_links = hapd->mld->num_links - 1; |
| 180 | + for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) |
| 181 | + if (hapd->mld_link_id != link_id && |
| 182 | + (hapd->mld->active_links & BIT(link_id))) |
| 183 | + active_links++; |
| 184 | |
| 185 | if (active_links > max_simul_links) { |
| 186 | wpa_printf(MSG_ERROR, |
| 187 | -- |
| 188 | 2.18.0 |
| 189 | |