developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From 8df808e1c82be7ce9b00937bb14a2536824f16d2 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 19 Jan 2024 14:11:05 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 069/126] mtk: hostapd: Handle DFS radar detection in MLO |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | To handle DFS CAC in MLO, we add the following changes: |
| 7 | 1. Add link id info to radar detect cmd for the kernel to use the correct link. |
| 8 | 2. Block RNR IE for disabled iface. (the EID len would be wrong without it) |
| 9 | 3. Only flush the old stations for the first BSS; otherwise, after DFS CAC |
| 10 | stations would be flushed again. |
| 11 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 12 | Add background radar handling |
| 13 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 14 | The logic has changed here, so rebase it. |
| 15 | Avoid flushing old stations for non-first BSS so that the stations |
| 16 | can remain connected when non-first BSS is added via link add or it |
| 17 | completes CAC. |
| 18 | Also, handle the case when the first BSS requires CAC. |
| 19 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 20 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 21 | --- |
| 22 | src/ap/ap_drv_ops.c | 9 +++++++++ |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 23 | src/ap/hostapd.c | 11 ++++++++++- |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 24 | src/ap/ieee802_11.c | 3 +++ |
| 25 | src/drivers/driver_nl80211.c | 18 ++++++++++++++++++ |
| 26 | src/drivers/driver_nl80211.h | 1 + |
| 27 | src/drivers/driver_nl80211_event.c | 3 ++- |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 28 | 6 files changed, 43 insertions(+), 2 deletions(-) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 29 | |
| 30 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 31 | index 48c2801da..f51d5be8e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 32 | --- a/src/ap/ap_drv_ops.c |
| 33 | +++ b/src/ap/ap_drv_ops.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 34 | @@ -1041,6 +1041,15 @@ int hostapd_start_dfs_cac(struct hostapd_iface *iface, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 35 | return -1; |
| 36 | } |
| 37 | data.radar_background = radar_background; |
| 38 | + data.link_id = -1; |
| 39 | + |
| 40 | +#ifdef CONFIG_IEEE80211BE |
| 41 | + if (hapd->conf->mld_ap) { |
| 42 | + data.link_id = hapd->mld_link_id; |
| 43 | + wpa_printf(MSG_DEBUG, |
| 44 | + "hostapd_start_dfs_cac: link_id=%d", data.link_id); |
| 45 | + } |
| 46 | +#endif /* CONFIG_IEEE80211BE */ |
| 47 | |
| 48 | res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data); |
| 49 | if (!res) { |
| 50 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 51 | index eefd4c5d3..93c164177 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 52 | --- a/src/ap/hostapd.c |
| 53 | +++ b/src/ap/hostapd.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 54 | @@ -1420,9 +1420,18 @@ int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon) |
| 55 | u8 if_addr[ETH_ALEN]; |
| 56 | int flush_old_stations = 1; |
| 57 | |
| 58 | - if (!hostapd_mld_is_first_bss(hapd)) |
| 59 | + if (!hostapd_mld_is_first_bss(hapd)) { |
| 60 | + /* Only flush old stations when setting up the first BSS for the MLD. */ |
| 61 | + flush_old_stations = 0; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 62 | wpa_printf(MSG_DEBUG, |
| 63 | "MLD: %s: Setting non-first BSS", __func__); |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 64 | + } else if (hapd->conf->mld_ap && |
| 65 | + hapd->iface->state == HAPD_IFACE_DFS) { |
| 66 | + /* Also, avoid flushing old STA when the first BSS of the MLD requires CAC. */ |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 67 | + flush_old_stations = 0; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 68 | + wpa_printf(MSG_DEBUG, |
| 69 | + "MLD: %s: Setting first BSS after CAC complete", __func__); |
| 70 | + } |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 71 | |
| 72 | wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)", |
| 73 | __func__, hapd, conf->iface, first); |
| 74 | diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 75 | index b87fae929..c6676b754 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 76 | --- a/src/ap/ieee802_11.c |
| 77 | +++ b/src/ap/ieee802_11.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 78 | @@ -7910,6 +7910,9 @@ u8 * hostapd_eid_rnr_colocation(struct hostapd_data *hapd, u8 *eid, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 79 | !is_6ghz_op_class(iface->conf->op_class)) |
| 80 | continue; |
| 81 | |
| 82 | + if (!iface->bss[0]->started) |
| 83 | + continue; |
| 84 | + |
| 85 | eid = hostapd_eid_rnr_iface(iface->bss[0], hapd, eid, |
| 86 | current_len, NULL, false); |
| 87 | } |
| 88 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 89 | index f6080f160..dec358fba 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 90 | --- a/src/drivers/driver_nl80211.c |
| 91 | +++ b/src/drivers/driver_nl80211.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 92 | @@ -10587,6 +10587,24 @@ static int nl80211_start_radar_detection(void *priv, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 93 | return -1; |
| 94 | } |
| 95 | |
| 96 | + if (freq->link_id != NL80211_DRV_LINK_ID_NA) { |
| 97 | + wpa_printf(MSG_DEBUG, "nl80211: Set link_id=%u for radar detect", |
| 98 | + freq->link_id); |
| 99 | + |
| 100 | + if (nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, freq->link_id)) { |
| 101 | + nlmsg_free(msg); |
| 102 | + return -ENOBUFS; |
| 103 | + } |
| 104 | + |
| 105 | + if (freq->radar_background) { |
| 106 | + struct i802_link *link = nl80211_get_link(bss, freq->link_id); |
| 107 | + |
| 108 | + link->background_freq = freq->freq; |
| 109 | + } else { |
| 110 | + nl80211_link_set_freq(bss, freq->link_id, freq->freq); |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | ret = send_and_recv_cmd(drv, msg); |
| 115 | if (ret == 0) |
| 116 | return 0; |
| 117 | diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h |
| 118 | index 9866c221c..a0a62e536 100644 |
| 119 | --- a/src/drivers/driver_nl80211.h |
| 120 | +++ b/src/drivers/driver_nl80211.h |
| 121 | @@ -56,6 +56,7 @@ struct i802_link { |
| 122 | unsigned int beacon_set:1; |
| 123 | |
| 124 | int freq; |
| 125 | + int background_freq; |
| 126 | int bandwidth; |
| 127 | u8 addr[ETH_ALEN]; |
| 128 | void *ctx; |
| 129 | diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 130 | index 73582aeb0..7f5a3d892 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 131 | --- a/src/drivers/driver_nl80211_event.c |
| 132 | +++ b/src/drivers/driver_nl80211_event.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 133 | @@ -1638,7 +1638,8 @@ nl80211_get_link_id_by_freq(struct i802_bss *bss, unsigned int freq) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 134 | unsigned int i; |
| 135 | |
| 136 | for_each_link(bss->valid_links, i) { |
| 137 | - if ((unsigned int) bss->links[i].freq == freq) |
| 138 | + if ((unsigned int) bss->links[i].freq == freq || |
| 139 | + (unsigned int) bss->links[i].background_freq == freq) |
| 140 | return i; |
| 141 | } |
| 142 | |
| 143 | -- |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 144 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 145 | |