blob: 9634a0cd40f0c76c14ca498551ce6e609d79ad22 [file] [log] [blame]
developer617abbd2024-04-23 14:50:01 +08001From d6e854c62cd825756cc1b46c8b006855cf9e057e Mon Sep 17 00:00:00 2001
2From: Michael-CY Lee <michael-cy.lee@mediatek.com>
3Date: Wed, 6 Mar 2024 15:01:33 +0800
4Subject: [PATCH 087/104] mtk: wpa_supplicant: add 'mld_allowed_phy'
5 configuration option for MLD STA
6
7A new configuration option named 'mld_allowed_phy' is added for MLD STA.
8This option indicates the bitmap of allowed phy for MLO connection.
9Note that setting 'mld_allowed_phy' to 0 makes no phy allowed for MLO.
10In other word, the STA becomes a legacy STA.
11
12CR-Id: WCNCR00289305
13Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
14Change-Id: I5ad15d3748c6fef476aa067cc4901157a96f8804
15---
16 wpa_supplicant/config.c | 1 +
17 wpa_supplicant/config.h | 1 +
18 wpa_supplicant/config_file.c | 2 ++
19 wpa_supplicant/sme.c | 18 ++++++++++++++++++
20 4 files changed, 22 insertions(+)
21
22diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
23index 7bb57e2ab..d3c75ee94 100644
24--- a/wpa_supplicant/config.c
25+++ b/wpa_supplicant/config.c
26@@ -5680,6 +5680,7 @@ static const struct global_parse_data global_fields[] = {
27 #endif /* CONFIG_PASN */
28 #ifdef CONFIG_TESTING_OPTIONS
29 { INT_RANGE(mld_force_single_link, 0, 1), 0 },
30+ { INT_RANGE(mld_allowed_phy, 0, 7), 0 },
31 { INT_RANGE(mld_connect_band_pref, 0, MLD_CONNECT_BAND_PREF_MAX), 0 },
32 { FUNC(mld_connect_bssid_pref), 0 },
33 #endif /* CONFIG_TESTING_OPTIONS */
34diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
35index 8981305c2..c0164fa76 100644
36--- a/wpa_supplicant/config.h
37+++ b/wpa_supplicant/config.h
38@@ -1800,6 +1800,7 @@ struct wpa_config {
39 u8 mld_connect_bssid_pref[ETH_ALEN];
40
41 int mld_force_single_link;
42+ u8 mld_allowed_phy; /* bitmap of allowed phy for MLO connection */
43 #endif /* CONFIG_TESTING_OPTIONS */
44 };
45
46diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
47index 7a3ed6373..875d00bb4 100644
48--- a/wpa_supplicant/config_file.c
49+++ b/wpa_supplicant/config_file.c
50@@ -1622,6 +1622,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
51 #ifdef CONFIG_TESTING_OPTIONS
52 if (config->mld_force_single_link)
53 fprintf(f, "mld_force_single_link=1\n");
54+ if (config->mld_allowed_phy)
55+ fprintf(f, "mld_allowed_phy=%u\n", config->mld_allowed_phy);
56 if (config->mld_connect_band_pref != MLD_CONNECT_BAND_PREF_AUTO)
57 fprintf(f, "mld_connect_band_pref=%d\n",
58 config->mld_connect_band_pref);
59diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
60index 5b69812b5..ef258fadc 100644
61--- a/wpa_supplicant/sme.c
62+++ b/wpa_supplicant/sme.c
63@@ -517,6 +517,16 @@ out:
64 }
65
66
67+#ifdef CONFIG_TESTING_OPTIONS
68+static bool check_mld_allowed_phy(struct wpa_supplicant *wpa_s, int freq)
69+{
70+ return ((wpa_s->conf->mld_allowed_phy & BIT(0)) && IS_2P4GHZ(freq)) ||
71+ ((wpa_s->conf->mld_allowed_phy & BIT(1)) && IS_5GHZ(freq)) ||
72+ ((wpa_s->conf->mld_allowed_phy & BIT(2)) && is_6ghz_freq(freq));
73+}
74+#endif /* CONFIG_TESTING_OPTIONS */
75+
76+
77 static void wpas_sme_set_mlo_links(struct wpa_supplicant *wpa_s,
78 struct wpa_bss *bss)
79 {
80@@ -528,6 +538,11 @@ static void wpas_sme_set_mlo_links(struct wpa_supplicant *wpa_s,
81 for_each_link(bss->valid_links, i) {
82 const u8 *bssid = bss->mld_links[i].bssid;
83
84+#ifdef CONFIG_TESTING_OPTIONS
85+ if (!check_mld_allowed_phy(wpa_s, bss->mld_links[i].freq))
86+ continue;
87+#endif /* CONFIG_TESTING_OPTIONS */
88+
89 wpa_s->valid_links |= BIT(i);
90 os_memcpy(wpa_s->links[i].bssid, bssid, ETH_ALEN);
91 wpa_s->links[i].freq = bss->mld_links[i].freq;
92@@ -577,6 +592,9 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
93 if ((wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_MLO) &&
94 !wpa_bss_parse_basic_ml_element(wpa_s, bss, wpa_s->ap_mld_addr,
95 NULL, ssid, NULL) &&
96+#ifdef CONFIG_TESTING_OPTIONS
97+ wpa_s->conf->mld_allowed_phy &&
98+#endif /* CONFIG_TESTING_OPTIONS */
99 bss->valid_links) {
100 wpa_printf(MSG_DEBUG, "MLD: In authentication");
101 wpas_sme_set_mlo_links(wpa_s, bss);
102--
1032.39.2
104