blob: 6daae7e3363d5c23812b3a6f6ed63e25ac81744f [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 3443edc9c46258a0ce8a11ca579f7be29028e363 Mon Sep 17 00:00:00 2001
2From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Thu, 27 Jun 2024 13:44:00 +0800
4Subject: [PATCH 109/126] mtk: hostapd: rework radar event handling
5
6Specify the ifindex for the radar event in the sinlge wiphy model.
7This resolves the following MBSS MLD radar event issue.
8For example, if the topology is:
9MLD 1 (2G, 6G)
10MLD 2 (2G, 5G)
112G legacy AP
125G legacy AP
136G legacy AP
14Without specifying the ifindex, hostapd will handle the radar event
15with the drv->ctx (MLD 1 2G hapd).
16However, in this case, MLD 1 has no 5G link, so the radar event will
17be ignored.
18
19Depends-On: I41d67b4d6f4610694f3830fdd0154fd392bc7c1f
20
21Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
22---
23 src/drivers/driver_nl80211_event.c | 42 +++++++++++++++++++-----------
24 1 file changed, 27 insertions(+), 15 deletions(-)
25
26diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
27index 635401564..e95593a5b 100644
28--- a/src/drivers/driver_nl80211_event.c
29+++ b/src/drivers/driver_nl80211_event.c
30@@ -2464,11 +2464,23 @@ static void nl80211_connect_failed_event(struct wpa_driver_nl80211_data *drv,
31 static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
32 struct nlattr **tb)
33 {
34+ struct i802_bss *bss;
35 union wpa_event_data data;
36 enum nl80211_radar_event event_type;
37+ int ifidx;
38+
39+ if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT] ||
40+ !tb[NL80211_ATTR_IFINDEX])
41+ return;
42
43- if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT])
44+ ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]);
45+ bss = get_bss_ifindex(drv, ifidx);
46+ if (!bss) {
47+ wpa_printf(MSG_ERROR,
48+ "nl80211: Unknown ifindex (%d) for radar event, ignoring",
49+ ifidx);
50 return;
51+ }
52
53 os_memset(&data, 0, sizeof(data));
54 data.dfs_event.link_id = NL80211_DRV_LINK_ID_NA;
55@@ -2480,8 +2492,7 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
56 nla_get_u8(tb[NL80211_ATTR_MLO_LINK_ID]);
57 } else if (data.dfs_event.freq) {
58 data.dfs_event.link_id =
59- nl80211_get_link_id_by_freq(drv->first_bss,
60- data.dfs_event.freq);
61+ nl80211_get_link_id_by_freq(bss, data.dfs_event.freq);
62 }
63
64 /* Check HT params */
65@@ -2515,43 +2526,44 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
66 data.dfs_event.cf2 = nla_get_u32(tb[NL80211_ATTR_CENTER_FREQ2]);
67
68 wpa_printf(MSG_DEBUG,
69- "nl80211: DFS event on freq %d MHz, ht: %d, offset: %d, width: %d, cf1: %dMHz, cf2: %dMHz, link_id=%d",
70+ "nl80211: DFS event on freq %d MHz, ht: %d, offset: %d, width: %d, "
71+ "cf1: %dMHz, cf2: %dMHz, ifindex=%d, link_id=%d",
72 data.dfs_event.freq, data.dfs_event.ht_enabled,
73 data.dfs_event.chan_offset, data.dfs_event.chan_width,
74- data.dfs_event.cf1, data.dfs_event.cf2,
75+ data.dfs_event.cf1, data.dfs_event.cf2, ifidx,
76 data.dfs_event.link_id);
77
78 switch (event_type) {
79 case NL80211_RADAR_DETECTED:
80- wpa_supplicant_event(drv->ctx, EVENT_DFS_RADAR_DETECTED, &data);
81+ wpa_supplicant_event(bss->ctx, EVENT_DFS_RADAR_DETECTED, &data);
82 break;
83 case NL80211_RADAR_CAC_FINISHED:
84- wpa_supplicant_event(drv->ctx, EVENT_DFS_CAC_FINISHED, &data);
85+ wpa_supplicant_event(bss->ctx, EVENT_DFS_CAC_FINISHED, &data);
86 break;
87 case NL80211_RADAR_CAC_ABORTED:
88- wpa_supplicant_event(drv->ctx, EVENT_DFS_CAC_ABORTED, &data);
89+ wpa_supplicant_event(bss->ctx, EVENT_DFS_CAC_ABORTED, &data);
90 break;
91 case NL80211_RADAR_NOP_FINISHED:
92- wpa_supplicant_event(drv->ctx, EVENT_DFS_NOP_FINISHED, &data);
93+ wpa_supplicant_event(bss->ctx, EVENT_DFS_NOP_FINISHED, &data);
94 break;
95 case NL80211_RADAR_PRE_CAC_EXPIRED:
96- wpa_supplicant_event(drv->ctx, EVENT_DFS_PRE_CAC_EXPIRED,
97+ wpa_supplicant_event(bss->ctx, EVENT_DFS_PRE_CAC_EXPIRED,
98 &data);
99 break;
100 case NL80211_RADAR_CAC_STARTED:
101- wpa_supplicant_event(drv->ctx, EVENT_DFS_CAC_STARTED, &data);
102+ wpa_supplicant_event(bss->ctx, EVENT_DFS_CAC_STARTED, &data);
103 break;
104 case NL80211_RADAR_BACKGROUND_CHAN_UPDATE:
105- wpa_supplicant_event(drv->ctx, EVENT_DFS_BACKGROUND_CHAN_UPDATE, &data);
106+ wpa_supplicant_event(bss->ctx, EVENT_DFS_BACKGROUND_CHAN_UPDATE, &data);
107 break;
108 case NL80211_RADAR_BACKGROUND_CHAN_EXPAND:
109- wpa_supplicant_event(drv->ctx, EVENT_DFS_BACKGROUND_CHAN_EXPAND, &data);
110+ wpa_supplicant_event(bss->ctx, EVENT_DFS_BACKGROUND_CHAN_EXPAND, &data);
111 break;
112 case NL80211_RADAR_STA_CAC_SKIPPED:
113- wpa_supplicant_event(drv->ctx, EVENT_DFS_STA_CAC_SKIPPED, &data);
114+ wpa_supplicant_event(bss->ctx, EVENT_DFS_STA_CAC_SKIPPED, &data);
115 break;
116 case NL80211_RADAR_STA_CAC_EXPIRED:
117- wpa_supplicant_event(drv->ctx, EVENT_DFS_STA_CAC_EXPIRED, &data);
118+ wpa_supplicant_event(bss->ctx, EVENT_DFS_STA_CAC_EXPIRED, &data);
119 break;
120 default:
121 wpa_printf(MSG_DEBUG, "nl80211: Unknown radar event %d "
122--
1232.18.0
124