From 7b45c2e6bca990e4b2e67022cc5da45bc4acca3f Mon Sep 17 00:00:00 2001 From: Andrei Otcheretianski Date: Mon, 22 May 2023 22:33:38 +0300 Subject: [PATCH] nl80211: Select frame TX frequency according to the transmitting link In MLO, multiple BSSs can transmit on different frequencies. Select link frequencies according to the transmitter address. Signed-off-by: Andrei Otcheretianski --- src/drivers/driver_nl80211.c | 37 ++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 228a6417d..fda215cce 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -4141,6 +4141,29 @@ static void nl80211_link_set_freq(struct i802_bss *bss, s8 link_id, int freq) } +static int nl80211_get_link_freq(struct i802_bss *bss, const u8 *addr, + bool bss_freq_debug) +{ + size_t i; + + for (i = 0; i < bss->n_links; i++) { + if (os_memcmp(bss->links[i].addr, addr, ETH_ALEN) == 0) { + wpa_printf(MSG_DEBUG, + "nl80211: Use link freq=%d for address " + MACSTR, + bss->links[i].freq, MAC2STR(addr)); + return bss->links[i].freq; + } + } + + if (bss_freq_debug) + wpa_printf(MSG_DEBUG, "nl80211: Use bss->freq=%d", + bss->flink->freq); + + return bss->flink->freq; +} + + static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data, size_t data_len, int noack, unsigned int freq, int no_cck, @@ -4185,13 +4208,15 @@ static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data, } if (drv->device_ap_sme && is_ap_interface(drv->nlmode)) { - if (freq == 0) { - wpa_printf(MSG_DEBUG, "nl80211: Use bss->freq=%d", - bss->flink->freq); - freq = bss->flink->freq; - } - if ((int) freq == bss->flink->freq) + unsigned int link_freq = nl80211_get_link_freq(bss, mgmt->sa, + !freq); + + if (!freq) + freq = link_freq; + + if (freq == link_freq) wait_time = 0; + goto send_frame_cmd; }