blob: 8cdcaf5b88f5467f62e3a2a0351e0350c2a44d66 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 8df808e1c82be7ce9b00937bb14a2536824f16d2 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Fri, 19 Jan 2024 14:11:05 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 069/126] mtk: hostapd: Handle DFS radar detection in MLO
developer66e89bc2024-04-23 14:50:01 +08005
6To handle DFS CAC in MLO, we add the following changes:
71. Add link id info to radar detect cmd for the kernel to use the correct link.
82. Block RNR IE for disabled iface. (the EID len would be wrong without it)
93. Only flush the old stations for the first BSS; otherwise, after DFS CAC
10stations would be flushed again.
11
developer66e89bc2024-04-23 14:50:01 +080012Add background radar handling
13
developer05f3b2b2024-08-19 19:17:34 +080014The logic has changed here, so rebase it.
15Avoid flushing old stations for non-first BSS so that the stations
16can remain connected when non-first BSS is added via link add or it
17completes CAC.
18Also, handle the case when the first BSS requires CAC.
19
developer66e89bc2024-04-23 14:50:01 +080020Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
21---
22 src/ap/ap_drv_ops.c | 9 +++++++++
developer05f3b2b2024-08-19 19:17:34 +080023 src/ap/hostapd.c | 11 ++++++++++-
developer66e89bc2024-04-23 14:50:01 +080024 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 ++-
developer05f3b2b2024-08-19 19:17:34 +080028 6 files changed, 43 insertions(+), 2 deletions(-)
developer66e89bc2024-04-23 14:50:01 +080029
30diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
developer05f3b2b2024-08-19 19:17:34 +080031index 48c2801da..f51d5be8e 100644
developer66e89bc2024-04-23 14:50:01 +080032--- a/src/ap/ap_drv_ops.c
33+++ b/src/ap/ap_drv_ops.c
developer05f3b2b2024-08-19 19:17:34 +080034@@ -1041,6 +1041,15 @@ int hostapd_start_dfs_cac(struct hostapd_iface *iface,
developer66e89bc2024-04-23 14:50:01 +080035 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) {
50diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
developer05f3b2b2024-08-19 19:17:34 +080051index eefd4c5d3..93c164177 100644
developer66e89bc2024-04-23 14:50:01 +080052--- a/src/ap/hostapd.c
53+++ b/src/ap/hostapd.c
developer05f3b2b2024-08-19 19:17:34 +080054@@ -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;
developer66e89bc2024-04-23 14:50:01 +080062 wpa_printf(MSG_DEBUG,
63 "MLD: %s: Setting non-first BSS", __func__);
developer05f3b2b2024-08-19 19:17:34 +080064+ } 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. */
developer66e89bc2024-04-23 14:50:01 +080067+ flush_old_stations = 0;
developer05f3b2b2024-08-19 19:17:34 +080068+ wpa_printf(MSG_DEBUG,
69+ "MLD: %s: Setting first BSS after CAC complete", __func__);
70+ }
developer66e89bc2024-04-23 14:50:01 +080071
72 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)",
73 __func__, hapd, conf->iface, first);
74diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
developer05f3b2b2024-08-19 19:17:34 +080075index b87fae929..c6676b754 100644
developer66e89bc2024-04-23 14:50:01 +080076--- a/src/ap/ieee802_11.c
77+++ b/src/ap/ieee802_11.c
developer05f3b2b2024-08-19 19:17:34 +080078@@ -7910,6 +7910,9 @@ u8 * hostapd_eid_rnr_colocation(struct hostapd_data *hapd, u8 *eid,
developer66e89bc2024-04-23 14:50:01 +080079 !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 }
88diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
developer05f3b2b2024-08-19 19:17:34 +080089index f6080f160..dec358fba 100644
developer66e89bc2024-04-23 14:50:01 +080090--- a/src/drivers/driver_nl80211.c
91+++ b/src/drivers/driver_nl80211.c
developer05f3b2b2024-08-19 19:17:34 +080092@@ -10587,6 +10587,24 @@ static int nl80211_start_radar_detection(void *priv,
developer66e89bc2024-04-23 14:50:01 +080093 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;
117diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
118index 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;
129diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
developer05f3b2b2024-08-19 19:17:34 +0800130index 73582aeb0..7f5a3d892 100644
developer66e89bc2024-04-23 14:50:01 +0800131--- a/src/drivers/driver_nl80211_event.c
132+++ b/src/drivers/driver_nl80211_event.c
developer05f3b2b2024-08-19 19:17:34 +0800133@@ -1638,7 +1638,8 @@ nl80211_get_link_id_by_freq(struct i802_bss *bss, unsigned int freq)
developer66e89bc2024-04-23 14:50:01 +0800134 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--
developer05f3b2b2024-08-19 19:17:34 +08001442.18.0
developer66e89bc2024-04-23 14:50:01 +0800145