blob: cca2e9ad16612117bf126854c4f9b67c1c32c7dc [file] [log] [blame]
developer66e89bc2024-04-23 14:50:01 +08001From ec7d47b2566da59c52d995f5e404a1c00e746fe5 Mon Sep 17 00:00:00 2001
2From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Thu, 11 Apr 2024 18:16:38 +0800
4Subject: [PATCH 103/104] mtk: hostapd: make sure all links are set before
5 enabling beacon
6
7NL80211_CMD_NEW_BEACON will first be set, but we've modified mac80211 to
8disable this beacon. After that, hostapd will block
9NL80211_CMD_SET_BEACON until all links are setting up.
10(use NL80211_CMD_START_AP event to check if all expected links are enabled)
11
12Update: in wpa_driver_nl80211_set_ap(), send_and_recv() is used, implies
13that hostapd should already sync with driver, so don't need to use
14NL80211_CMD_START_AP event.
15
16This can make sure that the first beacon of each link includes the
17correct RNR and per-STA profile.
18
19Note that in NL80211_CMD_NEW_BEACON, we also set beacon interval to 0,
20which helps to bypass some mac80211 beacon active checks, e.g., during ACS.
21
developer66e89bc2024-04-23 14:50:01 +080022Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +080023---
24 hostapd/config_file.c | 2 ++
25 src/ap/ap_config.h | 2 ++
26 src/ap/beacon.c | 10 ++++++++++
27 src/ap/hostapd.c | 14 ++++++++++++++
28 src/ap/hostapd.h | 1 +
29 5 files changed, 29 insertions(+)
30
31diff --git a/hostapd/config_file.c b/hostapd/config_file.c
32index 2add62ca9..8abe1bc46 100644
33--- a/hostapd/config_file.c
34+++ b/hostapd/config_file.c
35@@ -5354,6 +5354,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
36 bss->mld_ap = !!atoi(pos);
37 } else if (os_strcmp(buf, "mld_primary") == 0) {
38 bss->mld_primary = !!atoi(pos);
39+ } else if (os_strcmp(buf, "mld_allowed_links") == 0) {
40+ bss->mld_allowed_links = atoi(pos);
41 } else if (os_strcmp(buf, "mld_addr") == 0) {
42 if (hwaddr_aton(pos, bss->mld_addr)) {
43 wpa_printf(MSG_ERROR, "Line %d: Invalid mld_addr",
44diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
45index 5192c1f07..0ea5a04e2 100644
46--- a/src/ap/ap_config.h
47+++ b/src/ap/ap_config.h
48@@ -968,6 +968,8 @@ struct hostapd_bss_config {
49
50 /* The AP is the primary AP of an AP MLD */
51 u8 mld_primary;
52+ /* Allowed link bitmap of the AP MLD to which the AP is affiliated */
53+ u16 mld_allowed_links;
54
55 /* The MLD ID to which the AP MLD is affiliated with */
56 u8 mld_id;
57diff --git a/src/ap/beacon.c b/src/ap/beacon.c
58index a5c46b067..a5c9dd87e 100644
59--- a/src/ap/beacon.c
60+++ b/src/ap/beacon.c
61@@ -2164,6 +2164,12 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
62 os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
63 head->u.beacon.beacon_int =
64 host_to_le16(hapd->iconf->beacon_int);
65+ /* if MLD AP hasn't finished setting up all links, also set beacon interval
66+ * to 0. This allows mac80211 to bypass some beacon active checks, for
67+ * example, when doing ACS
68+ */
69+ if (hapd->conf->mld_ap && !hapd->mld->started)
70+ head->u.beacon.beacon_int = host_to_le16(0);
71
72 /* hardware or low-level driver will setup seq_ctrl and timestamp */
73 capab_info = hostapd_own_capab_info(hapd);
74@@ -2553,6 +2559,10 @@ static int __ieee802_11_set_beacon(struct hostapd_data *hapd)
75 int res, ret = -1, i;
76 struct hostapd_hw_modes *mode;
77
78+ /* skip setting beacon if other links are not started yet */
79+ if (hapd->conf->mld_ap && !hapd->mld->started && hapd->beacon_set_done)
80+ return 0;
81+
82 if (!hapd->drv_priv) {
83 wpa_printf(MSG_ERROR, "Interface is disabled");
84 return -1;
85diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
86index 3d3359291..c31e0badd 100644
87--- a/src/ap/hostapd.c
88+++ b/src/ap/hostapd.c
89@@ -1314,6 +1314,20 @@ static int hostapd_start_beacon(struct hostapd_data *hapd,
90 if (!conf->start_disabled && ieee802_11_set_beacon(hapd) < 0)
91 return -1;
92
93+ if (hapd->conf->mld_ap && !hapd->mld->started) {
94+ struct hostapd_data *p_hapd;
95+ u16 valid_links = 0;
96+
97+ for_each_mld_link(p_hapd, hapd)
98+ valid_links |= BIT(p_hapd->mld_link_id);
99+
100+ if (valid_links == hapd->conf->mld_allowed_links ||
101+ !hapd->conf->mld_allowed_links) {
102+ hapd->mld->started = 1;
103+ ieee802_11_set_beacon(hapd);
104+ }
105+ }
106+
107 if (flush_old_stations && !conf->start_disabled &&
108 conf->broadcast_deauth) {
109 u8 addr[ETH_ALEN];
110diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
111index 5b37be87b..83636649f 100644
112--- a/src/ap/hostapd.h
113+++ b/src/ap/hostapd.h
114@@ -537,6 +537,7 @@ struct hostapd_mld {
115 * freed when num_links is 0.
116 */
117 u8 refcount;
118+ bool started;
119
120 struct hostapd_data *fbss;
121 struct dl_list links; /* List head of all affiliated links */
122--
1232.39.2
124