blob: 6e58fad71adb9054798d435ffe618b5e7677c77d [file] [log] [blame]
From 934ce986f46bbbb7d2b76e4ccfb7acaf76a9e2a7 Mon Sep 17 00:00:00 2001
From: Michael-CY Lee <michael-cy.lee@mediatek.com>
Date: Wed, 6 Mar 2024 15:01:33 +0800
Subject: [PATCH 68/69] mtk: wpa_supplicant: add 'mld_allowed_phy'
configuration option for MLD STA
A new configuration option named 'mld_allowed_phy' is added for MLD STA.
This option indicates the bitmap of allowed phy for MLO connection.
Note that setting 'mld_allowed_phy' to 0 makes no phy allowed for MLO.
In other word, the STA becomes a legacy STA.
CR-Id: WCNCR00289305
Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
Change-Id: I5ad15d3748c6fef476aa067cc4901157a96f8804
---
wpa_supplicant/config.c | 1 +
wpa_supplicant/config.h | 1 +
wpa_supplicant/config_file.c | 2 ++
wpa_supplicant/sme.c | 18 ++++++++++++++++++
4 files changed, 22 insertions(+)
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 7bb57e2ab..d3c75ee94 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -5680,6 +5680,7 @@ static const struct global_parse_data global_fields[] = {
#endif /* CONFIG_PASN */
#ifdef CONFIG_TESTING_OPTIONS
{ INT_RANGE(mld_force_single_link, 0, 1), 0 },
+ { INT_RANGE(mld_allowed_phy, 0, 7), 0 },
{ INT_RANGE(mld_connect_band_pref, 0, MLD_CONNECT_BAND_PREF_MAX), 0 },
{ FUNC(mld_connect_bssid_pref), 0 },
#endif /* CONFIG_TESTING_OPTIONS */
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 8981305c2..c0164fa76 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -1800,6 +1800,7 @@ struct wpa_config {
u8 mld_connect_bssid_pref[ETH_ALEN];
int mld_force_single_link;
+ u8 mld_allowed_phy; /* bitmap of allowed phy for MLO connection */
#endif /* CONFIG_TESTING_OPTIONS */
};
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 7a3ed6373..875d00bb4 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -1622,6 +1622,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
#ifdef CONFIG_TESTING_OPTIONS
if (config->mld_force_single_link)
fprintf(f, "mld_force_single_link=1\n");
+ if (config->mld_allowed_phy)
+ fprintf(f, "mld_allowed_phy=%u\n", config->mld_allowed_phy);
if (config->mld_connect_band_pref != MLD_CONNECT_BAND_PREF_AUTO)
fprintf(f, "mld_connect_band_pref=%d\n",
config->mld_connect_band_pref);
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 5b69812b5..ef258fadc 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -517,6 +517,16 @@ out:
}
+#ifdef CONFIG_TESTING_OPTIONS
+static bool check_mld_allowed_phy(struct wpa_supplicant *wpa_s, int freq)
+{
+ return ((wpa_s->conf->mld_allowed_phy & BIT(0)) && IS_2P4GHZ(freq)) ||
+ ((wpa_s->conf->mld_allowed_phy & BIT(1)) && IS_5GHZ(freq)) ||
+ ((wpa_s->conf->mld_allowed_phy & BIT(2)) && is_6ghz_freq(freq));
+}
+#endif /* CONFIG_TESTING_OPTIONS */
+
+
static void wpas_sme_set_mlo_links(struct wpa_supplicant *wpa_s,
struct wpa_bss *bss)
{
@@ -528,6 +538,11 @@ static void wpas_sme_set_mlo_links(struct wpa_supplicant *wpa_s,
for_each_link(bss->valid_links, i) {
const u8 *bssid = bss->mld_links[i].bssid;
+#ifdef CONFIG_TESTING_OPTIONS
+ if (!check_mld_allowed_phy(wpa_s, bss->mld_links[i].freq))
+ continue;
+#endif /* CONFIG_TESTING_OPTIONS */
+
wpa_s->valid_links |= BIT(i);
os_memcpy(wpa_s->links[i].bssid, bssid, ETH_ALEN);
wpa_s->links[i].freq = bss->mld_links[i].freq;
@@ -577,6 +592,9 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
if ((wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_MLO) &&
!wpa_bss_parse_basic_ml_element(wpa_s, bss, wpa_s->ap_mld_addr,
NULL, ssid, NULL) &&
+#ifdef CONFIG_TESTING_OPTIONS
+ wpa_s->conf->mld_allowed_phy &&
+#endif /* CONFIG_TESTING_OPTIONS */
bss->valid_links) {
wpa_printf(MSG_DEBUG, "MLD: In authentication");
wpas_sme_set_mlo_links(wpa_s, bss);
--
2.39.2