blob: 9f5346e8c7d903bb83acf2b89007d48699dfb82e [file] [log] [blame]
developer617abbd2024-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
22CR-Id: WCNCR00238098
23Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
24Change-Id: I99320f7802041dc7d8e780041bb686ce3700c0b6
25---
26 hostapd/config_file.c | 2 ++
27 src/ap/ap_config.h | 2 ++
28 src/ap/beacon.c | 10 ++++++++++
29 src/ap/hostapd.c | 14 ++++++++++++++
30 src/ap/hostapd.h | 1 +
31 5 files changed, 29 insertions(+)
32
33diff --git a/hostapd/config_file.c b/hostapd/config_file.c
34index 2add62ca9..8abe1bc46 100644
35--- a/hostapd/config_file.c
36+++ b/hostapd/config_file.c
37@@ -5354,6 +5354,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
38 bss->mld_ap = !!atoi(pos);
39 } else if (os_strcmp(buf, "mld_primary") == 0) {
40 bss->mld_primary = !!atoi(pos);
41+ } else if (os_strcmp(buf, "mld_allowed_links") == 0) {
42+ bss->mld_allowed_links = atoi(pos);
43 } else if (os_strcmp(buf, "mld_addr") == 0) {
44 if (hwaddr_aton(pos, bss->mld_addr)) {
45 wpa_printf(MSG_ERROR, "Line %d: Invalid mld_addr",
46diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
47index 5192c1f07..0ea5a04e2 100644
48--- a/src/ap/ap_config.h
49+++ b/src/ap/ap_config.h
50@@ -968,6 +968,8 @@ struct hostapd_bss_config {
51
52 /* The AP is the primary AP of an AP MLD */
53 u8 mld_primary;
54+ /* Allowed link bitmap of the AP MLD to which the AP is affiliated */
55+ u16 mld_allowed_links;
56
57 /* The MLD ID to which the AP MLD is affiliated with */
58 u8 mld_id;
59diff --git a/src/ap/beacon.c b/src/ap/beacon.c
60index a5c46b067..a5c9dd87e 100644
61--- a/src/ap/beacon.c
62+++ b/src/ap/beacon.c
63@@ -2164,6 +2164,12 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
64 os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
65 head->u.beacon.beacon_int =
66 host_to_le16(hapd->iconf->beacon_int);
67+ /* if MLD AP hasn't finished setting up all links, also set beacon interval
68+ * to 0. This allows mac80211 to bypass some beacon active checks, for
69+ * example, when doing ACS
70+ */
71+ if (hapd->conf->mld_ap && !hapd->mld->started)
72+ head->u.beacon.beacon_int = host_to_le16(0);
73
74 /* hardware or low-level driver will setup seq_ctrl and timestamp */
75 capab_info = hostapd_own_capab_info(hapd);
76@@ -2553,6 +2559,10 @@ static int __ieee802_11_set_beacon(struct hostapd_data *hapd)
77 int res, ret = -1, i;
78 struct hostapd_hw_modes *mode;
79
80+ /* skip setting beacon if other links are not started yet */
81+ if (hapd->conf->mld_ap && !hapd->mld->started && hapd->beacon_set_done)
82+ return 0;
83+
84 if (!hapd->drv_priv) {
85 wpa_printf(MSG_ERROR, "Interface is disabled");
86 return -1;
87diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
88index 3d3359291..c31e0badd 100644
89--- a/src/ap/hostapd.c
90+++ b/src/ap/hostapd.c
91@@ -1314,6 +1314,20 @@ static int hostapd_start_beacon(struct hostapd_data *hapd,
92 if (!conf->start_disabled && ieee802_11_set_beacon(hapd) < 0)
93 return -1;
94
95+ if (hapd->conf->mld_ap && !hapd->mld->started) {
96+ struct hostapd_data *p_hapd;
97+ u16 valid_links = 0;
98+
99+ for_each_mld_link(p_hapd, hapd)
100+ valid_links |= BIT(p_hapd->mld_link_id);
101+
102+ if (valid_links == hapd->conf->mld_allowed_links ||
103+ !hapd->conf->mld_allowed_links) {
104+ hapd->mld->started = 1;
105+ ieee802_11_set_beacon(hapd);
106+ }
107+ }
108+
109 if (flush_old_stations && !conf->start_disabled &&
110 conf->broadcast_deauth) {
111 u8 addr[ETH_ALEN];
112diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
113index 5b37be87b..83636649f 100644
114--- a/src/ap/hostapd.h
115+++ b/src/ap/hostapd.h
116@@ -537,6 +537,7 @@ struct hostapd_mld {
117 * freed when num_links is 0.
118 */
119 u8 refcount;
120+ bool started;
121
122 struct hostapd_data *fbss;
123 struct dl_list links; /* List head of all affiliated links */
124--
1252.39.2
126