blob: 6daae7e3363d5c23812b3a6f6ed63e25ac81744f [file] [log] [blame]
From 3443edc9c46258a0ce8a11ca579f7be29028e363 Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Thu, 27 Jun 2024 13:44:00 +0800
Subject: [PATCH 109/126] mtk: hostapd: rework radar event handling
Specify the ifindex for the radar event in the sinlge wiphy model.
This resolves the following MBSS MLD radar event issue.
For example, if the topology is:
MLD 1 (2G, 6G)
MLD 2 (2G, 5G)
2G legacy AP
5G legacy AP
6G legacy AP
Without specifying the ifindex, hostapd will handle the radar event
with the drv->ctx (MLD 1 2G hapd).
However, in this case, MLD 1 has no 5G link, so the radar event will
be ignored.
Depends-On: I41d67b4d6f4610694f3830fdd0154fd392bc7c1f
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
src/drivers/driver_nl80211_event.c | 42 +++++++++++++++++++-----------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
index 635401564..e95593a5b 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -2464,11 +2464,23 @@ static void nl80211_connect_failed_event(struct wpa_driver_nl80211_data *drv,
static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
struct nlattr **tb)
{
+ struct i802_bss *bss;
union wpa_event_data data;
enum nl80211_radar_event event_type;
+ int ifidx;
+
+ if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT] ||
+ !tb[NL80211_ATTR_IFINDEX])
+ return;
- if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT])
+ ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]);
+ bss = get_bss_ifindex(drv, ifidx);
+ if (!bss) {
+ wpa_printf(MSG_ERROR,
+ "nl80211: Unknown ifindex (%d) for radar event, ignoring",
+ ifidx);
return;
+ }
os_memset(&data, 0, sizeof(data));
data.dfs_event.link_id = NL80211_DRV_LINK_ID_NA;
@@ -2480,8 +2492,7 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
nla_get_u8(tb[NL80211_ATTR_MLO_LINK_ID]);
} else if (data.dfs_event.freq) {
data.dfs_event.link_id =
- nl80211_get_link_id_by_freq(drv->first_bss,
- data.dfs_event.freq);
+ nl80211_get_link_id_by_freq(bss, data.dfs_event.freq);
}
/* Check HT params */
@@ -2515,43 +2526,44 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
data.dfs_event.cf2 = nla_get_u32(tb[NL80211_ATTR_CENTER_FREQ2]);
wpa_printf(MSG_DEBUG,
- "nl80211: DFS event on freq %d MHz, ht: %d, offset: %d, width: %d, cf1: %dMHz, cf2: %dMHz, link_id=%d",
+ "nl80211: DFS event on freq %d MHz, ht: %d, offset: %d, width: %d, "
+ "cf1: %dMHz, cf2: %dMHz, ifindex=%d, link_id=%d",
data.dfs_event.freq, data.dfs_event.ht_enabled,
data.dfs_event.chan_offset, data.dfs_event.chan_width,
- data.dfs_event.cf1, data.dfs_event.cf2,
+ data.dfs_event.cf1, data.dfs_event.cf2, ifidx,
data.dfs_event.link_id);
switch (event_type) {
case NL80211_RADAR_DETECTED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_RADAR_DETECTED, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_RADAR_DETECTED, &data);
break;
case NL80211_RADAR_CAC_FINISHED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_CAC_FINISHED, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_CAC_FINISHED, &data);
break;
case NL80211_RADAR_CAC_ABORTED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_CAC_ABORTED, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_CAC_ABORTED, &data);
break;
case NL80211_RADAR_NOP_FINISHED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_NOP_FINISHED, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_NOP_FINISHED, &data);
break;
case NL80211_RADAR_PRE_CAC_EXPIRED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_PRE_CAC_EXPIRED,
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_PRE_CAC_EXPIRED,
&data);
break;
case NL80211_RADAR_CAC_STARTED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_CAC_STARTED, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_CAC_STARTED, &data);
break;
case NL80211_RADAR_BACKGROUND_CHAN_UPDATE:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_BACKGROUND_CHAN_UPDATE, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_BACKGROUND_CHAN_UPDATE, &data);
break;
case NL80211_RADAR_BACKGROUND_CHAN_EXPAND:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_BACKGROUND_CHAN_EXPAND, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_BACKGROUND_CHAN_EXPAND, &data);
break;
case NL80211_RADAR_STA_CAC_SKIPPED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_STA_CAC_SKIPPED, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_STA_CAC_SKIPPED, &data);
break;
case NL80211_RADAR_STA_CAC_EXPIRED:
- wpa_supplicant_event(drv->ctx, EVENT_DFS_STA_CAC_EXPIRED, &data);
+ wpa_supplicant_event(bss->ctx, EVENT_DFS_STA_CAC_EXPIRED, &data);
break;
default:
wpa_printf(MSG_DEBUG, "nl80211: Unknown radar event %d "
--
2.18.0