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