blob: fab4ef824f7d237622374b988ea4c2b33ee8aa6c [file] [log] [blame]
developer66e89bc2024-04-23 14:50:01 +08001From a0cbcd04400458bf7f4f4086beecbf8db6800c36 Mon Sep 17 00:00:00 2001
2From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Fri, 19 Jan 2024 14:11:05 +0800
4Subject: [PATCH 089/104] mtk: hostapd: Handle DFS radar detection in MLO
5
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
12CR-Id: WCNCR00274293
13Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
14Change-Id: Idbeba92aeadd8b34f61202e4c3df52bae19d9b73
15
16Add background radar handling
17
18CR-Id: WCNCR00274293
19Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
20---
21 src/ap/ap_drv_ops.c | 9 +++++++++
22 src/ap/hostapd.c | 3 +++
23 src/ap/ieee802_11.c | 3 +++
24 src/drivers/driver_nl80211.c | 18 ++++++++++++++++++
25 src/drivers/driver_nl80211.h | 1 +
26 src/drivers/driver_nl80211_event.c | 3 ++-
27 6 files changed, 36 insertions(+), 1 deletion(-)
28
29diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
30index ac7ef00cd..9357ce7b6 100644
31--- a/src/ap/ap_drv_ops.c
32+++ b/src/ap/ap_drv_ops.c
33@@ -1012,6 +1012,15 @@ int hostapd_start_dfs_cac(struct hostapd_iface *iface,
34 return -1;
35 }
36 data.radar_background = radar_background;
37+ data.link_id = -1;
38+
39+#ifdef CONFIG_IEEE80211BE
40+ if (hapd->conf->mld_ap) {
41+ data.link_id = hapd->mld_link_id;
42+ wpa_printf(MSG_DEBUG,
43+ "hostapd_start_dfs_cac: link_id=%d", data.link_id);
44+ }
45+#endif /* CONFIG_IEEE80211BE */
46
47 res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data);
48 if (!res) {
49diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
50index f8b05de45..8e3f0b281 100644
51--- a/src/ap/hostapd.c
52+++ b/src/ap/hostapd.c
53@@ -1371,6 +1371,9 @@ int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon)
54 if (!hostapd_mld_is_first_bss(hapd))
55 wpa_printf(MSG_DEBUG,
56 "MLD: %s: Setting non-first BSS", __func__);
57+ else
58+ /* Only flush old stations when setting up first BSS for MLD. */
59+ flush_old_stations = 0;
60
61 wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)",
62 __func__, hapd, conf->iface, first);
63diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
64index 0f357d786..fe0a5bce4 100644
65--- a/src/ap/ieee802_11.c
66+++ b/src/ap/ieee802_11.c
67@@ -7852,6 +7852,9 @@ u8 *hostapd_eid_rnr_colocation(struct hostapd_data *hapd, u8 *eid,
68 !is_6ghz_op_class(iface->conf->op_class))
69 continue;
70
71+ if (!iface->bss[0]->started)
72+ continue;
73+
74 eid = hostapd_eid_rnr_iface(iface->bss[0], hapd, eid,
75 current_len, NULL, false);
76 }
77diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
78index 17aaa16a8..ad73b4ac1 100644
79--- a/src/drivers/driver_nl80211.c
80+++ b/src/drivers/driver_nl80211.c
81@@ -10589,6 +10589,24 @@ static int nl80211_start_radar_detection(void *priv,
82 return -1;
83 }
84
85+ if (freq->link_id != NL80211_DRV_LINK_ID_NA) {
86+ wpa_printf(MSG_DEBUG, "nl80211: Set link_id=%u for radar detect",
87+ freq->link_id);
88+
89+ if (nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, freq->link_id)) {
90+ nlmsg_free(msg);
91+ return -ENOBUFS;
92+ }
93+
94+ if (freq->radar_background) {
95+ struct i802_link *link = nl80211_get_link(bss, freq->link_id);
96+
97+ link->background_freq = freq->freq;
98+ } else {
99+ nl80211_link_set_freq(bss, freq->link_id, freq->freq);
100+ }
101+ }
102+
103 ret = send_and_recv_cmd(drv, msg);
104 if (ret == 0)
105 return 0;
106diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
107index 9866c221c..a0a62e536 100644
108--- a/src/drivers/driver_nl80211.h
109+++ b/src/drivers/driver_nl80211.h
110@@ -56,6 +56,7 @@ struct i802_link {
111 unsigned int beacon_set:1;
112
113 int freq;
114+ int background_freq;
115 int bandwidth;
116 u8 addr[ETH_ALEN];
117 void *ctx;
118diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
119index 90084356d..03bad4bb3 100644
120--- a/src/drivers/driver_nl80211_event.c
121+++ b/src/drivers/driver_nl80211_event.c
122@@ -1631,7 +1631,8 @@ nl80211_get_link_id_by_freq(struct i802_bss *bss, unsigned int freq)
123 unsigned int i;
124
125 for_each_link(bss->valid_links, i) {
126- if ((unsigned int) bss->links[i].freq == freq)
127+ if ((unsigned int) bss->links[i].freq == freq ||
128+ (unsigned int) bss->links[i].background_freq == freq)
129 return i;
130 }
131
132--
1332.39.2
134